From 858d911e063f6d113734815f3b16cab3fe2dc129 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=85=95=E7=82=8E?= <29385962@qq.com> Date: Thu, 11 Aug 2022 02:48:19 +0000 Subject: [PATCH] =?UTF-8?q?update=20ARDUINO=5FMPPT=5FFIRMWARE=5FV2.1/4=5FC?= =?UTF-8?q?harging=5FAlgorithm.ino.=20=E6=9B=B4=E6=94=B9=E7=AE=97=E6=B3=95?= =?UTF-8?q?=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../4_Charging_Algorithm.ino | 54 ++++++++++++------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/ARDUINO_MPPT_FIRMWARE_V2.1/4_Charging_Algorithm.ino b/ARDUINO_MPPT_FIRMWARE_V2.1/4_Charging_Algorithm.ino index 5e8cdcd..b3636d1 100644 --- a/ARDUINO_MPPT_FIRMWARE_V2.1/4_Charging_Algorithm.ino +++ b/ARDUINO_MPPT_FIRMWARE_V2.1/4_Charging_Algorithm.ino @@ -11,7 +11,7 @@ void buck_Disable(){ } void predictivePWM(){ //预测PWM 算法 if(voltageInput<=0){PPWM=0;} ///当电压输入为零时防止不确定答案 - else if(voltageOutput>voltageBatteryMax){PPWM =(PPWM_margin*pwmMax*voltageBatteryMax)/(100.00*voltageInput)*0.98;} //计算预测 PWM Floor 并存储在变量中 + else if(voltageOutput>voltageBatteryMax){PPWM =(PPWM_margin*pwmMax*voltageBatteryMax)/(100.00*voltageInput)*0.98;} //输出电压过大则以电池最大电压为计算基准,防止错误重启充电 20220707 else{PPWM =(PPWM_margin*pwmMax*voltageOutput)/(100.00*voltageInput);} //计算预测 PWM Floor 并存储在变量中 PPWM = constrain(PPWM,0,pwmMaxLimited); } @@ -32,40 +32,56 @@ void Charging_Algorithm(){ if(REC==1){ // IUV RECOVERY - (仅对充电模式有效) REC=0; //重置 IUV 恢复布尔标识符 buck_Disable(); //在 PPWM 初始化之前禁用降压 - lcd.setCursor(0,0);lcd.print("POWER SOURCE "); //显示液晶信息 - lcd.setCursor(0,1);lcd.print("DETECTED "); //显示液晶信息 + //lcd.setCursor(0,0);lcd.print("POWER SOURCE "); //显示液晶信息 + //lcd.setCursor(0,1);lcd.print("DETECTED "); //显示液晶信息 + //tft.fillScreen(TFT_BLACK); + tft.drawString("POWER SOURCE DETECTED", 10, 40, 3); Serial.println("> Solar Panel Detected"); //显示串口信息 Serial.print("> Computing For Predictive PWM "); //显示串口信息 for(int i = 0; i<40; i++){Serial.print(".");delay(30);} //For loop "loading... 效果 Serial.println(""); //在串行上显示下一行的换行符 Read_Sensors(); predictivePWM(); - PWM = PPWM; - lcd.clear(); - } + PWM = PPWM; + //lcd.clear(); + } else{ //NO ERROR PRESENT - 继续电源转换 /////////////////////// CC-CV BUCK PSU ALGORITHM ////////////////////////////// + /* + PSU和cc-cv模式的充电算法问题,充电电流设定值,如果设定值大于输入源额定值,会导致pwm不断增加拉低输入电压直至达到小于电池电压,重启 + 如果设定较小值,则无法发挥最大功率 + */ if(MPPT_Mode==0){ // CC-CV PSU 模式 - if(currentOutput>currentCharging) {PWM--;} //电流高于 → 降低占空比 + if(PSUcurrentMax>=currentCharging || PSUcurrentMax==0.0000 || currentOutput<0.02){PSUcurrentMax = currentCharging;} //初始化psu输入最大电流 + + if(currentOutput>currentCharging) {PWM--;} //电流高于限定值 → 降低占空比 + //psu模式和psu充电模式还是要区别一下,充电模式为了充电可以榨干输入源,psu模式则并不一定需要,所以暂时关闭此判断 20220811 + //if(currentOutput>PSUcurrentMax) {PWM--;} //电流高于外部最大值 → 降低占空比 else if(voltageOutput>voltageBatteryMax){PWM--;} //电压高于 → 降低占空比 + else if(voltageInputcurrentCharging){PWM--;} //电流高于 → 降低占空比 - else if(voltageOutput>voltageBatteryMax){PWM--;} //电压高于 → 降低占空比 - else{ //MPPT 算法 - if(powerInput>powerInputPrev && voltageInput>voltageInputPrev) {PWM--;} // ↑P ↑V ; →MPP //D-- - else if(powerInput>powerInputPrev && voltageInputvoltageInputPrev){PWM++;} // ↓P ↑V ; MPP→ //D++ - else if(powerInputvoltageBatteryMax) {PWM--;} // MP MV ; 达到 MPP - else if(voltageOutputcurrentCharging){PWM--;} //电流高于 → 降低占空比 + else if(voltageOutput>voltageBatteryMax){PWM--;} //电压高于 → 降低占空比 + else{ //MPPT 算法 + if( voltageInput>=(voltageBatteryMax+voltageDropout+1) && voltageInput>=(voltageOutput+voltageDropout+1)){ //输入大于电池最大电压设定及当前电池电压的条件下进行pwm处理,否则抬高电压,阻止过分拉低电压 20220803 + if(powerInput>powerInputPrev && voltageInput>voltageInputPrev) {PWM--;} // ↑P ↑V ; →MPP //D-- 功率上升且电压上升,继续 抬高电压 + else if(powerInput>powerInputPrev && voltageInputvoltageInputPrev){PWM++;} // ↓P ↑V ; MPP→ //D++ 功率下降,电压上升,尝试 拉低电压 + else if(powerInputvoltageBatteryMax) {PWM--;} // MP MV ; 达到 MPP + else if(voltageOutput