Arduino - PV MPPT Solar Charger

31K9343

Intro: Arduino - PV MPPT Solar Charger

There are many charge controllers available in market. ordinary cheap charge controllers are not efficient to use maximum power from solar Panels. The ones which are efficient, are very costly.

So i decided to make my own charge controller which is Efficient, and smart enough to understand the battery needs and solar conditions. it takes appropriate actions to draw maximum available power from solar and put it inside the battery very efficiently.

IF YOU LIKE MY EFFORT THAN PLEASE VOTE THIS INSTRUCTABLES.

STEP 1: What Is MPPT and Why Do We Need It?

Our Solar panels are dumb and not smart to understand the battery conditions. Assume we have a 12v/100 watt solar panel and it'll give an output between 18V-21V depends upon manufactures, but batteries are rated for 12v nominal voltage, at full charge conditions they will be 13.6v and will be 11.0v at full discharge. now lets assume our batteries are at 13v charging, panels are giving 18v, 5.5A at 100% working efficiency(not possible to have 100% but lets assume). ordinary controllers have a PWM voltage regulator ckt which drops the voltage to 13.6, but no gain in current. it only provides protection against over charging and leakage current to panels during nights.

So we are having 13.6v*5.5A = 74.8 watt.

We loose approx 25 watt.

To encounter this issue i have used smps buck converter. these kind of convertes have above 90% efficiency.

Second problem that we have is non-linear output of solar panels. they needs to be operated at certain voltage to harvest maximum available power. Their output varies through the day.

To solve this issue MPPT algorithms are used. MPPT(Maximum Power Point Tracking) as the name suggests this algorithm tracks the maximum available power from panels and varies the output parameters to sustain the condition.

So by using MPPT our panels will be generating maximum available power and buck converter will be putting this charge efficiently into batteries.

STEP 2: HOW MPPT WORKS?

I,m not gonna discuss this in detail. so if you wanna understand it have a look to this link -What is MPPT?

In this project i have tracked the input V-I characteristics and output V-I also. by multiplying the input V-I and output V-I we can have the power in watts.

lets say we are having 17 V, 5 A i.e. 17x5 = 85 watt at any time of the day. at the same time our output is 13 V, 6A i.e 13x6 = 78 Watt.

Now MPPT will increase or decrease the output voltage to by comparing to previous input/output power.

if previous input power was high and output voltage was lower than present then output voltage will be lower down again to get back to the high power and if output voltage was high then present voltage will be increased to the previous level. thus it keeps oscillating around maximum power point. this oscillations are minimized by efficient MPPT algorithms.

STEP 3: Implementing MPPT on Arduino

This is the brain of this charger. Below is the Arduino code to regulate the output and implementing MPPT in a single code block.

// Iout = output current

// Vout = output voltage

// Vin = input voltage

// Pin = input power, Pin_previous = last input power

// Vout_last = last output voltage, Vout_sense = present output voltage

void regulate(float Iout, float Vin, float Vout) {<br>  if((Vout>Vout_max) || (Iout>Iout_max) || ((Pin>Pin_previous && Vout_sense<Vout_last) || (Pin<Pin_previous && Vout_sense>Vout_last))) 
{
    
if(duty_cycle>0) 
{
   
 duty_cycle -=1;
   
 }
   
 analogWrite(buck_pin,duty_cycle);
 
 }
  
else if ((Vout<Vout_max) && (Iout<Iout_max) && ( (Pin>Pin_previous && Vout_sense>Vout_last) || (Pin<Pin_previous && Vout_sense<Vout_last)))
{
if(duty_cycle<240) 
{<br>    duty_cycle+=1;
    
}
    
analogWrite(buck_pin,duty_cycle);
  
}
  
Pin_previous = Pin;
  
Vin_last = Vin;
Vout_last = Vout;
}

STEP 4: Buck Converter

I have used N-channel mosfet to make the buck converter. usually people choose P-channel mosfet for high side switching and if they choose N-channel mosfet for the same purpose than a driver IC will be required or boot strapping ckt.

but i modified the buck converter ckt to have a low side switching using N-channel mosfet. i,m using N-channel because these are low cost, high power ratings and lower power dissipation. this project uses IRFz44n logic level mosfet, so it can be directly drive by an arduino PWM pin.

for higher load current one should use a transistor to apply 10V at gate to get the mosfet into saturation completely and minimize the power dissipation, i have also did the same.

as you can see in ckt above i have placed the mosfet on -ve voltage, thus using +12v from panel as ground. this configuration allows me to use a N-channel mosfet for buck converter with minimum components.

but it also have some drawbacks. as you have both sides -ve voltage seperated, you don't have a common reference ground anymore. so measuring of voltages are very tricky.

i have connected the Arduino at Solar input terminals and using its -ve line as ground for arduino. we can easily measure the input volateg at this point by using a voltage divider ckt as per our requirement. but can't measure the output voltage so easily as we don't have a common ground.

Now to do this there is a trick. instead of measuring the voltage accros output capacitor, i have measured the voltage between two -ve lines. using solar -ve as ground for arduino and output -ve as the signal/voltage to be measured. value that you have got with this measurement should be substracted from the input voltage measured and you will get the real output voltage across output capacitor.

Vout_sense_temp=Vout_sense_temp*0.92+float(raw_vout)*volt_factor*0.08; //measure volatge across input gnd and output gnd.<br>
  Vout_sense=Vin_sense-Vout_sense_temp-diode_volt; //change voltage difference between two grounds to output voltage.. 

For current measurements i have used ACS-712 current sensing modules. They have been powered by arduino and connected to input gnd.

internal timers are modified to gain 62.5 Khz PWM at pin D6. which is used to drive the mosfet. a output blocking diode will be required to provide reverse leakage and reverse polarity protection use schottky diode of desired current rating for this purpose. Value of inductor depends upon frequency and output current requirements. you can use online available buck converter calculators or use 100uH 5A-10A load. never exceed the maximum output current of inductor by 80%-90%.

STEP 5: Final Touch Up -


you can also add additional features to your charger. like mine have LCD too display the parameters and 2 switches to take input from user.

I'll update the final code and complete ckt diagram very soon.

STEP 6: UPDATE:- Actual Circuit Diagram, BOM & Code

UPDATE:-

I have uploaded the code, bom and circuit. it,s slightly different from mine, because it,s easier to make this one.


36 Comments

In your article, you mentioned use N-Type mosfet, but in your bom components list and in schematic use P-Type Mosfet???? Which one true?
You can use anyone of them. I have used P-type in schematic and bom because it’s easier to use in this application. You won’t require a gate driver ic for it.
However N-type mosfets are much more efficient. But in this application it’ll be used in high side switching. Which requires a specific gate driver ic having bootstrap ckt inbuilt to drive the mosfet.
So just for simplicity and less bom cost i have used P-type. I hope it clarifies your doubt.
Hi Abhinav,
MPPT Solar Charger, Can you throw the circuit diagram of your project? or Can you give me photo of the connection parts of the circuit board? This circuit diagram doesn't belong to this project.
Thank you
would you please just explain your code and highlight the main components?
Hy, i've question
I'm make this buck-boost converter using all of ur component and code
But when i running it, the buck converter doesnt run.
Its down the voltage like 0.8 volt
What its wrong, can u help me?
Is the source code work with Arduino Mega? If it's work, is there any differences on the pin and source code that used between UNO and Mega? One more question, is it work for 100Wp solar panel? (assume that I have changed the Inductor and Capacitor value)
yes, it will work with mega. but you have to set maximum pwm frequency using arduino mega's registers.
you may use 100W panel without any issues. i,m using 200W with same components. good luck...
I've tried this but why the PWM won't generate? I've followed the schematic and use the code,but the duty cycle always 0.
Is is possible to make a bigger version that can handle upto say 3000W?
Yes it’s possible. But inductor size and values will be recalculated for that much of power. Also frequency also should be optimised.
I’ll try to make one in near future
which mosfet is used here? can i use p type mosfet 9540N?

I am getting error when trying to compile. Please help.

Arduino: 1.8.2 (Windows 10), Board: "Arduino/Genuino Uno"

C:\Users\980\Documents\Arduino\PV_MPPT_Solar_Charger\PV_MPPT_Solar_Charger.ino: In function 'void setup()':

PV_MPPT_Solar_Charger:64: error: expected primary-expression before '/' token

TCCR0B = TCCR0B & 0b11111000 | 0x01; / set pwm at Max... 62.5 Khz

^

PV_MPPT_Solar_Charger:64: error: 'set' was not declared in this scope

TCCR0B = TCCR0B & 0b11111000 | 0x01; / set pwm at Max... 62.5 Khz

^

PV_MPPT_Solar_Charger:88: error: 'Vout_sense_temp' was not declared in this scope

Vout_sense_temp=float(raw_vout)*volt_factor;

^

exit status 1

expected primary-expression before '/' token

This report would have more information with

"Show verbose output during compilation"

option enabled in File -> Preferences.

use // instead of / .

Hello, great project. Can you use a different solar painel? For example, 10w?

Hello, congrats for your design, and thank you very mush for sharing it !
It looks really interesting, at last to have a good working and efficient solar charger.
I don't know so much of battery and electricity, so I have a few questions about your device.
First I see few feedbacks,in spite of the deep relevance of the MPPT design. Do you have some new observation, did you fix the issue raised by Marbo ?
Does the charger work well for you ?
I'd like to use a charger for AGM or "deep discharge"-able battery, will it work properly with this kind of battery ?

Well firstly a correction 12V lead acid batteries are fully charged at 12.7V.

Secondly couldn't you put the code in an arduino text file ".ino" for easy download

current code is highly customized for personal use. i'll clean it up and upload.

and about batteries you are right but wrong also. A lead acid battery needs higher voltage i.e. 13.2 - 13.8 volts to charge properly. this voltage is considered as Float charging voltage. also if battery is deep discharged below 30% than a voltage of 14.2 - 14.8 volts is required to fast charge the battery, it,s known as Boost charging. this type of charging is required compulsory once in a month to remove sulfation from battery plates thus increases battery life.

now you are right because a full charge battery have 12.7 volts at resting condition. but it requires higher voltage to force the current into the battery.

More Comments