A PIC based Battery Management System

Richard,

I have the LVC designed but not built. I'm still waiting for parts to arrive.

- Brad
 
BTW I posted some schematics for an LVC cutoff using discrete components in another thread.
http://endless-sphere.com/forums/viewtopic.php?f=14&t=3345&st=0&sk=t&sd=a&start=300
The cost is roughly in the $0.50 per cell range. Just pointing this out in case you missed it, not suggesting you don't try your cpu approach.
 
Randomly said:
BTW I posted some schematics for an LVC cutoff using discrete components in another thread.
http://endless-sphere.com/forums/viewtopic.php?f=14&t=3345&st=0&sk=t&sd=a&start=300
The cost is roughly in the $0.50 per cell range. Just pointing this out in case you missed it, not suggesting you don't try your cpu approach.
I think the purpose of the CPU approach is to do things a simple LVC can't. Like display cell voltages -- something I'd like to be able to do also.
 
Randomly said:
BTW I posted some schematics for an LVC cutoff using discrete components in another thread.
http://endless-sphere.com/forums/viewtopic.php?f=14&t=3345&st=0&sk=t&sd=a&start=300
The cost is roughly in the $0.50 per cell range. Just pointing this out in case you missed it, not suggesting you don't try your cpu approach.

Just looked at that. I like the neat current switching method of ANDing up all the outputs. I'd have figured it out quicker if you'd drawn them as long tailed pairs, but its still neat.

Nick
 
I agree with rf. It's worth a little more to me to be able to SEE the cell voltages, current draw, etc. With a microprocessor per cell, the cost is still low. I'm spending $1.69 per microprocessor, $.16 per opto plus some small resistors. For less than $2 per cell plus $20 for a nice backlit lcd display, I'm happy.

I should get my programmer today. Its at the post office.

I'm already thinking again about the charing circuit. Since the microprocessors all communicate, it wouldn't be difficult to signal the processors to tell them they are in charing mode and then tell each processor who has the highest voltage and how much higher they are than the lower voltage.

From my understanding, the simple solution is to have the processor trigger a transistor to bleed off power through a big resistor to keep things balanced. The main processor could cut off the power to the charger when the cells are all charged. Is this the best way?

What is the best way to manage turning on and off the transistors? Do we just turn on the highest cell? Do we turn on the top 25%? How much do we need to drain?

- Brad
 
rf said:
Randomly said:
BTW I posted some schematics for an LVC cutoff using discrete components in another thread.
http://endless-sphere.com/forums/viewtopic.php?f=14&t=3345&st=0&sk=t&sd=a&start=300
The cost is roughly in the $0.50 per cell range. Just pointing this out in case you missed it, not suggesting you don't try your cpu approach.
I think the purpose of the CPU approach is to do things a simple LVC can't. Like display cell voltages -- something I'd like to be able to do also.

The potential advantages of a cpu approach are obvious. Cell voltage monitoring, Coulomb counting, Over current protection, under voltage protection, over voltage protection, Temperature monitoring and cutouts, Charge control, Cell balancing, displays to light up, buttons to push, buzzers to beep etc.
As I tried to state in the previous post pointing out the discrete LVC thread, the discrete LVC is not a replacement for a cpu approach. Perhaps I should have phrased it more clearly.

As always there is a cost/complexity/feature tradeoff, the discrete LVC is just one data point in a spectrum of solutions. It's good to be aware of the options available depending on what solution you need.

That thread however covers some important design points which are completely relevant, such as minimizing current drain on an LVC cutoff, low drain throttle/brake cutoff circuits, FET power disconnect circuits, high speed power FET gate drivers with low quiescent current, proper behavior under any cell voltages, etc. Although the discrete circuit doesn't give you cell voltages it has some desirable qualities such as extremely low current drain and proper protection behavior under all states of charge or discharge which would also be desirable goals in a CPU based version. It seemed prudent to make people in this thread aware of it in case they missed it.

Some other points that need to be considered on a CPU per cell approach is even current consumption for each cell. Uneven discharge of the cells due to uneven power consumption (which might arise with one of the cells CPU being used as a master controller) will require more cell balancing to balance the pack on charging.

As to cell balancing - the simplest approach is just to turn on a load across the cell if that cell voltage is higher than the others (or higher than the lowest cell voltage in the pack). A transistor or FET and a power resistor. Balancing currents may only need to be on the order of 100-200 ma. Since cost isn't really a concern, using a FET like a FDN335N which has a comfortably low VGS of 2.5V would be simple to drive directly with a CPU port line. Typically the BMS cannot dissipate much heat because it's usually in an enclosed place with limited heatsinking. You also do not want to have it warming up your Lithium cells much because heat is the bane of batteries, especially Lithium.

LiFEPO4 cells usually do not require much balancing. The cells typically have low self discharge rates and the cells tend to have long cycle lives, degrade slowly, and have fairly good capacity matching between cells. The charge and discharge efficiencies also tend to be very close and consistent.

LiPo cells however degrade quicker so the individual cell capacities will diverge more. They have shorter cycle lives, tend to be less well matched, and most importantly are subject to micro 'soft shorts' which are difficult to control in manufacturing. One cell may have a 5%/month self discharge rate and another cell may have almost no self discharge rate.

Cell balancing is intended to fix the uneven discharge and charging of cells due to varying charge and discharge efficiencies between cells and uneven self discharge rates between cells.

To balance say a LiPO pack which you are charging up to 4.2V per cell, as cells reach 4.1V you turn on the load on that cell to slow down it's effective charging rate and let the other cells catch up. You can also PWM the balancing loads to fine tune the charging rates of the cells (note that the PWM frequency here can be fractions of a hertz). The goal is to have all the cells reach 4.2V at the same time.

If you implement some charging control you can also reduce the overall pack charging current to less than or equal to the individual load balancing currents which will allow you to continue balancing without overcharging any individual cell. A similar effect could be obtain with simpler circuitry by just turning the charging current off to let the balancing currents 'catch up' for a period of time, then turn the charging current back on, effectively reducing the charge current by PWM it at a very slow frequency. There's lots of fun software possibilities with a relatively simple hardware setup.
 
Randomly said:
[...]
Cell balancing is intended to fix the uneven discharge and charging of cells due to varying charge and discharge efficiencies between cells and uneven self discharge rates between cells.
[...]
Cell balancing is only necessary if you don't have a working LVC or a decent charger that delivers a full charge to every cell.

Bleed-off balancing is wasteful of input power as well as cell life and should be avoided whenever possible. Fully charging every cell is better.

Richard
 
rf said:
Cell balancing is only necessary if you don't have a working LVC or a decent charger that delivers a full charge to every cell.

Bleed-off balancing is wasteful of input power as well as cell life and should be avoided whenever possible. Fully charging every cell is better.

Richard

You seem to have acquired some information that is almost all totally wrong.

Cell balancing is required regardless of having a working LVC or not because of other effects such as different self discharge rates among cells due to manufacturing variance and different aging rates between cells. Both cell aging and self discharge rates are highly temperature dependent so a thermal gradient across the pack can exacerbate this problem. One cell may self discharge 5% of it's charge in a month and others will have hardly discharged at all. If you don't correct that imbalance the total pack capacity is reduced by 5%.

I'm not sure what you mean by a decent charger that delivers a full charge to every cell. The ONLY way to deliver a full charge to every cell is to implement some form of cell balancing.

Bleed-off balancing is wasteful of energy?

Yes it does dissipate some energy as heat, but the only energy needed to be dissipated is the difference in energy lost between cells since the last charge cycle. If you are discharging and charging your pack once every few days this will probably be less than 1% of the pack capacity. This would not fall into my category of 'wasting input power'. If you were to implement a balancer that differentially charged the cells instead of bleeding them for balancing you might be able to save 80% of that 1%. It would probably take you years to break even with the cost (energy or financial) of the added complexity and components.

Bleed-off balancing during charging absolutely does NOT waste cell life. If you think it does please explain the physics behind your reasoning.

In fact pack balancing increases cell life. Cell aging is accelerated by the depth of charge/discharge and cell temperature. This is why GM is only charging their A123 packs for the Volt car to 80% capacity and discharging only down to 30%, giving up 50% of their battery capacity in order to gain cell life. If you do not cell balance you will always have one cell that runs out first and experiences the deepest discharge of the pack, which will cause it to lose capacity faster than the other cells in the pack. As it loses capacity it will discharge even quicker than the other cells and accelerate this process. Although cell balancing won't eliminate this effect it will minimize the discharge differential between cells slowing this effect down. Remember the pack AH capacity is the AH capacity of the weakest cell.
I hope that's helpful.
 
If we are bleeding off less power than the charger puts out, I don't see how this could negatively affect the batteries.

As someone stated earlier, with a processor, we don't have to wait until the cell is full to start balancing. We can start balancing as soon as we start charging. We need to come up with a formula that works well. You could throttle the cell wth the highest voltage, which would mean that you would always have one cell in the pack throttled. You could throttle any cell that has a voltage that is X higher than the lowest cell voltage, etc.

I got my parts and programmer. It took a night to get my programmer working so that I could build a flashing LED demo. Last night, I got serial communications with an LCD display working through an optocoupler. I have digital IO and timers working. I am able to read analog voltages by comparing to the 1.1 volt internal reference. Unfortunately, I'm currently getting readings that are about 10% high. Is the 1.1 volt internal reference this far off? I haven't decoupled the ADCVcc from Vcc as they say to in the datasheet.

I can see now that resources are scarce in these chips. By adding a floating point divide in the code, I use up almost half of the available program memory! It looks like I should be able to cram in the basic functions, though.

- Brad
 
Randomly and bquick are relatively new to the forum so they may not have followed all the previous discussions about cell management techniques. The "short answer" is that there are many techniques for managing cells and so there's no absolute answer. In a "perfect world" you would have precise control of each cell and be able to limit it's low and high voltage and possibly even it's rate of energy release and charge. In the "practical world" the bleed away balancing technique works okay.

Just my two cents worth. :)
 
You don't want to start balancing as soon as you start charging, but only when the pack is nearing full charge.

Consider a pack of 10AH cells, but one of them has a lower capacity of 9AH. This lower capacity cell voltage will fall faster under discharge and rise faster under charge than the other cells. If you start charging and balancing this pack after it has been fully discharged the low capacity cell will have the lowest voltage, so you will start bleeding current out of the other cells to let it 'catch up' in charge. At some point it will catch up in cell voltage to the other cells, but since it's capacity is less it charges up faster than the other cells and it will soon pass them up. Now you will have stopped bleeding current off the other cells and be bleeding current off your low capacity cell to let the other cells catch up in voltage to it.

You are basically having to undo all the charge bleeding you did at the start of the charge cycle which was effectively unbalancing the pack. The problem occurs because you are using cell voltage as a comparative measure of total stored charge, but this only works if all the cell capacities are identical.

The aim of charging balancing is to get all the cells to reach the maximum desired charge voltage. This means all the cells will have the maximum stored charge they are individually capable of without being overcharged. The pack capacity then is the capacity of the smallest capacity cell.

Charge balancing is best achieved when the cell voltages are nearing their full charge voltage. The only way to implement early charge balancing effectively would be to keep individual histories of cell capacity vs cell voltage or use cell voltage rates of change under charge to estimate individual cell capacity and use that information to estimate cell state of charge and balance accordingly.
 
safe said:
Randomly and bquick are relatively new to the forum so they may not have followed all the previous discussions about cell management techniques. The "short answer" is that there are many techniques for managing cells and so there's no absolute answer. In a "perfect world" you would have precise control of each cell and be able to limit it's low and high voltage and possibly even it's rate of energy release and charge. In the "practical world" the bleed away balancing technique works okay.

Just my two cents worth. :)

If you could point me in the direction of some of the informative threads you are referring to I would be most grateful.
thanks :)
 
Randomly,

Thanks for the explanation about cells with lower capacity. That makes a lot of sense. The advantage of bleeding earlier is that you don't have to bleed as strongly, meaning you can use smaller components. I suppose there's no harm if not all cells reach maximum charge voltage every time as long as you are doing LVC also. With this in mind, each cell's processor could try to guess at what voltage it needs to turn on the balancing resistor. When the first cell hit max voltage, the charging could be stopped and then each processor could adjust it's guess for the next charging cycle. Over enough charging cycles, the goal would be to get them to all hit peak voltage at the same time. This could be difficult considering that you won't always be starting the charging at the same point of discharge.

I've been tempted to use the multiple charger method shown above, but at 2 amps, it would take 20 hours to charge my pack. I'd like to hit between 10 and 20 amps.

- Brad
 
yes, I've always liked the stack of wall warts charger approach. It solves the balancing problem simply, requires minimal electrical knowledge, takes advantage of cheap mass produced parts to achieve a reasonable cost. The only downsides are that it's a bit cumbersome and you need to make a lot of reliable medium current connections with a multipin connector that has reasonable cycle life. But I think it's probably the best approach for the average do-it-yourselfer

If you want to accelerate the charging rate there is no reason you can't augment the wall wart chargers with a large high current bulk charger in parallel that you just turn off (hopefully automatically) when the pack nears it's end of charge voltage, and let the wall warts continue their charging to top off the cells and balance them. There shouldn't be any problem running both the wall warts and a bulk charger that is current limited at the same time. That would be relatively easy to accomplish with the CPU per cell approach, or even a discrete approach. Don't forget to monitor cell temps if you are charging at a high rate, temperature is the bane of cell cycle life.
 
safe said:
Randomly and bquick are relatively new to the forum so they may not have followed all the previous discussions about cell management techniques. The "short answer" is that there are many techniques for managing cells and so there's no absolute answer. In a "perfect world" you would have precise control of each cell and be able to limit it's low and high voltage and possibly even it's rate of energy release and charge. In the "practical world" the bleed away balancing technique works okay.

Just my two cents worth. :)
Hmm. Trying to be the voice of reason.

What have you done with safe? Has he been abducted?

:)
 
rf said:
What have you done with safe? Has he been abducted?
Sorry...

This thread has been like "Abu Ghraib" in that every time one of my "Foes" wanted something to nag me about they pointed to my being here (months ago) and people being upset about it. So I've been hesistant to getting too involved.

I think other people have answered well enough.

Just now I've started using the "Foes" facility and so far it's kind of nice. It's hiding everything offensive and all of a sudden everyone is nice again. Cool. :)
 
A great and comphrehensive discussion guys :shock: I'll just add my thoughts on some recent work I've been doing.

Now my ideas below won't be new I'm sure.

I've been dabbling and experimenting over last few weeks, and I do like the idea of an intelligent expandable BMS. Appologies in advance for my schematic skills, I could also only export the diagrams to a bmp file.

For any BMS there are an ever increasing number of desirable features,
but we have to draw the line somewhere for the sake of reproducability, practicality and cost.

I would like a BMS to monitor individual cells (in my new 50x40ah Li-fepo4 pack) or subpacks (In the case of the Insight)

I would like to know the cell V and temp, the pack capacity and voltage etc.

I've come up with a digital solution here which has many functions, only limited by the programmers collective ingenuity (Thats all of you ).

http://www.solarvan.co.uk/insight/digitalslave.bmp 356kb Schematic

Proteus design file here

http://www.solarvan.co.uk/insight/BatmonMinusInstruments.DSN

This uses a Picaxe 08M or (12F683 pic) 8pin chip on each cell at a cost of about £1-2.00. (pcb and discrete components extra of course but if we could get it down to £5-8.00 a cell that's not bad.) Each cell is going to be fitted with one of these small circuits. The pic has a wide operating voltage from 2-5.5v so covers virtually all the various types of Li-Ion chemistry. It sits there 24/7 (need to keep the current drain to a minimum for smaller cells, but I can afford a few ma on 40ah cells) running a cell monitoring program checking the cell (subpack) voltage against it's reference. It's also checking the cell temp, and activating it's balancing load if the cell goes over Max V. Now this idea uses an opto isolated serial bus for comms with the master PIC and dashboard display. All the serial opto outputs are connected in parallel so the cells have a common data bus.

The master pic pulls the interupt opto of cell one high and triggers an initial delay of say 0.1 seconds in the slave pic, the slave then starts the serial data output routine which dumps the cell data onto the bus for the master to receive and record. The act of data transmission triggers the interupt on cell two which waits for 0.1 seconds and then transmits it's data, add infinitum along the pack. The master recieves and checks all the data (Missing data can simply trigger an alarm condition etc) it then acts on data as reqd, calculating pack voltage from sum of cells, checking for over temp condition, etc etc etc.

Note on the first cell in the pack the master PIC would be connected to (pins 1 and 2) of the interboard connector to initiate the interupt sequence, the cell 1 slave would then connect it's output (pins 3 and 4) to the input (pins 1 and 2) of the next slave. Hope that makes sense, like a cascade effect. Bit of work to do on timing of data etc and all slaves must run the same software.

I'm off on hols now for a couple of weeks, I'll take a few schematics and have a further think. More ideas very welcome.

Here is a first draft slave PIC code
`Battery Management System Slave Module
`Based on Picaxe 08M microcontroller
`Original concept, hardware and code by Peter Perkins
`peter@solarvan.gotadsl.co.uk
`V1.00 280508


`Byte Variables for speed
`b1 = Cell voltage
`b2 = Cell temperature
`Balancing voltage is set at >3.75v For Li-fepo4 cells



start: `Initialise program and variables/interrupts as reqd
setint %00001000,%00001000 `Activate interrupt when pin 3 goes high

main:
low 2 `Pull pin 2 low to draw current through the ref 1.25v diode
pause 100 `Wait 0.1 of a second
input 2 'Turn off current and turn pin 2 back to an input
readadc 2, b1 `Measure the voltage stored across the capacitor
b1 = 255 - b1 `Invert the value of b1 so higher voltage = higher value
If b1 > 170 then `Turn on cell balancing load if voltage >3.75v
high 1 `Turn on load resistor
else
low 1 `Turn off load resistor
endif
readadc 4,b2 `Read the cell temperature into variable b2
goto main `Goto main loop



interrupt: `Send cell data to master Picaxe via opto serial bus

pause 100 `Wait 100 milliseconds to ensure data received OK and prior Pic has sent data
`This may be cut or removed depending on hardware response

sertxd(b1,b2) `Send raw cell/slave data to master, include :-Cell V, Cell temp
setint %00001000,%00001000 `Reset the interrupt and wait for another data request.
return `Return from interrupt to main program.

Once everything is working as reqd I could probably buy a job lot of the bare slave PIC's and program them in assembler with the final code.

The Picaxe basic is nice and easy for development though and can be simulated using Proteus VSM software. So any experts on schematics and pcb development want to lend a hand Come on down!

Picaxe stuff/info is here

http://www.rev-ed.co.uk/picaxe/

I'm going to make up three slave boards when I get back from hols and clag them onto three of my old TS cells, I'll fire them up and see how the idea works in practise. I don't really see any major limit to the number of cells/slaves you could have except time taken to poll them all may become excessive or the parallel leakage of the data opto may become an issue. I think a pack scan rate of once a second if I can acheive it would be good.

Peter

PS

I've specced up the outline for a very basic test board which will fit on my new cells and my old TS ones. See diagram. The darker grey areas are solder pads for the cell terminals onto which the pcb mounts.

If someone wants to put this into a pcb program and draw it up as per my schematic keeping all the components between the inner holes on the centre section of board that might be a start. Components would be on the opposite side of the single layer board, the view shows the solder side. I would prefer not to use surface mount devices so that people can easily assemble their own. (cheaper)

By keeping all the components in the centre part users could simply hacksaw off the ends if there application did not need the outer holes (Me for instance) or it was too long to fit on their cells .

http://www.solarvan.co.uk/bmspcbv1.jpg

Over to you.

Also if someone wants to convert my rudimentary code above into assembler for the 12F683 pic that's even better.

http://ww1.microchip.com/downloads/en/DeviceDoc/41211D_.pdf

Picaxe 08M or 12F683 pic datasheet.

My old website http://www.solarvan.co.uk might help people to put a name to a face :D
 
I took a look at the schematic, seems like it would work.
The only suggestion I would make would be to replace the LM335 with a something like an MCP9700. The required supply voltage for the LM335 can easily exceed the available cell voltage depending on temperature and cell voltage, giving you bogus readings. The MCP9700 will also reduce the quiescent current a great deal. Don't forget your A/D reference voltage is going to vary with cell voltage when you read the Temp sensor. looks like fun.
 
Welcome peterperkins! We're honored to have you amongst us. I'm a longtime admirer of your site, and was very sorry to see the solarvan sold. I'm sure we'll all enjoy having the benefit of your experience here.
 
Oh good! somebody who knows how to program the little ones...

Can the Picaxe 8 do a PWM output? It would be good if the shunt resistor could be throttled by a PWM. If the cell voltage is too high, the PWM duty cycle gets incremented. Once it reaches 99%, it triggers the charger to slow down.

Is there a way to make the cell units go to sleep when the battery is idle? How do you wake them up?
 
We are acquiring some very impressive talent on this thread, so I'm going to work twice as hard to be respectful this time around.

Welcome Peter.
 
Thanks for the comments, i'll respond when i get back from holidays in a couple of weeks. I did take along my pocket pc and some bms papers to try and work on the Master Schematic & Software while i'm away.
 
That design seems to have a lot of parts. If you daisy chain the processors by serial communication in a complete loop, it reduces the number of opto-couplers and also allows you to do complex messaging TO the individual cell processors.

- Brad
 
The PICAxe 08M does PWM OK, although it's a bit idiosyncratic to program pulse width and period. I've used these things in a few projects and been pretty impressed with their ease of use. The best thing is that they are very quick to get going, even someone with very little experience could get a PICAxe doing something useful in an hour or two.

I did a few quick sums a while ago and worked out that one of these cheap and cheerful chips would even make a fairly good brushed motor controller, it has enough capability for the PWM outputs to drive a FET drive circuit, monitor voltage and current and interface directly with a voltage or resistance type throttle.

Jeremy
 
Back
Top