Pulse Width Modulation (PWM) vs Maximum Power Point Tracking (MPPT) Solar Charge Controller Simulator Educational Kit. LY2024J09301. © 2024 Universiti Teknologi Malaysia – All Rights Reserved.
Drawback with Conventional Solar Educational Kit
- Requires sunlight. Unable to be used indoor or raining condition.
- Commonly use PWM since MPPT is expensive due to the additional power converter inside the charge controller. The cost and complexity become higher if both method is included.
- If use MPPT, the algorithm cannot be observed since it’s too fast (<1s).
- Change in battery cannot be observe since the PV and load used for education kit is small.
- Difficult to observe the battery full and depleted condition.
- Need multiple sensors and displays to observe all the important parameters of the system (commonly 6 sensors and 10 displays). These make the cost high.
- Safety issues since the battery can short-circuit and cause fire.
- The kit is heavy and takes a large space.
The solution is to create an Arduino Simulator of the Solar Charge Controller. Advantages of PWM vs MPPT Solar Charge Controller Educational Kit:
- No need for sunlight.
- Can operate in either PWM or MPPT.
- The MPPT is set to operate slower, good for education (around 20s).
- Change in battery is observable as the battery is set to a very small capacity.
- Easy to observe the battery full and depleted condition since battery changes quickly.
- No need for sensor as it is inside a simulation model. All the parameters are displayed in 1 display. These make the cost low and easy to observe.
- No safety issues at this is only simulator.
- The kit is light and small in size.
The PV, load, and charge controller is model inside the Arduino, which is the important component of this product. The irradiance (sunlight intensity) and the load are controlled using the potentiometers. The data from the potentiometers is then process by the model to produce the energy flows at the PV, battery, and load. The State of Charge (SOC) of the battery is also counted. There are 2 operating options for charge controller, which are the PWM and MPPT modes. The result of the simulation is then displayed at LCD 2004 with I2C module. The parameters displayed include the voltage, current, and power of the PV, load, and battery, as well as the SOC of the battery. 1 switch is added to control the operating mode (PWM or MPPT).
The code for the project is provided here:
// Cereated by Razman Ayop on 24 August 2024 to 8 September 2024
// The objective is to help students under Academic Service Learning (ASL) to visualize how PWM & MPPT charge controller works
// The project also is made to test the complexity of the project to ensure it is acceptable for Final Year Project (FYP) or not.
include
include
// 0. Parameters
// 0.1. Battery
float SOC; // State of Charge (SOC)
float Vbat_nom=24; // Nominal Battery Voltage, V
float SOCnom=0.5; // Nominal SOC
float SOCini=0.5; // Initial SOC
float SOCmin=0.2; // Minimum SOC
float SOCmax=0.95; // Maximum SOC
float SOCrc=0.5; // Reconnect SOC
float m_Vbat=8; // Vbat Gradient, V/SOC
float Cbat=40000; // Battery Capacity, W/s
float Vbat; // Battery Voltage, V
float Ibat; // Battery Current. +Charge, -Discharge.
float Pbat; // Battery Power,W
float Ebat; // Battery Energy, Ws
float Ebat_sto0=SOCini*Cbat; // Previous Battery Energy Storage, Ws
float Ebat_sto; // Battery Energy Storage, Ws
// 0.2. PV Model
float Voc_stc=50; // STC Open Circuit Voltage, V
float Vmp_stc=40; // STC Maximum Power Voltage, V
float Isc_stc=11; // STC Short Circuit Current, A
float Imp_stc=10; // STC Maximum Power Current, A
float Ns=1; // Number of Series PV Module
float Np=1; // Number of Parallel PV Module
float Voc; // Open Circuit Voltage, V
float Vmp; // Maximum Power Voltage, V
float Isc; // Short Circuit Current, A
float Imp; // Maximum Power Current, A
float G=1000; // Irradiance, W/m^2
float Gmax=1000; // Maximum Irradiance, W/m^2
float Vpv; // PV Voltage, V
float Ipv; // PV Current, A
float Ppv; // PV Power, W
float Epv; // PV Energy, Ws
float Vpv0=Vbat_nom; // Set PV voltage same as battery voltage
float Ipv0=1; // PV Current
// 0.3. Load Parameters
float Vload=0; // Load Voltage, V
float Iload=0; // Load Current, A
float Ploadmax=700; // Ploadmax, W
float Pload; // Load Power, W
float Eload; // Load Energy, Ws
// 0.4. Other Parameter
float Vstep=0.5; // P&O MPPT Voltage Step, V
float tsam=1; // Sample Time, s
float Sload=0; // Load Switch, 0=On, 1=Off
float Spv=0; // PV Switch, 0=On, 1=Off
int MODE=1; // Operating Mode. 0=PWM, 1=MPPT
float dPV; // Change of Power-Voltage
float Vref=Vbat_nom; // Reference Voltage
float T=12345; // Test Parameter
// 0.5. Input
int pinG=A0; // G ADC Pin
float valG=1000; // G Value
int pinLoad=A1; // Load ADC Pin
float valLoad; // Load Value
int pinMod=2; // Mode Digital In Pin
// 0.6. Output
LiquidCrystal_I2C lcd(0x27, 20, 4); // set the LCD address to 0x27 (SDA A4, SCL A5) for a 20 chars and 4 line display
void setup() {
// Initiate Serial Monitor
Serial.begin(9600);
Serial.print(“\n\nInitiate Charge Controller\n”);
// Set Digital Input
pinMode(pinMod,INPUT);
// Set LCD
lcd.init(); // initialize the lcd
lcd.backlight(); // Turn on the LCD screen backlight
}
void loop() {
// 1. Component Models
// 1.1. PV Array Model
delay(500);
valG=analogRead(pinG);
G=valG/1023Gmax; Voc=NsVoc_stc;
Vmp=NsVmp_stc; Isc=G/1000NpIsc_stc; Imp=G/1000Np*Imp_stc;
// 1.2. Battery Model
SOC=Ebat_sto0/Cbat;
Vbat=m_VbatSOC+(Vbat_nom-m_VbatSOCnom);
// 1.3. Load
valLoad=analogRead(pinLoad);
Pload=valLoad/1023*Ploadmax;
if (Sload==1 && SOC<SOCrc){
Vload=0;
Iload=0;
Pload=0;
}
else {
Vload=Vbat;
Iload=Pload/Vload;
Sload=0;
}
// 2.0. PWM vs MPPT
MODE=digitalRead(pinMod);
if (MODE==LOW){
// 2.1. PWM Mode
Vpv=Vbat;
if (Vpv<=Vmp){
Ipv=(Imp-Isc)/VmpVpv+Isc; } else { Ipv=Imp/(Vmp-Voc)Vpv+(Imp-ImpVmp/(Vmp-Voc)); } Ppv=VpvIpv;
Vpv0=Vpv;
Ipv0=Ipv;
Vref=Vpv;
}
else {
// 2.2. MPPT Mode
Vpv=Vref;
if (Vpv<=Vmp){ Ipv=(Imp-Isc)/VmpVpv+Isc; } else { Ipv=Imp/(Vmp-Voc)Vpv+(Imp-ImpVmp/(Vmp-Voc)); } Ppv=VpvIpv; dPV=(Ppv-Vpv0Ipv0)(Vpv-Vpv0); if (dPV>=0) {
Vref=Vpv+Vstep;
}
else {
Vref=Vpv-Vstep;
}
Vpv0=Vpv;
Ipv0=Ipv;
}
// 3.0. Energy Management System (EMS)
Epv=Ppvtsam; Eload=Ploadtsam;
Spv=0;
Ebat=Epv-Eload; // +Charge, -Discharge
Ebat_sto=Ebat_sto0+Ebat;
SOC=Ebat_sto/Cbat;
if (Ebat>0){
// 3.1. Excess Energy
if (SOC>=SOCmax){
// 3.1.1. Battery Full
SOC=SOCmax;
Ebat=-Eload;
Ebat_sto=Ebat_sto0+Ebat;
Vpv=Voc;
Ipv=0;
Ppv=0;
Spv=1;
}
}
else {
// 3.2. Less Energy
if (SOC<=SOCmin){
// 3.2.1. Battery Depleted
SOC=SOCmin;
Ebat=Epv;
Ebat_sto=Ebat_sto0+Ebat;
Vload=0;
Iload=0;
Pload=0;
Sload=1;
}
}
Ebat_sto0=Ebat_sto;
Pbat=Ebat/tsam;
Ibat=Pbat/Vbat;
// 4.0. Serial Print
Serial.print(“Vpv = “);
Serial.print(Vpv);
Serial.print(“, Ipv = “);
Serial.print(Ipv);
Serial.print(“, Ppv = “);
Serial.print(Ppv);
Serial.print(“… Vbat = “);
Serial.print(Vbat);
Serial.print(“, Ibat = “);
Serial.print(Ibat);
Serial.print(“, Pbat = “);
Serial.print(Pbat);
Serial.print(“, SOC = “);
Serial.print(SOC);
Serial.print(“… Vload = “);
Serial.print(Vload);
Serial.print(“, Iload = “);
Serial.print(Iload);
Serial.print(“, Pload = “);
Serial.print(Pload);
Serial.print(“. TEST = “);
Serial.print(valLoad);
Serial.print(“. \n”);
// 5.0. LCD Display
lcd.clear();
//PV
lcd.setCursor(0, 0);
lcd.print(“PV: “);
lcd.setCursor(4, 0);
lcd.print(Vpv);
lcd.setCursor(8, 0);
lcd.print(“V “);
lcd.setCursor(10, 0);
lcd.print(Ipv);
lcd.setCursor(14, 0);
lcd.print(“A “);
lcd.setCursor(16, 0);
lcd.print(Ppv);
lcd.setCursor(19, 0);
lcd.print(“W “);
//Load
lcd.setCursor(0, 1);
lcd.print(“LD:”);
lcd.setCursor(4, 1);
lcd.print(Vload);
lcd.setCursor(8, 1);
lcd.print(“V “);
lcd.setCursor(10, 1);
lcd.print(Iload);
lcd.setCursor(14, 1);
lcd.print(“A “);
lcd.setCursor(16, 1);
lcd.print(Pload);
lcd.setCursor(19, 1);
lcd.print(“W “);
//BAT
lcd.setCursor(0, 2);
lcd.print(“BA:”);
lcd.setCursor(4, 2);
lcd.print(Vbat);
lcd.setCursor(8, 2);
lcd.print(“V “);
lcd.setCursor(10, 2);
lcd.print(Ibat);
lcd.setCursor(16, 2);
lcd.print(“A “);
lcd.setCursor(4, 3);
lcd.print(SOC*100);
lcd.setCursor(8, 3);
lcd.print(“% “);
lcd.setCursor(10, 3);
lcd.print(Pbat);
lcd.setCursor(16, 3);
lcd.print(“W “);
}
This research was supported by Ministry of Higher Education (MOHE) through Fundamental Research Grant Scheme (FRGS/1/2021/TK0/UTM/02/19). The authors would like to express gratitude to Universiti Teknologi Malaysia (UTM) for providing comprehensive facilities. Lastly, thanks to colleagues who have either directly or indirectly contributed to the completion of this work.