Changeset 1465 for applications

Show
Ignore:
Timestamp:
08/02/12 22:42:13 (12 years ago)
Author:
smidl
Message:

oprava pretekani A*Ch

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  
    527527        } 
    528528         
     529        //printf("Gin: %d,%d,%d,%d\n", Ch[0],Ch[1],Ch[2],Ch[3] ); 
     530         
    529531        for (i=dimx-1; i>=0; i--) 
    530532        { 
     
    539541                                //                              rho=qsqrt(tmp_long);                   // verze pro DSP 
    540542                                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 
    542544                                c=(((int32)*Ch_ii)<<14)/rho; 
    543545                                 
     
    547549                                for (k=0;k<=i; k++) 
    548550                                { 
    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                                        } 
    553556                                        else  
    554                                                 *Ch_ki=tmp_long>>14; 
     557                                                *Ch_ki=tmp_long>>14; // qCh 
    555558                                        *A_kj=tau; 
    556559                                         
     
    571574                                tmp_long=(int32)*Ch_ii**Ch_ii+(int32)*Ch_ij**Ch_ij; 
    572575                                //                      rho=qsqrt(tmp_long);                     // verze pro DSP 
    573                                 if (tmp_long>(1<<30)-1) 
     576                                if (tmp_long>(1<<30)-1){ 
    574577                                        rho=(1<<15)-1; 
     578                                } 
    575579                                else 
    576580                                        rho=(int16)(sqrt((double)tmp_long));       // verze pro PC 
     
    586590                                        tau=((int32)c**Ch_kj-(int32)s**Ch_ki)>>14; 
    587591                                        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                                        } 
    590595                                        else  
    591596                                                *Ch_ki=tmp_long>>14; 
     
    637642                                tmp_long=((int32)beta**Ch_ij -(int32)sigma**w_i)/gamma; 
    638643                                 
    639                                 if (tmp_long>32767) 
     644                                if (tmp_long>32767){ 
    640645                                        tmp_long=32767; 
     646                                } 
    641647                                if (tmp_long<-32768) 
    642648                                        tmp_long=-32768; 
  • applications/pmsm/simulator_zdenek/ekf_example/matrix_vs.h

    r1464 r1465  
    1414#define qCU 15 
    1515#define qD 13 
    16 #define qCh 14 
     16#define qCh 13 
    1717 
    1818#define int16 short 
    1919#define int32 int 
     20#define int64 long 
    2021 
    2122/* Matrix multiply Full matrix by upper diagonal matrix with unit diagonal; */