# DIY solar panel battery charger diversion regulator

I picked up a used solar panel and want to build a charge controller for it.
The plan:
I want to run the batteries at 14.8 for 3 hours then drop down to 13.2.
Until the voltage gets to 14.8 no loads turn on.
Once it goes over 14.8 the smallest load goes, it waits something like 5 seconds checks the voltage again.
If it’s still over 14.8 the next load is connected.

Maybe one relay on each digital pin and the load can increase by 1 amp each step
It’s possible the first digital pin could be 1 amp, the next is 2, 3rd load is 4, largest load is 8 amps. Using the ++ to increase the value of these 4 digits if the voltage is high and – to decrease the value as the voltage decreases.

My solar panel provides about 10 amps, runs up to 19 volts open circuit.
I’ve done some searching on here and found a buck regulator style charge controller, but no diversion regulators, which seem easier to build and more useful.

Many diversion regulators use a dump load and waste this energy.
I’d like to use it for an air compressor, water pump, fans etc. Let it do something useful.

It would be great if we could just add another panel or wind charger,… or battery and have it work just as well.

I am thinking of using this power supply to convert the panel voltage to something the arduino can use: http://www.adafruit.com/product/1385

There are quite a few boards with 4 relays (or more for battery vent fan etc.)
So that hardware is readily available. Is there a preferred relay shield?

For the voltage divider that is used to read a portion of the battery voltage;
I copied this from another post (and adjusted it):

The Analog i/p works best if the source impedance is < 10K.
(I think source impedance means center tap or analog input to ground.)

If you used 10K, 20V needs to be reduced to 5v. You need 15V dropped across a resistor in series with 10K.
This would give 30K. So you use a 40K POT and adjust it so the wiper is 10K to GND.
20V/40K= 500uA or .0005 Amps drain form 20Volt battery.
This represents very little current to the massive lead acid batteries and not a significant heat loss in the POT.

I’m not good at programming but have been practicing/trying.
Here’s something for everyone to laugh at but I’m sure that together we can come up with a better way.

``````/*
Diversion regulators help charge and protect batteries by reading the voltage of a solar panel
and keeping it at or below the limit by diverting the extra power to a load.
Input from analog pin 0 controls output on digital pins 13, 12 and 11.
The goal is to hold the battery at 14.8 for 3 hours, then drop it to 13.2 for the rest of the day.

The circuit:
* A voltage divider provides a percentage of the total voltage.
* one resistor to ground
* the other resistor to source voltage
* Both resistors are connected together and this center tap is connected to the analog pin0
* 4 different loads are used to hold the voltage near the required voltage
*/

int lowPin = 13;      // dump a small load to maintain desired level
int midPin = 12;       // dump a bigger load
int highPin = 11;      // dump a large load, might not be used
int sensorPin = A0;    // select the input pin for the voltage divider
int sensorValue = 0;
int battLevel = 14.8;    //voltage goal, this variable will 14.8 or 13.2
int time = 0;
int timeout = 300;      //

void setup() {
// declare the digital pins as OUTPUTs:
pinMode(lowPin, OUTPUT);
pinMode(midPin, OUTPUT);
pinMode(highPin, OUTPUT);
time = 0;
}

void loop () {
if (sensorValue < 12.8) {        // if the sun has gone down long enough for the batteries to drop below 12.8 volts
battLevel = 14.8;              // the goal becomes 14.8
}
if (sensorValue > battLevel) {   // if the battery level goes above 14.8
time = 0;                      // it should try to hold it there for 3 hours
if (time > timeout) {
battLevel = 13.2;                // timed out on the 14.8 start the float charge
}
}
if (sensorValue > battLevel) {   // appropriate loads get applied to keep it at 14.8 or 13.2
delay (50);
time++;
if (sensorValue < battLevel) {
delay (50);                    //
time++;
}
}
}
}
``````

It’s not near complete but I doubt this will be the proper route,… someone will come up with something better using switch case, STATE or something but it gives an idea of the direction and shows I putt forth some effort not just dumping it on the forum.

I’ll start putting the voltage divider together and get an input value.
And purchase the suggested relay board.

14.8v is over charging the battery and can reduce its life.

A normal “12v” lead acid battery is fully charged at 14.2v.

“Source impedance” is the impedance of the source literally. It is the “resistance” of the feed circuit.

You will also need to be aware the voltage varies considerably over a short time so you will need to give your system hysteresis.

As soon as you connect the dump load, the voltage will drop so you will need to run the load for a time then remove the dump and check the voltage again. Make sure your load can stand constant switching.

Weedpharma

Thanks for the tips. True, I might not want 14.8 volts. Different batteries require different charging voltages. Each person would have to set their own trip levels.

So is my description of source (edit) impedance the same as yours? A center tap on the voltage divider?

I'm aware the load will lower the voltage, that's the plan. Most diversion regulators operate the way you describe; turn on for a short while, then turn off and check voltage. I don't like it. I want to keep the load connected and check the voltage level. For example turning on a small computer fan won't drop it enough but should allow for the small voltage adjustment needed to hold the voltage at the right level..

You said source "impedance" now you say "voltage". Which is it?

Weedpharma

This would give 30K. So you use a 40K POT and adjust it so the wiper is 10K to GND.
20V/40K= 500uA or .0005 Amps drain form 20Volt battery.

I would use fixed resistors as they are much more robust. The essential thing is not to exceed 5v and damage the Arduino. If it is not giving exactly 5v you can make adjustments in software.

My open lead-acid batteries are charged at 14.9v from a diesel generator - but I want to get the max energy for the least amount of diesel. I just use my solar panels to reduce my diesel consumption.

If the sun is affected by clouds there will be huge short-term (almost instantaneous) variations in solar panel output. I’m not sure how your diversion system will deal with that.

I think you need to explain what the overall purpose of the project is.

…R

Doh, yeah I meant impedance. I corrected it, thanks. "You will also need to be aware the voltage varies considerably over a short time so you will need to give your system hysteresis." By hysteresis you mean take out the peaks and make it a steady voltage that isn't jumping all over?

That's something I have been tossing around in my head, glad you mentioned it. I agree with using the resistors, they don't change if bumped, a POT can be more difficult to get a precise resistance and I probably have the resistors on hand. That POT idea was from the text I copied from another post. Since the panel won't go over 19 volts even when disconnected I thought 20 volt max would be safe. Should I calculate for 25 volts to give a little more safety margin?

As I see it, if the clouds come in or someone walks in front of the panel the voltage will drop and all loads will disconnect. Whenever the voltage drops below battLevel the charge controller isn't needed. At the beginning of the day and until the voltage gets above 14.8 (for example) no loads will be connected.

The solar panel will overcharge the battery bank without a charge controller. I'm hoping we can come up with a simple easy to build programmable charge controller that will keep the voltage below or at a desired level for a set time. At the same time use the extra energy to run something useful like air circulating fans, water pump or an air compressor and use these devices in parallel with the battery while it's charging to keep it at the right voltage.

I see they have a 4 relay Seed board at the local Radio Shack. I'm going to take a closer look at how it works with the Arduino.

Any suggestions on the programming? Am I going in the right direction with it or should I use a different method like switch case, STATE, a dowhile or ifelse?

graphing: if the clouds come in or someone walks in front of the panel the voltage will drop and all loads will disconnect.

With clouds the solar output can go up and down in seconds and you probably don't want to switch your loads on and off that often. It is not an easy problem to deal with. You could put a diode between the battery and the solar panel and loads if you don't want the battery to feed the loads. You could adjust the solar voltage to offset the diode drop - if the higher voltage is not a problem for the other loads.

I know the idea of "wasting" the solar energy seems wrong. But it would be worth while calculating its monetary value. You may find it is not worth all the trouble.

Also you are wasting energy by taking the output from the solar panels at 14.8v rather than 19v. 10A at 19v is 190W but 10A and 14.8v is only 148W. The idea behind MPPT controllers is to capture that difference by outputting 190/14.8 = 12.8 amps (less efficiency losses). However I remain sceptical about whether they pay for themselves. Last time I did some research none of solar panel retailers in the UK had data to demonstrate the economics of the MPPT controllers they were selling. They could easily collect that data over a few months. I think there is a good reason why they didn't do it.

And I do realize that those solar panels would overcharge your battery if left unregulated.

How many solar panels have you? I have three that each provide a max of about 4 amps (80w at 20v).

...R

MPPT chargers can give from 20% to 30% more than a conventional PWM type charger, but as to whether they are cost effective largely depends on how much they cost, and unfortunately most of the commercially available types do seem to be extremely expensive for whats inside them. If however, you are going to build some kind of charge controller and its going to use an Arduino or have some kind of Micro in it, its pretty easy to make a MPPT charger which will do all you want. I built a PIC 16F88 based MPPT charger some 7 years ago which does bulk charge, trickle charge, equalization charge with a 2 line LCD display for around \$35 in parts. Theres not much needed parts wise. There was an Arduino based MPPT charger by Tim Nolan which some people built, and I had a look at the design and it looked pretty good.

mauried: MPPT chargers can give from 20% to 30% more than a conventional PWM type charger, but as to whether they are cost effective largely depends on how much they cost, and unfortunately most of the commercially available types do seem to be extremely expensive for whats inside them.

Thanks for the link. I will have a look at it. I gave up trying a non-Arduino DIY MPPT controller a few years ago because the escaping smoke got too expensive.

I remain to be convinced that you can get the 20% to 30% benefit in practice in the UK if the solar panels are only charging a battery system that must supply power today even if there was little sun yesterday. Of course if there is another economically valuable outlet for the solar power the economics would be different.

...R

You most likley cant in the UK. There are simply too many variables involved to make a simplistic claim that covers all scenerios. The most important factor is the Solar Panels V/I curve and what the Solar panel voltage is at its maximum power point relative to the batteries voltage. The bigger the differance the better the MPPT charger will work, which usually means low latitudes and summer time. The panels I am using have a OC voltage of 21 V and a maximum power point at 16 V @ 6 amps. If someone invented a solar panel with a Maximum power point voltage of 14.4 V, then you would never need any type of MPPT. If you are going to build a charger like Tim Nolans, then I would suggest a hi current schottky diode in series with the battery. His circuit has one weakness and thats what happens if the PWM signal from the Arduino stops for any reason with the bottom FET turned on. You have a couple of microseconds to disconnect the battery before the FET is destroyed.

graphing: Doh, yeah I meant impedance. I corrected it, thanks. "You will also need to be aware the voltage varies considerably over a short time so you will need to give your system hysteresis." By hysteresis you mean take out the peaks and make it a steady voltage that isn't jumping all over?

Hysteresis is when you have a range of values so that it is not on/off/on........ All the time.

EG, if you let the regulator turn on the load at > 14v, when the load connects and draws current, the voltage will drop below 14v so will be disconnected, the voltage will rise and load will connect, the voltage will drop......

The program needs to be designed so that it takes into account the drop. You connect at 14v but disconnect at say 13.5v. This depends on the load and the capacity of the system. In full sun the load connects, drops to say 13.7v and all is ok. When the sun drops, the voltage falls to 13.4v and load is disconnected.

The other option is to simply leave the load connected for a fixed time, disconnect and measure etc.

This would be better for running a pump than having it on and off over short periods.

Weedpharma

Robin2: With clouds the solar output can go up and down in seconds and you probably don't want to switch your loads on and off that often. It is not an easy problem to deal with. You could put a diode between the battery and the solar panel and loads if you don't want the battery to feed the loads. You could adjust the solar voltage to offset the diode drop - if the higher voltage is not a problem for the other loads.

I know the idea of "wasting" the solar energy seems wrong. But it would be worth while calculating its monetary value. You may find it is not worth all the trouble.

Also you are wasting energy by taking the output from the solar panels at 14.8v rather than 19v. 10A at 19v is 190W but 10A and 14.8v is only 148W. The idea behind MPPT controllers is to capture that difference by outputting 190/14.8 = 12.8 amps (less efficiency losses). However I remain sceptical about whether they pay for themselves. Last time I did some research none of solar panel retailers in the UK had data to demonstrate the economics of the MPPT controllers they were selling. They could easily collect that data over a few months. I think there is a good reason why they didn't do it.

And I do realize that those solar panels would overcharge your battery if left unregulated.

How many solar panels have you? I have three that each provide a max of about 4 amps (80w at 20v).

...R

The kyocera 120 panel that I bought (for under a buck a watt) has diodes already installed so the battery doesn't drain through the panel when dark. I don't want a diode between the battery and load at least at this point I don't see the benefit. The panel could never put out 10 amps at 19 volts. That's open circuit, no load. As soon as the load is applied the voltage drops. I have 2 panels. One old used Carrizo gold. From the Corrizo power plant. Puts out about 2 amps. At this point I'm not worried about the relays turning on and off. I mean I don't want them clicking all the time but clouds shouldn't cause constant clicking.

Also thinking of possibly using the panel without a battery. Set the panel by the chicken coup and when the sun comes up, the fans turn for ventilation, water gets lifted for garden irrigation, etc. Or for camping, fans, cooler, water lifted for showers etc,

Weedpharma
Back to the impedance question.

I posted: “The Analog i/p works best if the source impedance is < 10K.
(I think source impedance means center tap or analog input to ground.)”

“Source impedance” is the impedance of the source literally. It is the “resistance” of the feed circuit."

Did I get it wrong when I said the the 10K resistor goes from center tap to ground when building a voltage divider for the analog input?

Also should I calculate for 25 volts max instead of 20,… since the panel can max out at 19 volts open circuit?

A voltage divider has the input applied to the top end of two series connected R's. The bottom end goes to gnd.

The "divided" voltage is taken from the centre of the two R's.

If you have 20 volts connected to the top, and the two R's are 10k each you will will measure 1/2 of the 20v input. This is too much for the Arduino.

If you had a divider consisting of 8.2k and 2.7k you you would have a ratio of

2.7 / 8.2 + 2.7 = close enough to quarter of the applied voltage of 20v, IE, 5v.

In your system, this would be ok. (The 2.7k is on the low end attached to gnd)

Put your panel in full noon sun and measure the open circuit voltage. If it goes above 20 volts, drop the lower R to 2.2k.

Weedpharma

Before my first post I did some searching about the voltage divider requirements for an analog input.
I posted this in the first post:

I copied this from another post (and adjusted it):

The Analog i/p works best if the source impedance is < 10K.
(I think source impedance means center tap or analog input to ground.)

If you used 10K, 20V needs to be reduced to 5v. You need 15V dropped across a resistor in series with 10K.
This would give 30K. So you use a 40K POT and adjust it so the wiper is 10K to GND.
20V/40K= 500uA or .0005 Amps drain form 20Volt battery.
This represents very little current to the massive lead acid batteries and not a significant heat loss in the POT.

Here’s the actual post unedited:
The Analog i/p works best if the source impedance is < 10K.
If you used 10K, 50V needs to be reduced to 5v. You need 45V dropped across a resistor in series with 10K.
This would give 90K. So you use a 100K POT and adjust it so the wiper is 10K to GND.
50V/100K= 500uA or .0005 Amps drain form 50Volt battery.
This represents very little current to the massive lead acid batteries and not a significant heat lose in the POT.
Do you think this would be acceptable?

The bold part is what I’m curious about.
You said, ““Source impedance” is the impedance of the source literally. It is the “resistance” of the feed circuit.”.
Is that the same as what I said, “(I think source impedance means center tap or analog input to ground.)”
Is that the place the 10k resistor goes?
The lower resistance you use in the voltage divider, the more current flows through it right?
So try to keep the resistors high but not so high it messes things up right?

My panel doesn’t go over 19 volts in full sun with snow on the ground and is listed as 19 volts open circuit. So I’ll keep the calculations at 20 volts max.

Oh, I got a relay board:
http://www.seeedstudio.com/wiki/Relay_Shield_V2.0
Supported Radio Shack in their hard times it was only about \$16 and no shipping.
Next I should buy a power supply that can run the arduino off the varying solar panel voltage.

The comment re source impedance refers to the way the analogue read circuit works. The arduino "samples" the voltage in a capacitor that takes a finite time to charge. If you have a high resistance (source impedance) circuit feeding the capacitor, it will not charge in the time the sample is read.

The solar panel is very low resistance (source impedance), IE, can charge the capacitor very quickly.

The R values given by me are only going to draw a few milliamperes. It also uses preferred value resistors that are readily available.

"Is that the same as what I said, "(I think source impedance means center tap or analog input to ground.)" Is that the place the 10k resistor goes?"

It is nothing to do with centre tap or input to gnd.

Connect the output of the panel to the top of the voltage divider I described earlier and connect the analogue input to the centre of the two resistors. Connect the panel gnd to Arduino gnd.

Weedpharma

Great, thanks. That’s what I thought he meant.

I played around with the sketch:
Not sure it’s the best way to do it but it’s the first program I’ve written by myself and it compiles.

``````/*
Diversion regulators help charge and protect batteries by reading the voltage of a solar panel
and keeping it at or below the limit by diverting the extra power to a load.
Input from analog pin 0 controls output on digital pins 13, 12 and 11.
The goal is to hold the battery at 14.8 for 3 hours, then drop it to 13.2 for the rest of the day.

The circuit:
* A voltage divider provides a percentage of the total voltage.
* one resistor to ground
* the other resistor to source voltage
* Both resistors are connected together and this center tap is connected to the analog pin0
* 4 different loads are used to hold the voltage near the required voltage
*/
int timeStart = 0;
int sensorPin = A0;      // select the input pin for the voltage divider
int sensorValue = 0;
int lowFloat = 675;      // estimated for 13.2 volts
int battRest = 654;      // estimated 12.8 battery voltage at night/rest
int battLevel = 0;       // voltage goal, this variable will hold 14.8 or 13.2
int time = 0;
int timeout = 300;       // needs adjusting, 3hr timer for 14.8 volts
0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0};
// 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70. 0xF0}; because relay 1 is hooked to pin 7, relay 4 to pin 4, low number/high load
// B00000000, B1000000, B01000000, B11000000, B00100000, B10100000, B01100000, B11100000, B00010000, B10010000, B0101000, B11010000, B00110000, B10110000, B01110000, B11110000};
void setup()
{
DDRD = B11110000;      // set PORTD (digital 4-7) to outputs
int load = 0;          //variable for the array
}

void loop () {
if (sensorValue < battRest) {      // if the sun has gone down long enough for the batteries to drop below 12.8 volts
battLevel = highBatt;           // the goal becomes 14.8
timeStart = 0;                  // timer doesn't start yet
}
if (sensorValue > highBatt) {    // if the battery level goes above 14.8
timeStart = 1;                  // the 14.8 volt 3hr timer starts
}
if (timeStart > 0) {             // If it has already passed 14.8 the timer starts
time++;                         // increment each time through the loop
}
if (time > timeout) {
battLevel = lowFloat;            // timed out on the 14.8, start the float charge
timeStart = 0;
}
delay(1000);
}

if (sensorValue > battLevel) {    // appropriate loads get applied to keep it at 14.8 or 13.2
delay (50);
}
if (sensorValue < battLevel) {
delay (50);                     //
}
}
``````

Any idea what 9 volt power supply I should use to power the arduino from the variable voltage of the solar panel/battery? It looks like the one I listed is out of stock.
I do have a 9 volt, 3-legged regulator but I want to use a switching power supply or buck regulator because I hear they use less power…

I found a couple resistors (salvaged from a board) for the voltage divider a 9.9k and a 42k. That will give a little extra headroom for the voltage. In case somehow it goes over 20.

I might use a 9 volt wall wart for the test.
And a 10 amp battery charger if the sun doesn’t come out.

Hi,

Can you please post a circuit diagram please, CAD or jpg, png, or pdf picture of a hand drawn copy will be okay.

Tom..... :)

I'll try to get that done. Shouldn't be much to it. 4 relays on the output and a voltage divider on the input. Trying to keep the circuit simple so anyone can build it. I ordered some adjustable buck regulators to power the arduino. What's a good program for drawing circuits?

Hi,