With the charging circuit already designed for the LiFePO4 battery charger, I had to figure out a way to simulate a battery in order to simulate the circuit. A battery is really just a voltage source with some internal resistance, so for the purposes of my simulation I just placed a .02 Ohm resistor in series with a voltage source.
To be realistic, I had the voltage source roughly follow the charging voltage curve of a LiFePO4 cell. Just to be thorough, I also slightly varied the voltages of each of the four cells so that they were always slightly out of balance. This better reflects real world conditions since cells are never identical and the circuit needs to be able to properly balance cells.
For each of the four duplicate cell circuits, I measured the current through the battery cell (using R2, R3, R10, & R14), the current through the TL431 (using R4, R7, R11, & R15), the current through the PNP transistor (using Q1, Q2, Q3, & Q4), and the voltage across each cell.
The results show almost identical voltage curves for each of the four circuits. The charging voltage of the constant current circuit follows the voltage of cell, maintaining a consistent 1A of current through each of the cells. Once the desired 3.65V is reached for each of the cells, the current rapidly tapers off and maintains that voltage, continually trickling top-off current to each cell. The transistor is then turned on and routes the excess current around the battery, correctly balancing each cell.
Overall everything looks correct and is performing as expected, so next up is putting this all on a PCB. My next post will show the final schematic and board layout for the charger.
One thought on “OpenADR: Battery Charger Simulation”
Thanks for these posts, they are great inspiration! I am trying to build a 4S LiFePO4 charging circuit with power path myself, and your work looks exactly right. One concern though: When the transistor switches on, doesn’t that also create a short across the battery cell terminals? If so, that could cause the cell to discharge rapidly (hopefully the cells are protected so they’ll just go into protection mode). Is this intentional? And is it safe?
Your simulation seems to verify that this is happening; the current across the ‘battery resistors’ dips below 0A since the current is now coming from the cell rather than going into it – but the graphs cut off at -0.1A so we can’t see how much current they are driving.