修改短路保护延时
This commit is contained in:
parent
0fcdfa75d3
commit
557fb2777e
|
@ -59,7 +59,7 @@ void start(void)
|
|||
|
||||
startInfo();
|
||||
|
||||
HAL_Delay(5000);
|
||||
// HAL_Delay(5000);
|
||||
|
||||
TimeSliceOffset_Start();
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@ uint8_t getExcessiveLoad(void);
|
|||
void setExcessiveLoadFlag(BOOL state);
|
||||
BOOL getExcessiveLoadFlag(void);
|
||||
|
||||
void setSoftShortCircuit(uint16_t disChargCurrAdcNum);
|
||||
|
||||
void setPowerOutput(BOOL state);
|
||||
|
||||
void checkAbnormal(void);
|
||||
|
|
|
@ -111,4 +111,12 @@ void readtotalChargCapacity(float *totalChargCapacity);
|
|||
void saveTime(timeInfo *time);
|
||||
void readTime(timeInfo *time);
|
||||
|
||||
|
||||
#define eventsOrderRecordStartAddr 200
|
||||
void setEventsOrderRecord(eventsOrderRecordMode mode);
|
||||
void printfEventsOrderRecord(void);
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -5,8 +5,10 @@
|
|||
#include "checkTime.h"
|
||||
#include "FM_GPIO.h"
|
||||
#include "task.h"
|
||||
#include "configParameter.h"
|
||||
#include "capture.h"
|
||||
|
||||
|
||||
static int checkMode = 0;
|
||||
|
||||
/* 软件输出过载标志位 */
|
||||
static BOOL disChargOverLoad = FALSE;
|
||||
|
@ -18,7 +20,7 @@ static BOOL shortCircuitFlag = FALSE;
|
|||
/* 硬件过载状态位 */
|
||||
static uint8_t excessiveLoad = 0;
|
||||
static BOOL excessiveLoadFlag = FALSE;
|
||||
|
||||
static BOOL excessiveLoadInterruptFlag = FALSE;
|
||||
|
||||
/**
|
||||
* @brief 设定放电过载状态
|
||||
|
@ -28,9 +30,9 @@ static BOOL excessiveLoadFlag = FALSE;
|
|||
*/
|
||||
void setDisChargOverLoad(void)
|
||||
{
|
||||
/* 三段式保护中的两段 */
|
||||
/* 三段式保护中的第三段 */
|
||||
static int num1 = 0;
|
||||
if (getDischargCurrent() > 30.0f) {
|
||||
if (getDischargCurrent() > thirdStageProtectionCurr) {
|
||||
// disChargOverLoad = TRUE;
|
||||
num1++;
|
||||
} else {
|
||||
|
@ -38,22 +40,24 @@ void setDisChargOverLoad(void)
|
|||
num1 = 0;
|
||||
}
|
||||
|
||||
/* 过载时间过长关闭输出(120S) */
|
||||
if (num1 >= 1200000) {
|
||||
/* 过载时间过长关闭输出 */
|
||||
if (num1 >= thirdStageProtectionDelay) {
|
||||
num1 = 0;
|
||||
disChargOverLoad = TRUE;
|
||||
setPowerOutput(FALSE);
|
||||
}
|
||||
|
||||
|
||||
/* 三段式保护中的第二段 */
|
||||
static int num2 = 0;
|
||||
if (getDischargCurrent() > 35.0f) {
|
||||
if (getDischargCurrent() > secondStageProtectionCurr) {
|
||||
num2++;
|
||||
} else {
|
||||
num2 = 0;
|
||||
}
|
||||
|
||||
/* 过载时间过长关闭输出(5S) */
|
||||
if (num1 >= 50000) {
|
||||
/* 过载时间过长关闭输出 */
|
||||
if (num1 >= secondStageProtectionDelay) {
|
||||
num1 = 0;
|
||||
disChargOverLoad = TRUE;
|
||||
setPowerOutput(FALSE);
|
||||
|
@ -66,17 +70,26 @@ void setDisChargOverLoad(void)
|
|||
* @retval
|
||||
*
|
||||
*/
|
||||
void setSoftShortCircuit(void)
|
||||
void setSoftShortCircuit(uint16_t disChargCurrAdcNum)
|
||||
{
|
||||
// /* 三段式保护中的第一段 */
|
||||
// static int num = 0;
|
||||
// if (getDischargCurrent() > firstStageProtectionCurr) {
|
||||
// num++;
|
||||
// } else {
|
||||
// num = 0;
|
||||
// }
|
||||
|
||||
/* 三段式保护中的第一段 */
|
||||
static int num = 0;
|
||||
if (getDischargCurrent() > 50.0f) {
|
||||
if (disChargCurrAdcNum > firstStageProtectionCurr) {
|
||||
num++;
|
||||
} else {
|
||||
num = 0;
|
||||
}
|
||||
|
||||
/* 200uS内都短路则关闭输出 */
|
||||
if (num >= 2) {
|
||||
if (num >= firstStageProtectionDelay) {
|
||||
shortCircuitFlag = TRUE;
|
||||
shortCircuit++;
|
||||
setPowerOutput(FALSE);
|
||||
|
@ -269,6 +282,50 @@ void checkFFMOS_CON(void)
|
|||
|
||||
// }
|
||||
|
||||
/**
|
||||
* @brief 输入功率过低保护
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
void setOverLoad(void)
|
||||
{
|
||||
setPowerOutput(FALSE);
|
||||
setExcessiveLoad();
|
||||
/* 第一次进入输出过载,启动过载保护任务 */
|
||||
if (getExcessiveLoad() == 1) {
|
||||
setExcessiveLoadFlag(TRUE);
|
||||
startExcessiveLoadProtection();
|
||||
}
|
||||
|
||||
/* 多次进入输出过载,关闭输出 */
|
||||
if (getExcessiveLoad() > 2) {
|
||||
zeroExcessiveLoad();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 判断是否输入功率过低
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
void lowInputLoadDetection(void)
|
||||
{
|
||||
static int num = 0;
|
||||
|
||||
if (excessiveLoadInterruptFlag == TRUE && getOutputVoltage() < lowInputLoadDetectionVolt) {
|
||||
num++;
|
||||
} else {
|
||||
num = 0;
|
||||
excessiveLoadInterruptFlag = FALSE;
|
||||
}
|
||||
|
||||
if (excessiveLoadInterruptFlag == TRUE && num == lowInputLoadDetectionDelay) {
|
||||
setOverLoad();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void checkAbnormal(void)
|
||||
{
|
||||
|
@ -285,8 +342,8 @@ void checkAbnormal(void)
|
|||
/* 判断 */
|
||||
checkFFMOS_CON();
|
||||
setDisChargOverLoad();
|
||||
setSoftShortCircuit();
|
||||
|
||||
// setSoftShortCircuit();
|
||||
lowInputLoadDetection();
|
||||
|
||||
|
||||
|
||||
|
@ -302,18 +359,19 @@ void checkAbnormal(void)
|
|||
*/
|
||||
void WORK_VOLT_Interrupt(void)
|
||||
{
|
||||
setPowerOutput(FALSE);
|
||||
setExcessiveLoad();
|
||||
/* 第一次进入输出过载,启动过载保护任务 */
|
||||
if (getExcessiveLoad() == 1) {
|
||||
setExcessiveLoadFlag(TRUE);
|
||||
startExcessiveLoadProtection();
|
||||
}
|
||||
// setPowerOutput(FALSE);
|
||||
// setExcessiveLoad();
|
||||
// /* 第一次进入输出过载,启动过载保护任务 */
|
||||
// if (getExcessiveLoad() == 1) {
|
||||
// setExcessiveLoadFlag(TRUE);
|
||||
// startExcessiveLoadProtection();
|
||||
// }
|
||||
|
||||
/* 多次进入输出过载,关闭输出 */
|
||||
if (getExcessiveLoad() > 2) {
|
||||
zeroExcessiveLoad();
|
||||
}
|
||||
// /* 多次进入输出过载,关闭输出 */
|
||||
// if (getExcessiveLoad() > 2) {
|
||||
// zeroExcessiveLoad();
|
||||
// }
|
||||
excessiveLoadInterruptFlag = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -557,6 +557,10 @@ void chargControlMode(void)
|
|||
endChargWork();
|
||||
}
|
||||
|
||||
else if (getBatteryState() == FALSE) {
|
||||
setMPPT_Mode(noBattery);
|
||||
}
|
||||
|
||||
else if (floatChargConditions()) {
|
||||
setMPPT_Mode(floatCharg);
|
||||
}
|
||||
|
|
|
@ -290,3 +290,56 @@ void readTime(timeInfo *time)
|
|||
{
|
||||
read_Flash((uint8_t *)time, time_SAVE_addr, sizeof(timeInfo));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 将事件顺序记录在flash中
|
||||
* @param
|
||||
*/
|
||||
void setEventsOrderRecord(eventsOrderRecordMode mode)
|
||||
{
|
||||
static uint32_t len = sizeof(int);
|
||||
float temp;
|
||||
write_Flash((uint8_t *)&mode, eventsOrderRecordStartAddr + len, sizeof(mode));
|
||||
len += sizeof(mode);
|
||||
temp = getDischargCurrent();
|
||||
write_Flash((uint8_t *)&temp, eventsOrderRecordStartAddr + len, sizeof(float));
|
||||
len += sizeof(float);
|
||||
temp = getOutputVoltage();
|
||||
write_Flash((uint8_t *)&temp, eventsOrderRecordStartAddr + len, sizeof(float));
|
||||
|
||||
int count = 0;
|
||||
read_Flash((uint8_t *)&count, eventsOrderRecordStartAddr, sizeof(count));
|
||||
count++;
|
||||
write_Flash((uint8_t *)&count, eventsOrderRecordStartAddr, sizeof(count));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 将事件从flash中依次读取出来
|
||||
* @param
|
||||
*/
|
||||
|
||||
void printfEventsOrderRecord(void)
|
||||
{
|
||||
int count = 0;
|
||||
read_Flash((uint8_t *)&count, eventsOrderRecordStartAddr, sizeof(count));
|
||||
|
||||
float temp;
|
||||
eventsOrderRecordMode mode;
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
read_Flash((uint8_t *)&temp, eventsOrderRecordStartAddr + sizeof(int)
|
||||
+ i * (sizeof(float) + sizeof(float)), sizeof(mode));
|
||||
log_info("eventsOrderRecordMode:%d\n", mode);
|
||||
|
||||
read_Flash((uint8_t *)&temp, eventsOrderRecordStartAddr + sizeof(int)
|
||||
+ i * (sizeof(float) + sizeof(float)) + sizeof(mode), sizeof(float));
|
||||
log_info("dischargCurrent:%f\n", temp);
|
||||
|
||||
read_Flash((uint8_t *)&temp, eventsOrderRecordStartAddr + sizeof(int)
|
||||
+ i * (sizeof(float) + sizeof(float)) + sizeof(mode) + sizeof(float), sizeof(float));
|
||||
log_info("OutputVoltage:%f\n", temp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "FM_TIM.h"
|
||||
#include "FM_GPIO.h"
|
||||
#include "capture.h"
|
||||
#include "bl_chargControl.h"
|
||||
|
||||
config_parameter g_cfgParameter = {0};
|
||||
static otherParameter g_otherParameter = {0};
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "uart_dev.h"
|
||||
#include "abnormalManage.h"
|
||||
#include "interruptSend.h"
|
||||
#include "configParameter.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -273,7 +274,7 @@ void Task_refreshJudgeData(void)
|
|||
|
||||
/* 有电池,太阳能输出功率大,电池电压低于14V,同时回路阻抗未测试或需要重新测试 */
|
||||
if ((getCheckImpedanceState() == FALSE || g_cfgParameter.loopImpedance == 0.0f)
|
||||
&& (getBatteryState() == TRUE) && (getChargCurrent() > 3.0f)
|
||||
&& (getBatteryState() == TRUE) && (getChargCurrent() > checkLoopImpedanceChargCurr)
|
||||
&& (getOutputVoltage() > 9) && (getSolarInCircuitVoltage() > 14)
|
||||
&& (getBatteryVoltage() < 14)) {
|
||||
TimeSliceOffset_Register(&m_impedanceCalculation, Task_impedanceCalculation
|
||||
|
@ -477,7 +478,7 @@ void Task_collectOpenCircuitVoltage(void)
|
|||
if (getBatteryState()) {
|
||||
collectOpenCircuitVoltageYesFlag = TRUE;
|
||||
stopChargWork();
|
||||
/* 设置延时为1000-500ms */
|
||||
/* 设置延时为(1000-500)ms */
|
||||
m_collectOpenCircuitVoltage.count = 500;
|
||||
}
|
||||
collectOpenCircuitVoltageYesNUM = 0;
|
||||
|
@ -485,11 +486,14 @@ void Task_collectOpenCircuitVoltage(void)
|
|||
|
||||
/* 检测开路电压 */
|
||||
if (collectOpenCircuitVoltageYesNUM == g_cfgParameter.collectOpenCircuitVoltageTime + 1) {
|
||||
/* 有电池才进行开路电压检测 */
|
||||
if (getBatteryState()) {
|
||||
setSolarOpenCircuitVoltage();
|
||||
beginChargWork();
|
||||
collectOpenCircuitVoltageYesFlag = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 开启HY配置模式后,配置完成后120S后自动退出
|
||||
|
|
|
@ -34,4 +34,6 @@ float get_OUT_VOLT_IN(void);
|
|||
|
||||
void adcCaptureFir();
|
||||
|
||||
extern void setSoftShortCircuit(uint16_t disChargCurrAdcNum);
|
||||
|
||||
#endif
|
|
@ -475,6 +475,8 @@ void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hdma)
|
|||
DSG_CURR_capture.IODataF[3] = (float32_t)DSG_CURR_capture.totalInData / indata16_size;
|
||||
PV_VOLT_IN_capture.IODataF[3] = (float32_t)PV_VOLT_IN_capture.totalInData / indata16_size;
|
||||
CHG_CURR_capture.IODataF[3] = (float32_t)CHG_CURR_capture.totalInData / indata16_size;
|
||||
|
||||
setSoftShortCircuit(DSG_CURR_capture.inData16[pointer - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,8 @@ typedef enum _chargMode{
|
|||
noWork = 0, /* 未进行充电 */
|
||||
MPPT = 1, /* 最大功率充电 */
|
||||
constantVoltage = 2, /* 恒压充电 */
|
||||
floatCharg = 3 /* 浮充充电 */
|
||||
floatCharg = 3, /* 浮充充电 */
|
||||
noBattery = 4, /* 无电池 */
|
||||
}chargMode;
|
||||
|
||||
typedef enum {
|
||||
|
@ -50,8 +51,20 @@ typedef struct _timeInfo {
|
|||
|
||||
/* 方式 */
|
||||
typedef enum {
|
||||
runLedChargMode = 1,
|
||||
runLedOtherMode = 2,
|
||||
runLedChargMode = 1, //充电模式
|
||||
runLedOtherMode = 2, //其他模式
|
||||
}runLedMode;
|
||||
|
||||
|
||||
/* 顺序事件记录 */
|
||||
typedef enum {
|
||||
firstStageProtection = 1, //第一段保护,短路保护
|
||||
secondStageProtection = 2, //第二段保护,介于过载和短路之间
|
||||
thirdStageProtection = 3, //第三段保护,过载保护
|
||||
excessiveLoadIn = 4, //进入了电压降低中断
|
||||
lowInputLoad = 5, //输入功率不足保护
|
||||
}eventsOrderRecordMode;
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
#ifndef CONFIG_PARAMETER_
|
||||
#define CONFIG_PARAMETER_
|
||||
|
||||
#include "comm_types.h"
|
||||
|
||||
|
||||
|
||||
// /* 第一段保护的延时时间(单位100uS) */
|
||||
// const uint32_t firstStageProtectionDelay = 2; // 200uS
|
||||
// /* 第一段保护的电流(单位A) */
|
||||
// const float_t firstStageProtectionCurr = 50.0f;
|
||||
|
||||
// /* 第二段保护的延时时间(单位100uS) */
|
||||
// const uint32_t secondStageProtectionDelay = 50000; // 5S
|
||||
// /* 第二段保护的电流(单位A) */
|
||||
// const float_t secondStageProtectionCurr = 30.0f;
|
||||
|
||||
// /* 第三段保护的延时时间(单位100uS) */
|
||||
// const uint32_t thirdStageProtectionDelay = 1200000; // 120S
|
||||
// /* 第三段保护的电流(单位A) */
|
||||
// const uint32_t thirdStageProtectionCurr = 35.0f;
|
||||
|
||||
// /* 检测回路阻抗时的充电电流要大于该值(单位A) */
|
||||
// const float_t checkLoopImpedanceChargCurr = 10.0f;
|
||||
|
||||
|
||||
// /* 第三段保护的延时时间(单位100uS) */
|
||||
// const uint32_t lowInputLoadDetectionDelay = 30; // 120S
|
||||
|
||||
|
||||
/* 第一段保护的延时时间(单位100uS) */
|
||||
#define firstStageProtectionDelay 2 // 200uS
|
||||
/* 第一段保护的电流(单位A) */
|
||||
#define firstStageProtectionCurr 50.0f
|
||||
|
||||
/* 第二段保护的延时时间(单位100uS) */
|
||||
#define secondStageProtectionDelay 50000 // 5S
|
||||
/* 第二段保护的电流(单位A) */
|
||||
#define secondStageProtectionCurr 30.0f
|
||||
|
||||
/* 第三段保护的延时时间(单位100uS) */
|
||||
#define thirdStageProtectionDelay 1200000 // 120S
|
||||
/* 第三段保护的电流(单位A) */
|
||||
#define thirdStageProtectionCurr 35.0f
|
||||
|
||||
/* 检测回路阻抗时的充电电流要大于该值(单位A) */
|
||||
#define checkLoopImpedanceChargCurr 10.0f
|
||||
|
||||
/* 输入功率较低延时(单位100uS) */
|
||||
#define lowInputLoadDetectionDelay 30 // 120S
|
||||
/* 输入功率较低延时电流(单位A) */
|
||||
#define lowInputLoadDetectionVolt 10.0f
|
||||
|
||||
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue