|
@@ -345,7 +345,7 @@ void MC_OverCurrent_SoftProtect_Process(uint16_t BusCurrent, uint16_t MaxCurrent
|
|
|
|
|
|
/******************************全局函数定义******************************/
|
|
|
#define OC_CLEARFLAG_DELAYTIME 15 //过流标志间隔清零延时,单位ms
|
|
|
-#define OC_COUNTER_TH 1000 //过流保护计数判断阈值
|
|
|
+#define OC_COUNTER_TH 100 //过流保护计数判断阈值
|
|
|
//过流保护检测
|
|
|
/*
|
|
|
检测原理:
|
|
@@ -356,38 +356,39 @@ void MC_OverCurrent_SoftProtect_Process(uint16_t BusCurrent, uint16_t MaxCurrent
|
|
|
|
|
|
更改处理方式20210630
|
|
|
1、关闭过流告警;
|
|
|
-2、出现过流信号时,封闭PWM2个周期。
|
|
|
+2、出现过流信号时,封闭PWM2个周期
|
|
|
*/
|
|
|
void MC_Protect_OverCurrent_Process(FlagStatus* OverCurrentTrigFlag, MC_ErrorCode_Struct_t* p_MC_ErrorCode)
|
|
|
{
|
|
|
static uint8_t OffPwmCnt = 0; //过流信号触发后,关闭PWM延时计数
|
|
|
static uint8_t StarPwmCnt = 0; //关闭PWM后启动PWM延时计数
|
|
|
|
|
|
+ if(*OverCurrentTrigFlag == RESET)
|
|
|
{
|
|
|
- if(*OverCurrentTrigFlag == RESET)
|
|
|
+ //关闭PWM计数清零
|
|
|
+ OffPwmCnt = 0;
|
|
|
+ //开启PWM
|
|
|
+ if(StarPwmCnt == 0)
|
|
|
{
|
|
|
- //关闭PWM计数清零
|
|
|
- OffPwmCnt = 0;
|
|
|
- //开启PWM
|
|
|
- if(StarPwmCnt == 0)
|
|
|
- {
|
|
|
- StarPwmCnt++;
|
|
|
- Enable_PwmGpio_Out();
|
|
|
- }
|
|
|
+ StarPwmCnt++;
|
|
|
+ Enable_PwmGpio_Out();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //开启PWM计数清零
|
|
|
+ StarPwmCnt = 0;
|
|
|
+ //2个PWM周期后,过流触发标志复位
|
|
|
+ if(OffPwmCnt >= 1)
|
|
|
+ {
|
|
|
+ *OverCurrentTrigFlag = RESET;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- //开启PWM计数清零
|
|
|
- StarPwmCnt = 0;
|
|
|
//关闭PWM
|
|
|
Disable_PwmGpio_Out();
|
|
|
- //2个PWM周期后,过流触发标志复位
|
|
|
- if(OffPwmCnt >= 1)
|
|
|
- {
|
|
|
- *OverCurrentTrigFlag = RESET;
|
|
|
- }
|
|
|
- OffPwmCnt++;
|
|
|
}
|
|
|
+ OffPwmCnt++;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -414,4 +415,5 @@ void MC_Protect_Check_Process(void)
|
|
|
|
|
|
//软件过流保护检测
|
|
|
MC_OverCurrent_SoftProtect_Process(MC_RunInfo.BusCurrent, MC_ConfigParam1.CurrentLimit * 1000, &MC_ErrorCode);
|
|
|
+
|
|
|
}
|