[TriEmbed] Designing a LiFePO4 battery charger

Charles West crwest at ncsu.edu
Sat Apr 11 12:48:21 CDT 2020


Hello!

I've put together a PCB to try to act as a charger for the 3 batteries
while monitoring voltage/current (with a microcontroller managing
everything).  It turns out that SamacSys is OK with people publishing their
footprints in open hardware projects (the footprints from Mouser's site),
so I can now publish my boards without worrying about legal trouble.

Please check it out if you get a chance and tell me what you think (I am
quite sure there is much for me to improve (particularly where the
footprint files are right now)).

Git repo for Kicad project:
https://gitlab.com/charlesrwest/batterycontrolcircuitdemonstration

Thanks,
Charlie

P.S.
I am going to post my motor control test board shortly as well.  Also, the
overview README for this project is below.

This KiCad board is intended to be used for battery charging and eventually
integrated into a large multifunctional PCB in the GoodBot Go robotics
platform.

Please email any questions to crwest at ncsu.edu

As of the writing of this document (11/4/20), this board has not been
tested (but the boards should arrive in 1-2 weeks).

Purpose:
Charge and monitor 3 series connected 4s Lithium Iron Phosphate batteries
from a 24 volt power supply while also supplying power to an outside board.

Features:
Fully customizable charging via USB programming a STM32F072RBT6
microcontroller (which can also be actively monitored and controlled via
exposed SPI port)
Voltage monitoring of each of the connected cells
Current monitoring of the charge being fed into each cell
Current monitoring of the current being sent out of the pack when not
charging

Details:
Computation/control is provided by the STM32F072RBT6 microcontroller.

The board is meant to operate in two modes: Charging mode and Discharging
mode.

Charging mode (Adaptor connected):

The most common charging method for different types of lithium batteries
appears to be CC/CV.  In this method, constant current is provided to a
discharged battery until its voltage reaches a certain value.  At that
point, the charger switches to constant voltage until the battery charge
reaches a different value.  Once the constant voltage charging is
completed, the battery is disconnected from the charger until its voltage
drops low enough that it is decided that it needs to be charged again.  To
allow this charging method to be used, current is provided from the adaptor
with high frequency PWM while both voltage and current are monitored for
each battery.

Each of the batteries is isolated from the others (and the pack output) by
disabling the first two NMOSFETS of NMosfets Q4 (bat 1->2), Q6 (bat 2->3),
Q8 (bat pack output).  These NMosfets are driven by IC8, IC9 and IC7
respectively while those are in turn controlled in turn by pins PB12, PB13
and PB14 on the microcontroller.  The last is left enabled to provide power
to the load while charging (which was a bad design decision which is
addressed in the to fix section).

The battery negative terminals are connected to ground via NMosfets (Bat1
-> connected, Bat2 -> Q5, Bat3 -> Q7).  These NMOSFETs are driven directly
from the microcontroller pins (though resistors are used) because they
offer reasonably low resistance at logic levels, are connected to ground
and don't need to switch fast.  Each NMOSFET gate is provided with a
draining resistor to bias them toward ground so they don't cause power loss
during startup.  During charging, these NMOSFETs are set active

The charging current to each battery is provided by a PWM modulated feed
from the 24V power supply, with the current and voltage supplied to each
battery monitored.

The PWM logic signals are provided by pins PA0 (Bat1), PA1 (Bat2), PA2
(Bat3) which drive NMosfet drivers IC1, IC2, IC3, which in turn drive
NMOSFETs Q1, Q2, Q3 to provide PWM power from the 24V adaptor.

The batteries' voltage is monitored with a voltage divider pair which feeds
the reduced voltages to the ADC sample points (Bat1 -> PC0, Bat2 -> PC2,
Bat3 -> PC4).

The batteries' charging current is monitored by the voltage across current
sense resistors (Bat1 -> R10, Bat2 -> R11, Bat3 -> R12) and amplified by
their respective current sense amplifiers (Bat1 -> IC4, Bat2 -> IC2, Bat3
-> IC3) before being sent to ADC sampling pins on the microcontroller (Bat1
-> PC1, Bat2 -> PC3, Bat3 -> PC5).

The PWM power signal is sent through a 4.7 uf capacitor to help smooth it
before the voltage is sampled.  The PWM signal could be set to hundreds of
kilohertz as needed to try to help smooth the charging voltage.

Discharging mode (Adaptor disconnected):
Each of the batteries is connected in series with the others and the pack
output by enabling NMosfets Q4 (bat 1->2), Q6 (bat 2->3), Q8 (bat pack
output).  These NMosfets are driven by IC8, IC9 and IC7 respectively while
those are in turn controlled in turn by pins PB12, PB13 and PB14 on the
microcontroller.  All other NMOSFETs are disabled.

The batteries' voltage is monitored with a voltage divider pair which feeds
the reduced voltages to the ADC sample points (Bat1 -> PC0, Bat2 -> PC2,
Bat3 -> PC4).  If the current drops suffiently, the serial NMOSFETs can be
disabled as well so that the only current draw is from the microcontroller
and NMOSFET drivers.


To Fix:
Upon reflection, I think that the +24V diode protected adaptor power
output, the +36V diode protected battery pack power output (which in
practice can go as high as +44V), the diode protected +12V output from the
first battery and the diode protected USB power output should all be
connected.  This would allow the highest voltage source to provided power
(with the battery pack voltage dropping rapidly onces Q4, Q6, and Q8 are
switched off) to the load and the linear regulator for the MCU without
messing with the CC/CV charging measurements.

Adaptor voltage should be monitored so that the microcontroller can know
whether the adaptor is connected easily.

On Mon, Mar 23, 2020 at 9:46 PM Charles West <crwest at ncsu.edu> wrote:

> @Shane Trent <shanedtrent at gmail.com>
>
> I was thinking of using 3 floating battery chargers (it's just 3
> batteries), but I'm finding it somewhat complicated by the fact that the
> batteries are wired in series.  I'm concerned that the 24V power supply
> will not be able to charge the last two cells because of their high
> voltage.  It only works if the chargers use the battery ground but the
> supply voltage is somehow raised to X higher than the output of the
> previous cell.  That's why I'm hoping to more or less break the serial
> connection before trying to charge them.  I'm a little leery of trying to
> charge multiple cells in parallel, even if they had charge balancing.
> Everything I've read seems to indicate that you should be very careful to
> pay individual attention to each cell (I'm somewhat nervous about the 4
> cell series charging, but it seems to be what they are designed for).
>
> @Pete
> Yes.  Each battery has its own charging circuit that connects to each of
> its terminals.  The FETs are meant to basically switch it from a serial
> battery setup to one where each battery is connected to ground on the -
> side and the charger on the positive side.
>
> I would love to have my robots last that long.  It seems pretty unlikely
> though.  The batteries would certainly give out before then, even given the
> more durable chemistry.  I'm mostly trying to limit what can go wrong to
> try to make it as reliable as is practical.
>
> @All
> I'm wondering if it might be better to add a dedicated microcontroller to
> the design and remove the specialized charger circuits.  A few tutorials
> I've read (such as this one: https://www.microfarad.de/li-charger/) seem
> to indicate that you can do the normal constant current/constant voltage
> algorithms charging batteries just with relatively unfiltered FET PWM
> (perhaps just a cap on the output).  If so, it would allow me to
> drastically reduce the cost of the charger/#number of different components
> and allow programmable change of the charging characteristics.  Does that
> sound practical to you guys or do you think that some sort of LC low pass
> filtering would be needed?
>
> Thanks,
> Charlie
>
>
> On Mon, Mar 23, 2020 at 11:12 AM Pete Soper <pete at soper.us> wrote:
>
>> Also, if you're thinking of lifetimes past ten years, at least look into
>> flash memory retention specs. If I read them right, to prevent the charge
>> going away will require rewriting much like DRAM, but with N year vs X
>> millisecind timing.
>> Pete
>>
>> -------- Original message --------
>> From: Shane Trent <shanedtrent at gmail.com>
>> Date: 3/23/20 10:49 AM (GMT-05:00)
>> To: Pete Soper <pete at soper.us>
>> Cc: Charles West <crwest at ncsu.edu>, TriEmbed Discussion <
>> triembed at triembed.org>
>> Subject: Re: [TriEmbed] Designing a LiFePO4 battery charger
>>
>> Charlie,
>>
>> What about using four, floating 14.6V chargers that are powered when AC
>> is available? You could leave the batteries in series and eliminate the
>> extra isolation FETs (or relays). And it would charge 4x faster than
>> charging them serially.
>>
>> About relays, If you use FETs with relays to eliminate current for open
>> and close events, the relays should last almost forever. The datasheet
>> below the DPDT relays used for NCD's 5A model (actually rated for 8A).
>> Looking at the "Electrical Endurance" chart, if you limit the open/close
>> current to less than 1 amp, you could expect 10^6 operations. That would
>> allow cycling the relays every 10 minutes for 19 years.
>> https://media.ncd.io/20181002093211/RT2_1014-735742.pdf
>>
>> You could also use a FET H-bridge for each battery to swap the batteries
>> out one at a time for charging. But as you pointed out, gate drivers would
>> be needed for 15 of the 16 FETs. I am starting to like the idea of the
>> faster charging of four floating chargers.
>>
>> Shane
>>
>>
>>
>>
>>
>> On Sun, Mar 22, 2020 at 9:57 PM Pete Soper <pete at soper.us> wrote:
>>
>>> So some other circuitry connects the individual batteries to the
>>> charger(s) some how?
>>>
>>> These relays are cycled what, a few times a day at most? I think
>>> depending on part selection they could last a very very long time if
>>> genuine parts from a vendor with a reputation to protect. Look for
>>> automotive ratings.
>>>
>>> I shouldn't have used the term "Rube Goldberg". That was with my
>>> application in mind, not yours. As Shane pointed out it could be straight
>>> forward.
>>>
>>> -Pete
>>>
>>> This <http://triembed.org/images/relays-schematic.pdf> is a Rube
>>> Goldberg circuit. :-)
>>> On 3/22/20 8:20 PM, Charles West wrote:
>>>
>>> @Pete
>>> I'm glad you guys are OK.  The crux of the issue is that I haven't seen
>>> any LiFEPO4 charger ICs that handle more than 7 cells in series.  Each of
>>> my three batteries have 4 cells in them, so I think I need to have one
>>> charger for each battery which charges the 4 cells of the battery in series.
>>>
>>> I only get 1-2 hrs of working time a day right now due to my daughter's
>>> pre-school shutting down, so it will be a little while before I get a
>>> functional schematic out.  However, I was tentatively thinking of using the
>>> following components:
>>> NMosfets (used for all):
>>> https://www.mouser.com/ProductDetail/ON-Semiconductor/NVMFS5C612NLAFT1G?qs=%2Fha2pyFadugLwIkhTqkZTKk6f9YgRBDTRk6R4I0d7T5BfE4p4JIMyYRpkPiujU25
>>> High side NMosfet driver (for NMosfets which are not connected to
>>> ground):
>>> https://www.mouser.com/ProductDetail/Analog-Devices-Linear-Technology/LTC7003EMSEPBF?qs=sGAEpiMZZMve4%2FbfQkoj%252BKKapMsNT2INsri6aFIMPoQ%3D
>>> Single battery charger (would use 3 of these with a 24V supply):
>>> https://www.mouser.com/ProductDetail/Texas-Instruments/BQ24630RGER?qs=sGAEpiMZZMsZtvfwwjgKgY9Zc%252BP5Y9S3
>>>
>>> Same schematic with auto-annotation:
>>>
>>> https://drive.google.com/file/d/19qjaiqOR5wqI34htY-u9LFqNepMjd0cY/view?usp=sharing
>>>
>>> Apologies if I wasn't clear.  I've annotated the schematic.  WIth the
>>> updated one M1, M3, M5 would be on and M2. M4 off during "normal"
>>> operation, resulting in ~36V from the 3 ~12v cells.  During charging, M1,
>>> M3, M5 would be off and M2, M4 would be on.  The idea is that M1, M3, M5
>>> control charge moving from the high side of a battery to the low side of
>>> the next one, so disabling them isolate the cells from each other.  The
>>> charger ICs seem to expect the low end of the batteries to be connected to
>>> ground, so M2, M4 being on makes that happen.
>>>
>>> Given that during series ("normal") operation, M1, M3, M5 have an
>>> approximately 0 voltage difference between source and drain (and M5
>>> requires a gate voltage relative to ground higher than the 24V the charger
>>> is getting), I think a gate driver with a charge pump is needed to drive
>>> the those 3 mosfets.  Does all of that make sense?
>>>
>>> Relays would be great in terms of functionality but I'm a little worried
>>> about reliability.  The hub motors I'm using are brushless & direct drive
>>> with a lower mechanical load than they were designed for, so they might
>>> last a fairly long time.  It would certainly simplify the design though.
>>>
>>> Thanks,
>>> Charlie
>>>
>>> On Sun, Mar 22, 2020 at 3:57 PM Shane Trent via TriEmbed <
>>> triembed at triembed.org> wrote:
>>>
>>>> Charlie,
>>>>
>>>> It doesn't surprise me that Pete beat me to the punch on mentioning
>>>> relays after you said "one battery at a time". I expect Pete and I share
>>>> similar ideas. My though was connect each battery to the COM terminals of a
>>>> DPDT relay and use the Normally Closed (NC) contacts to wire the batteries
>>>> in series. When AC power is available for charging, you can use the relay's
>>>> to pull one battery at a time out of the chain, check its voltage and
>>>> charge if needed.
>>>>
>>>> You would have the clack of mechanical relays but adding just two
>>>> MOSFETs should let you get the full expected mechanical life-cycle from the
>>>> relays. Include a strong N-type MOSFET at the bottom of your battery chain
>>>> and in the ground lead of your charger (keeping the charger isolated from
>>>> the circuit until that FET is enabled. These FETs allow you to ensure there
>>>> is no current flowing when you open or close the contacts of the relays.
>>>>
>>>> I expect the life-span of the relays will be more than sufficient to
>>>> outlive the motors/gear train on the project. And using relays would make
>>>> the functioning of the charging circuit easier to follow. Additionally, you
>>>> can buy a off-the-shelf relay board for prototyping (I have used NCD boards
>>>> on multiple projects). Let me know if you have any questions.
>>>>
>>>>
>>>> https://store.ncd.io/product/4-channel-dpdt-signal-relay-controller-4-gpio-with-i2c-interface/
>>>>
>>>>
>>>> Good luck with your project,
>>>> Shane
>>>>
>>>> On Sun, Mar 22, 2020 at 3:27 PM Pete Soper via TriEmbed <
>>>> triembed at triembed.org> wrote:
>>>>
>>>>> Hi Charlie! Jenny, Emily and I are well and happy.
>>>>>
>>>>> Your circuit made me chuckle, 'cause when I was thinking of your
>>>>> earlier posting I was going to share the scheme I intended to use for
>>>>> charging a capacitor with a string of microbial fuel cells by switching
>>>>> then between parallel and series connections. But that was at silly low
>>>>> currents were analog multiplexer chips would work. But the prototype was
>>>>> using relays. If you're interested I could dig up the schematic. Definitely
>>>>> the Rube Goldberg approach with relays, though, but your "one battery at a
>>>>> time" requirement would make it simpler. :-)
>>>>>
>>>>> Your schematic implies wanting to just charge one battery at a time,
>>>>> but I can't see your circuit working past an initial point. But I think
>>>>> it's in the right direction. (Nit: your schematic symbols are for some kind
>>>>> of very generic FET transistor and I'm sure you'd be using high current
>>>>> ones with body diodes, right? Bigger nit: if there were part numbers we
>>>>> could more easily reason about the wiring).
>>>>>
>>>>> So numbering the transistors from left to right as Q1-5, then with Q2
>>>>> and Q3 off but the others on, that's "normal mode", right? With Q1-3 off
>>>>> but Q4 and 5 on a lower voltage could charge the third battery. But I don't
>>>>> see how you go beyond there with this circuit.
>>>>>
>>>>> Or am I misunderstanding this? At a minimum you'd have to arrange for
>>>>> your single-battery charging voltage to reach the positive sides of the
>>>>> first two batteries, right? So maybe have Q6 and Q7 between the right side
>>>>> supply and the "positive side" of Q1 and Q3, using the Q3 and Q5 to
>>>>> disconnect paths as needed and then perhaps a  Q8 and Q9 to select between
>>>>> running the system to conduct the higher "all in series" battery voltage to
>>>>> the load and the lower, charger voltage to the one of three batteries. That
>>>>> is, a SPDT switch above the rightmost net going upwards in your schematic.
>>>>>
>>>>> Alternatively, figure out how laptop batteries are handled. They seem
>>>>> to be always one big series connection, but maybe the extra connection pins
>>>>> we see are for this same approach? I have no clue about that.
>>>>>
>>>>> -Pete
>>>>> On 3/22/20 1:09 PM, Charles West via TriEmbed wrote:
>>>>>
>>>>> Hey Carl!
>>>>>
>>>>> I'm glad to hear that you are doing well.  The 12v batteries have
>>>>> built in balancers/protection.  It's isolation for charger that I'm trying
>>>>> to figure out.  I think I have a potential solution (
>>>>> https://drive.google.com/file/d/1JxSStAuKn-OMZUCreYQjGUVy5fR2ADpU/view?usp=sharing)
>>>>> with the NMOSFETs between each battery needing a high side driver.  The
>>>>> idea is that when the batteries are operating normally, you turn on the
>>>>> between battery mosfets and disable the to ground mosfets, then inverse for
>>>>> charging.
>>>>>
>>>>> Does that make sense to you guys?
>>>>>
>>>>> Thanks,
>>>>> Charlie
>>>>>
>>>>> On Sat, Mar 21, 2020 at 4:42 PM Carl Nobile <carl.nobile at gmail.com>
>>>>> wrote:
>>>>>
>>>>>> Hey Charley,
>>>>>>
>>>>>> We're doing ok, I'm working from home 100% of the time now.
>>>>>>
>>>>>> This may not be the exact answer to your issue but it may help.
>>>>>> Banggood has a lot of LiIon battery protection boards. You may be able to
>>>>>> use one of these, it would make the actual charger a bit simpler.
>>>>>>
>>>>>> https://www.banggood.com/search/liion-battery-protection.html?from=nav
>>>>>>
>>>>>> ~Carl
>>>>>>
>>>>>>
>>>>>> On Sat, Mar 21, 2020 at 8:17 AM Charles West via TriEmbed <
>>>>>> triembed at triembed.org> wrote:
>>>>>>
>>>>>>> Hello all!
>>>>>>>
>>>>>>> I hope the virus hasn't affected you guys too badly.  My little
>>>>>>> family's been pretty much staying in our house for the last week and a half
>>>>>>> (since our daughter's preschool closed), but we are doing OK overall.
>>>>>>>
>>>>>>> The work on the sidewalk robot continues!  I'm in the middle of
>>>>>>> testing a brushless motor controller/MCU combination to drive the four hub
>>>>>>> motors that will be moving the Mk3 robot.  If all goes well, it will be
>>>>>>> built like a tank and strong enough that I could ride on it if I wanted to.
>>>>>>>
>>>>>>> The part I'm trying to figure out is battery charging/system
>>>>>>> protection.  The motors expect 36V, so I'm putting 3 4s LiFePO4 batteries
>>>>>>> in series to provide it.  What I'm not really sure about is how to
>>>>>>> integrate a charger.  Each of the batteries (batteries
>>>>>>> <https://www.amazon.com/gp/product/B07Q7FY8CC/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1>)
>>>>>>> is meant to substitute for a 12V lead-acid motorcycle? battery, with its
>>>>>>> own built in cell balancer.  I'm hoping to charge them with power from a
>>>>>>> 24V DC regulator, potentially with a simple 2 terminal charging dock.
>>>>>>>
>>>>>>> The issue I'm running into is that none of the charger ICs I'm
>>>>>>> looking at can handle 12 cells in series (and they would probably require
>>>>>>> 40V or so if they did).  I'm thinking that I should be able to have a
>>>>>>> seperate charger IC for each battery, but I'm not entirely clear on how you
>>>>>>> would charge them in parallel while having them connected in series.  I'm
>>>>>>> sure you can do it, because my other charger does it for Lithium polymer,
>>>>>>> but I'm not sure what the configuration would look like.
>>>>>>>
>>>>>>> If I may ask, do you have any ideas?
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Charlie
>>>>>>> _______________________________________________
>>>>>>> Triangle, NC Embedded Computing mailing list
>>>>>>>
>>>>>>> To post message: TriEmbed at triembed.org
>>>>>>> List info:
>>>>>>> http://mail.triembed.org/mailman/listinfo/triembed_triembed.org
>>>>>>> TriEmbed web site: http://TriEmbed.org
>>>>>>> To unsubscribe, click link and send a blank message: mailto:
>>>>>>> unsubscribe-TriEmbed at bitser.net?subject=unsubscribe
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> --
>>>>>>
>>>>>> -------------------------------------------------------------------------------
>>>>>> Carl J. Nobile (Software Engineer)
>>>>>> carl.nobile at gmail.com
>>>>>>
>>>>>> -------------------------------------------------------------------------------
>>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Triangle, NC Embedded Computing mailing list
>>>>>
>>>>> To post message: TriEmbed at triembed.org
>>>>> List info: http://mail.triembed.org/mailman/listinfo/triembed_triembed.org
>>>>> TriEmbed web site: http://TriEmbed.org
>>>>> To unsubscribe, click link and send a blank message: mailto:unsubscribe-TriEmbed at bitser.net?subject=unsubscribe <unsubscribe-TriEmbed at bitser.net?subject=unsubscribe>
>>>>>
>>>>> _______________________________________________
>>>>> Triangle, NC Embedded Computing mailing list
>>>>>
>>>>> To post message: TriEmbed at triembed.org
>>>>> List info:
>>>>> http://mail.triembed.org/mailman/listinfo/triembed_triembed.org
>>>>> TriEmbed web site: http://TriEmbed.org
>>>>> To unsubscribe, click link and send a blank message: mailto:
>>>>> unsubscribe-TriEmbed at bitser.net?subject=unsubscribe
>>>>>
>>>>>
>>>>
>>>> --
>>>> [image: photo]
>>>> *Shane D Trent*
>>>> Patent Agent
>>>>
>>>> 919-348-0061 | shanedtrent at gmail.com
>>>>
>>>> ShaneTrent.com | Skype: skype:shane.trent1
>>>> <#m_-9030084723900561827_m_7986295226178818095_m_9191686542577320692_m_5084229381385021503_m_1200211025825053041_m_929109980503807493_m_-7674261523543827778_SignatureSanitizer_SafeHtmlFilter_>
>>>> Raleigh, North Carolina
>>>> <http://www.linkedin.com/in/shanetrent> <http://twitter.com/sdtrent>
>>>>
>>>> Create your own WiseStamp email signature
>>>> <https://www.wisestamp.com/signature-in-email/?utm_source=promotion&utm_medium=signature&utm_campaign=create_your_own&srcid=5623268815667200>
>>>> _______________________________________________
>>>> Triangle, NC Embedded Computing mailing list
>>>>
>>>> To post message: TriEmbed at triembed.org
>>>> List info:
>>>> http://mail.triembed.org/mailman/listinfo/triembed_triembed.org
>>>> TriEmbed web site: http://TriEmbed.org
>>>> To unsubscribe, click link and send a blank message: mailto:
>>>> unsubscribe-TriEmbed at bitser.net?subject=unsubscribe
>>>>
>>>>
>>
>> --
>> [image: photo]
>> *Shane D Trent*
>> Patent Agent
>>
>> 919-348-0061 | shanedtrent at gmail.com
>>
>> ShaneTrent.com | Skype: skype:shane.trent1
>> <#m_-9030084723900561827_m_7986295226178818095_m_9191686542577320692_m_5084229381385021503_m_1200211025825053041_SignatureSanitizer_SafeHtmlFilter_>
>> Raleigh, North Carolina
>> <http://www.linkedin.com/in/shanetrent> <http://twitter.com/sdtrent>
>> Create your own WiseStamp email signature
>> <https://www.wisestamp.com/signature-in-email/?utm_source=promotion&utm_medium=signature&utm_campaign=create_your_own&srcid=5623268815667200>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.triembed.org/pipermail/triembed_triembed.org/attachments/20200411/70f926c2/attachment.htm>


More information about the TriEmbed mailing list