Просмотр исходного кода

更新

1.添加相关数据手册
2.代码更新
avery 7 месяцев назад
Родитель
Сommit
98b8484ed2

BIN
Docs/7MBR100XNA120-50.pdf


BIN
Docs/HTB100-P.pdf


BIN
Docs/MCU-DS-21_FU6815_65_64_V4.0_20240914.pdf


BIN
Docs/SiLM5852SH-AQ .pdf


+ 0 - 74
User/Application/AddFunction.c

@@ -280,28 +280,6 @@ void Speed_response(void)
                     #endif
                     mcFocCtrl.LoopTime = 0;
                 }
-                
-                //                              if(mcFocCtrl.Weak_LoopTime > WEAK_LOOP_TIME)
-                //                              {
-                //                                    #if (FiledWeakenCompEnable)
-                //                                       {
-                //                                           FiledWeakenControl(FOC__UD, FOC__UQ, _Q15(0.9),mcFocCtrl.IsRef);
-                ////                                                 GetFieldWeakenUsAndUdc_Q15(mcFocCtrl.UDFlt,mcFocCtrl.UQFlt,mcFocCtrl.mcDcbusFlt);
-                ////                                                 GetFieldWeakenIsTheta_Q15();
-                ////                                                 GetFieldWeakenIdRefAndIqRef_Q15(mcFocCtrl.IsRef);
-                //                                               if(mcFieldWeaken.mcIdref<ID_Limit)
-                //                                               {mcFieldWeaken.mcIdref=ID_Limit;}
-                //                                               mcFocCtrl.IdRef = mcFieldWeaken.mcIdref;
-                //                                               mcFocCtrl.IqRef = mcFieldWeaken.mcIqref;
-                //                                       }
-                //                                       #else
-                //                                       {
-                //                                               mcFocCtrl.IqRef = mcFocCtrl.IsRef;
-                //                                               mcFocCtrl.IdRef = 0;
-                //                                       }
-                //                                       #endif
-                //                                       mcFocCtrl.Weak_LoopTime = 0;
-                //                }
             }
             break;
         }
@@ -334,16 +312,13 @@ void main_ms(void)
         mcFocCtrl.Powerlpf = 0;
     }
     
-    //              mcFocCtrl.mcDcbus_chazhiFlt    =  LPF_realize1(mcFocCtrl.mcDcbus_chazhi, mcFocCtrl.mcDcbus_chazhiFlt, LPF_K(5.0));     //反电动势滤波
     /*****温度DCbus_AND_Ibus采样获取值并滤波******/
     AdcSampleValue.ADC_huan_temp   = LPF_realize1(Huan_ADC, AdcSampleValue.ADC_huan_temp, LPF_K(20.0));        //环静温度
     AdcSampleValue.ADC_guan_temp   = LPF_realize1(Guan_ADC, AdcSampleValue.ADC_guan_temp, LPF_K(20.0));        //盘管温度
     AdcSampleValue.ADC_paiqi_temp  = LPF_realize1(Paiqi_ADC, AdcSampleValue.ADC_paiqi_temp, LPF_K(20.0));      //排气温度
-    //              AdcSampleValue.ADC_yaji_temp   = LPF_realize1(Yaji_ADC  , AdcSampleValue.ADC_yaji_temp  , LPF_K(20.0));    //压机外壳温度
     AdcSampleValue.ADC_IPM_temp    = LPF_realize1(IPM_ADC, AdcSampleValue.ADC_IPM_temp, LPF_K(20.0));          //IPM温度
     mcFocCtrl.mcDcbusFlt           = LPF_realize1(DCBUS_ADC, mcFocCtrl.mcDcbusFlt, LPF_K(5.0));               //母线电压滤波
     mcFocCtrl.mcAcbusFlt           = LPF_realize1(mcFocCtrl.mcAcbus_max, mcFocCtrl.mcAcbusFlt, LPF_K(1.0));      //AC电压峰值滤波
-    //              IsLimit_Over_tect();
     #if (IQCOMPENSATEENBLE)
     {
         TorquePeakK(mcFocCtrl.Powerlpf);  //分段处理
@@ -587,49 +562,6 @@ void ID_IQ_Control(void)
 }
 
 
-
-
-
-/*IPM温度计算——返回值扩大10倍*/
-int16 IPM_RealTemp(uint16 ADC_vaule)
-{
-    int16 temp;
-    static uint32 R_Real = 0;
-    /*初始参数初始化*/
-    RealTempR.R_PU      = 2000;      //上拉电阻
-    RealTempR.R_PD      = 0;     //下拉电阻
-    RealTempR.R_Base    = 5000;   //25度时NTC阻值
-    RealTempR.B         = 3380;        //B
-    RealTempR.T25       = 298.15;      //固定 25.0+273.15
-    
-    /*NTC电阻计算  4.5——4096    5——4551*/
-    if (RealTempR.R_PU > 0)
-    {
-        R_Real = (RealTempR.R_PU * ADC_vaule) / (4551 - ADC_vaule);
-    }
-    
-    if (RealTempR.R_PD > 0)
-    {
-        R_Real = (RealTempR.R_PD * (4551 - ADC_vaule)) / ADC_vaule;
-    }
-    
-    if (ADC_vaule < 50)
-    {
-        temp                                    = - 1000;                               // -100C
-    }
-    else if (ADC_vaule > 4000)
-    {
-        temp                                    = -1500;                                    // 150C
-    }
-    else
-    {
-        /*NTC温度计算*/
-        temp                                    = 10 / (1 / RealTempR.T25 - ((log(RealTempR.R_Base) - log(R_Real)) / RealTempR.B)) - 2731; // UNIT: 0.1C
-        /*温度限制上位机原因*/
-    }
-    
-    return (temp);
-}
 /*PI参数分段处理*/
 void Current_Speed_PI(void)
 {
@@ -710,12 +642,6 @@ void Current_Speed_PI(void)
     FOC_QKI = DQki_1;
 }
 
-/*温度计算*/
-void Temp_jisuan(void)
-{
-    mcFocCtrl.IPMtemp   = IPM_RealTemp(AdcSampleValue.ADC_IPM_temp >> 3); //IPM温度计算
-}
-
 uint16 AimFrequencyMaxVAC = 500;
 /*指令获取*/
 void Control_Cmd(void)

+ 0 - 19
User/Application/FocControl.c

@@ -1,22 +1,3 @@
-/********************************************************************************
-
- **** Copyright (C), 2018, Fortior Technology Co., Ltd.                      ****
-
- ********************************************************************************
-    File Name     : FocControl.c
-    Author        : Bruce HW&RD
-    Date          : 2018-12-27
-    Description   : .C file function description
-    Version       : 1.0
-    Function List :
-
-    Record        :
-    1.Date        : 2018-12-27
-     Author      : Bruce HW&RD
-     Modification: Created file
-
-********************************************************************************/
-
 #include "FU68xx_5.h"
 #include <Myproject.h>
 

+ 2 - 67
User/Application/FocControlFunction.c

@@ -438,52 +438,6 @@ void MC_Stop(void)
     ClrBit(DRV_CR, FOCEN);    //关闭FOC                                                                                                         // disable FOC output and initial register
     mcState = mcInit;
 }
-
-/*  -------------------------------------------------------------------------------------------------
-    Function Name : void MotorControlInit(void)
-    Description   : 控制变量初始化清零,包括保护参数的初始化、电机状态初始化
-    Input         : 输入说明(详细)
-    Output        : 输出说明(详细)
-    -------------------------------------------------------------------------------------------------*/
-void MotorcontrolInit(void)
-{
-    memset(&Uartwatch, 0, sizeof(MCUART_watch));
-    memset(&RealTempR, 0, sizeof(ADCRR));
-    /***********保护******************/
-    memset(&mcFaultDect, 0, sizeof(FaultVarible));        // FaultVarible变量清零
-    /************保护次数*************/
-    memset(&mcProtectTime, 0, sizeof(ProtectVarible));    // ProtectVarible保护次数清零
-    /***********过流保护**************/
-    memset(&mcCurVarible, 0, sizeof(CurrentVarible));     // 电流保护的变量清零
-    memset(&Uart, 0, sizeof(MCUART));
-    memset(&Fengji_FG, 0, sizeof(FENGFG));
-    memset(&Time, 0, sizeof(TIMERTypeDef));
-    memset(&bujindianji, 0, sizeof(BUJINDIAN));      //
-    bujindianji.bujinsuss = 1;
-    memset(&PFCFaultDect, 0, sizeof(PFCFaultVarible));
-    memset(&ConTrolCmd, 0, sizeof(CONTROLCMDD));
-    #if (PFCEnable==1)
-    memset(&PFCSet, 0, sizeof(PFCValue));
-    PFCCONTROL.FlagONOFF = 0;
-    #endif
-    /*****电机状态机时序变量***********/
-    McStaSet.SetMode                   = 0;
-    /*************外部控制环************/
-    memset(&mcFocCtrl, 0, sizeof(FOCCTRL));             // mcFocCtrl变量清零
-    mcFocCtrl.mcDcbus_chazhi = 32760;
-    /******ADC采样滤波值*********/
-    memset(&AdcSampleValue, 0, sizeof(ADCSample));      // ADCSample变量清零
-    /**************************电流偏置校准变量**********************/
-    memset(&mcCurOffset, 0, sizeof(CurrentOffset));    // mcCurOffset变量清零
-    mcCurOffset.IuOffsetSum            = 16383;
-    mcCurOffset.IvOffsetSum            = 16383;
-    mcCurOffset.Iw_busOffsetSum        = 16383;
-    /*****速度环的响应***/
-    memset(&mcSpeedRamp, 0, sizeof(MCRAMP));          // mcSpeedRamp变量清零
-    mcSpeedRamp.IncValue    = Motor_Speed_Inc;
-    mcSpeedRamp.DecValue    = Motor_Speed_Dec;
-}
-
 /*---------------------------------------------------------------------------*/
 /*  Name     :   void VariablesPreInit(void)
     /* Input    :   NO
@@ -522,38 +476,19 @@ void GetCurrentOffset(void)
         
         while (ReadBit(ADC_CR, ADCBSY));
         
-        #if (Shunt_Resistor_Mode == Single_Resistor)    // 29.2ms 单电阻模式,上电验证硬件电路时,需观察mcCurOffset.IbusOffset是否为4096
-        mcCurOffset.Iw_busOffsetSum += ((ADC4_DR & 0x7ff8));
-        mcCurOffset.Iw_busOffset     = mcCurOffset.Iw_busOffsetSum >> 4;
-        mcCurOffset.Iw_busOffsetSum -= mcCurOffset.Iw_busOffset;
-        #elif (Shunt_Resistor_Mode == Double_Resistor)  //44ms 双电阻模式,上电验证硬件电路时,需观察mcCurOffset.IaOffset、mcCurOffset.IbOffset是否为4096
         mcCurOffset.IuOffsetSum     += ((ADC0_DR & 0x7ff8));
         mcCurOffset.IuOffset         = mcCurOffset.IuOffsetSum >> 4;
         mcCurOffset.IuOffsetSum     -= mcCurOffset.IuOffset;
         mcCurOffset.IvOffsetSum     += ((ADC1_DR & 0x7ff8));
         mcCurOffset.IvOffset         = mcCurOffset.IvOffsetSum >> 4;
         mcCurOffset.IvOffsetSum     -= mcCurOffset.IvOffset;
-        mcCurOffset.Iw_busOffset = mcCurOffset.IvOffset; //
-        //            mcCurOffset.Iw_busOffsetSum += ((ADC4_DR& 0x7ff8));
-        //            mcCurOffset.Iw_busOffset     = mcCurOffset.Iw_busOffsetSum >> 4;
-        //            mcCurOffset.Iw_busOffsetSum -= mcCurOffset.Iw_busOffset;
-        #elif (Shunt_Resistor_Mode == Three_Resistor)   //58.2ms 三电阻模式,上电验证硬件电路时,需观察mcCurOffset.IaOffset、mcCurOffset.IbOffset、mcCurOffset.IcOffset是否为4096
-        mcCurOffset.IuOffsetSum     += ((ADC0_DR & 0x7ff8));
-        mcCurOffset.IuOffset         = mcCurOffset.IuOffsetSum >> 4;
-        mcCurOffset.IuOffsetSum     -= mcCurOffset.IuOffset;
-        mcCurOffset.IvOffsetSum     += ((ADC1_DR & 0x7ff8));
-        mcCurOffset.IvOffset         = mcCurOffset.IvOffsetSum >> 4;
-        mcCurOffset.IvOffsetSum     -= mcCurOffset.IvOffset;
-        mcCurOffset.Iw_busOffsetSum += ((ADC4_DR & 0x7ff8));
-        mcCurOffset.Iw_busOffset     = mcCurOffset.Iw_busOffsetSum >> 4;
-        mcCurOffset.Iw_busOffsetSum -= mcCurOffset.Iw_busOffset;
-        #endif
+        mcCurOffset.Iw_busOffset = mcCurOffset.IvOffset;
         mcCurOffset.OffsetCount++;
         
         if (mcCurOffset.OffsetCount > Calib_Time)
         {
             if (((mcCurOffset.IuOffset > 19959) || (mcCurOffset.IuOffset < 10107)) ||
-                ((mcCurOffset.IvOffset > 19959) || (mcCurOffset.IvOffset < 10107)))//偏置电压不在正常范围内
+                ((mcCurOffset.IvOffset > 19959) || (mcCurOffset.IvOffset < 10107)))
             {
                 mcFaultSource = FaultIbusOffset;//进入偏置电压错误保护
                 FaultProcess();

+ 55 - 54
User/Application/intint.c

@@ -4,7 +4,6 @@
 
 void VREFConfigInit(void)
 {
-    /************************VREF&VHALF Config************************/
     #if (HW_ADC_VREF == VREF3_0)
     {
         SetBit(VREF_VHALF_CR, VRVSEL1);             //00-->4.5V   01-->VDD5
@@ -27,64 +26,50 @@ void VREFConfigInit(void)
     }
     #endif
     #if (VREF_OUT_EN)
-    SetBit(P3_AN, PIN5);                         //VREF Voltage -->P35 Output ?????P35??,???????
-    SetBit(P3_OE, PIN5);                         //VREF Voltage -->P35 Output ?????P35??
+    SetBit(P3_AN, PIN5);
+    SetBit(P3_OE, PIN5);
     #endif
     #if (VHALF_OUT_EN)
     SetBit(P3_AN, P32);
     #endif
-    SetBit(VREF_VHALF_CR, VREFEN | VHALFEN);    //VREF_VHALF_CR = 0x11;
-    /* ---------------------------------------------------------------------- */
+    SetBit(VREF_VHALF_CR, VREFEN | VHALFEN);
 }
-/*  -------------------------------------------------------------------------------------------------
-    Function Name : void HardwareInit(void)
-    Description   : 硬件初始化,初始化需要使用的硬件设备配置,FOC必须配置的是运放电压、运放初始化、ADC初始化、Driver初始化
-                    ,其他的可根据实际需求加。
-    Input         : 无
-    Output        : 无
-    -------------------------------------------------------------------------------------------------*/
+
+
 void HardwareInit(void)
 {
-    /************************VREF&VHALF Config************************/
-    VREFConfigInit();//参考电压初始化
-    /*********硬件FO过流,比较器初始化,用于硬件过流比较保护*********/
-    #if (HardwareCurrent_Protect == Hardware_FO_Protect)     //外部中断初始化,用于外部中断硬件过流FO的保护
-    INT0_Init();
-    #elif (HardwareCurrent_Protect == Hardware_CMP_Protect)  //选择比较过流,比较器初始化
-    CMP3_Init();
-    #elif (HardwareCurrent_Protect == Hardware_FO_CMP_Protect)//两者都选择
-    INT0_Init();
-    CMP3_Init();
-    #endif
-    // 为提高芯片的抗干扰能力,降低芯片功耗,将不需要用的GPIO默认都配置为输入上拉。
-    //    GPIO_Default_Init();
-    /************************硬件外设初始化**************************/
-    UART1_Init();           //调试工具初始化
-    #if (Uart_Select==Uart_MoNi)
-    MONI_UART1_Init();      //模拟串口初始化
-    #elif (Uart_Select==Uart_Yingjian)
-    UART2_Init();
-    #endif
-    GPIO_Init();            //GPIO初始化
-    ADC_Init();             //ADC初始化
-    AMP_Init();             //运放初始化
-    #if (PFCEnable == 1)//PFC比较器初始化
-    SetBit(P1_AN, P13 | P14 | P15);
-    ClrBit(P1_OE, P13);
-    SetBit(AMP_CR0, AMP3EN);
-    #endif
-    Driver_Init();          //pwm初始化
-    CMP3_Interrupt_Init();  // 比较器中断配置  建议和比较器初始化间隔一段时间
-    Timer3_Init();          //PWM OUTput 风机控制
-    Timer4_Init();          //FG 捕获
-    /***********SYSTICK定时器配置*******************/
+    // 上电等待
+    uint16 PowerUpCnt = 0;
+    
+    for (PowerUpCnt = 0; PowerUpCnt < 10000; PowerUpCnt++) {};
+    
+    // 参考电压初始化
+    VREFConfigInit();
+    
+    // 外部中断初始化 预驱故障中断保护
+	PreDriverFalutInt();
+		
+    GPIO_Init();
+    
+    ADC_Init();
+    
+    AMP_Init();
+    
+    Driver_Init();
+    
+    CMP3_Interrupt_Init();
+    
     SYST_ARR = 24000;
+    
     SetBit(IP2, PSYSTICK0);
-    //      SetBit(IP2 , PSYSTICK1);
+    
     SetBit(DRV_SR, SYSTIE);
+    
     _nop_(); _nop_();
+    
     #if (PFCEnable==1)//PFC初始化
     PFC_init();
+    
     #endif
     PI2_Init();
 }
@@ -97,15 +82,31 @@ void HardwareInit(void)
     ----------------------------------------------------------------------------------*/
 void SoftwareInit(void)
 {
-    /****初始化所有定义的参数变量****/
-    MotorcontrolInit();
-    /****电机初始状态为mcReady,故障保护为无故障******/
+    memset(&mcFaultDect, 0, sizeof(FaultVarible));        // FaultVarible变量清零
+    /************保护次数*************/
+    memset(&mcProtectTime, 0, sizeof(ProtectVarible));    // ProtectVarible保护次数清零
+    /***********过流保护**************/
+    memset(&mcCurVarible, 0, sizeof(CurrentVarible));     // 电流保护的变量清零
+    memset(&Time, 0, sizeof(TIMERTypeDef));
+    memset(&PFCFaultDect, 0, sizeof(PFCFaultVarible));
+    memset(&ConTrolCmd, 0, sizeof(CONTROLCMDD));
+    /*****电机状态机时序变量***********/
+    McStaSet.SetMode                   = 0;
+    /*************外部控制环************/
+    memset(&mcFocCtrl, 0, sizeof(FOCCTRL));             // mcFocCtrl变量清零
+    mcFocCtrl.mcDcbus_chazhi = 32760;
+    /******ADC采样滤波值*********/
+    memset(&AdcSampleValue, 0, sizeof(ADCSample));      // ADCSample变量清零
+    /**************************电流偏置校准变量**********************/
+    memset(&mcCurOffset, 0, sizeof(CurrentOffset));    // mcCurOffset变量清零
+    mcCurOffset.IuOffsetSum            = 16383;
+    mcCurOffset.IvOffsetSum            = 16383;
+    mcCurOffset.Iw_busOffsetSum        = 16383;
+    /*****速度环的响应***/
+    memset(&mcSpeedRamp, 0, sizeof(MCRAMP));          // mcSpeedRamp变量清零
+    mcSpeedRamp.IncValue    = Motor_Speed_Inc;
+    mcSpeedRamp.DecValue    = Motor_Speed_Dec;
     mcState       = mcReady;
-    PFCState      = PFCReady;
     mcFaultSource = 0;
-    PFCFaultSource = 0;
-    Uart.u1IduRevDataCnt = 0;
-    Uartwatch.cunflag = 1;
-    _nop_(); _nop_();
 }
 

+ 14 - 28
User/Application/main.c

@@ -1,49 +1,35 @@
-#include "FU68xx_5.h"
+/**
+    @copyright None
+    @file      main.c
+    @author    Comment Vivre
+    @date      2025-10-31
+    @brief     主函数 主循环
+*/
 #include <Myproject.h>
 
-extern uint16 PFCoffset;
-/********************************************************************************
-    Function Definition
-********************************************************************************/
 
+/**
+    @function     main
+    @brief        主函数 电机驱动主循环 任务循环
+    @date         2025-10-31
+*/
 void main(void)
 {
-    uint16 PowerUpCnt = 0;
-    
-    for (PowerUpCnt = 0; PowerUpCnt < SystemPowerUpTime; PowerUpCnt++) {};
-    
-    /*******************Hardware & Software Initial********************/
     HardwareInit();
-    
     SoftwareInit();
-    
-    //    Sys_Ctr_Int();
-    /****************************总中断使能**************************/
     EA = 1;
-    
     _nop_(); _nop_(); _nop_();
+    WatchDogConfig(600, Enable);
     
-    WatchDogConfig(600, Enable);//看们狗初始化
-    
-    Uart.Oder = 0x11; //初始值
-    
-    //    DMA0_XRAMToUART_Init();
-    //  Conf_DMA(1, XDATA_UART1, (uint16)GetAddr_UARTDBG(), DMALENT);
     while (1)
     {
-        PFCSet.OffsetFlag = 1;
-        
         if (flag_1ms_main == 1)
         {
             main_ms();
             flag_1ms_main   = 0;
         }
         
-        if (PFCSet.OffsetFlag == 1)
-        {
-            GetCurrentOffset(); // 压机电流偏置的获取
-        }
-        
+        GetCurrentOffset();
         MC_Control(); // 压机主控函数,状态扫描 2.6k
         User_Dri_main(); //用户使用主函数
         

+ 25 - 65
User/Hardware/GPIO.c

@@ -1,23 +1,3 @@
-/********************************************************************************
-
- **** Copyright (C), 2020, Fortior Technology Co., Ltd.                      ****
-
- ********************************************************************************
-    File Name     : GPIO.c
-    Author        : Bruce HW&RD
-    Date          : 2020-10-15
-    Description   : .C file function description
-    Version       : 1.0
-    Function List :
-
-    Record        :
-    1.Date        : 2020-10-15
-     Author      : Bruce HW&RD
-     Modification: Created file
-
-********************************************************************************/
-
-#include "FU68xx_5.h"
 #include <Myproject.h>
 
 void GPIO_Init(void)
@@ -60,53 +40,31 @@ void GPIO_Init(void)
 
 
 
-
-
-/*****************************************************************************
-    Function      : INT0_Init
-    Description   : INT0初始化
-    Input         : void
-    Output        : None
-    Return        :
-    Others        :
-    Record
-    1.Date        : 20201015
-     Author      : Bruce HW&RD
-     Modification: Created function
-
-*****************************************************************************/
-void INT0_Init(void)
+/**
+ * @function     PreDriverFalutInt
+ * @brief        预驱故障中断
+ * @date         2025-10-31
+*/
+void PreDriverFalutInt(void)
 {
-    /*EXTI Input Pin 配置 ---------------------------------------- */
-    ClrBit(P0_OE, PIN2);   // config P00 as input,配置P0.0为硬件过流FO端口
-    ClrBit(P0_PU, PIN2);   // 0:disable pull up, 1:enable P10 pull up
-    SetReg(LVSR, EXT0CFG0 | EXT0CFG1 | EXT0CFG2, EXT0CFG1);   //外部中断0配置
-    IF0  = 0; // clear P00 interrupt flag
-    // 00: rising edge interrupt,01: failing edge interrupt,1x: edge-change mode interrupt
-    IT01 = 0;
+	// 关闭输出 配置上拉
+	ClrBit(P0_OE, PIN2);
+	SetBit(P0_PU, PIN2);
+	// 中断源配置为P02
+	SetReg(LVSR, EXT0CFG0 | EXT0CFG1 | EXT0CFG2, EXT0CFG1);
+	// 清除中断标志位
+	IF0 = 0;
+	// 配置为下降沿触发
+	IT01 = 0;
     IT00 = 1;
-    SetBit(EVT_FILT, INT0_MOE_EN);  //INT0中断关闭MOE使能
-    /*  ----------------------------------------------------------------------------------
-        母线电流保护时间滤波宽度
-        00-不滤波
-        01-6cpu clock
-        10-12cpu clock
-        11-24cpu clock
-        -----------------------------------------------------------------------------------*/
-    SetBit(EVT_FILT, EFDIV1);
-    ClrBit(EVT_FILT, EFDIV0);
-    /*  ---------------------------------------------------------------------------
-        外部中断优先级配置及芯片中断总使能
-        PX01-PX00,中断优先级控制值从0-3依次表示优先级从最低到最高,共4级优化级控制
-        EX0,外部中断0使能
-        EA,芯片中断总使能
-        外部中断是否有滤波的配置,决定于选择硬件保护触发信号源,外部中断0或者比较器3中断。
-        若选择了比较器3中断,则外部中断无法进行滤波配置
-        --------------------------------------------------------------------------*/
-    SetBit(IP0, PX01); //优先级
-    SetBit(IP0, PX00);
-    EX0 = 1;        // 使能外部中断0, POO位外部中断输入硬件
-    EA = 1;         // 使能全局中断
+	// 中断触发时自动关闭MOE
+	SetBit(EVT_FILT, INT0_MOE_EN);
+	// 不滤波
+    ClrBit(EVT_FILT, EFDIV0 | EFDIV1);
+	// 配置中断优先级为最高
+	SetBit(IP0, PX00 |PX01);
+	// 外部中断0使能
+	EX0 = 1;
 }
 
 void INT1_Init(void)
@@ -131,3 +89,5 @@ void WatchDogConfig(uint32 value, uint8 Status)
     SetBit(WDT_CR, WDTRF);
 }
 
+
+

+ 3 - 3
User/Hardware/UART.c

@@ -293,9 +293,9 @@ void UartDealResponse(void)
         Uart.T_DATA[2]  =  S_Value2;                                                           //压机速度(rps)
         Uart.T_DATA[3]  =  Fengji_FG.FENJIPINLV2 / 10;                                         //风机转速
         Uart.T_DATA[4]  =  Uart.PengZhangFa_ACT ;                                              //电子膨胀阀开度
-        Uart.T_DATA[5]  =  (uint8)(Huan_temp / 5 + 100); //(uint8)(RealTempjisuan(AdcSampleValue.ADC_huan_temp>>3,3)/5+100) ;   //环境温度
-        Uart.T_DATA[6]  =  (uint8)(Guan_temp / 5 + 100); //(uint8)(RealTempjisuan(AdcSampleValue.ADC_guan_temp>>3,2)/5+100) ;   //交换器温度
-        Uart.T_DATA[7]  =  (uint8)(Paiqi_temp / 10 + 50); //(uint8)(RealTempjisuan(AdcSampleValue.ADC_paiqi_temp>>3,1)/10+50) ;  //排气温度
+        Uart.T_DATA[5]  =  (uint8)(Huan_temp / 5 + 100);
+        Uart.T_DATA[6]  =  (uint8)(Guan_temp / 5 + 100);
+        Uart.T_DATA[7]  =  (uint8)(Paiqi_temp / 10 + 50); 
         Uart.T_DATA[8]  =  0x00 ;                                                                //预留
         Uart.T_DATA[9]  =  FaultCommuMonCt ;                                                      //预留
         Uart.T_DATA[10] =  checkAdd1(Uart.T_DATA, 0, TX_LEN1 - 1);

+ 0 - 2
User/User_Drive/Temp_compute.h

@@ -14,8 +14,6 @@ typedef struct
 } ADCRR;
 
 extern ADCRR              xdata   RealTempR;
-extern int16 RealTempjisuan(uint16 ADC_vaule, uint8 flag);
-
 
 
 

+ 0 - 5
User/User_Drive/User_Dri_main.c

@@ -6,7 +6,6 @@ extern uint16 sendMessagelength;
 void User_Dri_main(void)            //
 {
     TargetRef_Process1();         //转速获取
-    Temp_jisuan();                        //温度计算
     #if (Debugg==1)
     {
         /*工具程序*/
@@ -15,10 +14,6 @@ void User_Dri_main(void)            //
     }
     #else
     {
-        //  I_IReal_10 实际电流   P_PowerReal实际功率
-        //mcTorqueCompensation.TorqueCompensateIqCurrentValue//mcTorqueCompensation.TorqueCompensateIqCurrentValue+3000
-        //               uart_boxing(2, FOC__THETA ,FOC__IA,IPM_RealTemp(AdcSampleValue.ADC_IPM_temp),RealTempjisuan(AdcSampleValue.ADC_paiqi_temp>>3,1),HW_BOARD_VOLT_MAX*mcFocCtrl.mcDcbusFlt/32767,RealTempjisuan(AdcSampleValue.ADC_guan_temp>>3,2),ID_Align_CURRENT_Start);
-        //              UART1deal();
         trace2();
     }
     #endif

+ 0 - 1
User/include/AddFunction.h

@@ -205,7 +205,6 @@ extern void Trace_Select(void);
 extern int16 fengjiPI(int16 feedbackvalue, int16 referencevalue);
 extern int16 IPM_RealTemp(uint16 ADC_vaule);
 extern void Current_Speed_PI(void);
-extern void Temp_jisuan(void);
 extern void IsLimit_Over_tect(void);
 extern void IsLimit_Over_deal(void);
 extern void Control_Cmd(void);

+ 8 - 9
User/include/Customer.h

@@ -1,7 +1,7 @@
 #ifndef __CUSTOMER_H_
 #define __CUSTOMER_H_
 
-////// ------------ 文件规范化 -------------------------------
+// ------------------------------------------------------------------------------------------------------------------
 // 1.电机相关参数: 电阻(Ω) DQ电感(H) 反电动势常数(V/RPM)  转向(CW/CCW) 基准转速(RPM) 极对数
 #define RS                             (0.5)
 #define LD                             (0.004)
@@ -15,31 +15,30 @@
 
 #define ID_Limit                       I_Value(-Psi/LD/2)
 
+// ------------------------------------------------------------------------------------------------------------------
 // 2.硬件相关:载波频率(KHz) 死区(us) 单电阻最小窗口(us) 驱动电平 基准电压(V) 
 #define PWM_FREQUENCY                  (5.0)
 #define PWM_DEADTIME                   (5.0)
 #define MIN_WIND_TIME                  (5.9)
 #define PWM_Level_Mode                 (High_Level)
 #define HW_ADC_VREF                    (VREF5_0)
+#define HW_ADC_REF                     (5.0)
 // ADC相关滤波使能 运放配置 运放倍数
 #define VREF_OUT_EN                    (1)
 #define VHALF_OUT_EN                   (1)
-#define HW_AMP_MODE                    (AMP_PGA_DUAL)
-#define HW_AMPGAIN                     (AMP2x)
-
+#define HW_AMP_MODE                    (AMP_NOMAL)
+#define HW_AMPGAIN                     (0.5)
 
 
+// ------------------------------------------------------------------------------------------------------------------
+// 3.其他
 
+#define HW_RSHUNT                      (0.04)                                  // (Ω)  采样电阻
 #define I_ValueX(Curr_Value)            (Curr_Value * HW_RSHUNT * HW_AMPGAIN / (HW_ADC_REF))
 #define I_Value(Curr_Value)             _Q15(I_ValueX(Curr_Value))
 
 #define MCU_CLOCK                      (24.0)                                  // (MHz) 主频
 
-
-#define HW_RSHUNT                      (0.04)                                  // (Ω)  采样电阻
-#define HW_ADC_REF                     (5.0)                                   // (V)  ADC参考电压  //5.0
-#define HW_ADC_REF_HALF                (2.5)                                   // (V)  ADC参考电压  //5.0
-
 #define RV1                            (940.0)                                  // (kΩ) 母线电压分压电阻1
 #define RV2                            (940.0)                                  // (kΩ) 母线电压分压电阻2
 #define RV3                            (0.3)                                    // (kΩ) 母线电压分压电阻3

+ 0 - 1
User/include/FocControl.h

@@ -63,7 +63,6 @@ extern PFCStaType   PFCState;
 /* Exported functions --------------------------------------------------------------------*/
 extern void MC_Control(void);
 extern void PFCRUN_Control(void);
-extern void MotorcontrolInit(void);
 extern void McTailWindDealwith(void);
 
 extern void TailWindDealwith(void);

+ 0 - 1
User/include/FocControlFunction.h

@@ -37,7 +37,6 @@ extern void TailWindDealwith(void);
 extern void Motor_Open(void);
 extern void Motor_Align(void);
 extern void McTailWindDealwith(void);
-extern void MotorcontrolInit(void);
 extern void BEMFTailWindDealwith(void);
 
 

+ 2 - 2
User/include/GPIO.H

@@ -10,7 +10,6 @@
 #define WAY4			      GP01          //四通阀口
 #define RST			        GP04          //驱动复位
 #define PTC_RELAY			  GP51          //PTC延时继电器口     家用GP51    商用GP42
-//#define Feng_FG		      GP00          //风机转速获取口
 #define AC_FAN_CTR		  GP44          //风机转速获取口
 
 
@@ -32,12 +31,13 @@
 /*************************************************************************************///External Function
 
 extern void GPIO_Init(void);
-extern void INT0_Init(void);
 extern void INT1_Init(void);
 extern void WatchDogConfig(uint32 value, uint8 Status);
 
 
 
+void PreDriverFalutInt(void);
+
 #endif
 
 

+ 3 - 18
User/include/Myproject.h

@@ -1,20 +1,9 @@
-/**************************** (C) COPYRIGHT 2017 Fortiortech shenzhen *****************************
-* File Name          : Myproject.h
-* Author             : Fortiortech Appliction Team
-* Version            : V1.0
-* Date               : 2017-12-27
-* Description        : This file contains all the common data types used for
-*                      Motor Control.
-***************************************************************************************************
-* All Rights Reserved
-**************************************************************************************************/
-
-/* Define to prevent recursive inclusion --------------------------------------------------------*/
 #ifndef __MYPROJECT_H_
 #define __MYPROJECT_H_
 
-/* Includes -------------------------------------------------------------------------------------*/
 #include <FU68xx_5.h>
+#include <FU68xx_5_Type.h>
+
 #include <Customer.h>
 #include <Parameter.h>
 #include <AddFunction.h>
@@ -30,21 +19,17 @@
 #include <DMA.h>
 #include <SPI.h>
 #include <TIMER.h>
-#include <Customer_Debug.h>
 #include <FocControlFunction.h>
 #include <FocControl.h>
 #include <PIInit.h>
-//#include "RSDDetect.h"
 #include <FOCTailDect.h>
 #include <Pfc.h>
 #include <FiledWeaken.h>
 #include <Communication.h>
 #include <TorqueCompensation.h>
-#include	<UART_4800.h>
-//#include "BEMFDetect.h"
+#include <UART_4800.h>
 #include <RPD.h>
 #include <Cmp.h>
-#include <FU68xx_5_Type.h>
 #include <intint.h>
 #include <Protect.h>
 #include <ProtectSet.h>

+ 0 - 2
User/include/Parameter.h

@@ -26,8 +26,6 @@
 #define _Q15(A)                         (int16)((A) * 0x7fff)       ///< Q15 format  128*256= 32767
 #define _Q16                            (65535.0)                   // Q16 format value
 #define _2PI                            (3.1415926 * 2) 
-/* Private define ------------------------------------------------------------*/
-#define SystemPowerUpTime               (10000)                                       // 上电等待时间,cpu计数时钟
 /*芯片参数值------------------------------------------------------------------*/
 /*CPU and PWM Parameter*/
 #define PWM_CYCLE                       (1000.0 / PWM_FREQUENCY)                      // 周期us

+ 49 - 0
readme.md

@@ -0,0 +1,49 @@
+### 30KW 电机驱动
+
+#### IO接口说明
+##### AD部分
+- VDCAD P24 AD2 		高压直流电压
+- VACAD P25 AD3 		三相交流电压
+- IAD 	 P27 AD4 		4-20mA信号采样
+- VAD   P30 			0-10V信号采样
+- NTC2  P33 AD6
+- NTC1  P34 AD7
+
+- VFO   P02     驱动器故障指示 低触发
+- RESET P04     驱动器复位     低触发
+- OH    P26 DA0 AD11   模块RTH1
+
+
+##### 六个按键 
+- 按下接地 初始化为上拉输入
+- KW1   P01
+- KW2   P07 
+- KW3   P00
+- KW4   P10
+- KW5   P11
+- KW6   P41
+
+##### 运放部分
+- 1P    P16 A1P
+- 1M    P17 A1M
+- 1O    P20 A1O AD0
+- 2P    P21 A2P
+- 2M    P22 A2M
+- 2O    P23 A2O AD1
+
+##### 通讯接口
+- MTXD  P05 TXD
+- MRXD  P06 RXD
+- RXD   P36 RXD2
+- TXD   P37 TXD2
+
+##### 外部接口
+- IN1   P31 			外部接口IN1
+- LP    P46 AD15		外部接口
+- T3    P13 AD12		外部接口
+- T2    P14 AD10		外部接口
+- T1    P15 AD13		外部接口
+
+##### 其他
+- LED   P03         LED上拉 低电平点亮
+- PTC   P51         主电源继电器驱动 高使能