Compare commits
No commits in common. "25af1a47ff88723f73ead4d577f5b7436d217a9b" and "3ea22514fd5b38b22d5050a9e0b52c7e0781a21e" have entirely different histories.
25af1a47ff
...
3ea22514fd
|
@ -62,9 +62,6 @@ void start(void)
|
||||||
|
|
||||||
uartCommonInit();
|
uartCommonInit();
|
||||||
|
|
||||||
|
|
||||||
// setDutyRatio(0.15f);
|
|
||||||
|
|
||||||
task_Init();
|
task_Init();
|
||||||
|
|
||||||
startInfo();
|
startInfo();
|
||||||
|
@ -75,7 +72,7 @@ void start(void)
|
||||||
// HAL_Delay(1000);
|
// HAL_Delay(1000);
|
||||||
// }
|
// }
|
||||||
/* 启动事件 */
|
/* 启动事件 */
|
||||||
// insertEventsOrderRecord(startEvent);
|
insertEventsOrderRecord(startEvent);
|
||||||
|
|
||||||
TimeSliceOffset_Start();
|
TimeSliceOffset_Start();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ void Init(void)
|
||||||
// HAL_Delay(10000);
|
// HAL_Delay(10000);
|
||||||
|
|
||||||
config_info_start();
|
config_info_start();
|
||||||
|
|
||||||
Init_debug_uart();
|
Init_debug_uart();
|
||||||
|
|
||||||
ADC_Capture_Init();
|
ADC_Capture_Init();
|
||||||
|
@ -49,8 +49,8 @@ void Init(void)
|
||||||
// POW_OUT_PCON_Open();
|
// POW_OUT_PCON_Open();
|
||||||
HAL_Delay(100);
|
HAL_Delay(100);
|
||||||
setPowerOutput(TRUE);
|
setPowerOutput(TRUE);
|
||||||
resetCheckImpedanceState();
|
|
||||||
|
|
||||||
|
// EN_PWMOUT_Eable();
|
||||||
// setDutyRatio(0.5);
|
// setDutyRatio(0.5);
|
||||||
// while (1) {
|
// while (1) {
|
||||||
// log_info("Init_debug_uart \n");
|
// log_info("Init_debug_uart \n");
|
||||||
|
|
|
@ -299,23 +299,12 @@ void checkFFMOS_CON(void)
|
||||||
// FFMOS_CON_Close();
|
// FFMOS_CON_Close();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
static uint8_t num = 100;
|
if (getChargCurrent() > 5.0f && FALSE == FFMOS_CON_read()) {
|
||||||
if (getChargCurrent() > 8.0f && FALSE == FFMOS_CON_read()) {
|
FFMOS_CON_Open();
|
||||||
num--;
|
|
||||||
if (!num) {
|
|
||||||
FFMOS_CON_Open();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (getChargCurrent() < 2.0f && TRUE == FFMOS_CON_read()) {
|
else if (getChargCurrent() < 2.0f && TRUE == FFMOS_CON_read()) {
|
||||||
// num--;
|
|
||||||
// if (!num) {
|
|
||||||
// FFMOS_CON_Close();
|
|
||||||
// }
|
|
||||||
FFMOS_CON_Close();
|
FFMOS_CON_Close();
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
num = 100;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
|
@ -371,18 +360,16 @@ void setOverLoad(void)
|
||||||
*/
|
*/
|
||||||
void lowInputLoadDetection(void)
|
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) {
|
||||||
num++;
|
num++;
|
||||||
// setOverLoad();
|
|
||||||
} else {
|
} else {
|
||||||
num = 0;
|
num = 0;
|
||||||
excessiveLoadInterruptFlag = FALSE;
|
excessiveLoadInterruptFlag = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (excessiveLoadInterruptFlag == TRUE && num == g_cfgParameter.inputPowerLowDetectionDelay) {
|
if (excessiveLoadInterruptFlag == TRUE && num == g_cfgParameter.inputPowerLowDetectionDelay) {
|
||||||
excessiveLoadInterruptFlag = FALSE;
|
|
||||||
setOverLoad();
|
setOverLoad();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -481,13 +468,6 @@ void DSG_PROT_Interrupt(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 反向充电短路中断,反向充电电流大于一定值
|
|
||||||
* @param
|
|
||||||
* @retval
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
void EXCHG_PROT_Interrupt(void)
|
void EXCHG_PROT_Interrupt(void)
|
||||||
{
|
{
|
||||||
setPowerOutput(FALSE);
|
setPowerOutput(FALSE);
|
||||||
|
|
|
@ -334,34 +334,20 @@ void mppt_readJust(void)
|
||||||
// return;
|
// return;
|
||||||
|
|
||||||
/* 调节电压,两个电压步调节 */
|
/* 调节电压,两个电压步调节 */
|
||||||
static float stepV1 = 0.2;
|
|
||||||
static float stepV2 = 0.05;
|
|
||||||
static float Power = 0;
|
static float Power = 0;
|
||||||
// static float totalPower = 0;
|
static float totalPower = 0;
|
||||||
// static float powerData[50] = {0};
|
static float powerData[50] = {0};
|
||||||
// static uint8_t powerIndex = 0;
|
static uint8_t powerIndex = 0;
|
||||||
|
|
||||||
static float totalChargeCurr = 0;
|
/* 获取50次的平均值 */
|
||||||
static float chargeCurrData[50] = {0};
|
totalPower -= powerData[powerIndex];
|
||||||
static uint8_t chargeCurrIndex = 0;
|
powerData[powerIndex] = getOutputVoltage() * getChargCurrent();
|
||||||
|
totalPower += powerData[powerIndex];
|
||||||
/* 获取50次值的和 */
|
powerIndex++;
|
||||||
totalChargeCurr -= chargeCurrData[chargeCurrIndex];
|
if (powerIndex >= 50) {
|
||||||
chargeCurrData[chargeCurrIndex] = getChargCurrent();
|
powerIndex = 0;
|
||||||
totalChargeCurr += chargeCurrData[chargeCurrIndex];
|
|
||||||
chargeCurrIndex++;
|
|
||||||
if (chargeCurrIndex >= 50) {
|
|
||||||
chargeCurrIndex = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// totalPower -= powerData[powerIndex];
|
|
||||||
// powerData[powerIndex] = getOutputVoltage() * getChargCurrent();
|
|
||||||
// totalPower += powerData[powerIndex];
|
|
||||||
// powerIndex++;
|
|
||||||
// if (powerIndex >= 50) {
|
|
||||||
// powerIndex = 0;
|
|
||||||
// }
|
|
||||||
|
|
||||||
static float lPower = 0;
|
static float lPower = 0;
|
||||||
static float lLPower = 0;
|
static float lLPower = 0;
|
||||||
// static float lLLPower = 0;
|
// static float lLLPower = 0;
|
||||||
|
@ -370,6 +356,9 @@ void mppt_readJust(void)
|
||||||
// static float kp = 0.005;
|
// static float kp = 0.005;
|
||||||
// static float ki = 0.00001;
|
// static float ki = 0.00001;
|
||||||
|
|
||||||
|
static float stepV1 = 0.2;
|
||||||
|
static float stepV2 = 0.1;
|
||||||
|
|
||||||
static uint8_t flag1 = 0; //表明上次运算是加还是减
|
static uint8_t flag1 = 0; //表明上次运算是加还是减
|
||||||
|
|
||||||
/* 延时一段时间才判断 */
|
/* 延时一段时间才判断 */
|
||||||
|
@ -389,14 +378,12 @@ void mppt_readJust(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getMosTemperState() == mosTemperReduce) {
|
if (getMosTemperState() == mosTemperReduce) {
|
||||||
SolarInCircuitV = 20;
|
SolarInCircuitV = 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
flag = 0;
|
flag = 0;
|
||||||
// Power = totalPower / 30.0f;
|
Power = totalPower / 50.0f;
|
||||||
// Power = totalPower;
|
|
||||||
Power = totalChargeCurr * getOutputVoltage();
|
|
||||||
|
|
||||||
static float powerT = 0;
|
static float powerT = 0;
|
||||||
powerT = Power - lPower;
|
powerT = Power - lPower;
|
||||||
|
@ -404,88 +391,10 @@ void mppt_readJust(void)
|
||||||
powerT = -powerT;
|
powerT = -powerT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 滞环值 */
|
|
||||||
float hysteresisValue1;
|
|
||||||
float hysteresisValue2;
|
|
||||||
/* 一段时间内电流都很小则固定电压输出 */
|
|
||||||
static uint8_t currMinFlag = 0;
|
|
||||||
static uint8_t currMinFlag1 = 0;
|
|
||||||
// if (getChargCurrent() < 0.8f) {
|
|
||||||
if (totalChargeCurr < 40) {
|
|
||||||
// hysteresisValue1 = getChargCurrent() * 1.7f;
|
|
||||||
// hysteresisValue2 = getChargCurrent() * 12;
|
|
||||||
currMinFlag++;
|
|
||||||
if (currMinFlag == 8) {
|
|
||||||
currMinFlag = 0;
|
|
||||||
SolarInCircuitV = 18.0f;
|
|
||||||
currMinFlag1 = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// else if (getChargCurrent() < 3 && currMinFlag1) {
|
|
||||||
else if (totalChargeCurr < 150 && currMinFlag1) {
|
|
||||||
currMinFlag1 = 0;
|
|
||||||
currMinFlag = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// else if (getChargCurrent() < 7) {
|
|
||||||
else if (totalChargeCurr < 350) {
|
|
||||||
currMinFlag1 = 0;
|
|
||||||
currMinFlag = 0;
|
|
||||||
// hysteresisValue1 = getChargCurrent() * 1.1f;
|
|
||||||
// hysteresisValue2 = getChargCurrent() * 10;
|
|
||||||
hysteresisValue1 = totalChargeCurr / 45.0f;
|
|
||||||
hysteresisValue2 = totalChargeCurr / 5.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
// else if (getChargCurrent() < 20) {
|
|
||||||
else if (totalChargeCurr < 1000) {
|
|
||||||
currMinFlag1 = 0;
|
|
||||||
currMinFlag = 0;
|
|
||||||
// hysteresisValue1 = getChargCurrent() * 0.7f;
|
|
||||||
// hysteresisValue2 = getChargCurrent() * 7;
|
|
||||||
hysteresisValue1 = totalChargeCurr / 70.0f;
|
|
||||||
hysteresisValue2 = totalChargeCurr / 7.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
// else if (getChargCurrent() < 25) {
|
|
||||||
else if (totalChargeCurr < 1250) {
|
|
||||||
currMinFlag1 = 0;
|
|
||||||
currMinFlag = 0;
|
|
||||||
// hysteresisValue1 = getChargCurrent() * 0.5f;
|
|
||||||
// hysteresisValue2 = getChargCurrent() * 5;
|
|
||||||
hysteresisValue1 = totalChargeCurr / 100.0f;
|
|
||||||
hysteresisValue2 = totalChargeCurr / 10.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
currMinFlag1 = 0;
|
|
||||||
currMinFlag = 0;
|
|
||||||
// hysteresisValue1 = getChargCurrent() * 0.3f;
|
|
||||||
// hysteresisValue2 = getChargCurrent() * 3;
|
|
||||||
hysteresisValue1 = totalChargeCurr / 150.0f;
|
|
||||||
hysteresisValue2 = totalChargeCurr / 16.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
// else {
|
|
||||||
// currMinFlag1 = 0;
|
|
||||||
// currMinFlag = 0;
|
|
||||||
// hysteresisValue1 = 120;
|
|
||||||
// hysteresisValue2 = 100;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
static uint8_t numFlag = 0;
|
|
||||||
// if ((lPower + 0.8f < Power) && (lLPower + 0.8f < Power) && (lLLPower + 0.8f < Power)) {
|
// if ((lPower + 0.8f < Power) && (lLPower + 0.8f < Power) && (lLLPower + 0.8f < Power)) {
|
||||||
// if ((lPower + 0.1f < Power) && (lLPower + 0.1f < Power)) {
|
if ((lPower + 0.1f < Power) && (lLPower + 0.1f < Power)) {
|
||||||
|
|
||||||
if ((lPower + hysteresisValue1 < Power) && (lLPower + hysteresisValue1 < Power)) {
|
|
||||||
numFlag = 0;
|
|
||||||
// if ((lPower + 0.3f < Power)) {
|
// if ((lPower + 0.3f < Power)) {
|
||||||
if (powerT > hysteresisValue2) {
|
if (powerT > 5) {
|
||||||
if (flag1) {
|
if (flag1) {
|
||||||
SolarInCircuitV += stepV1;
|
SolarInCircuitV += stepV1;
|
||||||
flag1 = 1;
|
flag1 = 1;
|
||||||
|
@ -503,10 +412,9 @@ 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 - 0.1f > Power) && (lLPower - 0.1f > Power)) {
|
||||||
// } else if ((lPower - 0.3f > Power)) {
|
// } else if ((lPower - 0.3f > Power)) {
|
||||||
if (powerT > hysteresisValue2) {
|
if (powerT > 5) {
|
||||||
numFlag = 0;
|
|
||||||
if (flag1) {
|
if (flag1) {
|
||||||
SolarInCircuitV -= stepV1;
|
SolarInCircuitV -= stepV1;
|
||||||
flag1 = 0;
|
flag1 = 0;
|
||||||
|
@ -523,30 +431,11 @@ void mppt_readJust(void)
|
||||||
flag1 = 1;
|
flag1 = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
numFlag++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 一段时间内都未调节 */
|
if (SolarInCircuitV > 20.0f) {
|
||||||
if (numFlag == 10) {
|
SolarInCircuitV = 20.0f;
|
||||||
if (Power < 300) {
|
|
||||||
SolarInCircuitV = 17.0f;
|
|
||||||
}
|
|
||||||
else if (flag1) {
|
|
||||||
SolarInCircuitV -= stepV2;
|
|
||||||
flag1 = 0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
SolarInCircuitV += stepV2;
|
|
||||||
flag1 = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (SolarInCircuitV > 19.0f) {
|
|
||||||
SolarInCircuitV = 19.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (SolarInCircuitV < 16.0f) {
|
else if (SolarInCircuitV < 16.0f) {
|
||||||
SolarInCircuitV = 16.0f;
|
SolarInCircuitV = 16.0f;
|
||||||
}
|
}
|
||||||
|
@ -567,8 +456,7 @@ void endChargWork(void)
|
||||||
setChargControlFlag(FALSE);
|
setChargControlFlag(FALSE);
|
||||||
setDutyRatioToZero();
|
setDutyRatioToZero();
|
||||||
setMPPT_Mode(noWork);
|
setMPPT_Mode(noWork);
|
||||||
beginStartControlTask();
|
beginStartControlTask();
|
||||||
EN_PWMOUT_Diseable();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -582,7 +470,6 @@ void stopChargWork(void)
|
||||||
setChargControlFlag(FALSE);
|
setChargControlFlag(FALSE);
|
||||||
setDutyRatioToZero();
|
setDutyRatioToZero();
|
||||||
setMPPT_Mode(noWork);
|
setMPPT_Mode(noWork);
|
||||||
EN_PWMOUT_Diseable();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -594,7 +481,6 @@ void stopChargWork(void)
|
||||||
void beginChargWork(void)
|
void beginChargWork(void)
|
||||||
{
|
{
|
||||||
beginStartControlTask();
|
beginStartControlTask();
|
||||||
EN_PWMOUT_Eable();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -606,7 +492,6 @@ void beginChargWork(void)
|
||||||
void startChargWork(void)
|
void startChargWork(void)
|
||||||
{
|
{
|
||||||
beginSoftStartTask();
|
beginSoftStartTask();
|
||||||
EN_PWMOUT_Eable();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -654,7 +539,7 @@ BOOL floatChargConditions(void)
|
||||||
BOOL mpptChargConditions(void)
|
BOOL mpptChargConditions(void)
|
||||||
{
|
{
|
||||||
if (((g_cfgParameter.constantVoltageChargeV - 0.2f) > getBatteryVoltage())
|
if (((g_cfgParameter.constantVoltageChargeV - 0.2f) > getBatteryVoltage())
|
||||||
&& (getChargCurrent() > 0.05f)) {
|
&& (getChargCurrent() > 0.1f)) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -781,8 +666,7 @@ void BatteryChargControl(void)
|
||||||
|
|
||||||
case MPPT:
|
case MPPT:
|
||||||
mpptCharge();
|
mpptCharge();
|
||||||
// mppt_constantVoltage(17.5f);
|
// mppt_constantVoltage(17.0f);
|
||||||
// setDutyRatio(0.1f);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case constantVoltage:
|
case constantVoltage:
|
||||||
|
|
|
@ -658,7 +658,6 @@ void stateMachine(device_handle device)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 串口通信协议的初始化 */
|
|
||||||
void uartCommonInit(void)
|
void uartCommonInit(void)
|
||||||
{
|
{
|
||||||
#ifdef HY_ChargeControlBox_PROTOCOL_ENABLE
|
#ifdef HY_ChargeControlBox_PROTOCOL_ENABLE
|
||||||
|
@ -1447,9 +1446,6 @@ uint16_t SL_ReadRegisterYearMonth(void *pMsg)
|
||||||
{
|
{
|
||||||
timeInfo time;
|
timeInfo time;
|
||||||
getRTC_Time(&time);
|
getRTC_Time(&time);
|
||||||
|
|
||||||
// debug_printf("%d-%d\n", time.year, time.month);
|
|
||||||
|
|
||||||
return (time.year << 8) | time.month;
|
return (time.year << 8) | time.month;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1462,9 +1458,6 @@ uint16_t SL_ReadRegisterDayHour(void *pMsg)
|
||||||
{
|
{
|
||||||
timeInfo time;
|
timeInfo time;
|
||||||
getRTC_Time(&time);
|
getRTC_Time(&time);
|
||||||
|
|
||||||
// debug_printf("%d-%d\n", time.day, time.hour);
|
|
||||||
|
|
||||||
return (time.day << 8) | time.hour;
|
return (time.day << 8) | time.hour;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1477,9 +1470,6 @@ uint16_t SL_ReadRegisterMinuteSecond(void *pMsg)
|
||||||
{
|
{
|
||||||
timeInfo time;
|
timeInfo time;
|
||||||
getRTC_Time(&time);
|
getRTC_Time(&time);
|
||||||
|
|
||||||
// debug_printf("%d-%d\n", time.minute, time.second);
|
|
||||||
|
|
||||||
return (time.minute << 8) | time.second;
|
return (time.minute << 8) | time.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1621,10 +1611,6 @@ uint16_t SL_WriteRegisterMinuteSecond(void *pMsg)
|
||||||
tempU8 = (uint8_t)(*(uint16_t*)pMsg);
|
tempU8 = (uint8_t)(*(uint16_t*)pMsg);
|
||||||
writeTime.second = tempU8;
|
writeTime.second = tempU8;
|
||||||
|
|
||||||
// debug_printf("%d-%d\n", writeTime.year, writeTime.month);
|
|
||||||
// debug_printf("%d-%d\n", writeTime.day, writeTime.hour);
|
|
||||||
// debug_printf("%d-%d\n", writeTime.minute, writeTime.second);
|
|
||||||
|
|
||||||
setRTC_Time(&writeTime);
|
setRTC_Time(&writeTime);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -123,17 +123,17 @@ void cfgTest(void)
|
||||||
*/
|
*/
|
||||||
void readFlashContent(config_info *configInfo)
|
void readFlashContent(config_info *configInfo)
|
||||||
{
|
{
|
||||||
read_config_info(configInfo);
|
read_config_info(configInfo);
|
||||||
/* 配置文件正确就返回 */
|
/* 配置文件正确就返回 */
|
||||||
// static volatile uint16_t tempCrc1, tempCrc2;
|
// static volatile uint16_t tempCrc1, tempCrc2;
|
||||||
// tempCrc1 = configInfo->crc;
|
// tempCrc1 = configInfo->crc;
|
||||||
// tempCrc2 = checkModebusCrc((uint8_t *)configInfo, CONFIG_INFO_SIZE - 2);
|
// tempCrc2 = checkModebusCrc((uint8_t *)configInfo, CONFIG_INFO_SIZE - 2);
|
||||||
// if (tempCrc1 == tempCrc2) {
|
// if (tempCrc1 == tempCrc2) {
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
if (configInfo->crc == checkModebusCrc((uint8_t *)configInfo, CONFIG_INFO_SIZE - 2)) {
|
if (configInfo->crc == checkModebusCrc((uint8_t *)configInfo, CONFIG_INFO_SIZE - 2)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// /* 更深处的配置文件正确就返回 */
|
// /* 更深处的配置文件正确就返回 */
|
||||||
|
@ -277,25 +277,26 @@ void config_info_start(void)
|
||||||
g_cfgParameter.reverseChargProtectionCurr = temp_configInfo.reverseChargProtectionCurr;
|
g_cfgParameter.reverseChargProtectionCurr = temp_configInfo.reverseChargProtectionCurr;
|
||||||
|
|
||||||
/* 读取的回路阻抗无效则回路阻抗设置为0 */
|
/* 读取的回路阻抗无效则回路阻抗设置为0 */
|
||||||
float fTemp;
|
float fTemp;
|
||||||
// fTemp = 0.01f;
|
// fTemp = 0.01f;
|
||||||
// saveLoopImpedance(&fTemp);
|
// saveLoopImpedance(&fTemp);
|
||||||
readLoopImpedance(&fTemp);
|
readLoopImpedance(&fTemp);
|
||||||
// setLoopImpedance(fTemp);
|
// setLoopImpedance(fTemp);
|
||||||
// if (getLoopImpedance() < 0 || getLoopImpedance() > 0.3f) {
|
// if (getLoopImpedance() < 0 || getLoopImpedance() > 0.3f) {
|
||||||
if (!setLoopImpedance(fTemp)) {
|
if (!setLoopImpedance(fTemp)) {
|
||||||
setLoopImpedance(0);
|
setLoopImpedance(0.01f);
|
||||||
fTemp = getLoopImpedance();
|
fTemp = getLoopImpedance();
|
||||||
saveLoopImpedance(&fTemp);
|
saveLoopImpedance(&fTemp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// readtotalElectricityConsumption(&fTemp);
|
readtotalElectricityConsumption(&fTemp);
|
||||||
// totalElectricityConsumptionInt(fTemp);
|
totalElectricityConsumptionInt(fTemp);
|
||||||
// readtotalChargCapacity(&fTemp);
|
readtotalChargCapacity(&fTemp);
|
||||||
// totalChargCapacityInt(fTemp);
|
totalChargCapacityInt(fTemp);
|
||||||
// timeInfo time;
|
|
||||||
// readTime(&time);
|
timeInfo time;
|
||||||
// setLastTime(time);
|
readTime(&time);
|
||||||
|
setLastTime(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -59,8 +59,8 @@ float getDutyRatio(void)
|
||||||
*/
|
*/
|
||||||
void setDutyRatio(float DutyRatio)
|
void setDutyRatio(float DutyRatio)
|
||||||
{
|
{
|
||||||
if (DutyRatio > 0.9f) {
|
if (DutyRatio > 0.95f) {
|
||||||
dutyRatio = 0.9f;
|
dutyRatio = 0.95f;
|
||||||
}
|
}
|
||||||
else if (DutyRatio < 0.05f) {
|
else if (DutyRatio < 0.05f) {
|
||||||
dutyRatio = 0.05f;
|
dutyRatio = 0.05f;
|
||||||
|
|
|
@ -160,7 +160,7 @@ void task_Init(void)
|
||||||
TimeSliceOffset_Register(&m_uart, Task_uart, uart_reloadVal, uart_offset);
|
TimeSliceOffset_Register(&m_uart, Task_uart, uart_reloadVal, uart_offset);
|
||||||
TimeSliceOffset_Register(&m_busFree, Task_busFree, busFree_reloadVal, busFree_offset);
|
TimeSliceOffset_Register(&m_busFree, Task_busFree, busFree_reloadVal, busFree_offset);
|
||||||
|
|
||||||
TimeSliceOffset_Register(&m_SOE, Task_SOE, SOE_reloadVal, SOE_offset);
|
TimeSliceOffset_Register(&m_SOE, Task_SOE, SOE_reloadVal, SOE_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -268,14 +268,14 @@ void Task_wdi(void)
|
||||||
// static uint32_t temp = 60 * 30;
|
// static uint32_t temp = 60 * 30;
|
||||||
if (!(--temp)) {
|
if (!(--temp)) {
|
||||||
temp = 0;
|
temp = 0;
|
||||||
// float tempF;
|
float tempF;
|
||||||
// tempF = getTotalElectricityConsumption();
|
tempF = getTotalElectricityConsumption();
|
||||||
// savetotalElectricityConsumption(&tempF);
|
savetotalElectricityConsumption(&tempF);
|
||||||
// tempF = getTotalChargCapacity();
|
tempF = getTotalChargCapacity();
|
||||||
// savetotalChargCapacity(&tempF);
|
savetotalChargCapacity(&tempF);
|
||||||
// timeInfo time;
|
timeInfo time;
|
||||||
// time = getLastTime();
|
time = getLastTime();
|
||||||
// saveTime(&time);
|
saveTime(&time);
|
||||||
// NVIC_SystemReset();
|
// NVIC_SystemReset();
|
||||||
resetCheckImpedanceState();
|
resetCheckImpedanceState();
|
||||||
temp = 60 * 60 * 24;
|
temp = 60 * 60 * 24;
|
||||||
|
@ -307,7 +307,7 @@ void Task_refreshJudgeData(void)
|
||||||
|
|
||||||
/* 有电池,太阳能输出功率大,电池电压低于14V,同时回路阻抗未测试或需要重新测试 */
|
/* 有电池,太阳能输出功率大,电池电压低于14V,同时回路阻抗未测试或需要重新测试 */
|
||||||
if ((getCheckImpedanceState() == FALSE || getLoopImpedance() == 0.0f)
|
if ((getCheckImpedanceState() == FALSE || getLoopImpedance() == 0.0f)
|
||||||
&& (getBatteryState() == TRUE) && (getChargCurrent() > g_cfgParameter.minCheckLoopImpedanceChargCurr)
|
&& (getBatteryState() == TRUE) && (getChargCurrent() > g_cfgParameter.maxChargCurr)
|
||||||
&& (getOutputVoltage() > 9) && (getSolarInCircuitVoltage() > 14)
|
&& (getOutputVoltage() > 9) && (getSolarInCircuitVoltage() > 14)
|
||||||
&& (getBatteryVoltage() < 14)) {
|
&& (getBatteryVoltage() < 14)) {
|
||||||
TimeSliceOffset_Register(&m_impedanceCalculation, Task_impedanceCalculation
|
TimeSliceOffset_Register(&m_impedanceCalculation, Task_impedanceCalculation
|
||||||
|
@ -378,15 +378,7 @@ 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);
|
|
||||||
EN_PWMOUT_Eable();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -395,7 +387,7 @@ void Task_startControl(void)
|
||||||
* @retval
|
* @retval
|
||||||
*/
|
*/
|
||||||
void beginStartControlTask(void)
|
void beginStartControlTask(void)
|
||||||
{
|
{
|
||||||
TimeSliceOffset_Register(&m_startControl, Task_startControl, startControl_reloadVal, startControl_offset);
|
TimeSliceOffset_Register(&m_startControl, Task_startControl, startControl_reloadVal, startControl_offset);
|
||||||
m_startControl.runFlag = 1;
|
m_startControl.runFlag = 1;
|
||||||
}
|
}
|
||||||
|
@ -417,7 +409,7 @@ void Task_softStart(void)
|
||||||
EN_PWMOUT_Eable();
|
EN_PWMOUT_Eable();
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (num > 70 || dutyRatio > 0.6f) {
|
else if (num > 70 || dutyRatio > 0.75f) {
|
||||||
TimeSliceOffset_Unregister(&m_softStart);
|
TimeSliceOffset_Unregister(&m_softStart);
|
||||||
m_softStart.runFlag = 0;
|
m_softStart.runFlag = 0;
|
||||||
|
|
||||||
|
@ -431,7 +423,7 @@ void Task_softStart(void)
|
||||||
setMPPT_Mode(floatCharg);
|
setMPPT_Mode(floatCharg);
|
||||||
}
|
}
|
||||||
setChargControlFlag(TRUE);
|
setChargControlFlag(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
setDutyRatio(getDutyRatio() + 0.01f);
|
setDutyRatio(getDutyRatio() + 0.01f);
|
||||||
|
|
|
@ -182,25 +182,24 @@ BOOL readOnlyPowerOutputState(void)
|
||||||
{
|
{
|
||||||
// static volatile GPIO_PinState gpioTemp1, gpioTemp2, gpioTemp3;
|
// static volatile GPIO_PinState gpioTemp1, gpioTemp2, gpioTemp3;
|
||||||
// GPIO_PinState gpioTemp1, gpioTemp2, gpioTemp3;
|
// GPIO_PinState gpioTemp1, gpioTemp2, gpioTemp3;
|
||||||
// GPIO_PinState gpioTemp1, gpioTemp2;
|
GPIO_PinState gpioTemp1, gpioTemp2;
|
||||||
|
|
||||||
// gpioTemp1 = HAL_GPIO_ReadPin(POW_FF_CON_GPIO_Port, POW_FF_CON_Pin);
|
gpioTemp1 = HAL_GPIO_ReadPin(POW_FF_CON_GPIO_Port, POW_FF_CON_Pin);
|
||||||
// gpioTemp2 = HAL_GPIO_ReadPin(POW_OUT_CON_GPIO_Port, POW_OUT_CON_Pin);
|
gpioTemp2 = HAL_GPIO_ReadPin(POW_OUT_CON_GPIO_Port, POW_OUT_CON_Pin);
|
||||||
// gpioTemp3 = HAL_GPIO_ReadPin(DSG_PROT_GPIO_Port, DSG_PROT_Pin);
|
// gpioTemp3 = HAL_GPIO_ReadPin(DSG_PROT_GPIO_Port, DSG_PROT_Pin);
|
||||||
|
|
||||||
// if (gpioTemp1 == GPIO_PIN_SET
|
if (gpioTemp1 == GPIO_PIN_SET
|
||||||
// && gpioTemp2 == GPIO_PIN_SET
|
&& gpioTemp2 == GPIO_PIN_SET
|
||||||
// // && gpioTemp3 == GPIO_PIN_SET) {
|
// && gpioTemp3 == GPIO_PIN_SET) {
|
||||||
// ) {
|
) {
|
||||||
// return TRUE;
|
return TRUE;
|
||||||
// }
|
}
|
||||||
|
|
||||||
if (!HAL_GPIO_ReadPin(POW_FF_CON_GPIO_Port, POW_FF_CON_Pin)
|
// if (HAL_GPIO_ReadPin(POW_FF_CON_GPIO_Port, POW_FF_CON_Pin)
|
||||||
&& HAL_GPIO_ReadPin(POW_OUT_CON_GPIO_Port, POW_OUT_CON_Pin)
|
// && HAL_GPIO_ReadPin(POW_OUT_CON_GPIO_Port, POW_OUT_CON_Pin)
|
||||||
&& !HAL_GPIO_ReadPin(DSG_PROT_GPIO_Port, DSG_PROT_Pin)
|
// && HAL_GPIO_ReadPin(DSG_PROT_GPIO_Port, DSG_PROT_Pin)) {
|
||||||
&& !HAL_GPIO_ReadPin(EXCHG_CURR_GPIO_Port, EXCHG_CURR_Pin)) {
|
// return TRUE;
|
||||||
return TRUE;
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,6 @@ void MX_GPIO_Init(void)
|
||||||
|
|
||||||
HAL_NVIC_SetPriority(EXTI15_10_IRQn, 0, 0);
|
HAL_NVIC_SetPriority(EXTI15_10_IRQn, 0, 0);
|
||||||
HAL_NVIC_EnableIRQ(EXTI15_10_IRQn);
|
HAL_NVIC_EnableIRQ(EXTI15_10_IRQn);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* USER CODE BEGIN 2 */
|
/* USER CODE BEGIN 2 */
|
||||||
|
|
|
@ -47,7 +47,7 @@ void MX_TIM3_Init(void)
|
||||||
htim3.Instance = TIM3;
|
htim3.Instance = TIM3;
|
||||||
htim3.Init.Prescaler = 0;
|
htim3.Init.Prescaler = 0;
|
||||||
htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
|
htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
htim3.Init.Period = 719;
|
htim3.Init.Period = 720;
|
||||||
htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||||
htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||||
if (HAL_TIM_PWM_Init(&htim3) != HAL_OK)
|
if (HAL_TIM_PWM_Init(&htim3) != HAL_OK)
|
||||||
|
|
|
@ -413,7 +413,7 @@ TIM16.PeriodNoDither=999
|
||||||
TIM16.Prescaler=71
|
TIM16.Prescaler=71
|
||||||
TIM3.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4
|
TIM3.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4
|
||||||
TIM3.IPParameters=PeriodNoDither,Channel-PWM Generation4 CH4
|
TIM3.IPParameters=PeriodNoDither,Channel-PWM Generation4 CH4
|
||||||
TIM3.PeriodNoDither=719
|
TIM3.PeriodNoDither=720
|
||||||
TIM6.IPParameters=Prescaler,PeriodNoDither,TIM_MasterOutputTrigger
|
TIM6.IPParameters=Prescaler,PeriodNoDither,TIM_MasterOutputTrigger
|
||||||
TIM6.PeriodNoDither=9
|
TIM6.PeriodNoDither=9
|
||||||
TIM6.Prescaler=71
|
TIM6.Prescaler=71
|
||||||
|
|
Loading…
Reference in New Issue