Nerd Ralph loves cheap and dirty hacks, and for that we applaud him. His latest endeavor is a LiFePO4 battery charger that he made out of parts he had on hand for under $0.50 US. (Although we think he really made it for the fun of making it.)
The circuit is centered around a TL431 programmable shunt regulator, which is an awesome and underrated chip in its own right. If you don’t know the TL431 (aka LM431), you owe it to yourself to fetch the datasheet and pick up a couple with your next electronics part order. In fact, it’s such a great chip, we can’t resist telling you about it for a minute.
Despite its misleading electrical symbol, think of the TL431 as being a voltage-activated switching transistor. When the voltage on the reference pin is lower than 2.5V, the transistor doesn’t conduct. When the voltage on the reference pin is higher than 2.5V, the transistor acts as a closed switch, sinking around 100 mA of current to ground.
If you tie the reference pin to the cathode, the TL431 does behave like a zener diode that has a breakdown voltage of 2.5 V, but that’s selling it short. The TL431 is a full-fledged IC with a precision voltage level reference, a comparator, and the active transistor all bundled up inside. The ability to put different voltages on the reference pin and the cathode make it interesting.
In the simplest circuit, you could drive an LED with a TL431. Connect an LED and a current-limiting resistor up to the cathode and ground the anode of the TL431. Then, when the voltage on the reference is higher than 2.5V, the LED will light up brightly. 2.5V isn’t interesting to you? You can add a voltage divider to increase the threshold to any value above 2.5 V that you’d like. Shown here is an LED that only lights up when the input is 5V or greater. You can use this idea anywhere you need a voltage activated switch, for instance as a battery’s low-voltage monitor.
Battery Chargers and Feedback
The TL431 is fine as a switch, but it thrives on feedback. To make a voltage regulator from the LED circuit shown here, all you need to do is add a transistor in place of the LED; have the TL431 turn the transistor on when the voltage drops below a target voltage and off when the voltage rises above. Indeed, this cheap and cheerful voltage regulator application is where almost all of the TL431s end up — providing voltage regulation in switching power supplies. You’ve probably got a few in your computer’s power supply right now, as a matter of fact.
So let’s go back to Nerd Ralph and his battery charger. Ralph’s simple battery charger is essentially this simple voltage regulator circuit. He chose the voltage-setting resistors
R2 to give him 2.5 V on the TL431 when the output sees 3.6 V, the voltage which a LiFePO4 battery is basically done charging.
To see the TL431 in action here, first imagine that it’s not conducting (off). Current flows from the power supply through
RB1 and into the transistor, turning it on. The voltage at
Vout increases, the battery charges, and the voltage in the middle of the voltage divider increases proportionately. When it reaches the 2.5 V threshold, the TL431 turns on and draws current, robbing the transistor of its base current and lighting the LED at the same time.
Because LiFePO4 batteries like to be charged with constant current nearly up to the end of their range, Ralph picked the transistor’s base resistor
RB1 to limit the maximum current delivered to the batteries. He tested the output current into a half-charged battery to verify that he was in the right ballpark.
Now we’re not entirely sold on this being a constant current charger circuit. The basic circuit is a voltage regulator, after all. Relying on the transistor’s current gain to be constant over temperature or across different transistors is a bit sketchy — for instance the Art of Electronics warns you explicitly about the variability of the current gain value. But the LiFePO4 cells look like they’re pretty robust compared to their other lithium battery cousins, and the voltage profile only really varies from 3.4 V at 10% charge to 3.6V at 90% charge. Constant enough.
It’s also missing a bunch of things we like to have in other LiPO chargers, like battery temperature sensing and disconnect at charge completion. But again, the LiFePO4 cells are robust enough to overcharge that he’ll probably get away with it if he doesn’t leave the batteries in the charger for very long. It’s a hack, after all.
Kudos and Comments
So first, we’d like to thank Ralph for reminding us of a very useful part for minimalist electronics. The TL431’s datasheet is full of cool applications, and the combined functions of a voltage reference and comparator-driven transistor in a couple-cent piece of silicon make that work. If you need a voltage-triggered switch anywhere in your project, you now know where to look.
Ken Shirriff has written a very nice dissection of the TL431 that includes die images. And for a truly esoteric use of the TL431, here’s a crystal radio design that abuses the TL431 as an audio amplifier.
What do you think of Ralph’s charger design? Do you have any favorite tricks for the TL431? What piece of silicon would you rate as an unknown gem in the rough? Let us know in the comments and send in a tip for parts you’d like to see featured in the future.