|
|
@@ -9,7 +9,7 @@
|
|
|
|
|
|
|
|
|
// math.h包含算术运算的数学函数
|
|
|
-#include <math.h>
|
|
|
+#include <math.h>
|
|
|
#include <Definition.h>
|
|
|
|
|
|
typedef enum
|
|
|
@@ -25,7 +25,7 @@ typedef enum
|
|
|
mcStop = 8,
|
|
|
mcFault = 9,
|
|
|
mcBrake = 10
|
|
|
-}MotStaType;
|
|
|
+} MotStaType;
|
|
|
|
|
|
|
|
|
|
|
|
@@ -46,7 +46,7 @@ void SPI_Init(void);
|
|
|
void WatchDogConfig(uint32 value, uint8 Status);
|
|
|
|
|
|
|
|
|
-unsigned short CRC_Check(unsigned char start_sector , unsigned char offset_sector);
|
|
|
+unsigned short CRC_Check(unsigned char start_sector, unsigned char offset_sector);
|
|
|
|
|
|
|
|
|
extern void FOC_Init(void);
|
|
|
@@ -57,19 +57,19 @@ extern void Motor_Open(void);
|
|
|
#if (FiledWeakenCompEnable)
|
|
|
typedef struct
|
|
|
{
|
|
|
- uint16 FieldWeakenActualUS_Q15;
|
|
|
+ uint16 FieldWeakenActualUS_Q15;
|
|
|
uint16 FieldWeakenActualDcbus_Q15;
|
|
|
int16 FieldWeakenIsTheta;
|
|
|
- int16 mcIqref;
|
|
|
+ int16 mcIqref;
|
|
|
int16 mcIdref;
|
|
|
-}FieldWeakeningTypeDef;
|
|
|
+} FieldWeakeningTypeDef;
|
|
|
|
|
|
-FieldWeakeningTypeDef xdata mcFieldWeaken;
|
|
|
-void GetFieldWeakenUsAndUdc_Q15(int16 Ud, int16 Uq , uint16 Dcbus);
|
|
|
+FieldWeakeningTypeDef xdata mcFieldWeaken;
|
|
|
+void GetFieldWeakenUsAndUdc_Q15(int16 Ud, int16 Uq, uint16 Dcbus);
|
|
|
void GetFieldWeakenIdRefAndIqRef_Q15(int16 Is);
|
|
|
void GetFieldWeakenIsTheta_Q15(void);
|
|
|
int16 mcFieldWeakenPI(int16 feedbackvalue, int16 referencevalue);
|
|
|
-void FiledWeakenControl(int16 Ud, int16 Uq , uint16 Dcbusk,int16 Is);
|
|
|
+void FiledWeakenControl(int16 Ud, int16 Uq, uint16 Dcbusk, int16 Is);
|
|
|
#endif
|
|
|
|
|
|
#define P_Power(POWER) _Q15(POWER*2/HW_BOARD_CURR_BASE/HW_BOARD_VOLTAGE_BASE/1.5)
|
|
|
@@ -86,16 +86,16 @@ typedef struct
|
|
|
|
|
|
typedef struct
|
|
|
{
|
|
|
- int16 mcDcbusFlt; // 母线电压
|
|
|
- int16 mcDcbus_max; // 母线电压最大值
|
|
|
- int16 mcDcbus_min; // 母线电压最小值
|
|
|
- int16 mcDcbus_chazhi; // 母线电压最小值
|
|
|
- int16 Powerlpf; // 功率滤波后的值
|
|
|
+ int16 mcDcbusFlt; // 母线电压
|
|
|
+ int16 mcDcbus_max; // 母线电压最大值
|
|
|
+ int16 mcDcbus_min; // 母线电压最小值
|
|
|
+ int16 mcDcbus_chazhi; // 母线电压最小值
|
|
|
+ int16 Powerlpf; // 功率滤波后的值
|
|
|
|
|
|
- int16 UQFlt; // UQ滤波后的值
|
|
|
- int16 UDFlt; // UD滤波后的值
|
|
|
+ int16 UQFlt; // UQ滤波后的值
|
|
|
+ int16 UDFlt; // UD滤波后的值
|
|
|
|
|
|
- uint16 State_Count; // 电机各个状态的时间计数
|
|
|
+ uint16 State_Count; // 电机各个状态的时间计数
|
|
|
} FOCCTRL;
|
|
|
|
|
|
extern CurrentVarible xdata mcCurVarible;
|
|
|
@@ -121,10 +121,11 @@ typedef enum
|
|
|
FaultLossPhase = 5, // 缺相保护
|
|
|
FaultStall = 6, // 堵转保护
|
|
|
FaultStart = 7, // 启动保护
|
|
|
- FaultIpmTemp = 9, // IPM温度保护
|
|
|
- FaultIbusOffset = 11, // pianzhi
|
|
|
- FaultshuruLoss = 14,
|
|
|
-
|
|
|
+ FaultIPMOTErr = 9, // IPM温度保护
|
|
|
+ FaultOffsetError = 11, // pianzhi
|
|
|
+ FaultOverPower = 12,
|
|
|
+ FaultshuruLoss = 14,
|
|
|
+ FaultPWMLoss = 15,
|
|
|
} FaultStateType;
|
|
|
|
|
|
|
|
|
@@ -136,44 +137,44 @@ typedef struct
|
|
|
uint16 CurrentPretectTimes; // 过流保护次数
|
|
|
uint8 StartFlag; // 启动保护的标志位,用于判断哪个方法起作用
|
|
|
uint8 StallFlag; // 堵转保护的标志位,用于判断哪个方法起作用
|
|
|
- uint8 IbusOffsetProtectTimes; //偏执电压保护次数
|
|
|
- uint8 shurulossTimes;
|
|
|
-
|
|
|
-}ProtectVarible;
|
|
|
+ uint8 IbusOffsetProtectTimes; //偏执电压保护次数
|
|
|
+ uint8 shurulossTimes;
|
|
|
+
|
|
|
+} ProtectVarible;
|
|
|
|
|
|
typedef struct
|
|
|
{
|
|
|
uint8 segment; // 分段执行
|
|
|
-
|
|
|
+
|
|
|
//voltage protect
|
|
|
uint16 OverVoltDetecCnt; // 过压检测计数
|
|
|
uint16 UnderVoltDetecCnt; // 欠压检测计数
|
|
|
uint16 VoltRecoverCnt; // 过压恢复计数
|
|
|
- uint16 OverTempDetecCnt; // 过温检测计数
|
|
|
- uint16 OverHuantempDetecCnt; // 过温检测计数
|
|
|
- uint16 OverGuantempDetecCnt; // 过温检测计数
|
|
|
- uint16 TempRecoverCnt; // 过温恢复计数
|
|
|
- uint16 HuantempRecoverCnt; // 过温恢复计数
|
|
|
- uint16 GuantempRecoverCnt; // 过温恢复计数
|
|
|
+ uint16 OverTempDetecCnt; // 过温检测计数
|
|
|
+ uint16 OverHuantempDetecCnt; // 过温检测计数
|
|
|
+ uint16 OverGuantempDetecCnt; // 过温检测计数
|
|
|
+ uint16 TempRecoverCnt; // 过温恢复计数
|
|
|
+ uint16 HuantempRecoverCnt; // 过温恢复计数
|
|
|
+ uint16 GuantempRecoverCnt; // 过温恢复计数
|
|
|
uint32 CurrentRecoverCnt; // 过流保护恢复计数
|
|
|
-
|
|
|
- uint8 IbusOffsetRecoverCnt; ///偏执电压保护恢复次数
|
|
|
+
|
|
|
+ uint8 IbusOffsetRecoverCnt; ///偏执电压保护恢复次数
|
|
|
//stall protect
|
|
|
uint16 StallDelayCnt; // 堵转延迟判断计时
|
|
|
uint16 StallDectEs; // method 1,与ES相关
|
|
|
- uint16 StallDectEs2; // method 1,与ES相关
|
|
|
+ uint16 StallDectEs2; // method 1,与ES相关
|
|
|
uint16 StallDectSpeed; // method 2,与速度相关
|
|
|
uint32 StallReCount; // 堵转保护恢复计数
|
|
|
-
|
|
|
+
|
|
|
//Loss Phase protect
|
|
|
uint16 Lphasecnt; // 缺相保护计时
|
|
|
uint16 AOpencnt ; // A缺相计数
|
|
|
uint16 BOpencnt ; // B缺相计数
|
|
|
uint16 COpencnt ; // C缺相计数
|
|
|
uint16 mcLossPHRecCount; // 缺相恢复计数
|
|
|
- uint16 shurulossRecCount; // 缺相恢复计数
|
|
|
- int16 shurulossCnt;
|
|
|
-
|
|
|
+ uint16 shurulossRecCount; // 缺相恢复计数
|
|
|
+ int16 shurulossCnt;
|
|
|
+
|
|
|
int32 CurrentASum;
|
|
|
int32 CurrentBSum;
|
|
|
int32 CurrentCSum;
|
|
|
@@ -182,14 +183,14 @@ typedef struct
|
|
|
int16 CurrentBAlign;
|
|
|
int16 CurrentCAlign;
|
|
|
|
|
|
- //start protect
|
|
|
+ //start protect
|
|
|
int16 StartESCount; // 启动保护判断ES的计数
|
|
|
int16 StartEsCnt; // 启动保护判断ES的计时
|
|
|
int16 StartDelay; // 启动保护判断ES的延迟
|
|
|
int16 StartFocmode; // 启动保护判断FOCMODE状态的计时
|
|
|
int16 StartSpeedCnt; // 启动保护判断速度和ES的计时
|
|
|
- uint32 commu_time;
|
|
|
-}FaultVarible;
|
|
|
+ uint32 commu_time;
|
|
|
+} FaultVarible;
|
|
|
|
|
|
extern FaultStateType xdata mcFaultSource;
|
|
|
extern ProtectVarible xdata mcProtectTime;
|