Changeset 1465 for applications/pmsm
- Timestamp:
- 08/02/12 22:42:13 (12 years ago)
- Location:
- applications/pmsm/simulator_zdenek/ekf_example
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/pmsm/simulator_zdenek/ekf_example/matrix_vs.cpp
r1464 r1465 527 527 } 528 528 529 //printf("Gin: %d,%d,%d,%d\n", Ch[0],Ch[1],Ch[2],Ch[3] ); 530 529 531 for (i=dimx-1; i>=0; i--) 530 532 { … … 539 541 // rho=qsqrt(tmp_long); // verze pro DSP 540 542 rho=(int16)(sqrt((double)tmp_long)); // verze pro PC 541 s=(((int32)*A_ij)<<14)/rho; 543 s=(((int32)*A_ij)<<14)/rho; // qCh + q14 /qch => s in q14 542 544 c=(((int32)*Ch_ii)<<14)/rho; 543 545 … … 547 549 for (k=0;k<=i; k++) 548 550 { 549 tau=((int32)c**A_kj-(int32)s**Ch_ki)>>14; 550 tmp_long=(int32)s**A_kj+(int32)c**Ch_ki; 551 if (tmp_long>(1<<29)) //q14 + q14 552 *Ch_ki = (1<<15)-1; 551 tau=((int32)c**A_kj-(int32)s**Ch_ki)>>14; // tau in qCh 552 tmp_long=(int32)s**A_kj+(int32)c**Ch_ki; // q14+qCh 553 if ((tmp_long>(1<<(14+14)))){ //q14 + q15 554 *Ch_ki = (1<<14)-1; // rezerva pro nasobeni A*Ch 555 } 553 556 else 554 *Ch_ki=tmp_long>>14; 557 *Ch_ki=tmp_long>>14; // qCh 555 558 *A_kj=tau; 556 559 … … 571 574 tmp_long=(int32)*Ch_ii**Ch_ii+(int32)*Ch_ij**Ch_ij; 572 575 // rho=qsqrt(tmp_long); // verze pro DSP 573 if (tmp_long>(1<<30)-1) 576 if (tmp_long>(1<<30)-1){ 574 577 rho=(1<<15)-1; 578 } 575 579 else 576 580 rho=(int16)(sqrt((double)tmp_long)); // verze pro PC … … 586 590 tau=((int32)c**Ch_kj-(int32)s**Ch_ki)>>14; 587 591 tmp_long =((int32)s**Ch_kj+(int32)c**Ch_ki); 588 if (tmp_long>(1<<29)) 589 *Ch_ki = (1<<15)-1; 592 if ((tmp_long>(1<<(14+14)))){ //q14 + q15 593 *Ch_ki = (1<<14)-1; // rezerva pronasobeni A*Ch 594 } 590 595 else 591 596 *Ch_ki=tmp_long>>14; … … 637 642 tmp_long=((int32)beta**Ch_ij -(int32)sigma**w_i)/gamma; 638 643 639 if (tmp_long>32767) 644 if (tmp_long>32767){ 640 645 tmp_long=32767; 646 } 641 647 if (tmp_long<-32768) 642 648 tmp_long=-32768; -
applications/pmsm/simulator_zdenek/ekf_example/matrix_vs.h
r1464 r1465 14 14 #define qCU 15 15 15 #define qD 13 16 #define qCh 1 416 #define qCh 13 17 17 18 18 #define int16 short 19 19 #define int32 int 20 #define int64 long 20 21 21 22 /* Matrix multiply Full matrix by upper diagonal matrix with unit diagonal; */