How to Make Universal Battery Charger

6,640

96

40

Posted

Introduction: How to Make Universal Battery Charger

In this Instructable I would like to share with you my most recent project, an AVR-based universal battery charger. What does it mean universal battery charger? Well, it can charge batteries. And it can charge all four basic types of rechargeable batteries - that is, NiCd, NiMH (usually in AA or AAA form), lithium cells (usually in the form of 18650 cells) and lead-based batteries (those 12V blocks). On each battery type, you can set multiple charging parameters.

Can it do more? Of course it can. Except for charging, it can also discharge your battery to measure its real capacity or to reduce memory effect on Ni-based cells. It also comes with voltage or current limited power supply and temperature probe.

It is Arduino-compatible, even though it is not written in Arduino language. Also, you can build it in blocks - there is charging block, discharging block, control block (display and buttons) and auxiliary block (fan and temperature probe). Those blocks work independently, so you can build your device only with block of your choice.

The build is not complicated and requires nothing special (you can get everything at radioshack or ebay). It will cost you about 10 - 15 USD, it depends on how cheap you get the parts. Build time depends on your skill, you must know how to work with soldering iron and schematics. However, this is not a project for beginners, so I will not describe every step here. I am posting the schematics and firmware, so you should be able to work with that.

You can also watch this video to see it in action:

Step 1: Control & Power

Power

The whole thing is powered from 12 - 20 V power source, I recommend either a desktop computer PSU or better an old laptop power brick. The maximal charging current is 3 A and charging voltage depends on the input voltage. Maximal discharging power depends on your heatsink, if you use a fan and a medium-sized heatsink you can achieve max discharging power of more than 20 W.

Accuracy

The biggest challenge in the whole build. For charging lithium batteries, you need to achieve more than 3% accuracy. So, a few rules:

  1. Use 1% or less tolerance resistors! (keep away from those 5% ones)
  2. Make all switching lines from thick copper cable and make them as short as possible.
  3. Put the opamp far from all switching parts.
  4. Respect analog ground, digital ground and power ground! (see the schematic)

The brain

The brain of the whole project is an ATmega 328P - the same as in your Arduino. Clocked at 20 MHz, it provides all the necessary controls. You can get this MCU for less than 2 USD from Ebay.

Controls

For user to control the device, a display and 5 buttons are used. The display is Nokia 5110s 96x48 monochromatic display, again from Ebay (2 USD). Five buttons (left, right, up, down, OK) are used to move in the menus. Also, three LEDs are used - one for power and two MCU-controllable (one is used as "charging" and the second one as "end-of-charge").

Step 2: Charging Part

The "hardest" part to build is this one. It consists of a PWM-controlled buck converter which steps down the input voltage. The output voltage and current are measured and evaluated by the MCU and eventually the duty cycle of the PWM is adjusted. The code contains algorithms for NiMH, NiCd, Li-Ion/Pol and SLA batteries.

Note: yes, I know that this is not the best and/or accurate method for regulating V/C. But it is accurate enough and is much simpler to build then the other options. Trust me, I have been using this charger for a few moths now and I never had a problem with it overcharging (or anyhow damaging) the battery.

Li-Ion/SLA charging

Lithium and lead batteries are charged with the same algorithm - the charger starts in constant current mode, waits for the voltage to rise and then switches to constant voltage. You can set the current and voltage limit. This algorithm has overvoltage and overtemperature protection. Also, the user can abrupt the charging at any given time. See the pictures for an example of lithium battery charge.

Ni-Cd/Ni-MH charging

Nickel-based batteries are charged in constant current mode for a given period of time or until one if the abruption methods kicks in. You can set the charging current, charging time and number of cells in series. This algorithm has overvoltage, overtemperature, -dV/dt and time-out protection.

Power supply

The charger can also serve as a simple constant voltage/constant current source. However, note that because of the slow MCU, the power supply has long transient response time. So use only loads which do not mind that.

Step 3: Discharging Part

A simple discharging part is also integrated in the project. It consists of a N-channel MOSFET and current sensing resistor. PWM from the MCU is converted to true analog voltage using a low pass filter and then fed into the gate of the MOSFET, which in turn serves as a variable resistor. The MCU regulates PWM duty cycle based on the measurement from current sense resistor. You MUST mount the discharging MOSFET onto a heatsink, because it is dissipating all of its energy into heat! IF you don not have a big enough heatsink, you must include a fan.

When you choose "discharge" from the main menu, you can set the discharging current and the minimal voltage ("undervoltage protection"). The software automatically measures battery capacity in mAh and mWh.

Step 4: Conclusion

Source

You can download the source code from my GitHub.

Please let me know if you like this project. I am thinking about building V2 with integrated battery balancer, so if there will be enough people interested, I will post the schematic for it. Also, if you have any questions or comments, feel free to post them!

Share

Recommendations

  • Epilog Challenge 9

    Epilog Challenge 9
  • First Time Author Contest 2018

    First Time Author Contest 2018
  • Sew Warm Contest 2018

    Sew Warm Contest 2018
user

We have a be nice policy.
Please be positive and constructive.

Tips

Questions

33 Comments

source code Open with what program ?

UPDATE: I am currently working on version 2 of this thing, with cell balancing, better UI and lots of other stuff. Also it will be in a form of an Arduino shield. V2 should be out in October, so insted of building this, I recommend waiting for V2.

Curious about this statement: "I know that this is not the best and/or accurate method for regulating V/C." - the way you have done it seems to be pretty standard for all the reference designs I have seen?

Hi,

yes, it indeed is, but most reference designs do not have a display and controls, they regulate based on some predefined values. In those applications you need the processor to react to a sudden change in the output ASAP, which is hard, when it is busy drawing the display or checking controls and doing a lot of other stuff. So yes, the method itself is okay. And the processor is still fast enough, I just wanted to point out that this is fine for battery charging, where the load changes slowly, but not for a lab bench power supply or something similar.

Hello,

Could you write the Fuse bits of AVR?

Hello,

Nice project.

Could you write the fuse bits?

srajmund0968@gmail.com

Welcome.

Project AVR fuse bit?

Welcome.

Project AVR fuse bit?

Welcome.

I want to change a pinouts LCD from CE=PD0, RST=PD1, DC=PB3, DATA=PB4, CLK=PB5 to PD3, PD4, PD2, PD1, PD0.

When I change pins PB4 and PB5 to different, LCD does not show.

Why?

How to change the connection LCD?

What are the differences between the different grounds? I've been looking at the schematic for a while now, and they all seem to have the same characteristics, so why do you recommend separating into 3 planes?