Changeset 1245 for applications/pmsm/simulator_zdenek/ekf_example
- Timestamp:
- 11/02/10 21:20:26 (14 years ago)
- Location:
- applications/pmsm/simulator_zdenek/ekf_example
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/pmsm/simulator_zdenek/ekf_example/ekf_obj.cpp
r1241 r1245 661 661 662 662 // Tuning of matrix R 663 R[0]=prevod(0. 05,15); // 0.05663 R[0]=prevod(0.1,15); // 0.05 664 664 R[3]=R[0]; 665 665 -
applications/pmsm/simulator_zdenek/ekf_example/matrix_vs.cpp
r1241 r1245 114 114 } 115 115 116 116 // Thorton procedure - Kalman predictive variance in UD 117 void thorton(int16 *U, int16 *D, int16 *PSIU, int16 *Q, int16 *G, int16 *Dold, unsigned int16 rows) { 118 thorton_fast(U, D, PSIU, Q, G, Dold, rows); 119 } 120 117 121 // Thorton procedure - Kalman predictive variance in UD 118 122 void thorton_fast(int16 *U, int16 *D, int16 *PSIU, int16 *Q, int16 *G, int16 *Dold, unsigned int16 rows) { … … 284 288 285 289 sigma = sigma >> 15; // navrat do Q15 286 if (sigma>32767)sigma=32767;290 // if (sigma>32767)sigma=32767; 287 291 288 292 for (j=0;j<dimx;j++) … … 393 397 } 394 398 } 395 } 396 for (j=0; j<i; j++){ 397 tmp_long=(long(Ch[i*dimx+i])*Ch[i*dimx+i]+long(Ch[i*dimx+j])*Ch[i*dimx+j]); 398 if (tmp_long>0){ 399 rho=sqrt((double)(tmp_long)); 400 s=(long(Ch[i*dimx+j])<<15)/rho; 401 c=(long(Ch[i*dimx+i])<<15)/rho; 402 for (k=0; k<=i; k++){ 403 tau=(long(c)*Ch[k*dimx+j]-long(s)*Ch[k*dimx+i])>>15; 404 Ch[k*dimx+i]=(long(s)*Ch[k*dimx+j]+long(c)*Ch[k*dimx+i])>>15; 405 Ch[k*dimx+j]=tau; 399 400 for (j=0; j<i; j++){ 401 tmp_long=(long(Ch[i*dimx+i])*Ch[i*dimx+i]+long(Ch[i*dimx+j])*Ch[i*dimx+j]); 402 if (tmp_long>0){ 403 rho=sqrt((double)(tmp_long)); 404 s=(long(Ch[i*dimx+j])<<15)/rho; 405 c=(long(Ch[i*dimx+i])<<15)/rho; 406 for (k=0; k<=i; k++){ 407 tau=(long(c)*Ch[k*dimx+j]-long(s)*Ch[k*dimx+i])>>15; 408 Ch[k*dimx+i]=(long(s)*Ch[k*dimx+j]+long(c)*Ch[k*dimx+i])>>15; 409 Ch[k*dimx+j]=tau; 410 } 406 411 } 407 412 } 413 408 414 } 409 415 } -
applications/pmsm/simulator_zdenek/ekf_example/matrix_vs.h
r1241 r1245 13 13 #define qAU 14 14 14 #define qD 14 15 #define qCh 1 515 #define qCh 14 16 16 17 #define int16 shortint18 #define int32 int17 #define int16 int 18 #define int32 long 19 19 20 20 /* Matrix multiply Full matrix by upper diagonal matrix with unit diagonal; */