Feed on
Posts
Comments

Since I’m starting to use more LiFePO4 14500 batteries I thought it would be a good idea to build a simple USB charger for them instead of having to charge 2 at a time on the xxx battery charger. The most simplest way would be to stick it on a CV/CC power supply or another way is to stick it on a CV power supply set to 3.6V with say a 1 ohm resistor and wait for it to reach 3.6V, not the quickest to charge but it works.

My first design was to use a voltage reference such as a TL1431M (or a resistor & zener diode) set to 3.3V with a decent op-amp like the MCP6242 with hysteresis threshold set to 3.2V – 3.6V and an PNP transistor to switch the 5V through say a 10-20 ohm resistor to the battery. This would only charge the battery if it was under 3.2V, stop at 3.6V and won’t start charging again until the battery dropped back to 3.2V which it shouldn’t.

It works one problem arises when you unplug the USB side and leave the battery in, it would start discharging a few mA due to being connected to the op-amps output but it’s not like that would really ever happen. But let’s put in an MCU, say an ATtiny13A to sort it out. I have plans to make a device in the future run off the LiFePO4 battery and recharge itself when the USB cable is connected if it matches the threshold voltages as before.

The ATtiny13 is powered off the LiFePO4 battery, worst case it would only draw 5-6uA when it’s powered down with the watchdog timer enabled. We have an N-mosfet to turn on the PNP transistor and is only done when the battery voltage matches our range and if the USB is connected. For that we have a 8.2K/10K resistor divider as our sense for the 5V USB but we also have a diode to prevent any leakage from the PNP making it’s way back to the 5V which would make the ATtiny think that USB was plugged in when it wasn’t. We also measure the battery voltage as well.

We’ll have to implement some sort of battery management. After playing around a little bit, I’m keeping track of if the battery is charged (3.6V or above) and if it was charged, we should only start re-charging when it drops below 3.2V. For detecting if the USB is plugged in, we just use the a pin interrupt when the ATtiny is sleeping which it does every 4 seconds. Download ATtiny13_LiFePO4_Charger

Tested, it’s a bit slow to charge due to the 10-20 ohm resistor but it all seems to be working fine. You could add in an op-amp, mosfet and a few resistors to have some constant current control instead of relying on the resistor to drop the voltage.

Leave a Reply