修改前端输入功率较低时的执行方式

This commit is contained in:
起床就犯困 2025-02-13 08:55:55 +08:00
parent a31b9af810
commit 25af1a47ff
11 changed files with 201 additions and 69 deletions

View File

@ -62,6 +62,9 @@ void start(void)
uartCommonInit();
// setDutyRatio(0.15f);
task_Init();
startInfo();
@ -72,7 +75,7 @@ void start(void)
// HAL_Delay(1000);
// }
/* 启动事件 */
insertEventsOrderRecord(startEvent);
// insertEventsOrderRecord(startEvent);
TimeSliceOffset_Start();
}

View File

@ -49,8 +49,8 @@ void Init(void)
// POW_OUT_PCON_Open();
HAL_Delay(100);
setPowerOutput(TRUE);
resetCheckImpedanceState();
// EN_PWMOUT_Eable();
// setDutyRatio(0.5);
// while (1) {
// log_info("Init_debug_uart \n");

View File

@ -299,12 +299,23 @@ void checkFFMOS_CON(void)
// FFMOS_CON_Close();
// }
if (getChargCurrent() > 5.0f && FALSE == FFMOS_CON_read()) {
static uint8_t num = 100;
if (getChargCurrent() > 8.0f && FALSE == FFMOS_CON_read()) {
num--;
if (!num) {
FFMOS_CON_Open();
}
}
else if (getChargCurrent() < 2.0f && TRUE == FFMOS_CON_read()) {
// num--;
// if (!num) {
// FFMOS_CON_Close();
// }
FFMOS_CON_Close();
}
else {
num = 100;
}
}
// /**
@ -364,12 +375,14 @@ void lowInputLoadDetection(void)
if (excessiveLoadInterruptFlag == TRUE && getOutputVoltage() < g_cfgParameter.inputPowerLowDetectionVolt) {
num++;
// setOverLoad();
} else {
num = 0;
excessiveLoadInterruptFlag = FALSE;
}
if (excessiveLoadInterruptFlag == TRUE && num == g_cfgParameter.inputPowerLowDetectionDelay) {
excessiveLoadInterruptFlag = FALSE;
setOverLoad();
}
}

View File

@ -334,20 +334,34 @@ void mppt_readJust(void)
// return;
/* 调节电压,两个电压步调节 */
static float stepV1 = 0.2;
static float stepV2 = 0.05;
static float Power = 0;
static float totalPower = 0;
static float powerData[50] = {0};
static uint8_t powerIndex = 0;
// static float totalPower = 0;
// static float powerData[50] = {0};
// static uint8_t powerIndex = 0;
/* 获取50次的平均值 */
totalPower -= powerData[powerIndex];
powerData[powerIndex] = getOutputVoltage() * getChargCurrent();
totalPower += powerData[powerIndex];
powerIndex++;
if (powerIndex >= 50) {
powerIndex = 0;
static float totalChargeCurr = 0;
static float chargeCurrData[50] = {0};
static uint8_t chargeCurrIndex = 0;
/* 获取50次值的和 */
totalChargeCurr -= chargeCurrData[chargeCurrIndex];
chargeCurrData[chargeCurrIndex] = getChargCurrent();
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 lLPower = 0;
// static float lLLPower = 0;
@ -356,9 +370,6 @@ void mppt_readJust(void)
// static float kp = 0.005;
// static float ki = 0.00001;
static float stepV1 = 0.2;
static float stepV2 = 0.08;
static uint8_t flag1 = 0; //表明上次运算是加还是减
/* 延时一段时间才判断 */
@ -378,13 +389,14 @@ void mppt_readJust(void)
}
if (getMosTemperState() == mosTemperReduce) {
SolarInCircuitV = 16;
SolarInCircuitV = 20;
}
flag = 0;
// Power = totalPower / 30.0f;
Power = totalPower;
// Power = totalPower;
Power = totalChargeCurr * getOutputVoltage();
static float powerT = 0;
powerT = Power - lPower;
@ -392,13 +404,88 @@ void mppt_readJust(void)
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.1f < Power) && (lLPower + 0.1f < Power)) {
if ((lPower + 8.0f < Power) && (lLPower + 8.0f < Power)) {
if ((lPower + hysteresisValue1 < Power) && (lLPower + hysteresisValue1 < Power)) {
numFlag = 0;
// if ((lPower + 0.3f < Power)) {
if (powerT > 250) {
if (powerT > hysteresisValue2) {
if (flag1) {
SolarInCircuitV += stepV1;
flag1 = 1;
@ -416,9 +503,9 @@ void mppt_readJust(void)
}
}
// } else if ((lPower - 0.8f > Power) && (lLPower - 0.8f > Power) && (lLLPower - 0.8f > Power)) {
} else if ((lPower - 8.0f > Power) && (lLPower - 8.0f > Power)) {
} else if ((lPower - hysteresisValue1 > Power) && (lLPower - hysteresisValue1 > Power)) {
// } else if ((lPower - 0.3f > Power)) {
if (powerT > 250) {
if (powerT > hysteresisValue2) {
numFlag = 0;
if (flag1) {
SolarInCircuitV -= stepV1;
@ -441,7 +528,7 @@ void mppt_readJust(void)
}
/* 一段时间内都未调节 */
if (numFlag == 100) {
if (numFlag == 10) {
if (Power < 300) {
SolarInCircuitV = 17.0f;
}
@ -456,9 +543,10 @@ void mppt_readJust(void)
}
if (SolarInCircuitV > 20.0f) {
SolarInCircuitV = 20.0f;
if (SolarInCircuitV > 19.0f) {
SolarInCircuitV = 19.0f;
}
else if (SolarInCircuitV < 16.0f) {
SolarInCircuitV = 16.0f;
}
@ -480,6 +568,7 @@ void endChargWork(void)
setDutyRatioToZero();
setMPPT_Mode(noWork);
beginStartControlTask();
EN_PWMOUT_Diseable();
}
/**
@ -493,6 +582,7 @@ void stopChargWork(void)
setChargControlFlag(FALSE);
setDutyRatioToZero();
setMPPT_Mode(noWork);
EN_PWMOUT_Diseable();
}
/**
@ -504,6 +594,7 @@ void stopChargWork(void)
void beginChargWork(void)
{
beginStartControlTask();
EN_PWMOUT_Eable();
}
/**
@ -515,6 +606,7 @@ void beginChargWork(void)
void startChargWork(void)
{
beginSoftStartTask();
EN_PWMOUT_Eable();
}
@ -562,7 +654,7 @@ BOOL floatChargConditions(void)
BOOL mpptChargConditions(void)
{
if (((g_cfgParameter.constantVoltageChargeV - 0.2f) > getBatteryVoltage())
&& (getChargCurrent() > 0.1f)) {
&& (getChargCurrent() > 0.05f)) {
return TRUE;
}
@ -690,6 +782,7 @@ void BatteryChargControl(void)
case MPPT:
mpptCharge();
// mppt_constantVoltage(17.5f);
// setDutyRatio(0.1f);
break;
case constantVoltage:

View File

@ -1447,6 +1447,9 @@ uint16_t SL_ReadRegisterYearMonth(void *pMsg)
{
timeInfo time;
getRTC_Time(&time);
// debug_printf("%d-%d\n", time.year, time.month);
return (time.year << 8) | time.month;
}
@ -1459,6 +1462,9 @@ uint16_t SL_ReadRegisterDayHour(void *pMsg)
{
timeInfo time;
getRTC_Time(&time);
// debug_printf("%d-%d\n", time.day, time.hour);
return (time.day << 8) | time.hour;
}
@ -1471,6 +1477,9 @@ uint16_t SL_ReadRegisterMinuteSecond(void *pMsg)
{
timeInfo time;
getRTC_Time(&time);
// debug_printf("%d-%d\n", time.minute, time.second);
return (time.minute << 8) | time.second;
}
@ -1612,6 +1621,10 @@ uint16_t SL_WriteRegisterMinuteSecond(void *pMsg)
tempU8 = (uint8_t)(*(uint16_t*)pMsg);
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);
return 0;

View File

@ -59,8 +59,8 @@ float getDutyRatio(void)
*/
void setDutyRatio(float DutyRatio)
{
if (DutyRatio > 0.95f) {
dutyRatio = 0.95f;
if (DutyRatio > 0.9f) {
dutyRatio = 0.9f;
}
else if (DutyRatio < 0.05f) {
dutyRatio = 0.05f;

View File

@ -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];
@ -307,7 +307,7 @@ void Task_refreshJudgeData(void)
/* 有电池太阳能输出功率大电池电压低于14V同时回路阻抗未测试或需要重新测试 */
if ((getCheckImpedanceState() == FALSE || getLoopImpedance() == 0.0f)
&& (getBatteryState() == TRUE) && (getChargCurrent() > g_cfgParameter.maxChargCurr)
&& (getBatteryState() == TRUE) && (getChargCurrent() > g_cfgParameter.minCheckLoopImpedanceChargCurr)
&& (getOutputVoltage() > 9) && (getSolarInCircuitVoltage() > 14)
&& (getBatteryVoltage() < 14)) {
TimeSliceOffset_Register(&m_impedanceCalculation, Task_impedanceCalculation
@ -378,7 +378,15 @@ 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();
}
}
/**
@ -409,7 +417,7 @@ void Task_softStart(void)
EN_PWMOUT_Eable();
}
else if (num > 70 || dutyRatio > 0.75f) {
else if (num > 70 || dutyRatio > 0.6f) {
TimeSliceOffset_Unregister(&m_softStart);
m_softStart.runFlag = 0;

View File

@ -182,25 +182,26 @@ BOOL readOnlyPowerOutputState(void)
{
// static volatile 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);
gpioTemp2 = HAL_GPIO_ReadPin(POW_OUT_CON_GPIO_Port, POW_OUT_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);
// gpioTemp3 = HAL_GPIO_ReadPin(DSG_PROT_GPIO_Port, DSG_PROT_Pin);
if (gpioTemp1 == GPIO_PIN_SET
&& gpioTemp2 == GPIO_PIN_SET
// && gpioTemp3 == GPIO_PIN_SET) {
) {
return TRUE;
}
// 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(DSG_PROT_GPIO_Port, DSG_PROT_Pin)) {
// if (gpioTemp1 == GPIO_PIN_SET
// && gpioTemp2 == GPIO_PIN_SET
// // && gpioTemp3 == GPIO_PIN_SET) {
// ) {
// return TRUE;
// }
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(DSG_PROT_GPIO_Port, DSG_PROT_Pin)
&& !HAL_GPIO_ReadPin(EXCHG_CURR_GPIO_Port, EXCHG_CURR_Pin)) {
return TRUE;
}
return FALSE;
}

View File

@ -104,6 +104,7 @@ void MX_GPIO_Init(void)
HAL_NVIC_SetPriority(EXTI15_10_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(EXTI15_10_IRQn);
}
/* USER CODE BEGIN 2 */

View File

@ -47,7 +47,7 @@ void MX_TIM3_Init(void)
htim3.Instance = TIM3;
htim3.Init.Prescaler = 0;
htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
htim3.Init.Period = 720;
htim3.Init.Period = 719;
htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_PWM_Init(&htim3) != HAL_OK)

View File

@ -413,7 +413,7 @@ TIM16.PeriodNoDither=999
TIM16.Prescaler=71
TIM3.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4
TIM3.IPParameters=PeriodNoDither,Channel-PWM Generation4 CH4
TIM3.PeriodNoDither=720
TIM3.PeriodNoDither=719
TIM6.IPParameters=Prescaler,PeriodNoDither,TIM_MasterOutputTrigger
TIM6.PeriodNoDither=9
TIM6.Prescaler=71