添加mppt异常关闭,修改部分异常保护bug
This commit is contained in:
parent
25af1a47ff
commit
fbd83bed35
|
@ -41,6 +41,7 @@
|
||||||
"w25qxx.h": "c",
|
"w25qxx.h": "c",
|
||||||
"w25q256.h": "c",
|
"w25q256.h": "c",
|
||||||
"gpio.h": "c",
|
"gpio.h": "c",
|
||||||
"bl_usart.h": "c"
|
"bl_usart.h": "c",
|
||||||
|
"soc.h": "c"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -63,7 +63,8 @@ void start(void)
|
||||||
uartCommonInit();
|
uartCommonInit();
|
||||||
|
|
||||||
|
|
||||||
// setDutyRatio(0.15f);
|
// setDutyRatio(0.0001f);
|
||||||
|
// EN_PWMOUT_Eable();
|
||||||
|
|
||||||
task_Init();
|
task_Init();
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
#ifndef BL_SOC_H_
|
||||||
|
#define BL_SOC_H_
|
||||||
|
|
||||||
|
|
||||||
|
int find_soc(float voltage);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -17,6 +17,7 @@ void startShortCircuitProtection(void);
|
||||||
void stopShortCircuitProtection(void);
|
void stopShortCircuitProtection(void);
|
||||||
void startExcessiveLoadProtection(void);
|
void startExcessiveLoadProtection(void);
|
||||||
void startSoftShortCircuitProtection(void);
|
void startSoftShortCircuitProtection(void);
|
||||||
|
void startEXCHGSCProtection(void);
|
||||||
|
|
||||||
void chargRunLed(uint8_t mode);
|
void chargRunLed(uint8_t mode);
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,15 @@ void Init(void)
|
||||||
// POW_OUT_PCON_Open();
|
// POW_OUT_PCON_Open();
|
||||||
HAL_Delay(100);
|
HAL_Delay(100);
|
||||||
setPowerOutput(TRUE);
|
setPowerOutput(TRUE);
|
||||||
|
|
||||||
|
// /* 判断有无电池 */
|
||||||
|
// if (getOutputVoltage() > 11.0f) {
|
||||||
|
// setBatteryState(TRUE);
|
||||||
|
// setPowerOutput(TRUE);
|
||||||
|
// } else {
|
||||||
|
// setBatteryState(FALSE);
|
||||||
|
// }
|
||||||
|
|
||||||
resetCheckImpedanceState();
|
resetCheckImpedanceState();
|
||||||
|
|
||||||
// setDutyRatio(0.5);
|
// setDutyRatio(0.5);
|
||||||
|
|
|
@ -85,6 +85,7 @@ void eventsOrderRecordStartInit(void)
|
||||||
| stopTemperature | mos管温度 |
|
| stopTemperature | mos管温度 |
|
||||||
| overchargCurr | 充电电流 |
|
| overchargCurr | 充电电流 |
|
||||||
| hardwareShortCircuitProtection| 输出电流 |
|
| hardwareShortCircuitProtection| 输出电流 |
|
||||||
|
| abnormalControl | 太阳能板输出电压 |
|
||||||
*/
|
*/
|
||||||
void insertEventsOrderRecord(eventsOrderRecordMode mode)
|
void insertEventsOrderRecord(eventsOrderRecordMode mode)
|
||||||
{
|
{
|
||||||
|
@ -145,6 +146,10 @@ void insertEventsOrderRecord(eventsOrderRecordMode mode)
|
||||||
soeInfo.insertData->temp = 0;
|
soeInfo.insertData->temp = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (mode == abnormalControl) {
|
||||||
|
soeInfo.insertData->temp = getSolarInCircuitVoltage();
|
||||||
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
soeInfo.count++;
|
soeInfo.count++;
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -357,7 +357,7 @@ void setOverLoad(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 多次进入输出过载,关闭输出 */
|
/* 多次进入输出过载,关闭输出 */
|
||||||
if (getExcessiveLoad() > 2) {
|
if (getExcessiveLoad() >= 2) {
|
||||||
zeroExcessiveLoad();
|
zeroExcessiveLoad();
|
||||||
insertEventsOrderRecord(lowInputLoad);
|
insertEventsOrderRecord(lowInputLoad);
|
||||||
}
|
}
|
||||||
|
@ -373,7 +373,9 @@ void lowInputLoadDetection(void)
|
||||||
{
|
{
|
||||||
static int num = 0;
|
static int num = 0;
|
||||||
|
|
||||||
if (excessiveLoadInterruptFlag == TRUE && getOutputVoltage() < g_cfgParameter.inputPowerLowDetectionVolt) {
|
if (excessiveLoadInterruptFlag == TRUE
|
||||||
|
&& getOutputVoltage() < g_cfgParameter.inputPowerLowDetectionVolt
|
||||||
|
&& getDischargCurrent() < g_cfgParameter.thirdStageProtectionCurr) {
|
||||||
num++;
|
num++;
|
||||||
// setOverLoad();
|
// setOverLoad();
|
||||||
} else {
|
} else {
|
||||||
|
@ -382,6 +384,7 @@ void lowInputLoadDetection(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (excessiveLoadInterruptFlag == TRUE && num == g_cfgParameter.inputPowerLowDetectionDelay) {
|
if (excessiveLoadInterruptFlag == TRUE && num == g_cfgParameter.inputPowerLowDetectionDelay) {
|
||||||
|
num = 0;
|
||||||
excessiveLoadInterruptFlag = FALSE;
|
excessiveLoadInterruptFlag = FALSE;
|
||||||
setOverLoad();
|
setOverLoad();
|
||||||
}
|
}
|
||||||
|
@ -466,16 +469,16 @@ void WORK_VOLT_Interrupt(void)
|
||||||
void DSG_PROT_Interrupt(void)
|
void DSG_PROT_Interrupt(void)
|
||||||
{
|
{
|
||||||
setShortCircuit();
|
setShortCircuit();
|
||||||
|
setPowerOutput(FALSE);
|
||||||
/* 第一次进入输出短路,启动短路任务 */
|
/* 第一次进入输出短路,启动短路任务 */
|
||||||
if (getShortCircuit() == 1) {
|
if (getShortCircuit() == 1) {
|
||||||
setShortCircuitFlag(TRUE);
|
|
||||||
startShortCircuitProtection();
|
startShortCircuitProtection();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 一定时间内第二次进入输出短路保护,关闭输出 */
|
/* 一定时间内第二次进入输出短路保护,关闭输出 */
|
||||||
else if (getShortCircuit() >= 2) {
|
else if (getShortCircuit() >= 2) {
|
||||||
stopShortCircuitProtection();
|
stopShortCircuitProtection();
|
||||||
setPowerOutput(FALSE);
|
// setPowerOutput(FALSE);
|
||||||
zeroShortCircuit();
|
zeroShortCircuit();
|
||||||
insertEventsOrderRecord(hardwareShortCircuitProtection);
|
insertEventsOrderRecord(hardwareShortCircuitProtection);
|
||||||
}
|
}
|
||||||
|
@ -490,7 +493,17 @@ void DSG_PROT_Interrupt(void)
|
||||||
|
|
||||||
void EXCHG_PROT_Interrupt(void)
|
void EXCHG_PROT_Interrupt(void)
|
||||||
{
|
{
|
||||||
|
setShortCircuit();
|
||||||
setPowerOutput(FALSE);
|
setPowerOutput(FALSE);
|
||||||
insertEventsOrderRecord(hardwareInputProtection);
|
/* 第一次进入输出短路,启动短路任务 */
|
||||||
|
if (getShortCircuit() == 1) {
|
||||||
|
startEXCHGSCProtection();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 一定时间内第二次进入输出短路保护,关闭输出 */
|
||||||
|
else if (getShortCircuit() >= 2) {
|
||||||
|
stopShortCircuitProtection();
|
||||||
|
insertEventsOrderRecord(hardwareInputProtection);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "comm_types.h"
|
#include "comm_types.h"
|
||||||
#include "FM_GPIO.h"
|
#include "FM_GPIO.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
#include "SOE.h"
|
||||||
|
|
||||||
|
|
||||||
static BOOL stopChargConditions(void);
|
static BOOL stopChargConditions(void);
|
||||||
|
@ -410,8 +411,9 @@ void mppt_readJust(void)
|
||||||
/* 一段时间内电流都很小则固定电压输出 */
|
/* 一段时间内电流都很小则固定电压输出 */
|
||||||
static uint8_t currMinFlag = 0;
|
static uint8_t currMinFlag = 0;
|
||||||
static uint8_t currMinFlag1 = 0;
|
static uint8_t currMinFlag1 = 0;
|
||||||
|
|
||||||
// if (getChargCurrent() < 0.8f) {
|
// if (getChargCurrent() < 0.8f) {
|
||||||
if (totalChargeCurr < 40) {
|
if (totalChargeCurr < 120) {
|
||||||
// hysteresisValue1 = getChargCurrent() * 1.7f;
|
// hysteresisValue1 = getChargCurrent() * 1.7f;
|
||||||
// hysteresisValue2 = getChargCurrent() * 12;
|
// hysteresisValue2 = getChargCurrent() * 12;
|
||||||
currMinFlag++;
|
currMinFlag++;
|
||||||
|
@ -437,8 +439,8 @@ void mppt_readJust(void)
|
||||||
currMinFlag = 0;
|
currMinFlag = 0;
|
||||||
// hysteresisValue1 = getChargCurrent() * 1.1f;
|
// hysteresisValue1 = getChargCurrent() * 1.1f;
|
||||||
// hysteresisValue2 = getChargCurrent() * 10;
|
// hysteresisValue2 = getChargCurrent() * 10;
|
||||||
hysteresisValue1 = totalChargeCurr / 45.0f;
|
hysteresisValue1 = totalChargeCurr / 40.0f;
|
||||||
hysteresisValue2 = totalChargeCurr / 5.0f;
|
hysteresisValue2 = totalChargeCurr / 4.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// else if (getChargCurrent() < 20) {
|
// else if (getChargCurrent() < 20) {
|
||||||
|
@ -447,8 +449,8 @@ void mppt_readJust(void)
|
||||||
currMinFlag = 0;
|
currMinFlag = 0;
|
||||||
// hysteresisValue1 = getChargCurrent() * 0.7f;
|
// hysteresisValue1 = getChargCurrent() * 0.7f;
|
||||||
// hysteresisValue2 = getChargCurrent() * 7;
|
// hysteresisValue2 = getChargCurrent() * 7;
|
||||||
hysteresisValue1 = totalChargeCurr / 70.0f;
|
hysteresisValue1 = totalChargeCurr / 60.0f;
|
||||||
hysteresisValue2 = totalChargeCurr / 7.0f;
|
hysteresisValue2 = totalChargeCurr / 6.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// else if (getChargCurrent() < 25) {
|
// else if (getChargCurrent() < 25) {
|
||||||
|
@ -457,8 +459,8 @@ void mppt_readJust(void)
|
||||||
currMinFlag = 0;
|
currMinFlag = 0;
|
||||||
// hysteresisValue1 = getChargCurrent() * 0.5f;
|
// hysteresisValue1 = getChargCurrent() * 0.5f;
|
||||||
// hysteresisValue2 = getChargCurrent() * 5;
|
// hysteresisValue2 = getChargCurrent() * 5;
|
||||||
hysteresisValue1 = totalChargeCurr / 100.0f;
|
hysteresisValue1 = totalChargeCurr / 90.0f;
|
||||||
hysteresisValue2 = totalChargeCurr / 10.0f;
|
hysteresisValue2 = totalChargeCurr / 9.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
@ -466,8 +468,8 @@ void mppt_readJust(void)
|
||||||
currMinFlag = 0;
|
currMinFlag = 0;
|
||||||
// hysteresisValue1 = getChargCurrent() * 0.3f;
|
// hysteresisValue1 = getChargCurrent() * 0.3f;
|
||||||
// hysteresisValue2 = getChargCurrent() * 3;
|
// hysteresisValue2 = getChargCurrent() * 3;
|
||||||
hysteresisValue1 = totalChargeCurr / 150.0f;
|
hysteresisValue1 = totalChargeCurr / 140.0f;
|
||||||
hysteresisValue2 = totalChargeCurr / 16.0f;
|
hysteresisValue2 = totalChargeCurr / 14.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// else {
|
// else {
|
||||||
|
@ -505,6 +507,7 @@ void mppt_readJust(void)
|
||||||
// } else if ((lPower - 0.8f > Power) && (lLPower - 0.8f > Power) && (lLLPower - 0.8f > Power)) {
|
// } else if ((lPower - 0.8f > Power) && (lLPower - 0.8f > Power) && (lLLPower - 0.8f > Power)) {
|
||||||
} else if ((lPower - hysteresisValue1 > Power) && (lLPower - hysteresisValue1 > Power)) {
|
} else if ((lPower - hysteresisValue1 > Power) && (lLPower - hysteresisValue1 > Power)) {
|
||||||
// } else if ((lPower - 0.3f > Power)) {
|
// } else if ((lPower - 0.3f > Power)) {
|
||||||
|
numFlag = 0;
|
||||||
if (powerT > hysteresisValue2) {
|
if (powerT > hysteresisValue2) {
|
||||||
numFlag = 0;
|
numFlag = 0;
|
||||||
if (flag1) {
|
if (flag1) {
|
||||||
|
@ -625,6 +628,33 @@ BOOL stopChargConditions(void)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 异常情况关闭充电 */
|
||||||
|
static uint16_t flag = 0;
|
||||||
|
if ((getSolarInCircuitVoltage() < (g_cfgParameter.stopSolarOutputCircuitV + 1)
|
||||||
|
|| getSolarInCircuitVoltage() > 18.5f)
|
||||||
|
&& getChargCurrent() < 0.1f
|
||||||
|
&& getMPPT_Mode() == MPPT) {
|
||||||
|
// return TRUE;
|
||||||
|
flag++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if ((getSolarInCircuitVoltage() < 17.8f
|
||||||
|
// || getSolarInCircuitVoltage() > 20)
|
||||||
|
// && getChargCurrent() < 0.1f
|
||||||
|
// && getMPPT_Mode() == MPPT) {
|
||||||
|
// // return TRUE;
|
||||||
|
// flag++;
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// flag = 0;
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (flag > 20000) {
|
||||||
|
flag = 0;
|
||||||
|
insertEventsOrderRecord(abnormalControl);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include "bl_comm.h"
|
#include "bl_comm.h"
|
||||||
#include "uart_dev.h"
|
#include "uart_dev.h"
|
||||||
#include "interruptSend.h"
|
#include "interruptSend.h"
|
||||||
|
#include "SOE.h"
|
||||||
|
|
||||||
uint8_t rs485_buff[buffLen]={0x00};
|
uint8_t rs485_buff[buffLen]={0x00};
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "capture.h"
|
#include "capture.h"
|
||||||
#include "bl_chargControl.h"
|
#include "bl_chargControl.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include "soc.h"
|
||||||
|
|
||||||
config_parameter g_cfgParameter = {0};
|
config_parameter g_cfgParameter = {0};
|
||||||
static otherParameter g_otherParameter = {0};
|
static otherParameter g_otherParameter = {0};
|
||||||
|
@ -79,9 +80,9 @@ void setDutyRatio(float DutyRatio)
|
||||||
*/
|
*/
|
||||||
void setDutyRatioToZero(void)
|
void setDutyRatioToZero(void)
|
||||||
{
|
{
|
||||||
EN_PWMOUT_Diseable();
|
|
||||||
dutyRatio = 0;
|
dutyRatio = 0;
|
||||||
set_pwmDutyRatio(dutyRatio);
|
set_pwmDutyRatio(dutyRatio);
|
||||||
|
EN_PWMOUT_Diseable();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -401,7 +402,7 @@ float getSOC(void)
|
||||||
*/
|
*/
|
||||||
void setSOC(void)
|
void setSOC(void)
|
||||||
{
|
{
|
||||||
|
g_otherParameter.SOC = find_soc(getBatteryVoltage()) / 100.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,119 @@
|
||||||
|
|
||||||
|
#include "soc.h"
|
||||||
|
|
||||||
|
// const float ocv_table[101] = {
|
||||||
|
// 2.80, 2.85, 2.90, 2.95, 3.00, 3.05, 3.10, 3.12, 3.14, 3.16, // 0-9%
|
||||||
|
// 3.18, 3.19, 3.20, 3.20, 3.20, 3.20, 3.21, 3.21, 3.21, 3.21, // 10-19%
|
||||||
|
// 3.22, 3.22, 3.22, 3.22, 3.22, 3.22, 3.23, 3.23, 3.23, 3.23, // 20-29%
|
||||||
|
// 3.23, 3.23, 3.23, 3.23, 3.23, 3.23, 3.23, 3.24, 3.24, 3.24, // 30-39%
|
||||||
|
// 3.24, 3.24, 3.25, 3.25, 3.25, 3.25, 3.25, 3.25, 3.25, 3.25, // 40-49%
|
||||||
|
// 3.25, 3.25, 3.25, 3.25, 3.25, 3.26, 3.26, 3.26, 3.26, 3.26, // 50-59%
|
||||||
|
// 3.26, 3.26, 3.26, 3.26, 3.26, 3.26, 3.27, 3.27, 3.27, 3.27, // 60-69%
|
||||||
|
// 3.28, 3.28, 3.28, 3.29, 3.29, 3.29, 3.30, 3.30, 3.31, 3.31, // 70-79%
|
||||||
|
// 3.32, 3.32, 3.33, 3.34, 3.35, 3.36, 3.38, 3.40, 3.42, 3.45, // 80-89%
|
||||||
|
// 3.48, 3.50, 3.52, 3.54, 3.56, 3.58, 3.60, 3.62, 3.63, 3.64, // 90-99%
|
||||||
|
// 3.65 // 100%
|
||||||
|
// };
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * 四节串联磷酸铁锂电池组 SOC-OCV 对应表 (SOC步长1%)
|
||||||
|
// * 电压范围:11.2V (0%) ~ 14.6V (100%)
|
||||||
|
// * 注意:
|
||||||
|
// * 1. 假设电池完全均衡,实际需考虑单体差异
|
||||||
|
// * 2. 电压单位:伏特(V)
|
||||||
|
// */
|
||||||
|
// const float ocv_table_4s[101] = {
|
||||||
|
// // 0-9% (单节2.80V~3.16V → 四节11.20V~12.64V)
|
||||||
|
// 11.20, 11.40, 11.60, 11.80, 12.00, 12.20, 12.40, 12.48, 12.56, 12.64, // 0-9%
|
||||||
|
|
||||||
|
// // 10-19% (单节3.18V~3.21V → 四节12.72V~12.84V)
|
||||||
|
// 12.72, 12.76, 12.80, 12.80, 12.80, 12.80, 12.84, 12.84, 12.84, 12.84, // 10-19%
|
||||||
|
|
||||||
|
// // 20-29% (单节3.22V~3.23V → 四节12.88V~12.92V)
|
||||||
|
// 12.88, 12.88, 12.88, 12.88, 12.88, 12.88, 12.92, 12.92, 12.92, 12.92, // 20-29%
|
||||||
|
|
||||||
|
// // 30-39% (单节3.23V~3.24V → 四节12.92V~12.96V)
|
||||||
|
// 12.92, 12.92, 12.92, 12.92, 12.92, 12.92, 12.92, 12.96, 12.96, 12.96, // 30-39%
|
||||||
|
|
||||||
|
// // 40-49% (单节3.24V~3.25V → 四节12.96V~13.00V)
|
||||||
|
// 12.96, 12.96, 13.00, 13.00, 13.00, 13.00, 13.00, 13.00, 13.00, 13.00, // 40-49%
|
||||||
|
|
||||||
|
// // 50-59% (单节3.25V~3.26V → 四节13.00V~13.04V)
|
||||||
|
// 13.00, 13.00, 13.00, 13.00, 13.00, 13.04, 13.04, 13.04, 13.04, 13.04, // 50-59%
|
||||||
|
|
||||||
|
// // 60-69% (单节3.26V~3.27V → 四节13.04V~13.08V)
|
||||||
|
// 13.04, 13.04, 13.04, 13.04, 13.04, 13.04, 13.08, 13.08, 13.08, 13.08, // 60-69%
|
||||||
|
|
||||||
|
// // 70-79% (单节3.28V~3.31V → 四节13.12V~13.24V)
|
||||||
|
// 13.12, 13.12, 13.12, 13.16, 13.16, 13.16, 13.20, 13.20, 13.24, 13.24, // 70-79%
|
||||||
|
|
||||||
|
// // 80-89% (单节3.32V~3.45V → 四节13.28V~13.80V)
|
||||||
|
// 13.28, 13.28, 13.32, 13.36, 13.40, 13.44, 13.52, 13.60, 13.68, 13.80, // 80-89%
|
||||||
|
|
||||||
|
// // 90-100% (单节3.48V~3.65V → 四节13.92V~14.60V)
|
||||||
|
// 13.92, 14.00, 14.08, 14.16, 14.24, 14.32, 14.40, 14.48, 14.52, 14.56, // 90-99%
|
||||||
|
// 14.60 // 100%
|
||||||
|
// };
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 四节串联磷酸铁锂电池组 SOC-OCV 对应表 (SOC步长1%)
|
||||||
|
* 电压范围:11.2V (0%) ~ 14.6V (100%)
|
||||||
|
* 注意:
|
||||||
|
* 1. 假设电池完全均衡,实际需考虑单体差异
|
||||||
|
* 2. 电压单位:伏特(V)
|
||||||
|
*/
|
||||||
|
const float ocv_table_4s[21] = {
|
||||||
|
// 0-9% (单节2.80V~3.16V → 四节11.20V~12.64V)
|
||||||
|
12.00, 12.64, // 0-9%
|
||||||
|
|
||||||
|
// 10-19% (单节3.18V~3.21V → 四节12.72V~12.84V)
|
||||||
|
12.80, 12.84, // 10-19%
|
||||||
|
|
||||||
|
// 20-29% (单节3.22V~3.23V → 四节12.88V~12.92V)
|
||||||
|
12.88, 12.92, // 20-29%
|
||||||
|
|
||||||
|
// 30-39% (单节3.23V~3.24V → 四节12.92V~12.96V)
|
||||||
|
12.93, 12.96, // 30-39%
|
||||||
|
|
||||||
|
// 40-49% (单节3.24V~3.25V → 四节12.96V~13.00V)
|
||||||
|
12.98, 13.00, // 40-49%
|
||||||
|
|
||||||
|
// 50-59% (单节3.25V~3.26V → 四节13.00V~13.04V)
|
||||||
|
13.02, 13.04, // 50-59%
|
||||||
|
|
||||||
|
// 60-69% (单节3.26V~3.27V → 四节13.04V~13.08V)
|
||||||
|
13.05, 13.08, // 60-69%
|
||||||
|
|
||||||
|
// 70-79% (单节3.28V~3.31V → 四节13.12V~13.24V)
|
||||||
|
13.16, 13.24, // 70-79%
|
||||||
|
|
||||||
|
// 80-89% (单节3.32V~3.45V → 四节13.28V~13.80V)
|
||||||
|
13.40, 13.80, // 80-89%
|
||||||
|
|
||||||
|
// 90-100% (单节3.48V~3.65V → 四节13.92V~14.60V)
|
||||||
|
13.92, 14.24, // 90-99%
|
||||||
|
14.60 // 100%
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 得到通过电压得到当前SOC在数组中的位置
|
||||||
|
* @param
|
||||||
|
* @retval soc*100
|
||||||
|
*/
|
||||||
|
int find_soc(float voltage)
|
||||||
|
{
|
||||||
|
// static volatile int soc = 0;
|
||||||
|
// for(soc = 0; soc <= 100; soc++) {
|
||||||
|
for(int soc = 0; soc <= 100; soc++) {
|
||||||
|
if(ocv_table_4s[soc] >= voltage) {
|
||||||
|
return soc * 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#include "bl_usart.h"
|
#include "bl_usart.h"
|
||||||
#include "SOE.h"
|
#include "SOE.h"
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,13 +46,13 @@ static STR_TimeSliceOffset m_startControl;
|
||||||
static void Task_startControl(void);
|
static void Task_startControl(void);
|
||||||
|
|
||||||
/* 软启动 */
|
/* 软启动 */
|
||||||
#define softStart_reloadVal 1 /* 任务执行间隔 */
|
#define softStart_reloadVal 10 /* 任务执行间隔 */
|
||||||
#define softStart_offset 0 /* 任务执行偏移量 */
|
#define softStart_offset 0 /* 任务执行偏移量 */
|
||||||
static STR_TimeSliceOffset m_softStart;
|
static STR_TimeSliceOffset m_softStart;
|
||||||
static void Task_softStart(void);
|
static void Task_softStart(void);
|
||||||
|
|
||||||
/* 回路阻抗检测 */
|
/* 回路阻抗检测 */
|
||||||
#define impedanceCalculation_reloadVal 20 /* 任务执行间隔 */
|
#define impedanceCalculation_reloadVal 100 /* 任务执行间隔 */
|
||||||
#define impedanceCalculation_offset 0 /* 任务执行偏移量 */
|
#define impedanceCalculation_offset 0 /* 任务执行偏移量 */
|
||||||
static STR_TimeSliceOffset m_impedanceCalculation;
|
static STR_TimeSliceOffset m_impedanceCalculation;
|
||||||
static void Task_impedanceCalculation(void);
|
static void Task_impedanceCalculation(void);
|
||||||
|
@ -96,6 +95,12 @@ void Task_collectOpenCircuitVoltage(void);
|
||||||
static STR_TimeSliceOffset m_shortCircuitProtection;
|
static STR_TimeSliceOffset m_shortCircuitProtection;
|
||||||
static void Task_shortCircuitProtection(void);
|
static void Task_shortCircuitProtection(void);
|
||||||
|
|
||||||
|
/* 反向充电短路保护 */
|
||||||
|
#define EXCHGSCProtection_reloadVal 1000 /* 任务执行间隔 */
|
||||||
|
#define EXCHGSCProtection_offset 0 /* 任务执行偏移量 */
|
||||||
|
static STR_TimeSliceOffset m_EXCHGSCProtection;
|
||||||
|
static void Task_EXCHGSCProtection(void);
|
||||||
|
|
||||||
/* 过载保护 */
|
/* 过载保护 */
|
||||||
#define excessiveLoad_reloadVal 1000 /* 任务执行间隔 */
|
#define excessiveLoad_reloadVal 1000 /* 任务执行间隔 */
|
||||||
#define excessiveLoad_offset 0 /* 任务执行偏移量 */
|
#define excessiveLoad_offset 0 /* 任务执行偏移量 */
|
||||||
|
@ -200,21 +205,20 @@ void Task_wdi(void)
|
||||||
{
|
{
|
||||||
feedDog();
|
feedDog();
|
||||||
|
|
||||||
// debug_printf("chargCurrent:%f \n", getChargCurrent());
|
debug_printf("chargCurrent:%f \n", getChargCurrent());
|
||||||
// debug_printf("outputVoltage:%f \n", getOutputVoltage());
|
debug_printf("outputVoltage:%f \n", getOutputVoltage());
|
||||||
// debug_printf("BatteryVoltage:%f \n", getBatteryVoltage());
|
debug_printf("BatteryVoltage:%f \n", getBatteryVoltage());
|
||||||
// debug_printf("dischargCurrent:%f \n", getDischargCurrent());
|
debug_printf("dischargCurrent:%f \n", getDischargCurrent());
|
||||||
// debug_printf("solarInCircuitVoltage:%f \n", getSolarInCircuitVoltage());
|
debug_printf("solarInCircuitVoltage:%f \n", getSolarInCircuitVoltage());
|
||||||
// debug_printf("HighSideMosTemperature:%f \n", getHighSideMosTemperature());
|
debug_printf("HighSideMosTemperature:%f \n", getHighSideMosTemperature());
|
||||||
// debug_printf("InputVoltage:%f \n", getInputVoltage());
|
debug_printf("InputVoltage:%f \n", getInputVoltage());
|
||||||
// debug_printf("DischargMosState:%d \n", getDischargMosState());
|
debug_printf("DischargMosState:%d \n", getDischargMosState());
|
||||||
// debug_printf("MPPT_Mode:%d \n", getMPPT_Mode());
|
debug_printf("MPPT_Mode:%d \n", getMPPT_Mode());
|
||||||
// debug_printf("loopImpedance:%f \n", getLoopImpedance());
|
debug_printf("loopImpedance:%f \n", getLoopImpedance());
|
||||||
// debug_printf("DutyRatio:%f \n", getDutyRatio());
|
debug_printf("DutyRatio:%f \n", getDutyRatio());
|
||||||
// // debug_printf("OUT_VOLT_IN:%f \n", get_OUT_VOLT_IN());
|
// debug_printf("OUT_VOLT_IN:%f \n", get_OUT_VOLT_IN());
|
||||||
// debug_printf("HAL_GetTick:%d \n", HAL_GetTick());
|
debug_printf("HAL_GetTick:%d \n", HAL_GetTick());
|
||||||
// debug_printf("getExChargeCurr:%f \n", getExChargeCurr());
|
debug_printf("getExChargeCurr:%f \n", getExChargeCurr());
|
||||||
|
|
||||||
|
|
||||||
// char buf[100];
|
// char buf[100];
|
||||||
// sprintf(buf, "chargCurrent:%f \n", getChargCurrent());
|
// sprintf(buf, "chargCurrent:%f \n", getChargCurrent());
|
||||||
|
@ -351,6 +355,14 @@ void Task_refreshJudgeData(void)
|
||||||
stopChargWork();
|
stopChargWork();
|
||||||
insertEventsOrderRecord(overInputVolt);
|
insertEventsOrderRecord(overInputVolt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint8_t num = 0;
|
||||||
|
if (20 == num++) {
|
||||||
|
num = 0;
|
||||||
|
setSOC();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -364,9 +376,16 @@ void Task_refreshJudgeData(void)
|
||||||
*/
|
*/
|
||||||
void Task_startControl(void)
|
void Task_startControl(void)
|
||||||
{
|
{
|
||||||
|
static uint8_t numStart = 0;
|
||||||
|
if (g_cfgParameter.checkCanStartTime > numStart++) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
numStart = 0;
|
||||||
|
|
||||||
/* 是否达到启动条件 */
|
/* 是否达到启动条件 */
|
||||||
if (getSolarInCircuitVoltage() > g_cfgParameter.startSolarOpenCircuitV
|
if (getSolarInCircuitVoltage() > g_cfgParameter.startSolarOpenCircuitV
|
||||||
&& getSolarInCircuitVoltage() < g_cfgParameter.maxOpenSolarOutputCircuitV) {
|
&& getSolarInCircuitVoltage() < g_cfgParameter.maxOpenSolarOutputCircuitV) {
|
||||||
|
|
||||||
TimeSliceOffset_Unregister(&m_startControl);
|
TimeSliceOffset_Unregister(&m_startControl);
|
||||||
m_startControl.runFlag = 0;
|
m_startControl.runFlag = 0;
|
||||||
|
|
||||||
|
@ -378,15 +397,16 @@ void Task_startControl(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 启动软起动任务 */
|
/* 启动软起动任务 */
|
||||||
// TimeSliceOffset_Register(&m_softStart, Task_softStart, softStart_reloadVal, softStart_offset);
|
TimeSliceOffset_Register(&m_softStart, Task_softStart, softStart_reloadVal, softStart_offset);
|
||||||
if (getBatteryState() == TRUE) {
|
|
||||||
setMPPT_Mode(MPPT);
|
|
||||||
} else {
|
|
||||||
setMPPT_Mode(floatCharg);
|
|
||||||
}
|
|
||||||
|
|
||||||
setChargControlFlag(TRUE);
|
// if (getBatteryState() == TRUE) {
|
||||||
EN_PWMOUT_Eable();
|
// setMPPT_Mode(MPPT);
|
||||||
|
// } else {
|
||||||
|
// setMPPT_Mode(floatCharg);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// setChargControlFlag(TRUE);
|
||||||
|
// EN_PWMOUT_Eable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -408,22 +428,59 @@ void beginStartControlTask(void)
|
||||||
*/
|
*/
|
||||||
void Task_softStart(void)
|
void Task_softStart(void)
|
||||||
{
|
{
|
||||||
|
// static uint16_t num = 0;
|
||||||
|
// static float dutyRatio = 0;
|
||||||
|
// num++;
|
||||||
|
|
||||||
|
// if (num < 5) {
|
||||||
|
// set_pwmDutyRatio(0.1f);
|
||||||
|
// EN_PWMOUT_Eable();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// else if (num > 70 || dutyRatio > 0.7f) {
|
||||||
|
// TimeSliceOffset_Unregister(&m_softStart);
|
||||||
|
// m_softStart.runFlag = 0;
|
||||||
|
|
||||||
|
// dutyRatio = 0;
|
||||||
|
// num = 0;
|
||||||
|
// setDutyRatio(0.75f);
|
||||||
|
|
||||||
|
// if (getBatteryState() == TRUE) {
|
||||||
|
// setMPPT_Mode(MPPT);
|
||||||
|
// } else {
|
||||||
|
// setMPPT_Mode(floatCharg);
|
||||||
|
// }
|
||||||
|
// setChargControlFlag(TRUE);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// else {
|
||||||
|
// setDutyRatio(getDutyRatio() + 0.01f);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
static uint16_t num = 0;
|
static uint16_t num = 0;
|
||||||
static float dutyRatio = 0;
|
// static float dutyRatio = 0;
|
||||||
num++;
|
num++;
|
||||||
|
|
||||||
if (num < 5) {
|
if (num < 5) {
|
||||||
set_pwmDutyRatio(0.1f);
|
|
||||||
EN_PWMOUT_Eable();
|
EN_PWMOUT_Eable();
|
||||||
|
//最小占空比斩波
|
||||||
|
setDutyRatio(0.0001f);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (num > 70 || dutyRatio > 0.6f) {
|
else if (num > 80) {
|
||||||
TimeSliceOffset_Unregister(&m_softStart);
|
TimeSliceOffset_Unregister(&m_softStart);
|
||||||
m_softStart.runFlag = 0;
|
m_softStart.runFlag = 0;
|
||||||
|
|
||||||
dutyRatio = 0;
|
|
||||||
num = 0;
|
num = 0;
|
||||||
setDutyRatio(0.75f);
|
|
||||||
|
// debug_printf("getSolarInCircuitVoltage : %f", getSolarInCircuitVoltage());
|
||||||
|
|
||||||
|
//电压过低时不启动
|
||||||
|
if (getSolarInCircuitVoltage() < 18.5f) {
|
||||||
|
TimeSliceOffset_Register(&m_startControl, Task_startControl, startControl_reloadVal, startControl_offset);
|
||||||
|
setDutyRatioToZero();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (getBatteryState() == TRUE) {
|
if (getBatteryState() == TRUE) {
|
||||||
setMPPT_Mode(MPPT);
|
setMPPT_Mode(MPPT);
|
||||||
|
@ -433,9 +490,9 @@ void Task_softStart(void)
|
||||||
setChargControlFlag(TRUE);
|
setChargControlFlag(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
// else {
|
||||||
setDutyRatio(getDutyRatio() + 0.01f);
|
// setDutyRatio(0.01f);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief 启动软启动任务
|
* @brief 启动软启动任务
|
||||||
|
@ -691,10 +748,11 @@ void Task_shortCircuitProtection(void)
|
||||||
static uint8_t num = 0;
|
static uint8_t num = 0;
|
||||||
num++;
|
num++;
|
||||||
|
|
||||||
|
|
||||||
/* 设定输出短路保护时间 */
|
/* 设定输出短路保护时间 */
|
||||||
if (num == 2) {
|
if (num == 2) {
|
||||||
setPowerOutput(FALSE);
|
// setPowerOutput(FALSE);
|
||||||
setPowerOutput(TRUE);
|
setPowerOutput(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -738,6 +796,53 @@ void stopShortCircuitProtection(void)
|
||||||
m_shortCircuitProtection.runFlag = 0;
|
m_shortCircuitProtection.runFlag = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 反向充电短路保护任务,短路后启动该任务
|
||||||
|
* @param
|
||||||
|
* @retval
|
||||||
|
*/
|
||||||
|
void Task_EXCHGSCProtection(void)
|
||||||
|
{
|
||||||
|
static uint8_t num = 0;
|
||||||
|
num++;
|
||||||
|
|
||||||
|
/* 设定输出短路保护时间 */
|
||||||
|
if (num == 2) {
|
||||||
|
// setPowerOutput(FALSE);
|
||||||
|
setPowerOutput(TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 设定输出短路保护时间 */
|
||||||
|
if (num == g_cfgParameter.shortCircuitJudgmentDelay) {
|
||||||
|
num = 0;
|
||||||
|
zeroShortCircuit();
|
||||||
|
TimeSliceOffset_Unregister(&m_EXCHGSCProtection);
|
||||||
|
m_EXCHGSCProtection.runFlag = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 启动短路保护任务
|
||||||
|
* @param
|
||||||
|
* @retval
|
||||||
|
*/
|
||||||
|
void startEXCHGSCProtection(void)
|
||||||
|
{
|
||||||
|
TimeSliceOffset_Register(&m_EXCHGSCProtection, Task_EXCHGSCProtection
|
||||||
|
, EXCHGSCProtection_reloadVal, EXCHGSCProtection_offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 关闭短路保护任务
|
||||||
|
* @param
|
||||||
|
* @retval
|
||||||
|
*/
|
||||||
|
void stopEXCHGSCProtection(void)
|
||||||
|
{
|
||||||
|
TimeSliceOffset_Unregister(&m_EXCHGSCProtection);
|
||||||
|
m_EXCHGSCProtection.runFlag = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 过载保护任务,输入不够供给输出后启动该任务
|
* @brief 过载保护任务,输入不够供给输出后启动该任务
|
||||||
* @param
|
* @param
|
||||||
|
@ -786,6 +891,8 @@ void Task_excessiveLoad(void)
|
||||||
/* 关闭输出后开始计时 */
|
/* 关闭输出后开始计时 */
|
||||||
if (readPOW_OUT_PCON_State() == FALSE) {
|
if (readPOW_OUT_PCON_State() == FALSE) {
|
||||||
numLong++;
|
numLong++;
|
||||||
|
} else {
|
||||||
|
numLong = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 达到时间就重新尝试输出 */
|
/* 达到时间就重新尝试输出 */
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1463,6 +1463,9 @@
|
||||||
<file>
|
<file>
|
||||||
<name>$PROJ_DIR$\..\APP\businessLogic\Src\parameter.c</name>
|
<name>$PROJ_DIR$\..\APP\businessLogic\Src\parameter.c</name>
|
||||||
</file>
|
</file>
|
||||||
|
<file>
|
||||||
|
<name>$PROJ_DIR$\..\APP\businessLogic\Src\soc.c</name>
|
||||||
|
</file>
|
||||||
<file>
|
<file>
|
||||||
<name>$PROJ_DIR$\..\APP\businessLogic\Src\SOE.c</name>
|
<name>$PROJ_DIR$\..\APP\businessLogic\Src\SOE.c</name>
|
||||||
</file>
|
</file>
|
||||||
|
|
|
@ -68,6 +68,7 @@ typedef enum {
|
||||||
hardwareInputProtection, //硬件防反输入保护
|
hardwareInputProtection, //硬件防反输入保护
|
||||||
InputProtection, //软件防反输入保护
|
InputProtection, //软件防反输入保护
|
||||||
startEvent, //启动
|
startEvent, //启动
|
||||||
|
abnormalControl, //异常控制
|
||||||
}eventsOrderRecordMode;
|
}eventsOrderRecordMode;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue