修改mppt的方式为扰动干扰法
This commit is contained in:
parent
a768f1cf3f
commit
a3b56a4252
|
@ -5,7 +5,7 @@
|
|||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1033085767641952736" id="ilg.gnumcueclipse.managedbuild.cross.riscv.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT RISC-V Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="742743566734499151" id="ilg.gnumcueclipse.managedbuild.cross.riscv.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT RISC-V Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||
</provider>
|
||||
|
|
|
@ -20,11 +20,8 @@
|
|||
#define ASCII_CHAR_FORM_FEED 0x0C /* '\f' */
|
||||
#define ASCII_CHAR_CARRIAGE_RETURN 0x0D /* '\r' */
|
||||
|
||||
|
||||
|
||||
#define RS485_MAX_PACK_DATA_LEN 30
|
||||
|
||||
|
||||
typedef uint32_t device_handle;
|
||||
extern device_handle g_bat485_uart3_handle;
|
||||
extern device_handle g_gw485_uart4_handle;
|
||||
|
|
|
@ -467,7 +467,7 @@ void HY_MsgProcFunc_batteryStatus(device_handle device, void *pMsg, uint32_t Msg
|
|||
pack.dischargCurrent = g_otherParameter.Discharg_Current;
|
||||
pack.chargCurrent1 = g_otherParameter.Charg_Current;
|
||||
pack.SOC = g_otherParameter.SOC;
|
||||
pack.openCircuitVoltage1 = g_otherParameter.Solar_In_Circuit_Voltage;
|
||||
pack.openCircuitVoltage1 = g_otherParameter.Solar_Open_Circuit_Voltage;
|
||||
|
||||
if (g_controlParameter.dutyRatio > 0 && g_otherParameter.Charg_Current > 0.05) {
|
||||
pack.chargSwitchStatus1 = HY_switchON;
|
||||
|
|
|
@ -35,6 +35,7 @@ void mppt_constantVoltage(float InVoltage)
|
|||
float_t pv1Volt = g_otherParameter.Solar_In_Circuit_Voltage;
|
||||
float_t error = pv1Volt - InVoltage;
|
||||
float_t stepPwm = kp * error + ki * pv1Volt;
|
||||
|
||||
g_controlParameter.dutyRatio += stepPwm;
|
||||
|
||||
Set_duty_ratio(&g_controlParameter.dutyRatio);
|
||||
|
@ -61,12 +62,12 @@ void mppt_constantVoltageB(float OutVoltage)
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 恒定输出电压(输出检测端)
|
||||
* @brief 恒定输出电压(输出检测端,没有电池时)
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
void mppt_constantVoltageO(float OutVoltage)
|
||||
void mppt_constantVoltageNoBatteryO(float OutVoltage)
|
||||
{
|
||||
static float_t kp = 0.005;
|
||||
static float_t ki = 0.00001;
|
||||
|
@ -80,6 +81,134 @@ void mppt_constantVoltageO(float OutVoltage)
|
|||
Set_duty_ratio(&g_controlParameter.dutyRatio);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 恒定输出电压(输出检测端)
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
float_t lastVolt = 0;
|
||||
float_t lastStepPwm = 0;
|
||||
float_t lastDutyRatio = 0;
|
||||
void mppt_constantVoltageO(float OutVoltage)
|
||||
{
|
||||
static float_t kp = 0.005;
|
||||
static float_t ki = 0.00001;
|
||||
// static uint8_t flag = 0;
|
||||
|
||||
float_t outVolt = g_otherParameter.Output_Voltage;
|
||||
|
||||
float_t error = OutVoltage - outVolt;
|
||||
float_t StepPwm = kp * error + ki * outVolt;
|
||||
|
||||
/* 当有电池时,输出电压的曲线是先上升后下降 */
|
||||
if (lastDutyRatio >= g_controlParameter.dutyRatio) {
|
||||
// if (lastVolt >= outVolt) {
|
||||
g_controlParameter.dutyRatio += StepPwm;
|
||||
// } else {
|
||||
// g_controlParameter.dutyRatio -= StepPwm;
|
||||
// }
|
||||
} else {
|
||||
// if (lastVolt >= outVolt) {
|
||||
// g_controlParameter.dutyRatio -= StepPwm;
|
||||
// } else {
|
||||
// g_controlParameter.dutyRatio += StepPwm;
|
||||
// }
|
||||
g_controlParameter.dutyRatio -= StepPwm;
|
||||
}
|
||||
|
||||
if (g_otherParameter.overTemperature == 0) {
|
||||
|
||||
} else if (g_otherParameter.overTemperature == 1) {
|
||||
g_controlParameter.dutyRatio -= 0.1;
|
||||
} else if (g_otherParameter.overTemperature == 2) {
|
||||
g_controlParameter.dutyRatio -= 0.2;
|
||||
} else if (g_otherParameter.overTemperature == 3) {
|
||||
g_controlParameter.dutyRatio -= 0.3;
|
||||
}
|
||||
|
||||
lastVolt = outVolt;
|
||||
lastStepPwm = StepPwm;
|
||||
lastDutyRatio = g_controlParameter.dutyRatio;
|
||||
|
||||
Set_duty_ratio(&g_controlParameter.dutyRatio);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 通过扰动干扰法追踪最大功率点
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
float_t lastPower = 0;
|
||||
float_t lastSolarInCircuitVoltage = 0;
|
||||
void mppt_readJust(void)
|
||||
{
|
||||
static float_t step1 = 0.01;
|
||||
static float_t step2 = 0.005;
|
||||
static float_t tempV = 0.1;
|
||||
|
||||
static uint16_t flag = 0;
|
||||
flag++;
|
||||
if (flag < 600) {
|
||||
return;
|
||||
}
|
||||
flag = 0;
|
||||
|
||||
float_t SolarInCircuitVoltage = get_PV1_VOLT_IN();
|
||||
float_t power = g_otherParameter.Output_Voltage * g_otherParameter.Charg_Current;
|
||||
|
||||
float_t voltageDifference = SolarInCircuitVoltage - lastSolarInCircuitVoltage;
|
||||
|
||||
/* 输出电压随占空比增加电压减小 */
|
||||
if (power <= lastPower) {
|
||||
if (lastSolarInCircuitVoltage <= SolarInCircuitVoltage) {
|
||||
if (voltageDifference > tempV) {
|
||||
g_controlParameter.dutyRatio += step2;
|
||||
} else {
|
||||
g_controlParameter.dutyRatio += step1;
|
||||
}
|
||||
} else {
|
||||
if (voltageDifference > tempV) {
|
||||
g_controlParameter.dutyRatio -= step2;
|
||||
} else {
|
||||
g_controlParameter.dutyRatio -= step1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (lastSolarInCircuitVoltage <= SolarInCircuitVoltage) {
|
||||
if (voltageDifference > tempV) {
|
||||
g_controlParameter.dutyRatio -= step2;
|
||||
} else {
|
||||
g_controlParameter.dutyRatio -= step1;
|
||||
}
|
||||
} else {
|
||||
if (voltageDifference > tempV) {
|
||||
g_controlParameter.dutyRatio += step2;
|
||||
} else {
|
||||
g_controlParameter.dutyRatio += step1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lastPower = power;
|
||||
lastSolarInCircuitVoltage = SolarInCircuitVoltage;
|
||||
|
||||
/* 过温保护 */
|
||||
if (g_otherParameter.overTemperature == 0) {
|
||||
|
||||
} else if (g_otherParameter.overTemperature == 1) {
|
||||
g_controlParameter.dutyRatio -= 0.1;
|
||||
} else if (g_otherParameter.overTemperature == 2) {
|
||||
g_controlParameter.dutyRatio -= 0.2;
|
||||
} else if (g_otherParameter.overTemperature == 3) {
|
||||
g_controlParameter.dutyRatio -= 0.3;
|
||||
}
|
||||
|
||||
Set_duty_ratio(&g_controlParameter.dutyRatio);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 恒流充电(大电流充电),mppt最大功率充电
|
||||
* @param
|
||||
|
@ -88,7 +217,8 @@ void mppt_constantVoltageO(float OutVoltage)
|
|||
*/
|
||||
void ConstantCurrentCharge(void)
|
||||
{
|
||||
mppt_constantVoltage(18);
|
||||
// mppt_constantVoltage(18);
|
||||
mppt_readJust();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -150,7 +280,7 @@ void MpptModeChoice(void)
|
|||
{
|
||||
/* 太阳能板输出电压小于一定值且充电电流也小于一定值时mppt停止工作 */
|
||||
if ((g_otherParameter.Input_Voltage < g_controlParameter.stopSolarOpenCircuitV
|
||||
&& g_otherParameter.Charg_Current < 0.05) ){
|
||||
&& g_otherParameter.Charg_Current < 0.1) ){
|
||||
// && g_otherParameter.MPPT_Mode != NoWork) {
|
||||
g_otherParameter.MPPT_Mode = NoWork;
|
||||
|
||||
|
@ -213,14 +343,27 @@ void MpptContorl(void)
|
|||
|
||||
g_otherParameter.Charg_BatteryCurrent = g_otherParameter.Charg_Current - g_otherParameter.Discharg_Current;
|
||||
|
||||
|
||||
if (!g_otherParameter.overTemperature) {
|
||||
MpptModeChoice();
|
||||
|
||||
/* 无电池时,恒压输出 */
|
||||
if (!g_otherParameter.batteryState) {
|
||||
if (!g_otherParameter.overTemperature) {
|
||||
// mppt_constantVoltageNoBatteryO(g_controlParameter.FloatV);
|
||||
|
||||
mppt_constantVoltageO(g_controlParameter.FloatV);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// /* 有电池时 */
|
||||
// if (!g_otherParameter.overTemperature) {
|
||||
// MpptModeChoice();
|
||||
// MpptContorlChoice();
|
||||
// }
|
||||
|
||||
MpptContorlChoice();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -46,14 +46,10 @@ void Init()
|
|||
POW_OUT_CON_Init();
|
||||
POW_FF_CON_Init();
|
||||
DSG_PROT_Init();
|
||||
WORK_VOLT_INT_Init();
|
||||
|
||||
/* 1ms */
|
||||
TIM3_Init(10);
|
||||
|
||||
|
||||
// uart_dev_write(g_gw485_uart4_handle, "1\n", sizeof("1\n"));
|
||||
|
||||
TimeSliceOffset_Register(&m_WdiRunled, Task_WdiRunled, WdiRunled_reloadVal, WdiRunled_offset);
|
||||
TimeSliceOffset_Register(&m_refreshRegister, Task_refreshRegister,
|
||||
refreshRegister_reloadVal, refreshRegister_offset);
|
||||
|
@ -96,12 +92,14 @@ void Task_WdiRunled(void)
|
|||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
static uint8_t tempT = 10;
|
||||
static uint8_t tempT = 15;
|
||||
if (tempT != 0) {
|
||||
tempT--;
|
||||
if (tempT == 0) {
|
||||
GPIO_WriteBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN, SET);
|
||||
GPIO_WriteBit(POW_FF_CON_GPIO, POW_FF_CON_PIN, SET);
|
||||
Delay_Ms(1);
|
||||
WORK_VOLT_INT_Init();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -202,18 +200,17 @@ void Task_refreshRegister(void)
|
|||
g_otherParameter.Solar_In_Circuit_Voltage = get_PV1_VOLT_IN();
|
||||
g_otherParameter.HighSideMos_Temperature = get_MOSFET_Temper();
|
||||
|
||||
if (g_controlParameter.dutyRatio == 0 && g_collectOpenCircuitVoltageFlag == 0) {
|
||||
if (g_controlParameter.dutyRatio == 0 && g_otherParameter.batteryState == 0) {
|
||||
g_otherParameter.Solar_Open_Circuit_Voltage = get_PV1_VOLT_IN();
|
||||
}
|
||||
|
||||
g_otherParameter.Charg_BatteryCurrent = g_otherParameter.Charg_Current
|
||||
- g_otherParameter.Discharg_Current;
|
||||
g_otherParameter.totalChargCapacity += totalChargCapacity / 3600000;
|
||||
g_otherParameter.totalElectricityConsumption += totalElectricityConsumption / 3600000;
|
||||
// saveTotalPower(&g_otherParameter.totalElectricityConsumption, &g_otherParameter.totalChargCapacity);
|
||||
|
||||
totalChargCapacity = 0;
|
||||
g_otherParameter.totalElectricityConsumption += totalElectricityConsumption / 3600000;
|
||||
totalElectricityConsumption = 0;
|
||||
// saveTotalPower(&g_otherParameter.totalElectricityConsumption, &g_otherParameter.totalChargCapacity);
|
||||
|
||||
g_otherParameter.SOC = 0;
|
||||
|
||||
|
@ -339,9 +336,13 @@ void Task_excessiveLoad(void)
|
|||
num++;
|
||||
}
|
||||
|
||||
if (num == 1 && g_otherParameter.excessiveLoadFlag == 1) {
|
||||
GPIO_WriteBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN, SET);
|
||||
}
|
||||
|
||||
/* 多次过载则关闭输出 */
|
||||
if (g_otherParameter.excessiveLoadFlag >= 2) {
|
||||
GPIO_WriteBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN, RESET);
|
||||
// GPIO_WriteBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN, RESET);
|
||||
num = 0;
|
||||
}
|
||||
|
||||
|
@ -459,7 +460,7 @@ STR_TimeSliceOffset g_dataJudgment;
|
|||
void Task_dataJudgment(void)
|
||||
{
|
||||
/* 判断有无电池 */
|
||||
if (g_otherParameter.batteryState == 0 && (g_otherParameter.Charg_BatteryCurrent > 0.1 || g_otherParameter.Charg_BatteryCurrent < -0.1)
|
||||
if (g_otherParameter.batteryState == 0 && (g_otherParameter.Charg_BatteryCurrent > 1 || g_otherParameter.Charg_BatteryCurrent < -1)
|
||||
&& g_otherParameter.Output_Voltage < 14.2) {
|
||||
g_otherParameter.batteryState = 1;
|
||||
}
|
||||
|
@ -473,8 +474,8 @@ void Task_dataJudgment(void)
|
|||
}
|
||||
|
||||
if (g_otherParameter.overTemperature != 0
|
||||
&& g_otherParameter.HighSideMos_Temperature < g_controlParameter.HighSideMosTemperature_start + 3) {
|
||||
if (g_otherParameter.overTemperature == 2) {
|
||||
&& g_otherParameter.HighSideMos_Temperature < g_controlParameter.HighSideMosTemperature_start) {
|
||||
if (g_otherParameter.overTemperature == 3) {
|
||||
TimeSliceOffset_Register(&m_softStart, Task_softStart, softStart_reloadVal, softStart_offset);
|
||||
}
|
||||
g_otherParameter.overTemperature = 0;
|
||||
|
@ -483,15 +484,31 @@ void Task_dataJudgment(void)
|
|||
|
||||
if (g_otherParameter.overTemperature == 0
|
||||
&& g_otherParameter.HighSideMos_Temperature < g_controlParameter.HighSideMosTemperature_stop
|
||||
&& g_otherParameter.HighSideMos_Temperature > g_controlParameter.HighSideMosTemperature_end + 3) {
|
||||
g_controlParameter.dutyRatio -= 0.15;
|
||||
&& g_otherParameter.HighSideMos_Temperature > g_controlParameter.HighSideMosTemperature_end) {
|
||||
g_controlParameter.dutyRatio -= 0.05;
|
||||
Set_duty_ratio(&g_controlParameter.dutyRatio);
|
||||
g_otherParameter.overTemperature = 1;
|
||||
}
|
||||
|
||||
if (g_otherParameter.overTemperature != 2
|
||||
&& g_otherParameter.HighSideMos_Temperature > g_controlParameter.HighSideMosTemperature_stop + 3) {
|
||||
if (g_otherParameter.overTemperature == 1
|
||||
&& g_otherParameter.HighSideMos_Temperature < g_controlParameter.HighSideMosTemperature_stop
|
||||
&& g_otherParameter.HighSideMos_Temperature > g_controlParameter.HighSideMosTemperature_end + 5) {
|
||||
g_controlParameter.dutyRatio -= 0.05;
|
||||
Set_duty_ratio(&g_controlParameter.dutyRatio);
|
||||
g_otherParameter.overTemperature = 2;
|
||||
}
|
||||
|
||||
if (g_otherParameter.overTemperature == 2
|
||||
&& g_otherParameter.HighSideMos_Temperature < g_controlParameter.HighSideMosTemperature_stop
|
||||
&& g_otherParameter.HighSideMos_Temperature > g_controlParameter.HighSideMosTemperature_end + 10) {
|
||||
g_controlParameter.dutyRatio -= 0.05;
|
||||
Set_duty_ratio(&g_controlParameter.dutyRatio);
|
||||
g_otherParameter.overTemperature = 3;
|
||||
}
|
||||
|
||||
if (g_otherParameter.overTemperature != 3
|
||||
&& g_otherParameter.HighSideMos_Temperature > g_controlParameter.HighSideMosTemperature_stop) {
|
||||
g_otherParameter.overTemperature = 3;
|
||||
TIM_Cmd(TIM3, DISABLE);
|
||||
TIM_SetCompare4(TIM4, 0);
|
||||
g_controlParameter.dutyRatio = 0;
|
||||
|
@ -677,17 +694,18 @@ void Task_collectOpenCircuitVoltage(void)
|
|||
g_otherParameter.collectOpenCircuitVoltageNUM++;
|
||||
if (g_otherParameter.collectOpenCircuitVoltageNUM == g_controlParameter.collectOpenCircuitVoltageTime) {
|
||||
if (g_otherParameter.batteryState) {
|
||||
g_collectOpenCircuitVoltageFlag = 1;
|
||||
TIM_Cmd(TIM3, DISABLE);
|
||||
Delay_Ms(1);
|
||||
TIM_SetCompare4(TIM4, 0);
|
||||
g_controlParameter.dutyRatio = 0;
|
||||
g_collectOpenCircuitVoltageFlag = 1;
|
||||
g_collectOpenCircuitVoltage.count = 500;
|
||||
}
|
||||
}
|
||||
|
||||
if (g_collectOpenCircuitVoltageFlag) {
|
||||
g_collectOpenCircuitVoltageFlag = 0;
|
||||
// printf("1\n");
|
||||
g_otherParameter.Solar_Open_Circuit_Voltage = get_PV1_VOLT_IN();
|
||||
TimeSliceOffset_Register(&m_softStart, Task_softStart, softStart_reloadVal, softStart_offset);
|
||||
}
|
||||
|
|
|
@ -183,14 +183,21 @@ void EXTI15_10_IRQHandler(void)
|
|||
// WORK_VOLT_INT_close();
|
||||
// TimeSliceOffset_Register(&g_overloadDelay, Task_overloadDelay
|
||||
// , overloadDelay_reloadVal, overloadDelay_offset);
|
||||
Delay_Us(10);
|
||||
// Delay_Us(10);
|
||||
// Delay_Ms(1);
|
||||
// WORK_VOLT_INT_open();
|
||||
GPIO_WriteBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN, RESET);
|
||||
EXTI_ClearITPendingBit(EXTI_Line12); //Çå³ýÖжϱê־λ
|
||||
if (0 == g_otherParameter.excessiveLoadFlag) {
|
||||
TimeSliceOffset_Register(&g_excessiveLoad, Task_excessiveLoad
|
||||
, excessiveLoad_reloadVal, excessiveLoad_offset);
|
||||
}
|
||||
g_otherParameter.excessiveLoadFlag++;
|
||||
|
||||
/* 多次过载则关闭输出 */
|
||||
if (g_otherParameter.excessiveLoadFlag >= 2) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -112,8 +112,10 @@ void TIM2_IRQHandler(void)
|
|||
g_otherParameter.Charg_Current = get_CHG_CURR();
|
||||
g_otherParameter.Discharg_Current = get_DSG_CURR();
|
||||
|
||||
totalChargCapacity += g_otherParameter.Charg_Current * g_otherParameter.Output_Voltage;
|
||||
totalElectricityConsumption += g_otherParameter.Discharg_Current * g_otherParameter.Output_Voltage;
|
||||
// totalChargCapacity += g_otherParameter.Charg_Current * g_otherParameter.Output_Voltage;
|
||||
// totalElectricityConsumption += g_otherParameter.Discharg_Current * g_otherParameter.Output_Voltage;
|
||||
totalChargCapacity += g_otherParameter.Charg_Current;
|
||||
totalElectricityConsumption += g_otherParameter.Discharg_Current;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
25097
obj/mppt_Nos_V0.4.lst
25097
obj/mppt_Nos_V0.4.lst
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue