⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 idc.lst

📁 PMSM电机的磁场定向控制
💻 LST
📖 第 1 页 / 共 2 页
字号:
C166 COMPILER V6.04, IDC                                                                   07/02/2007 15:03:32 PAGE 1   


C166 COMPILER V6.04, COMPILATION OF MODULE IDC
OBJECT MODULE PLACED IN IDC.OBJ
COMPILER INVOKED BY: C:\Keil\C166\BIN\C166.EXE IDC.C MODV2 BROWSE MODV2 DEBUG

 stmt lvl     source

    1         #include "MAIN.H"
    2         #include "DEF.H"
    3         #include "TABLES.H"
    4         #include "TableQ15.h"
    5         
    6         extern void SVM(TComplex *m, char *Sector);
    7         extern void PI_Controller(TPI * PI, int NewInput,int * Result);
    8         
    9         void Clarke_Park_Trans(TPhaseCurrent * In, TComplex * angle, TComplex * Result);
   10         void Park_Rev(TComplex * Frame_dq, TComplex * angle, TComplex  * Result);
   11         void InitPIController(TPI * Data, int Kp, int Ki,int Limit);
   12         
   13         const int T_sample = 0x000D;  /* 400us  Q1.15 */
   14         
   15         char Sector;
   16         int period_number=1;
   17         int count=0;
   18         int QuadratureCurrent = 0x0;
   19         int DirectCurrent  = 0x0;
   20         int RotorSpeedSet = 0x0;
   21         int RotorSpeed;
   22         int oldposition;
   23         int deltaposition;
   24         int deltagammaQ15;      
   25         int omega;
   26         unsigned int ENC_OFFSET=0x44c;   //0x44c=1100;0x898=2200;
   27         int test_position;
   28         
   29         unsigned int decoval;
   30         unsigned long int decoder_wert;
   31         
   32         TPhaseCurrent PhaseCurrent;
   33         TPhaseCurrent PhaseCurrentQ15;
   34         TComplex Gamma;
   35         TComplex RotorCurrentQ15;
   36         TComplex PIRotorCurrentQ15;
   37         TComplex StatorCurrentQ15;
   38         
   39         TPI PI_Data_Id;         // PI Current Direct
   40         TPI PI_Data_Iq;         // PI Current Quadrature
   41         TPI PI_Data_Speed;      // PI control speed
   42         
   43         //****************************************************************************
   44         // @Function      void InitPIController(TPI * Data, int Kp, int Ki,int Limit)
   45         //
   46         //----------------------------------------------------------------------------
   47         // @Description   Initialation for PI Controller 
   48         //                                      
   49         //----------------------------------------------------------------------------
   50         // @Returnvalue   none
   51         //
   52         //----------------------------------------------------------------------------
   53         // @Parameters    TPI *Data
   54         //                                int Kp 
   55         //                                int Ki 
C166 COMPILER V6.04, IDC                                                                   07/02/2007 15:03:32 PAGE 2   

   56         //                                int Limit 
   57         //
   58         //----------------------------------------------------------------------------
   59         // @Date          01.10.2003
   60         //
   61         //****************************************************************************
   62         void InitPIController(TPI * Data, int Kp, int Ki,int Limit)
   63         {       
   64  1              Data->SetValue = 0;
   65  1              Data->A0 = Kp;
   66  1              Data->A1 = ((((long)Ki << 4)*(long)T_sample) >> 15) - Kp; /* Q16.0 format */
*** WARNING C192 IN LINE 66 OF IDC.C: '=': value truncated
   67  1              Data->Limit = Limit;
   68  1              Data->Integral = 0;
   69  1              Data->Error = 0;
   70  1      }
   71         
   72         //****************************************************************************
   73         // @Function      void InitFOC (void) 
   74         //
   75         //----------------------------------------------------------------------------
   76         // @Description   This Function is makeing settings for PI-Controller 
   77         //
   78         //
   79         //----------------------------------------------------------------------------
   80         // @Returnvalue   None
   81         //
   82         //----------------------------------------------------------------------------
   83         // @Parameters    int Sector
   84         //
   85         //----------------------------------------------------------------------------
   86         // @Date          01.10.2003
   87         //
   88         //****************************************************************************
   89         void InitFOC(void)
   90         {       
   91  1              InitPIController(&PI_Data_Speed, 0x3000, 0x0020, 0x5000);
   92  1              InitPIController(&PI_Data_Id, 0x1200, 0x0080,0x5000);
   93  1              InitPIController(&PI_Data_Iq, 0x1200, 0x0080,0x5000);
   94  1      
   95  1              DirectCurrent   =       0x0000;         // no field-weaking
   96  1              QuadratureCurrent=      0x0000;
   97  1      }
   98         
   99         
  100         
  101         //****************************************************************************
  102         // @Function      void ClarkeParkTrans (TPhaseCurrent * In, TComplex * angle, TComplex * Result) 
  103         //
  104         //----------------------------------------------------------------------------
  105         // @Description   Implemants the Clark and Park Transformation 
  106         //                                (Three Phase Frame -> Rotor Frame Transformation)
  107         //                                Execution time 2.2us @ 40MHz  
  108         //----------------------------------------------------------------------------
  109         // @Returnvalue   Tcomplex *Result (Current in rotating Frame)
  110         //
  111         //----------------------------------------------------------------------------
  112         // @Parameters    TPhaseCurrent *In (Current in 3 Phases frame)
  113         //                                Tcomplex *angle 
  114         //
  115         //----------------------------------------------------------------------------
  116         // @Date          04.10.2003
C166 COMPILER V6.04, IDC                                                                   07/02/2007 15:03:32 PAGE 3   

  117         //
  118         //****************************************************************************
  119         void ClarkeParkTrans(TPhaseCurrent *In, TComplex *angle, TComplex *Result)
  120         {
  121  1              int Ibeta;
  122  1              TComplex IsPark;
  123  1      
  124  1              Ibeta = ((long)In->iv - (long)In->iw)*(long)SQRT3INV >> 15;
*** WARNING C192 IN LINE 124 OF IDC.C: '=': value truncated
  125  1              IsPark.real = ((long)In->iu)*((long)angle->real) + ((long)Ibeta)*((long)angle->imag) >> 15;
*** WARNING C192 IN LINE 125 OF IDC.C: '=': value truncated
  126  1              IsPark.imag = ((long)Ibeta)*((long)angle->real) - ((long)In->iu)*((long)angle->imag) >> 15;
*** WARNING C192 IN LINE 126 OF IDC.C: '=': value truncated
  127  1      
  128  1              * Result =IsPark; 
  129  1       
  130  1      }
  131         
  132         //****************************************************************************
  133         // @Function      void ParkInverse (TComplex *Frame_dq, TComplex *angle, TComplex  *Result) 
  134         //
  135         //----------------------------------------------------------------------------
  136         // @Description   Implemants the reverse Park Transformation 
  137         //                                (Rotor Frame -> Stator Frame Transformation)
  138         //                                Execution time 1.45us @ 40MHz 
  139         //----------------------------------------------------------------------------
  140         // @Returnvalue   Tcomplex *Result (Current in Stator Frame)
  141         //
  142         //----------------------------------------------------------------------------
  143         // @Parameters    Tcomplex *Frame_dq (Current in rotating frame)
  144         //                                Tcomplex *angle 
  145         //
  146         //----------------------------------------------------------------------------
  147         // @Date          04.10.2003
  148         //
  149         //****************************************************************************
  150         void ParkInverse (TComplex *Frame_dq, TComplex *angle, TComplex  *Result)
  151         {
  152  1              TComplex Is_rev_Park;
  153  1      
  154  1              Is_rev_Park.real = ((long)Frame_dq->real)*((long)angle->real) - ((long)Frame_dq->imag)*((long)angle->imag
             -) >> 15;
*** WARNING C192 IN LINE 154 OF IDC.C: '=': value truncated
  155  1              Is_rev_Park.imag = ((long)Frame_dq->real)*((long)angle->imag) + ((long)Frame_dq->imag)*((long)angle->real
             -) >> 15;
*** WARNING C192 IN LINE 155 OF IDC.C: '=': value truncated
  156  1      
  157  1              *Result=Is_rev_Park;
  158  1       
  159  1      }
  160         
  161         //****************************************************************************
  162         // @Function      void GetRotorPosition (void) 
  163         //
  164         //----------------------------------------------------------------------------
  165         // @Description   This Function calculates the actual position of the Rotor of 
  166         //                                the PMSM in degrees   
  167         //                                Execution time 1.8us @ 40MHz  
  168         //
  169         //----------------------------------------------------------------------------
  170         // @Returnvalue     
  171         //
C166 COMPILER V6.04, IDC                                                                   07/02/2007 15:03:32 PAGE 4   

  172         //----------------------------------------------------------------------------
  173         // @Parameters    None
  174         //
  175         //----------------------------------------------------------------------------
  176         // @Globals               
  177         //
  178         //----------------------------------------------------------------------------
  179         // @Date          03.11.2003
  180         //
  181         //****************************************************************************
  182         int GetRotorPosition(void)
  183         {
  184  1              int decoval;
  185  1      
  186  1              decoval=GPT12E_T3;              
  187  1              if(!(decoval>=0&&decoval<=6000))                
  188  1                      decoval=decoval-0xE890;
  189  1                                              
  190  1              test_position = decoval;
  191  1      
  192  1              decoval=decoval%3000;
  193  1              decoval=decoval+ENC_OFFSET;     
  194  1              
  195  1              if (decoval>3000)
  196  1              {
  197  2                      decoval=decoval-3000;
  198  2              }
  199  1              
  200  1              // Sinus and Cosine Function of Rotor Angle
  201  1              // for Park Transformation
  202  1              decoval=decoval/3;
  203  1              Gamma.imag=sin_table[decoval];
  204  1              Gamma.real=cos_table[decoval];
  205  1                      
  206  1              return decoval;
  207  1      }
  208         
  209         //****************************************************************************
  210         // @Function      void Iphases (void) 
  211         //
  212         //----------------------------------------------------------------------------
  213         // @Description   Measure the phase currents with LEMs in phases 
  214         //                                FUNCTION NOT USED WHEN MEASUREMENT IN DC LINK
  215         //
  216         //----------------------------------------------------------------------------
  217         // @Returnvalue   None
  218         //
  219         //----------------------------------------------------------------------------
  220         // @Parameters    None
  221         //
  222         //----------------------------------------------------------------------------
  223         // @Date          04.11.2003
  224         //
  225         //****************************************************************************
  226         /*
  227         void Iphases (void) 
  228         {
  229                 int adciu;
  230                 int adciv;
  231         
  232                 // Set the ADC and start the conversion
  233                 PECC0          =  0x0202;       // load PECC0 control register
C166 COMPILER V6.04, IDC                                                                   07/02/2007 15:03:32 PAGE 5   

  234                 DSTP0=_sof_(&adc_result[0]);
  235                 ADC_CON_ADST   =  1;            // set start bit for phases measurement
  236         

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -