From a31b9af81057e104984b55ff6fb177cb4e661278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B7=E5=BA=8A=E5=B0=B1=E7=8A=AF=E5=9B=B0?= <11730503+psx123456@user.noreply.gitee.com> Date: Tue, 11 Feb 2025 08:57:47 +0800 Subject: [PATCH] =?UTF-8?q?MPPT=E7=AE=97=E6=B3=95=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- APP/businessLogic/Src/abnormalManage.c | 7 ++++ APP/businessLogic/Src/bl_chargControl.c | 37 +++++++++++++++---- APP/businessLogic/Src/bl_usart.c | 1 + APP/businessLogic/Src/inFlash.c | 49 ++++++++++++------------- APP/businessLogic/Src/task.c | 44 +++++++++++----------- 5 files changed, 84 insertions(+), 54 deletions(-) diff --git a/APP/businessLogic/Src/abnormalManage.c b/APP/businessLogic/Src/abnormalManage.c index 36690e7..bd59d04 100644 --- a/APP/businessLogic/Src/abnormalManage.c +++ b/APP/businessLogic/Src/abnormalManage.c @@ -468,6 +468,13 @@ void DSG_PROT_Interrupt(void) } } +/** + * @brief 反向充电短路中断,反向充电电流大于一定值 + * @param + * @retval + * + */ + void EXCHG_PROT_Interrupt(void) { setPowerOutput(FALSE); diff --git a/APP/businessLogic/Src/bl_chargControl.c b/APP/businessLogic/Src/bl_chargControl.c index 6d5e1dc..bef35e8 100644 --- a/APP/businessLogic/Src/bl_chargControl.c +++ b/APP/businessLogic/Src/bl_chargControl.c @@ -357,7 +357,7 @@ void mppt_readJust(void) // static float ki = 0.00001; static float stepV1 = 0.2; - static float stepV2 = 0.1; + static float stepV2 = 0.08; static uint8_t flag1 = 0; //表明上次运算是加还是减 @@ -383,7 +383,8 @@ void mppt_readJust(void) flag = 0; - Power = totalPower / 50.0f; + // Power = totalPower / 30.0f; + Power = totalPower; static float powerT = 0; powerT = Power - lPower; @@ -391,10 +392,13 @@ void mppt_readJust(void) powerT = -powerT; } + static uint8_t numFlag = 0; // 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 + 8.0f < Power) && (lLPower + 8.0f < Power)) { + numFlag = 0; // if ((lPower + 0.3f < Power)) { - if (powerT > 5) { + if (powerT > 250) { if (flag1) { SolarInCircuitV += stepV1; flag1 = 1; @@ -412,9 +416,10 @@ void mppt_readJust(void) } } // } else if ((lPower - 0.8f > Power) && (lLPower - 0.8f > Power) && (lLLPower - 0.8f > Power)) { - } else if ((lPower - 0.1f > Power) && (lLPower - 0.1f > Power)) { + } else if ((lPower - 8.0f > Power) && (lLPower - 8.0f > Power)) { // } else if ((lPower - 0.3f > Power)) { - if (powerT > 5) { + if (powerT > 250) { + numFlag = 0; if (flag1) { SolarInCircuitV -= stepV1; flag1 = 0; @@ -431,8 +436,26 @@ void mppt_readJust(void) flag1 = 1; } } + } else { + numFlag++; } + /* 一段时间内都未调节 */ + if (numFlag == 100) { + if (Power < 300) { + SolarInCircuitV = 17.0f; + } + else if (flag1) { + SolarInCircuitV -= stepV2; + flag1 = 0; + } + else { + SolarInCircuitV += stepV2; + flag1 = 1; + } + } + + if (SolarInCircuitV > 20.0f) { SolarInCircuitV = 20.0f; } @@ -666,7 +689,7 @@ void BatteryChargControl(void) case MPPT: mpptCharge(); - // mppt_constantVoltage(17.0f); + // mppt_constantVoltage(17.5f); break; case constantVoltage: diff --git a/APP/businessLogic/Src/bl_usart.c b/APP/businessLogic/Src/bl_usart.c index dcc5217..9f0d13c 100644 --- a/APP/businessLogic/Src/bl_usart.c +++ b/APP/businessLogic/Src/bl_usart.c @@ -658,6 +658,7 @@ void stateMachine(device_handle device) #endif } +/* 串口通信协议的初始化 */ void uartCommonInit(void) { #ifdef HY_ChargeControlBox_PROTOCOL_ENABLE diff --git a/APP/businessLogic/Src/inFlash.c b/APP/businessLogic/Src/inFlash.c index 022ef35..cddc356 100644 --- a/APP/businessLogic/Src/inFlash.c +++ b/APP/businessLogic/Src/inFlash.c @@ -123,17 +123,17 @@ void cfgTest(void) */ void readFlashContent(config_info *configInfo) { - read_config_info(configInfo); - /* 配置文件正确就返回 */ + read_config_info(configInfo); + /* 配置文件正确就返回 */ // static volatile uint16_t tempCrc1, tempCrc2; // tempCrc1 = configInfo->crc; // tempCrc2 = checkModebusCrc((uint8_t *)configInfo, CONFIG_INFO_SIZE - 2); // if (tempCrc1 == tempCrc2) { // return; // } - if (configInfo->crc == checkModebusCrc((uint8_t *)configInfo, CONFIG_INFO_SIZE - 2)) { - return; - } + if (configInfo->crc == checkModebusCrc((uint8_t *)configInfo, CONFIG_INFO_SIZE - 2)) { + return; + } // /* 更深处的配置文件正确就返回 */ @@ -277,26 +277,25 @@ void config_info_start(void) g_cfgParameter.reverseChargProtectionCurr = temp_configInfo.reverseChargProtectionCurr; /* 读取的回路阻抗无效则回路阻抗设置为0 */ - float fTemp; - // fTemp = 0.01f; - // saveLoopImpedance(&fTemp); - readLoopImpedance(&fTemp); - // setLoopImpedance(fTemp); - // if (getLoopImpedance() < 0 || getLoopImpedance() > 0.3f) { - if (!setLoopImpedance(fTemp)) { - setLoopImpedance(0.01f); - fTemp = getLoopImpedance(); - saveLoopImpedance(&fTemp); - } - - readtotalElectricityConsumption(&fTemp); - totalElectricityConsumptionInt(fTemp); - readtotalChargCapacity(&fTemp); - totalChargCapacityInt(fTemp); - - timeInfo time; - readTime(&time); - setLastTime(time); + float fTemp; + // fTemp = 0.01f; + // saveLoopImpedance(&fTemp); + readLoopImpedance(&fTemp); + // setLoopImpedance(fTemp); + // if (getLoopImpedance() < 0 || getLoopImpedance() > 0.3f) { + if (!setLoopImpedance(fTemp)) { + setLoopImpedance(0); + fTemp = getLoopImpedance(); + saveLoopImpedance(&fTemp); + } + +// readtotalElectricityConsumption(&fTemp); +// totalElectricityConsumptionInt(fTemp); +// readtotalChargCapacity(&fTemp); +// totalChargCapacityInt(fTemp); +// timeInfo time; +// readTime(&time); +// setLastTime(time); } diff --git a/APP/businessLogic/Src/task.c b/APP/businessLogic/Src/task.c index f015bd0..4c0f521 100644 --- a/APP/businessLogic/Src/task.c +++ b/APP/businessLogic/Src/task.c @@ -200,20 +200,20 @@ void Task_wdi(void) { feedDog(); -// debug_printf("chargCurrent:%f \n", getChargCurrent()); -// debug_printf("outputVoltage:%f \n", getOutputVoltage()); -// debug_printf("BatteryVoltage:%f \n", getBatteryVoltage()); -// debug_printf("dischargCurrent:%f \n", getDischargCurrent()); -// debug_printf("solarInCircuitVoltage:%f \n", getSolarInCircuitVoltage()); -// debug_printf("HighSideMosTemperature:%f \n", getHighSideMosTemperature()); -// debug_printf("InputVoltage:%f \n", getInputVoltage()); -// debug_printf("DischargMosState:%d \n", getDischargMosState()); -// debug_printf("MPPT_Mode:%d \n", getMPPT_Mode()); -// debug_printf("loopImpedance:%f \n", getLoopImpedance()); -// debug_printf("DutyRatio:%f \n", getDutyRatio()); -// // debug_printf("OUT_VOLT_IN:%f \n", get_OUT_VOLT_IN()); -// debug_printf("HAL_GetTick:%d \n", HAL_GetTick()); -// debug_printf("getExChargeCurr:%f \n", getExChargeCurr()); + debug_printf("chargCurrent:%f \n", getChargCurrent()); + debug_printf("outputVoltage:%f \n", getOutputVoltage()); + debug_printf("BatteryVoltage:%f \n", getBatteryVoltage()); + debug_printf("dischargCurrent:%f \n", getDischargCurrent()); + debug_printf("solarInCircuitVoltage:%f \n", getSolarInCircuitVoltage()); + debug_printf("HighSideMosTemperature:%f \n", getHighSideMosTemperature()); + debug_printf("InputVoltage:%f \n", getInputVoltage()); + debug_printf("DischargMosState:%d \n", getDischargMosState()); + debug_printf("MPPT_Mode:%d \n", getMPPT_Mode()); + debug_printf("loopImpedance:%f \n", getLoopImpedance()); + debug_printf("DutyRatio:%f \n", getDutyRatio()); +// debug_printf("OUT_VOLT_IN:%f \n", get_OUT_VOLT_IN()); + debug_printf("HAL_GetTick:%d \n", HAL_GetTick()); + debug_printf("getExChargeCurr:%f \n", getExChargeCurr()); // char buf[100]; @@ -268,14 +268,14 @@ void Task_wdi(void) // static uint32_t temp = 60 * 30; if (!(--temp)) { temp = 0; - float tempF; - tempF = getTotalElectricityConsumption(); - savetotalElectricityConsumption(&tempF); - tempF = getTotalChargCapacity(); - savetotalChargCapacity(&tempF); - timeInfo time; - time = getLastTime(); - saveTime(&time); + // float tempF; + // tempF = getTotalElectricityConsumption(); + // savetotalElectricityConsumption(&tempF); + // tempF = getTotalChargCapacity(); + // savetotalChargCapacity(&tempF); + // timeInfo time; + // time = getLastTime(); + // saveTime(&time); // NVIC_SystemReset(); resetCheckImpedanceState(); temp = 60 * 60 * 24;