A PIC based Battery Management System

In all the 'factory' systems I've looked at, they use resistors to shunt the cells.
Whether you use big darlingtons with a heatsink or smaller transistors in the switch mode with a resistor, the result is about the same. I'd just like to avoid messing with heatsinks if possible.

I know there must be FETs out there that can fully turn on with 3v of gate voltage. A regular bipolar transistor in the saturated switch mode would be fine too, since the objective is to dissipate power anyway. In the switch mode, a smaller transistor with no heat sink could do the job.

On larger packs, you'd probably want to use a higher shunt current. Even with a modest 500ma or so, even a large pack should balance fairly quickly as long as none of the cells are damaged.

As soon as the first shunt gets activated, you could drop the charger down to a current that is less than or equal to the shunt current to ensure the cell voltage can't get any higher. This would be like a 2 speed approach.

I think what would be cooler is to have a porportional control of the charging current. Start out at 100% of whatever the charger can do. As soon as any cell reaches the upper target voltage, reduce charger output by 10% (or whatever). Keep reducing until all of the shunts become active. During this process, any cell that dips below the target gets the shunt turned off until it goes up again.

By tapering the charge, you would minimize the balancing time for a given shunt capacity. If a shunt went bad and couldn't pull down a cell, the charger could reduce all the way to zero to still protect all the cells. If you kept track of the time it took to complete the balancing phase, you would have a good indication of how well matched the cells are.

One of the PWM outputs from the processor could be used to throttle the charger. This could be done by interfacing to the charger circuit, or by using a FET on the BMS like Gary's. I think you could PWM the charging current rather than throttling it linearly. Interfacing to the charger, you could pull down the PWM duty cycle in the charger and have a linear output.

BTW: heres the datasheet for the Atmel Atmega8L used in momo's balancer:
ATMEGA8L The PDIP version only handles 6 analog inputs, the others have 8.
 
fechter said:
By tapering the charge, you would minimize the balancing time for a given shunt capacity. If a shunt went bad and couldn't pull down a cell, the charger could reduce all the way to zero to still protect all the cells.
Yeah, I see that. There's going to be a point where if you can't slow down the charger the shunting activity is going to get overwhelmed. If the imbalance is severe then you need to back all the way off so that the limits of the shunting can be respected. The PIC could have some limits designed into it so that when it calculates that the shunting is inadequate it tells the charger to back off.

And there are FET's that trigger at 3 volts. I forget at the moment, but there was a thread a while back where that issue was discussed. They do exist.

So you are basically using a FET to trigger a sink through a resistor to ground right?

Could you diagram that in it's simpliest form?

Or short of that, could you simply restate that picture of things in it's simpliest form? (what attaches to what?)
 
Balancing Options

This might seem academic, but sometimes having a picture set firmly in your mind makes it easier to imagine what you are doing. These are the three major types of balancing schemes...
 

Attachments

  • balancing by slowing.gif
    balancing by slowing.gif
    7.3 KB · Views: 2,338
  • balancing by transferring.gif
    balancing by transferring.gif
    6.5 KB · Views: 2,336
  • balancing by stopping.gif
    balancing by stopping.gif
    6.1 KB · Views: 2,335
I think your last example is closest to what I'm talking about, but not quite. If a bulk charger/supply is used, and you had no shunts, all the current must go through all the cells. If some cells are already at a point that the charger is in the CV mode limiting the voltage, those cells will start limiting the amount of current that they can accept. The cell that is the fullest will then limit the current that all the rest of the cells can receive. What the shunts do is to bypass whatever current the cell can no longer accept, so that the next cell in series can receive the full charge amount, if it needs it. This allows each cell to have, in effect, its own CV charge control, so that it can gradually taper off the amount of current it can accept in order to get that last 10-15% into the cell. What we are doing with our BMS is that once the first cell hits 3.65V, and its shunt starts to bypass some current, we then throttle back the charge current to about 1A because once the cells start hitting that point they are going to reduce the amount of current they can accept anyway so throttling back the current reduces the total bypass current, which significantly reduces the heat that is generated.

To reduce the current, we are using a simple op-amp servo loop with a very low value shunt resistor (.005 ohm) to measure the current flow. I suppose you could do this with PWM, but you'd still need some way to measure the current, and using PWM could introduce noise.

In any case, using this shunt method, each cell gets a 100% charge, but that doesn't necessarily mean the cells are balanced. Because of increasingly different internal resistances, capacities and thermal characteristics, each cell's "100%" level can and will be different. Over time, this difference between the highest cell's 100% "resting" voltage level, and the lowest, can be from 2-4%, from what I've seen. This is not a problem. There really is no need to drag down the level of the higher cells to that of the lowest, just so they are "balanced". What's the point? As long as you are doing a low voltage check on each cell, it doesn't really matter if the cells are at exactly the same levels.

-- Gary
 
A Visual Understanding of Shunt Balancing

It's really nice for me to actually do the homework and draw up the diagram and run the simulation of what we are talking about. I think this is how a shunt type balancing scheme works. The circular thing on the bottom named "Charger" is sending out from 0-10 volts in a pulse type wave so we can see how things behave in chart form. In real life you would hold this constant.

:arrow: The first chart shows that no current is diverted when the shunt is closed.

:arrow: The second chart shows what current flows when the shunt is opened.


Am I correct with all this stuff?
 

Attachments

  • Shunt Balancing Diagram.gif
    Shunt Balancing Diagram.gif
    15 KB · Views: 2,276
  • Shunt Balancing With Shunt Off.gif
    Shunt Balancing With Shunt Off.gif
    14.6 KB · Views: 2,277
  • Shunt Balancing With Shunt On.gif
    Shunt Balancing With Shunt On.gif
    14.9 KB · Views: 2,273
ohhhhhh, i think i know what he means now, basically i think the idea is that once a cell reaches what is considered the 100% charged voltage, the shunt circuitry is turned on, but it is more complex than the stuff that we have come up with, there is a current sense resistor that measures the current going through all of the cells from the charger, and there is another current sense resistor that is inline with the balancer that measures the balancing current, the voltages of the charge current sense resistor and the balance current sense resistor are input to the op-amp belonging to that cell, and the output goes to that cells balancing transistor, the effect is to make the balance current exactly equal to the charge current, so that the cell does not charge or discharge, it just stays at the voltage that was considered full.

at least thats what i took from it.
 
Shunting With FET's

A "short circuit" is when you directly connect the positive and negative leads of a cell together. What this really means is that a circuit with low resistance is allowing too much current to flow, but it's also the same circuit layout as a bypass shunt... the only difference is the AMOUNT of resistance.

So the way I see doing this is to make the "short circuit" using a FET and then insert a small resistor to keep the bypass current from going too far. The FET's themselves contribute some resistance as does the wire, but the added safety of a resistor of known value will put a true upper limit on shunting.

A FET that can be driven by the PIC needs to be identified... (it needs to be less than the 10 volt FET I'm using here)

This is an "off" or "on" type of solution. So the PIC might need to modulate the switching and sometimes have the FET on to lighten the cell load and other times leave it off to let the cell get a little more charge. That's all up to software.

In this example the shunt current is 250mA.
 

Attachments

  • Shunt Using FET's Diagram.gif
    Shunt Using FET's Diagram.gif
    15.8 KB · Views: 2,241
  • Shunt Using FET's Chart.gif
    Shunt Using FET's Chart.gif
    15.8 KB · Views: 2,242
Safe, please spare me the graph, but your schematic is close.

When the shunt is on, the current through the shunt is determined by the value of the resistor. We don't need to measure the current, we just need to adjust the charging curent so the shunts don't get overwhelmed. This would be determined by the voltage measurements.

Just for disscussion, let's say the shunt draws 500ma. When the shunt first turns on, there will be 500ma passing through it, but at the same time the charging current could be over 500ma, and the rest would be going into the battery.

As soon as the voltage on the cell gets over the set point, that means the charge current is too high and needs to back off.

If the shunts are all on, and the charge current is 500ma, there will be no current going into the cells.

A FET like an IRF7313 will be able to turn on with 3v of gate drive. They're tiny little suckers too, and come in a dual package. I'm sure there are others that would work.

Cell Shunt.jpg
 
I notice you've complicated the circuit by adding a transistor and an optocoupler. I presume this is with the idea that you can do automated control using the right combinations of components and if the resistor is just right everything will trigger on schedule.

But since our goal is to use a PIC (and they are particularly good at things like knowing when to turn on a FET because software can be arbitrarily complex without incurring extra costs) I would guess that we would NOT want to add the extra components for economic reasons.

:arrow: Does that make sense? Was that your intention?

Were you advocating for more components with that circuit diagram or was it just the most convenient one you could copy/paste?


What would be great is if there was a single chip that could do all the functions defined in that chart and sold for pennies. That way the component price is cheap and the assembly cost is also cheap.

:arrow: I'm still trying to stay focused on the ideal of fully using the PIC and dropping the component list to a minimum.
 
fechter, ahh i see, im glad that that is a lot simpler than i thought. 500mA seems like it would work, the charge would just be terminated when the last shunt turns on, but why use fets, at 500mA there isn't much heat being produced by the transistor so you could just use a darlington couldn't you? it seems like the analog circuitry would stay exactly the same for the balancer except that the mcu needs to be able to tell the charger to go into 500mA charge mode, and one the last shunt turns on to turn off the charger.

a problem i see with that is if all of the shunt resistors are not exactly the same then when the shunts are active some cells will be slightly charging and others slightly discharging, it might be such a small current that it wont matter though.
 
Throwing Numbers Around

:arrow: Okay, so let's throw some numbers around...

Assume we are talking about the "modern world" of big cells (20Ah-40Ah) and that we have assigned our charger a maximum of 1000 watts of power because that's what a typical house wall socket can handle. If we have a 36 volt system then we divide the 1000 watts by 36 volts and get a peak charging current of about 27 amps.

Now let's say we want to wimp out a little and drop the current requirement down to 20 amps just to make life easier. Now we are only charging at 720 watts.

If we want to circumvent a cell at near the end of charge we will need either a FET that can handle 20 amps (not impossible to find) or some other option. It's the other option that needs to be examined fully before you really stick to it. Now is the time to reverse a mistake of underestimating the demands of a modern charging and balancing system.

:arrow: So let's see people post ways to pull 20 amps.

And I'm okay with the idea of slowing down the charger so as to not overstress the shunting activity... in other words charge at 20 amps and then once the shunting starts you back way off. With this and the PIC you could potentially isolate the risk of overheating during the main charging session and only focus on the end of charge period. (so being able to balance at 0.5 amps while being 1/40 of the full charge current of 20 amps is okay)
 
safe, the thing is you don't need to balance with a high current, once on of the cells reaches the fully charged voltage you drop the charging current down to say 1A. now you activate that cells shunt so that it bypasses 1A, now that cell remains fully charged not discharging or charging at all. at the same time the rest of the cells top off at 1A which should take long because they should all be very close to fully charged, and every time a cell reaches the charged voltage its shunt turns on, and then the last shunt turns on you're all done and the pack is charged, you turn off the charger and turn off all the shunts.

you may need to differentiate between the first cells cutoff voltage and subsequent ones because of the difference in voltage drop across the cell between charging at 20A and 1A, for example if the cells have an internal resistance of 10mOhm, then at 20A thats a voltage drop of .2V, if the cell voltage is 3.6V it will appear to be 3.8V, after that at 1A the voltage drop will be 10mV so a 3.6V cell will appear as 3.610V. what im not sure about is if a cell gets damaged when its voltage reaches the max or if the applied voltage reaches the max.
 
Actually, the shunt function is not meant to be an on and off function. The shunt gradually takes over the current in a linear fashion. Think of how a single CC/CV charger works. As the cell charges it becomes harder to accept current at the same rate so the voltage rises. This happens at a fairly steady rate until the cell voltage reaches about 3.65-3.70V. At that point, the voltage starts to rise at a much faster rate. At this point, the cell is about 85-90% full. What the charger does at this point is to hold the voltage at 3.65V. Since the cell can't keep accepting current at the max level if the voltage is held, the current starts to taper off. When the current gets down to where it is under about 100 mA, the cell is about as full as it can get.

The shunts can mimic the CV portion of the charge profile by clamping the voltage to 3.65V. At first, all the current goes into the cell. Gradually, the cell will reduce the amount of current it can accept. Whatever portion of the full charger current it can't accept, the shunt will bypass. The net result is that the max current goes through the combination of the shunt and the cell, so that the next cell in series can have the full amount of of current that the charger is putting out.

You also just can't cutoff the charging once the last shunt first starts to conduct. The last one needs to wait until the full amount of the charge current is being bypassed. For most LiFePO4 cells, the CV gradual draw down of the current takes about 10-15 minutes. Since it doesn't make much difference whether the full current is 1A or 3-4A, once the shunts are going, dropping the current to 1A, or even 500 mA won't make a big difference, timewise. It might add 5 minutes, but I'm not even sure it would be this much.

-- Gary
 
GGoodrum, how does the shunt for each cell control its transistor to vary the bypass current, is it with the op-amp you mentioned before or was that op-amp to change the overall whole pack current? if not how is the bypass current varied?
 
dirty_d said:
GGoodrum, how does the shunt for each cell control its transistor to vary the bypass current, is it with the op-amp you mentioned before or was that op-amp to change the overall whole pack current? if not how is the bypass current varied?

No, the op-amp is used to throttle back the full charge current to about 1A (this is adjustable in our implementation...). Here is the basic shunt circuit:

Single%20Shunt.png


The LM431 is what does the setting of the 3.65V limit. It is basically just a programmable zener. The voltage divider adjust the battery voltage down to the LM431's 2.5V reference voltage. The pot is set so that when the cell hits 3.65V, the LM431 sees 2.5V. The rest just pretty much happens. If, say, the charger is putting out 4A, the cell will charge at 4A until the cell voltage reaches 3.65V. At that point the cell starts dropping the current it can take in, and the shunt starts passing whatever part of the 4A that the cell is not using. Eventually the cell will only accept a tiny bit and the shunt is conducting most of the 4A. In order to reduce the amount of heat that is generated, once the shunt starts conducting, the current can be dropped down. Initially, this will cause the cell voltage to dip below the 3.65V cutoff point as it is easier for the cell to accept 1A than 4A, but very quickly it will be back up to the point that the shunt starts to conduct again.

-- Gary
 
The cell itself controls the amount of current that goes through the shunt. Whatever the cell can't accept, has to go through the shunt.

With the PIC version, the LM431 zener function can be replaced by software, but again, I'm not sure it is worth it. The LM431 is $0.11 at Mouser.
 
ahh i get it now, that is very cool. with another LM431 you could also do the LVC, :( what is there left for the PIC to do?

edit: actually you couldn't do the LVC that way, then when the cell is over the low voltage the second lm431 would be draining the cell.
 
Using transistors as the only dissipating element requires that you run them in the linear mode.
You might be able to put some hysterysis on the 431 voltage monitor and force it into the switching mode if you used a resistor. If you used, say 10mv, of hysterysis, then the shunt would always be either off or full on (through a resistor). During balancing, this would start an oscillation in the shunt circuit that would be constantly switching on and off like a PWM. 10mv or so of ripple on the cell voltage won't hurt the battery I think.

By doing this, you can use a smaller transistor with no heat sink, and still get a good shunt current. The average current will be a function of the duty cycle, and can vary from 0 to 100%

In an analog version of this, there is the possibility that switching noise from one cell could trigger another cell and set up some kind of feedback. In a PIC driven version, the timing of the shunts turning on and off would be determined by the PIC, which would be sequential.

It would be interesting to set one up on a breadboard and see what happens.
I've seen at least two commercial balancers that apparently work like this.
 
fechter said:
Using transistors as the only dissipating element requires that you run them in the linear mode.
You might be able to put some hysterysis on the 431 voltage monitor and force it into the switching mode if you used a resistor. If you used, say 10mv, of hysterysis, then the shunt would always be either off or full on (through a resistor). During balancing, this would start an oscillation in the shunt circuit that would be constantly switching on and off like a PWM. 10mv or so of ripple on the cell voltage won't hurt the battery I think.

By doing this, you can use a smaller transistor with no heat sink, /quote]

Sorry Fechter, I have to disagree with you, a forced PWM oscillation wouldn't reduce the heat dissipated by the shunt transistors. Run an energy balance for the circuit. I think you'll find that since PWM doesn't provide any new place for the energy to GO, all the shunted energy will still show up as heat in the transistor.

GGoodrum, and crew, has what I think is the optimal per-cell BMS for lithium cells. I don't see how a micro-processor could improve on it using only transistors/resistors to shunt the cells. Now, a micro-processor is vital for more sophisticated balancing schemes that use Inductors or transformers to transfer charge from cell to cell. In this case the micro-processor would now have two options when a cell starts hitting the LVC. First shut off the whole battery pack, or second transfer charge from the strong cells in the pack to the weak cell and keep going. (I can't think of a way to trigger this second behavior unless the state of all the cells is know in one spot) The simplest circuit I've seen that can shuttle charge around efficiently is the charger over in this thread. Admittedly, that's a lot of work just to get an extra ~2% range out of a battery pack :oops:

Marty
 
lawsonuw said:
GGoodrum, and crew, has what I think is the optimal per-cell BMS for lithium cells. I don't see how a micro-processor could improve on it using only transistors/resistors to shunt the cells.
The whole idea of the thread was to use a PIC for the BMS, so if you want to do things the old fashioned way you should just skip the PIC idea altogether. :roll:

I'm still not sure if these existing solutions really can handle the mandated 20 amp current minimum for a modern charging system. I'd like to see what happens when 20 amps are used and see whether things burn up or not. Most people are currently charging at very low C rates and it's rare to see anyone charging at faster than about 4-5 amps. This just seems too slow for the bigger cells. I guess LifeBatts are headed towards 8 amps, so they are getting there, but 20 amps is the ideal we should shoot for. (since the house wall plug is a standard that will be around for a long time and they can handle about 1000 watts)

:arrow: Will the old techniques be able to take the heat of 20 amps?
 
lawsonuw said:
Sorry Fechter, I have to disagree with you, a forced PWM oscillation wouldn't reduce the heat dissipated by the shunt transistors. Run an energy balance for the circuit. I think you'll find that since PWM doesn't provide any new place for the energy to GO, all the shunted energy will still show up as heat in the transistor.

I think you misunderstood. The transistor would be in series with a big resistor so the voltage drop across the transistor is low and the resistor would have to dissipate most of the heat.

Gary's circuit is almost perfect, but the idea here is to see if we can come up with a way to duplicate the performance (or close enough) and do it cheaper. The overall cost to make the BMS has to include assembly cost as well as all the parts.
 
safe, that should be able to handle it fine, what it does is jsut charge at 20A then once the first cell gets to the cutoff voltage, the charger starts charging at a much lower amperage, the voltage will now be back down below max, but it stays at the low current charge, then once the cells get back up to a few mV before 3.56V the shunts start to turn on, and the closer the cells get to 3.65V the more on the shunt is, so it has the effect of holding it right at 3.65V while the current through the cell gradually decreases and the current through the shunt is at carrying almost all the current. this can charge at however high a current you want, just at the end you have to switch down to a current that the shunts can handle.
 
No Excuses, No Compromises

The most basic circuit to be used with a PIC would look like this below. I have not modeled this fully and it's now just a test diagram, but the ideas are pretty simple. By placing the first resistor before the FET it means that low priced FET's can be used rather than more expensive ones. (so that argument that FET's are too expensive evaporates) After the first resistor you place a second, then the voltage dividing measurement connection, then the other half of the voltage divider is completed with the third resistor.

You will need to run a startup routine in the PIC to figure the true resistances (no manual measurements required) and be able to get the high precision of voltage measurements you want. That problem will be solved on the math side and not the component side. The balancing can be fully on or off or cycled as need be by the PIC... the main thing is that the charger need not worry about the FET because it would be able to handle the 20 amp load (being behind the safety of a resistor) without any problems.

:idea: Can anyone identify a single flaw in the concept?

:arrow: Is this perfection for the PIC based BMS?
 

Attachments

  • Basic Balancing Circuit.gif
    Basic Balancing Circuit.gif
    3.9 KB · Views: 2,726
safe said:


:idea: Can anyone identify a single flaw in the concept?

:arrow: Is this perfection for the PIC based BMS?

No, actually there are several flaws...

The resistor in series with the FET to act as a shunt needs to be a much lower value, like a few ohms.

When the shunt FET activates, it will throw the voltage measurement off because it's in the same string. The voltage monitoring needs to be separate from the shunt.

You need to keep the FET gate at the right voltage relative to the source. You need either a optocoupler or a floating FET gate driver.
 
Back
Top