MPPT算法异常

This commit is contained in:
起床就犯困 2025-02-11 08:57:47 +08:00
parent 3ea22514fd
commit a31b9af810
5 changed files with 84 additions and 54 deletions

View File

@ -468,6 +468,13 @@ void DSG_PROT_Interrupt(void)
} }
} }
/**
* @brief
* @param
* @retval
*
*/
void EXCHG_PROT_Interrupt(void) void EXCHG_PROT_Interrupt(void)
{ {
setPowerOutput(FALSE); setPowerOutput(FALSE);

View File

@ -357,7 +357,7 @@ void mppt_readJust(void)
// static float ki = 0.00001; // static float ki = 0.00001;
static float stepV1 = 0.2; static float stepV1 = 0.2;
static float stepV2 = 0.1; static float stepV2 = 0.08;
static uint8_t flag1 = 0; //表明上次运算是加还是减 static uint8_t flag1 = 0; //表明上次运算是加还是减
@ -383,7 +383,8 @@ void mppt_readJust(void)
flag = 0; flag = 0;
Power = totalPower / 50.0f; // Power = totalPower / 30.0f;
Power = totalPower;
static float powerT = 0; static float powerT = 0;
powerT = Power - lPower; powerT = Power - lPower;
@ -391,10 +392,13 @@ void mppt_readJust(void)
powerT = -powerT; powerT = -powerT;
} }
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 + 8.0f < Power) && (lLPower + 8.0f < Power)) {
numFlag = 0;
// if ((lPower + 0.3f < Power)) { // if ((lPower + 0.3f < Power)) {
if (powerT > 5) { if (powerT > 250) {
if (flag1) { if (flag1) {
SolarInCircuitV += stepV1; SolarInCircuitV += stepV1;
flag1 = 1; 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.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)) { // } else if ((lPower - 0.3f > Power)) {
if (powerT > 5) { if (powerT > 250) {
numFlag = 0;
if (flag1) { if (flag1) {
SolarInCircuitV -= stepV1; SolarInCircuitV -= stepV1;
flag1 = 0; flag1 = 0;
@ -431,8 +436,26 @@ void mppt_readJust(void)
flag1 = 1; 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) { if (SolarInCircuitV > 20.0f) {
SolarInCircuitV = 20.0f; SolarInCircuitV = 20.0f;
} }
@ -666,7 +689,7 @@ void BatteryChargControl(void)
case MPPT: case MPPT:
mpptCharge(); mpptCharge();
// mppt_constantVoltage(17.0f); // mppt_constantVoltage(17.5f);
break; break;
case constantVoltage: case constantVoltage:

View File

@ -658,6 +658,7 @@ void stateMachine(device_handle device)
#endif #endif
} }
/* 串口通信协议的初始化 */
void uartCommonInit(void) void uartCommonInit(void)
{ {
#ifdef HY_ChargeControlBox_PROTOCOL_ENABLE #ifdef HY_ChargeControlBox_PROTOCOL_ENABLE

View File

@ -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,26 +277,25 @@ 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.01f); setLoopImpedance(0);
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;
timeInfo time; // readTime(&time);
readTime(&time); // setLastTime(time);
setLastTime(time);
} }

View File

@ -200,20 +200,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];
@ -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;