Go Down

Topic: Arduino controlled battery charger (Read 2039 times) previous topic - next topic

rogerClark

Sep 02, 2014, 01:26 pm Last Edit: Sep 02, 2014, 01:45 pm by rogerClark Reason: 1
This isn't the most interesting Arduino based project in the world, but its useful to me ;-)

Here is the long story.

I have a Black and Decker cordless drill which is around 10 years old.

Some time ago, the charger packed up, and when I looked inside both the analog electronics control board and the transformer had completely failed.
I suspect something happened to the control board, which had overloaded the transformer and caused it to overheat and burn out.

Anyway.
Looking for solutions, I I finally settled on getting a replacement transformer from a local supplier (Jaycar.com.au) which was virtually the same physical size as the original transformer, but was 5VA more powerful and also had lots of output voltage taps (where as the original transformer just seemed to output 24V).

The control board however was also broken, so by solution was to remove most of the analogue components from the control board, and just leave the main rectifier diodes, one of which I had to replace because it was blown.

Then build a constant current charger from a LM315 and a resistor, and control the charging using an Arduino Pro Mini connected to a relay, to connect the constant current system to the battery.

I also built a resistor divider so that the Arduino could measure the voltage on the battery as top of charge voltage is around 22V.

Finally I coded up the control logic with a number of states.

READY (waiting for battery to be inserted)

ANALYSE BATTERY (measures voltage on the battery after the insertion has been detected by the ADC)

ALREADY CHARGED (if voltage on the battery is above 19.5V, I assume its already fully charged, as its an 18V battery, so  anything above 18V usually indicates is just been removed from the charger and re-inserted)

CHARGE (turn on the relay and charge the battery using the constant current - analog circuit at around 750mA)

CHARGED (The code detects 2 different things to determine if the battery is charged. (a) is the voltage above 22.2V (b) has the voltage on the battery dropped since 1 minute ago - even though its being charged at 750mA, - this condition occurs when the battery reaches saturation - but I can't recall the technical / chemistry details)

TIMEOUT - if the battery has been charged for more than 2.5 Hours, at 750mA, it should be charged, so if the voltage is still not above 22.2V etc, there must be some problem, so stop it charging.

Initially, I just controlled the 2 existing LEDS (green and red), using  by the Arduino, to indicate what the charger was doing.

However this week I fitted a Nokia 5110 LCD to the top of the charger in a housing I designed and printed in3D (PLA plastic).
This is a big improvement as I can see exactly what the charger is doing,

I will post the code in a day or two, and I guess I should also draw up a schematic
But, at the moment the code is a bit messy, and could do with the formatting / tabbing being tidied up and unused variables removed.
And I don't have a schematic, as I designed each section, eg the constant current section, individually, so there wasn't a need to draw a schematic

As I can only post 4 photos per posting, I've had to do multiple followup posts.

rogerClark

More photos !

rogerClark

#2
Sep 02, 2014, 01:31 pm Last Edit: Sep 02, 2014, 01:47 pm by rogerClark Reason: 1
Yet more photos

Battery finally being charged, and photos of the underside of the charger showing the mains transformer, the control board (in its original location,but stripped of most of its original components, and just used as a handy place to attach the Arduino and the relay etc

rogerClark


Photo of the relay ;-)

alangarcia


RPCoyle

PRETTY COOL... looking forward to the code you used. I am thinking of doing similar to this but with a solar charger

rogerClark

@RPCoyle

No worries

I'll try to get around to posting the code soon.

Note. The charge rate is controlled by a modified version of the existing charger circuitry. The Arduino simply monitors the battery voltage (closely), and determines when the battery has finished charging, or indeed needs to be charged at all.

In the longer term, I'd like to replace the existing analogue charging circuit with a PWM based system using a FET and a current sensor, ut as I need the charger so that my cordless drill actually works, getting the basics working was more of a priority ;-)

very nice  :0 but where's the arduino board ? and where is the code ?

rogerClark

The Arduino board is shown in

This image, which I've already posted.
http://forum.arduino.cc/index.php?action=dlattach;topic=264532.0;attach=94801

Its an Arduino Pro mini, so is very small

Re: Code.

Be patient, I have a day job I need to do, in order to pay the bills and buy Arduino's ;-)

rogerClark

OK. Here is the code.

I've cleaned it up a bit, but its still a bit messy.
I've noticed while cleaning it, that I could move some of the code that displays stuff on the LCD, as its not in the most logical order.
But it doesn't affect the operation

In terms of the external circuitry.

The voltage of the battery connected to Analog A0, via a resistor divider network, so that the maximum voltage that can be read is approximately 40V

The resistor divider I used is 4.7k and 33k , however I had to manually calibrate the readings of battery voltage using my digital multimeter, so that the conversion factor ended up being 0.037153406 rather than the calculated value which should be 0.039166389


The relay that connects the constant current charger circuit to the battery is controlled by pin 9
The charger had two existing LED's (A red and a green LED), so I wired these to the Arduino to indicate whether the battery was being charged, and whether it had finished charging, and whether the the charger had finished because it had reached peak voltage or had detected a fall in voltage while charging (known as slope detection)
However these LED's have been superseded by the LCD display. But I still left them connected and didn't change the code.

If anyone notices and mistakes etc, please let me know



Workshopshed

Great project Roger. I went for a simple LM200 circuit (mostly because that's what I had to hand) when I built a battery charger the other year.

http://www.workshopshed.com/2013/05/battery-charger-6v-sealed-leadacid.html

rogerClark

Hi Workshopshed

My charger evolved a bit over time.

Initially I was hoping to not use a current regulator at all, but just use PWM into a big FET and monitor the current though a 20A hall effect current sensor, but I needed to get the charger working ASAP as I actually needed it to charge batteries for my drill ;-)

So the compromise was to use a LM317 as a constant current regulator and just use the Arduino to monitor the battery voltage and control the charging. - which I had in my box of components.

Anyway... It works. which is the main thing, and I may get around to updating it in the future and use PWM after all.

AlxDroidDev

Very nice and I am very interested in your project.
I also own a B&D 12V cordless drill (model CG1200), and mine has the original "el cheapo" charger, that gives no status indication. Since it is made of a NiCd cells, charging it from the wrong state, too little or too much can easily damage the battery pack.  I am in my 2nd battery pack, and the packs are quite expensive.
If you're interest, I'd like to contribute to further develop this project.
Learn to live: Live to learn.
Showing off my work: http://arduino.cc/forum/index.php/topic,126197.0.html

Go Up