Changeset 1329 for applications/pmsm/simulator_zdenek/ekf_example
- Timestamp:
- 04/13/11 12:16:50 (14 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
r1326 r1329 542 542 else 543 543 */ 544 if (tmp_sum>0) 545 *respom++=(tmp_sum+(1<<14)-1)>>15; 546 else 547 *respom++=(tmp_sum-(1<<14)+1)>>15; 544 *respom++=(tmp_sum+(1<<14))>>15; 548 545 549 546 tmp_sum=0; … … 597 594 tau=((int32)c**A_kj-(int32)s**Ch_ki)>>14; 598 595 tmp_long=(int32)s**A_kj+(int32)c**Ch_ki; 599 if (tmp_long>(1<<2 8)) //q14 + q15600 *Ch_ki = (1<<1 4)-1;596 if (tmp_long>(1<<29)) //q14 + q14 597 *Ch_ki = (1<<15)-1; 601 598 else 602 599 *Ch_ki=tmp_long>>14; … … 741 738 // alpha+=((long)sigma*sigma)>>15; 742 739 tmp_long=((int32)alpha<<15)+(((int32)sigma*sigma)<<(30-2*qCh)); 743 if (tmp_long>0) 744 alpha=(tmp_long+(1<<14)-1)>>15; // vyssi presnost 745 else 746 alpha=(tmp_long-(1<<14)+1)>>15; // vyssi presnost 740 alpha=(tmp_long+(1<<14))>>15; // vyssi presnost 747 741 748 742 // gamma= qsqrt(((long)alpha*beta)); // verze pro DSP … … 769 763 // w_i+=((long)tau*sigma)>>15; 770 764 tmp_long = ((int32)*w_i<<15)+((int32)tau*sigma<<(30-2*qCh)); 771 /*if (tmp_long>0) 772 *w_i=(tmp_long+(1<<14)-1)>>15; 773 else 774 *w_i=(tmp_long-(1<<14)+1)>>15; 775 */ *w_i=(tmp_long)>>15; 765 *w_i=(tmp_long+(1<<14))>>15; 776 766 777 767 w_i++; … … 789 779 w_i++; 790 780 } 791 printf("Kg: %d %d\n",w[0],w[1]); 792 } 793 } 794 781 } 782 } 783 -
applications/pmsm/simulator_zdenek/ekf_example/matrix_vs.h
r1321 r1329 16 16 #define qCh 14 17 17 18 #define int16 int //short19 #define int32 long //int18 #define int16 short 19 #define int32 int 20 20 21 21 /* Matrix multiply Full matrix by upper diagonal matrix with unit diagonal; */