C51 COMPILER V9.52.0.0   MC_MOTORFUNCTION_LAYER                                            08/21/2018 12:02:27 PAGE 1   


C51 COMPILER V9.52.0.0, COMPILATION OF MODULE MC_MOTORFUNCTION_LAYER
OBJECT MODULE PLACED IN .\obj\MC_MotorFunction_layer.obj
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE User\Source\MC_MotorFunction_layer.c LARGE OMF2 WARNINGLEVEL(0) OPTIMIZE(SI
                    -ZE) BROWSE NOAREGS INCDIR(.\Library\Include;.\User\Include) DEBUG PRINT(.\obj\MC_MotorFunction_layer.lst) TABS(2) OBJECT
                    -(.\obj\MC_MotorFunction_layer.obj)

line level    source

   1          /************************ (C) COPYRIGHT 2015 FT *******************************
   2          * File Name          : 
   3          * Author             : Application Team  Tom.wang 
   4          * Version            : V2.0.0
   5          * Date               : 06/15/2015
   6          * Description        : 功能层
   7          ********************************************************************************
   8          /*******************************************************************************
   9          * All Rights Reserved
  10          *******************************************************************************/
  11          
  12          /* Includes ------------------------------------------------------------------*/
  13          #include <FU6812_MCU.h>
  14          #include <sys_conf.h>
  15          #include <MC_MotorCotrol_layer.h>  
  16          #include <MC_MotorFunction_layer.h> 
  17          #include <MC_MotorDriver_layer.h>   
  18          
  19          /** @addtogroup FT68xx
  20            * @{
  21            */
  22          
  23          /* Private typedef -----------------------------------------------------------*/
  24          /* Private define ------------------------------------------------------------*/
  25          /* Private macro -------------------------------------------------------------*/
  26          /* Private variables ---------------------------------------------------------*/
  27          Power_TypeDef xdata Power; 
  28          extern u16 idata giEventCounter;
  29          /* Private function prototypes -----------------------------------------------*/
  30          u16 Drv_PowerThermCalc(u16 VthMeas);      //温度计算
  31          void Drv_RotorCircleNumCalc(void);      //运行圈数计算
  32          void MCL_OverLoadInit(u16 OL0A,u16 OL1A,u16 OL2A,u16 OL3A,u32 OL0ms,u32 OL1ms,u32 OL2ms,u32 OL3ms);
  33          u8 MCL_OverLoadCalc(u16 Ibus);              //过载计算
  34          void Mcl_NoloadCale(void);                  //空载判断
  35          
  36          /* Private functions ---------------------------------------------------------*/
  37          
  38          
  39          /*******************************************************************************
  40          * Function Name  : MCL_OverLoadInit    //过载 
  41          * Description    : 温度200-> 20℃  
  42          * Input          : PTC温度
  43          * Output         : None
  44          * Return         : ADC采集值
  45          *******************************************************************************/
  46          
  47          #if(OVERLOAD_EN)
              void MCL_OverLoadInit(u16 OL0A,u16 OL1A,u16 OL2A,u16 OL3A,
                                    u32 OL0ms,u32 OL1ms,u32 OL2ms,u32 OL3ms)
                {
                  Ctl.OL.Value = 0x7F; 
                  Ctl.OL.Group[0].Current = OL0A;
                  Ctl.OL.Group[1].Current = OL1A;
C51 COMPILER V9.52.0.0   MC_MOTORFUNCTION_LAYER                                            08/21/2018 12:02:27 PAGE 2   

                  Ctl.OL.Group[2].Current = OL2A;
                  Ctl.OL.Group[3].Current = OL3A;
              
                  Ctl.OL.Group[0].Nms = OL0ms;
                  Ctl.OL.Group[1].Nms = OL1ms;
                  Ctl.OL.Group[2].Nms = OL2ms;
                  Ctl.OL.Group[3].Nms = OL3ms;
                    
                  Ctl.OL.Group[0].msCounter = 0;
                  Ctl.OL.Group[1].msCounter = 0;
                  Ctl.OL.Group[2].msCounter = 0;
                  Ctl.OL.Group[3].msCounter = 0;
                  
                  Ctl.OL.Group[0].flg = 0;
                  Ctl.OL.Group[1].flg = 0;
                  Ctl.OL.Group[2].flg = 0;
                  Ctl.OL.Group[3].flg = 0;
                }
              #endif
  73          
  74          
  75           /******************************************************************************* 
  76          * Function Name  : MCL_OverLoadCalc 
  77          * Author         : wangt  
  78          * Description     
  79          * Input          : None 
  80          * Output         : None 
  81          * Return         : 
  82          *******************************************************************************/  
  83          #if(OVERLOAD_EN) 
              u8 MCL_OverLoadCalc(u16 Ibus)   
                { 
                  u16 tIbus = 0;    //输入电流值
                  tIbus = Ibus;
              
                  if((Ctl.OL.msFlag == 0x7F)&&(Ctl.OL.Value == 0x7F)&&(Ctl.State == MOTOR_NORMAL))
                    {
                      if(tIbus >= Ctl.OL.Group[0].Current)    
                        {  
                           Ctl.OL.Group[0].msCounter++;
                           if(tIbus >= Ctl.OL.Group[1].Current)  
                           {
                               Ctl.OL.Group[0].msCounter++;
                               Ctl.OL.Group[1].msCounter++;
                               if(tIbus >= Ctl.OL.Group[2].Current) 
                               {
                                   Ctl.OL.Group[0].msCounter++;
                                   Ctl.OL.Group[1].msCounter++;
                                   Ctl.OL.Group[2].msCounter++;
                                   if(tIbus>=Ctl.OL.Group[3].Current) 
                                   {  
                                       Ctl.OL.Group[0].msCounter++;
                                       Ctl.OL.Group[1].msCounter++;
                                       Ctl.OL.Group[2].msCounter++;
                                       Ctl.OL.Group[3].msCounter++;
                                   }
                                   else
                                   {
                                      Ctl.OL.Group[3].msCounter--;  
                                   }
                               }
                               else
C51 COMPILER V9.52.0.0   MC_MOTORFUNCTION_LAYER                                            08/21/2018 12:02:27 PAGE 3   

                               {
                                   Ctl.OL.Group[2].msCounter--;  
                                   Ctl.OL.Group[3].msCounter--;  
                               }
                           }
                           else
                           {
                               Ctl.OL.Group[1].msCounter--;  
                               Ctl.OL.Group[2].msCounter--;  
                               Ctl.OL.Group[3].msCounter--;                
                           }
                        }
                        else
                        {   
                           Ctl.OL.Group[0].msCounter--; 
                           Ctl.OL.Group[1].msCounter--;  
                           Ctl.OL.Group[2].msCounter--;  
                           Ctl.OL.Group[3].msCounter--;  
                        } 
                     if(Ctl.OL.Group[0].msCounter >= Ctl.OL.Group[0].Nms) 
                     {
                       Ctl.OL.Group[0].flg = TRUE;
                       Ctl.OL.Value = 0xF0; 
                     }
                     if(Ctl.OL.Group[1].msCounter >= Ctl.OL.Group[1].Nms)
                     {
                       Ctl.OL.Group[1].flg = TRUE; 
                       Ctl.OL.Value = 0xF1; 
                     }
                     if(Ctl.OL.Group[2].msCounter >= Ctl.OL.Group[2].Nms)
                     {
                       Ctl.OL.Group[2].flg = TRUE; 
                       Ctl.OL.Value = 0xF2; 
                     }
                     if(Ctl.OL.Group[3].msCounter >= Ctl.OL.Group[3].Nms)
                     {
                       Ctl.OL.Group[3].flg = TRUE;  
                       Ctl.OL.Value = 0xF3; 
                     }
                     
                     if(Ctl.OL.Group[0].msCounter<-100)
                     {
                       Ctl.OL.Group[0].msCounter = -100; 
                     }
                     if(Ctl.OL.Group[1].msCounter<-100)
                     {
                       Ctl.OL.Group[1].msCounter = -100;  
                     }
                     if(Ctl.OL.Group[2].msCounter<-100)
                     {
                       Ctl.OL.Group[2].msCounter = -100;  
                     }
                     if(Ctl.OL.Group[3].msCounter<-100)
                     {
                       Ctl.OL.Group[3].msCounter = -100;  
                     }
              
                     Ctl.OL.msFlag = 0;
                    }   
                  return Ctl.OL.Value; 
                } 
              #endif
C51 COMPILER V9.52.0.0   MC_MOTORFUNCTION_LAYER                                            08/21/2018 12:02:27 PAGE 4   

 178            
 179          /*******************************************************************************
 180          * Function Name  : Drv_PowerThermCalc    
 181          * Description    : 参考电压5.0V
 182          * Input          : PTC温度
 183          * Output         : None
 184          * Return         : ADC采集值
 185          *******************************************************************************/
 186          u16 Drv_PowerThermCalc(u16 VthMeas)
 187            {
 188   1          u16 tVthMeas;
 189   1          u16 tTherm;
 190   1      
 191   1          tVthMeas =  VthMeas;
 192   1      
 193   1          if(tVthMeas > 16383)
 194   1            {
 195   2              tTherm = 250;        
 196   2            }
 197   1          else if(tVthMeas > 14863)
 198   1            {
 199   2              tTherm = 300;        
 200   2            }
 201   1          else if(tVthMeas > 12041)
 202   1            {
 203   2              tTherm = 400;        
 204   2            }
 205   1          else if(tVthMeas > 10035)
 206   1            {
 207   2              tTherm = 500;        
 208   2            }
 209   1          else if(tVthMeas > 7582)
 210   1            {
 211   2              tTherm = 600;        
 212   2            }
 213   1          else if(tVthMeas > 5959)
 214   1            {
 215   2              tTherm = 700;        
 216   2            }
 217   1          else if(tVthMeas > 4681)
 218   1            {
 219   2              tTherm = 800;        
 220   2            }
 221   1          else if(tVthMeas > 3687)
 222   1            {
 223   2              tTherm = 900;        
 224   2            }
 225   1          else if(tVthMeas > 2918)
 226   1            {
 227   2              tTherm = 1000;        
 228   2            }
 229   1          else if(tVthMeas > 2324)
 230   1            {
 231   2              tTherm = 1100;
 232   2            }
 233   1          else if(tVthMeas > 1864)
 234   1            {
 235   2              tTherm = 1200;
 236   2            }
 237   1          else
 238   1          {
 239   2            tTherm = 2000;
C51 COMPILER V9.52.0.0   MC_MOTORFUNCTION_LAYER                                            08/21/2018 12:02:27 PAGE 5   

 240   2          }
 241   1          return tTherm;      
 242   1        }  
 243          
 244          /*******************************************************************************
 245          * Function Name  : Drv_RotorCircleNumCalc    
 246          * Description    : 
 247          * Input          : 电机运行圈数计算
 248          * Output         : None
 249          * Return         : 
 250          *******************************************************************************/
 251          
 252          void Drv_RotorCircleNumCalc(void)   //Ctl.Step
 253          {         
 254   1        s8 StepERR; 
 255   1        Ctl.Spd.RotorPosition = Ctl.gStepCur;
 256   1      
 257   1        StepERR = Ctl.Spd.RotorPosition - Ctl.Spd.RotorPositionqPre;
 258   1        if((StepERR == 5)||(StepERR == -1))
 259   1        {
 260   2          StepERR = 2;
 261   2        }
 262   1        else if(StepERR == -5)
 263   1        {
 264   2          StepERR = 1;
 265   2        }
 266   1        if(StepERR  == 2) 
 267   1        {
 268   2          Ctl.Spd.ComNum--;
 269   2        }    
 270   1        else if(StepERR == 1)
 271   1        {
 272   2          Ctl.Spd.ComNum++;
 273   2        }  
 274   1        if(Ctl.gDirectionC != Ctl.gDirectionS)
 275   1        {
 276   2          giEventCounter = 0;
 277   2        }
 278   1        Ctl.gDirectionS = StepERR;
 279   1        Ctl.Spd.RotorPositionqPre = Ctl.Spd.RotorPosition;  
 280   1        #if(MOTORCIRCLECALEEN)       
                Ctl.Spd.MechCircleNum =  =  Ctl.Spd.ComNum/(6*POLE_PAIR);  //机械圈数
                #endif
 283   1      }
 284          
 285          
 286          /*******************************************************************************
 287          * Function Name  : Mcl_NoloadCale    
 288          * Description    : 电机空载判断
 289          * Input          : 
 290          * Output         : 
 291          * Return         : 
 292          *******************************************************************************/
 293          void Mcl_NoloadCale(void)            
 294          {
 295   1        #if(NOLOAD_EN)
                if(Ctl.Noload.Counter > NOLOADNUM)
                {
                   if(Ctl.Noload.Counter > (NOLOADNUM))
                   {
                     Ctl.Noload.Counter = (NOLOADNUM);
                   }
C51 COMPILER V9.52.0.0   MC_MOTORFUNCTION_LAYER                                            08/21/2018 12:02:27 PAGE 6   

                   Ctl.Noload.Flag = 0X7F;
                }
                else
                {
                  Ctl.Noload.Flag = 0XFF;
                }
                #endif
 309   1      }
 310          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    304    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =      6       1
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
   EDATA SIZE       =   ----    ----
   HDATA SIZE       =   ----    ----
   XDATA CONST SIZE =   ----    ----
   FAR CONST SIZE   =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)
