A PIC based Battery Management System

fechter said:
Thanks for the comments Patrick. I was told the communication was via I2C bus. The cell processor is an ATtiny48 ( http://www.atmel.com/dyn/products/p...family_name=AVR%AE+8%2DBit+RISC+&part_id=4350 ). The transistor that controls the shunt resistor is in the switching mode and is a FET with low on resistance. This avoids the need for a heat sink at 2 amps.

I was told something completely different about the communications, but I won't embarrass anybody in this post. Will report back. Also remember this design was first for TS 90 Ah cells, $200 each. Not unreasonable to spend 10% of pack cost on a BMS. Oh, and BTW, the cell modules draw 1 mA; perhaps less in a properly configured (sleeping?) system.

The board I've got has an ATtiny 25V, which is battery specific. It really doesn't matter, almost anything will do in this simple application. And I'm assuming a 10 bit ADC is good enough. But still, you are looking at small dollars min. for the MCU, ($10 for a PICaxe), plus the board, etc. I hope to implement a trial system on one of my bikes to get a better feel. It will be a lot of work, but worth it. Better if I get a real-time feed from the master - that would be super, and save a lot on instrumentation.

Whilst the existing master is very capable, it might be overkill for a lot of applications. It's also bulky (from an ebike perspective), needs 12V, room for display, etc. I think there is an application for a very minimalist master that has just a few digital outs:

One shunt on (charging)
All shunts on (charging)
One cell hit min voltage x
One cell hit min voltage y

You get the idea. A few tens of dollars for this. I'm going to propose this - anybody have any input on what they would like to see?

Also, for a fuller display. Coulomb counting is an absolute must. So is fan control. The FET may not need a heatsink, but I might have heard the resistors hit 200F. An input for cell temp - although the TS cells don't heat under either severe load or heavy charging.

Charger integration is important. This is a function of the charger (power supply) used. Silly to have a big supply, and then burn excess current heating something up. I think Commandas BMS design is very cool in this respect. Would almost be worth it just to have two different supplies, and shut one off. Then you could mix and match what voltages/currents you needed for your application.

I welcome any input on the project. Thanks!
 
Hi Patrick,

Thanks for the info. There's a lot of confusion about over I2C, SPI ,etc, and Atmel have their own TWI (Two wire Interface). I think we discussed some of this about a hundred pages ago. To my mind the big questions are not about the hardware of the interface but about many peers to one master rather than peer to peer.

As for feedback, I once started a thread once about the features an ideal BMS could have, but it will have disappeared back in time by now.

Nick

PS. Found it http://endless-sphere.com/forums/viewtopic.php?f=14&t=5126&p=76710#p76710
Didn't generate much discussion, though.
One thing I would add in retrospect is that LVC and overcurrent could have both hard and soft cutoffs. The soft cutoff would be a throttle/brake override and the hard cutoff would come in slightly later and disconnect the battery.
 
wrobinson0413 said:
The list that Tiberius gave in the older thread, is the "Everything I wanted under the Christmas tree" list. From an economical point, there are features that might cost too much to implement.
Wayne

Totally agree Wayne; I was trying to think of every application. With a processor per cell and sufficient comms between them, a lot of those features are software, so all we need to do is to allow a little more code space and leave them until later. Where there is hardware involved, the approach could be to have it fitted "for but not with", as they say.

The difficulty comes when there is a design choice that closes off an option for future development, so it is good to have an idea of what future development may be wanted.

Nick
 
Just an update on where I am with my own PIC (Picaxe) based BMS design.

The Long Day Closes.

Thanks to massive help from Roger Crier a fellow UK Honda Insight owner who drove up from Birmingham today bearing gifts, and spent 8 hrs in my garage with me wiring up slaves, I can report the finished assembled cell blocks & bms boards.

A couple of wiring glitches aside all 50 slaves worked first time BMS is also reporting correct pack voltage. Scan rate at 1200baud serial comms is once per second for 50 cells No issues with 50 opto's on Master Bus at present.

I have made no efforts at the moment to include any power saving functions in the Digital Slave software unlike the Slave Analogue On/Off ones which I did for Greg, so the Digital Slaves continous drain is an average of 1ma, or 41days for 1ah consumed.

Roger kindly provided some nice clear vacum formed safety covers for the packs and they set the job off a treat.

The led's looks pretty dancing round the slave boards as well It's like a Mexican wave

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

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

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

Jobs for next three days include adding plugs and sockets for the various data/bcm connections to each cell block.

Installing the Master Display and front to back wiring into the car for the video and control led's switches.

The full rambling story is available here http://batteryvehiclesociety.org.uk/forums/viewtopic.php?t=1245

Thanks to the members here who were working on other versions I did make a few late changes to my Slave design including power jumpers and extra decoupling caps. I have tried bench charging and no probems with pic lock ups etc, but in the car will be different again we shall see. :shock:

Just to humour me, here are a couple of YouTube videos, the second one shows the Worlds most expensive Led christmas lights. (Probably :roll: )

http://www.youtube.com/watch?v=gAaSTQ2cWrk

http://www.youtube.com/watch?v=JIMPLMPyopY
 
Very nice work Peter. A slice of engineering heaven.

Also thanks for posting the pictures and write up, it's much appreciated.

One thought I had about having 50 opto isolator outputs ganged together is that leakage currents could become a problem at high temperatures since they are multiplied by 50 times. I don't know your opto spec's or the output load impedance they are driving but it's just something to check quickly against the opto datasheet against your worst case expected temperatures. It may be a non-issue.

I'd wish you good luck but I think you are making your own.
 
heres a brand new chip LTC6802, its not available yet, but a couple of these and a microcontroller would work for a good BMS.

http://www.linear.com/pc/productDetail.jsp?navId=H0,C1,C1003,C1037,C1134,P86662

they also offer a eval board here:
http://www.linear.com/ad/6802.jsp
 
I've just about finished the high current connections on my battery blocks. The final interrupt driven digital slave software with 10x oversampling just has to be loaded in and they are done. Hooray Should finish that today. I've binned the power saving feature at the moment as I was getting delayed trying to save ua of power, when I'm only using 1ma anyway Need to get a grip. I'll fiddle with that later one car is on road.

Edit Finished high current Anderson connectors and re-programmed slaves with latest digital slave software. This is the final version of the digital slave program before I actually get to test it in the car!! Seems to work ok on the bench.

http://www.solarvan.co.uk/bms/SLAVESIMPLEDIGITAL011008_V15_1200BAUD.TXT

I have used some plastic nut covers on the cells to help prevent the live terminals breaching the plastic cover, it also gives a bit more room under the cover, so I may not need the fans. Also the cover forms part of the floor of the little cubby hole in the rear of the Insight so it may be loaded slightly, this avoids any weight pressing on the circuit boards.

My mate Roger is making me some more covers slightly thicker and with deeper sides as I have mangled these about during this prototype work. They are fine for this but I am aiming to get it looking as good as possible.

http://www.solarvan.co.uk/bms/BatBlocks1.jpg

Each block has two data connectors.

The front block (at rear in photo) has one x two pole Anderson connector + & -

The rear block (at front in photo) has two x two pole Anderson connectors
+ & - as above but also another break in the circuit which corresponds to the Insight OEM main switch on the nimh pack.

So the configuration of the Li-fepo4 pack connectors/bcm taps etc is identical to the oem nimh pack
 
wrobinson0413 said:
An example of a feature that Patrick mentioned was a built in charger. Personally I would want that in a e-motorcycle just like I would like it in an e-car, but it is just not practical I think for an ebike since we have so little space to work with already. Maybe others would disagree with that, but if I need to charge batteries, I walk my bike to the charger or carry it out to the bike. If it is on the ebike, then it is one other thing that needs weather proofing and protection against other abuse.

There is a ton of great info, ideas and opinions in this thread. I started reading some time ago, but feel I should re-read and finish all pages.

I've started my own micro-controller based charger/BMS project, based on TME balancers, and the Arduino Diecimila micro-controller. I originally assumed that a simple active and passive component design would be best, but with off the shelf balancers like the TME Xtrema selling for $35, and able to do 6 channels of cell voltage A-D conversion for real time info or recording. I'm now thinking digital is the way to go.

With motor hall sensor, or traditional magnetic reed input (or back EMF even), I'm looking to produce a Cycle Analyst type of device, with advantages like individual cell voltage recording, instead of just pack voltage.

I'm hoping to use as many inexpensive (yet reliable) off the shelf parts as possible, and make this project more about integration and open-source collaborative software development than hardware development.


I DO disagree about on-bike charging, for my needs, and with my methods at least. For me, on-bike charging is THE solution to range extension beyond 400-1000 watt hours. There are 120vac outlets all over and many have owners that don't care or at least have no way to cost effectively police their use. I've never yet seen a sign saying "Do not use".

Yes, it is important to find ways to keep bulk and weight down. My current charging solution is VERY low tech; Too low tech as I've damaged cells/batts accidentally overcharging when I don't watch every minute. It merely passes 120vac through a big resistor (1500w heater) to limit current, then full wave rectifies it and feeds the pulsating DC into the battery pack. I manually do CV with smaller loads and a light dimmer. This is relatively light and small and has relatively low bulk, except for the heater which could be replaced with a small folding hair dryer.

My micro-controller version will add PWM to the above to achieve finer, programmable CC and CV control. Heater/resistor could then be removed for better efficiency and 3 pounds less weight. Yes, this ties straight to the AC line and thus I think could never be UL or CSA approved, and I'd have trouble recommending this approach to others due to shock hazard. Isolation transformer could fix, but at definite costs in terms of money, weight and bulk.

Such a charger has real advantages though; no costly/heavy/bulky: transformers, capacitors, DC->DC conversion, and other regulation components.
 
I have a working prototype of an Arduino based charger running now. :)

It's pretty simple. Just two cells of LiMn to test for now, the Arduino pulls power from the 2 cells, about 30-100 mA right now, but there are sleep modes for when I want to record/display cell stats while riding, and use it for "intelligent LVC" or with bike at rest to monitor self discharge.

Only current and lower cell voltage monitored at present, I will use resistor voltage dividers for other cells: 2:1 - 5:1 ratios to bring all under 5 volts. If any cell ever goes over 5v, I think I have bigger problems than worrying about exactly how much over.
The 6 analog inputs seem to have VERY high impedance; readings didn't drop at all with 470K resistor, so I can use big values and not worry about running down battery by monitoring.

Only using 1 digital output at present; runs to a 2N2222 I've had for decades, and some resistors. It shunts up to 0.5 amps or so. Currently shunts whole pack but I'm just testing the shunt concept now; if whole pack to shunt, it would be better just to interrupt current from charger instead of wasting power. Charger is currently putting out about 0.5 amps too, so charge and shunt are matched. IE. the shunt can dissipate all the charging current.

Code is so simple it's not funny. Just a loop that reads the voltage; if it's over or at 4.19v it turns shunt on; if it's under, it turns shunt on and charging resumes. Loop runs 1000 times per second. SO, IMO, this is "bit banged PWM". It works... :) DMM shows cell is in 4.19 to 4.18v range; occasionally I see 4.17 for whatever reason. Current through shunt tends to bounce around some value; it rose from 0 to 100 mA; I don't know why but currently only showing 30 mA or so (now 40).

It may be a challenge to find a simple shunting circuit that would work for higher cells, like cell 2 - 5 on my 5 cell YardWorks LiMn batts. I will see.

Voltages can be sent out the serial port/USB regularly for logging or display.

I ordered TME balancers last week,to use the I2C interface for monitoring cell voltages. Now I feel like I might be close enough to having my own balancers/BMS/charger/PC Interface working, I may not need the TME equipment. I could probably use the BIMs for I2C opto-isolation on 20s packs, even with my own devices.

Was thinking of making 5s4p packs though, for 27 KMH max and possibly better range and less concerns about high C rate discharges killing my batteries too early in their cycle lives. With 5s4p packs where all cells are undamaged and reasonably well matched, I could parallel all cells and need only 1 5 cell balancer/Interface etc. and not worry about isolation issues.

With 20s1p split into 4 batts with 5 cells each, I'd use the 4 TME balancers (or 4 of my own "Arduino Plus"'s) and the 2 BIMS (or some isolation board of my own). Hmmm, 5 virtual cells are a LOT less work (?) and worry than 20 real cells it seems.


I'm hooked on the Arduino now. Don't let the name throw you off like it did for me at first; it's wonderful, I promise. :) There are "Lillypad" Arduino's meant to be sewn into clothing. I could think of uses for that, like virtual VR type throttles dependent on whatever motion or sensable action you can measure. Heart-rate speed control, auto-braking on methane detection... list goes on. :mrgreen:

A hall or magnetic reed switch hookup and a console with LCD and buttons could complete the system hardware-wise and do bike computer / CA type stuff. A throttle connection in and out (Drive by wire ?) could be useful too, in addition to 3 axis accelerometers, GPS and some storage space. Perhaps an Eee PC or similar small Linux PC could do fancy graphs and real time display duties.


I have LOTS of professional software design/development experience, and I think a key route to getting things done quickly is to take the minimalist route; whatever gets the job done, simply and robustly. Smaller code is easier to read, change, debug or "prove correct", etc.

As an example, I'm imaging a bike computer / CA type device. To keep it simple, I'd avoid menus for main functionality. I'd just have fixed areas on the LCD for speed, distance, time, average speed, max speed and perhaps pack percentage left. Each displayed value would have one button to clear it; perhaps not needed for speed and pack %age though. In any case, the idea is that if you spend a few more bucks for a bigger LCD and a few more buttons, you may be able to avoid complicated code and User Interface / Menu issues.

For data-logging, simple lines of text via serial, or USB or I2C equivalent seems to be the way to go. A dedicated logging micro-controller could contain a CF or SD flash and just read and records the lines from multiple logging controllers.

Arduino has many "shields" available, which are cards that plug right in to add common peripherals etc. I'm looking to use off the shelf components as much as possible, and only build what makes sense to build. Micro-controllers can be like Lego, and I'd prefer to buy the Lego pieces ready-made and just add the system design and code.
 
Two ideas:
1.. Maybe the best solution is neither "CPU per cell" nor "one cpu for all" but rather something in between, perhaps one cpu per group of four or maybe eight cells. Here is my thinking:
- gives you enough voltage to properly regulate and filter the 12v down to 5v for the CPU to avoid EMI issues. You could use a simple low power linear regulator, give up a couple of microamps for simplicity.
- has plenty of voltage resolution, 0.015v or so. (16v / 10 bits)
- can use the PIC or Atmel's built in 4 or 8 channel mux.
- low cost and low component count.
- I don't mind paying for 6 optos, much better than 24.

2.. Re the 110v line connected charger that Mike (?) mentioned as tempting but possibly unsafe. I feel that temptation too. Although I was thinking along the lines of a PIC-controlled PWM thing, not a space heater. :)
The easy thing is to add a commercially purchased UL-approved GFI (ground fault interrupter) which is very light compared to the transformer you don't need. There is one on the cord of any newish hair dryer, for instance. That would provide good practical safety for us hackers. It might save my life or Mike's for the one time in a thousand when we are sloppy or unlucky. I think (not totally sure here) that it's possible to get UL certification for things like line-connected chargers that have GFI built in, so it might even work for commercial products.
 
Yes, a comprimise solution may be optimum from a cost standpoint. I'd be more inclined to think of 2 to 4 cells per MCU. The voltage differentials get pesky beyond that. The voltage regulator is another issue to deal with. Optos aren't that expensive, but good to optimize. I guess they could cost more than the MCU in some cases.

I've seen some 'Bad Boy' chargers before. The GFCI from a hair dryer or similar would be a must in my book. With the right capacitor for a current limiter it might be almost safe. Still scares me just thinking about it.
 
If I were building the BMS today I'd probably do 4 cells per CPU. 2 cells per has merit also. I like the LP2950 micropower regulator, and it's 1% accurate so it makes a decent Vref. But there is probably a less expensive solution.

Re the "bad boy charger", (I like that phrase!) haven't I seen large commercial chargers done that way? But I guess nowadays by the time you do a good switching power supply to efficiently regulate the line voltage down (or up!) to what the batteries need, it's only a small step to use a high-frequency transformer instead of the simple inductor.

The charger that comes with XM3500 is not that big or heavy. Throw it in the underseat storage bin, no problem. But I got a charger for a 60ah 72v pack from Elite, and the charger is huge and very heavy. I haven't opened it up yet to see why, but it's ugly!
 
I am referring to the circuit board design shown in this thread... I note that the power resistors will have the potential to have their leads broken over time. This would be due to metal fatigue from vibration as the body mass of the resistor moves. Just a thought.
Jeff K.
 
Thanks to all for the advice and support on this forum. I have run into a EV noise problem from my Honda Insight electric motor. It comes over signal and 0v from my Slaves boards and upsets my Master at present. I'll be reworking my layout with some decent screened cable and some clamping diodes/filtering over next few weeks. :roll:

As a temporary measure I have installed my system in an analog mode with the Master removed for upgrading with filtering etc. Seems to be working well now in my Li-fepo4 Honda Insight. I am using my digital slaves programmed with some analog control code and an analog temp master board to control my charger and over/under V alarms.

http://www.solarvan.co.uk/bms/ANALOG...211208_V01.TXT

http://www.solarvan.co.uk/bms/DigitalSlave080908.jpg

http://www.solarvan.co.uk/bms/AnalogueMaster010109.jpg

Went on a 45 mile test run yesterday and pushed mpg upto 112mpg from my previous norm in the current cold UK winter weather of about 93mpg. I'm hoping to break the 150mpg barrier in decent weather later :wink:
 
I noticed this thread just recently had become unstickied. Any chance that something of this monumental importance could be copied to an important "Archive" of some sort instead of just unstickifying it?

Anyways, I'm finding I need an LVC circuit and I think the PIC based system seems exceedingly easy for this. As far as I can imagine, it appears that the only thing it requires is a PIC(can be pretty cheap), a blah-blah-to-1 analog mux(16-to-1 for the 48 volt Lifepo4 folks), a few resistors for each LVC point, some programming that includes callibrating parameters and you're done! Pretty cheap! Especially since all I need to do to finish this circuit is the MUX and those are pretty cheap. No need to order many many different voltage comparators or other multiple-parts besides the multiple resistors for the resistive voltage dividers.

I'm also planning on constructing an array of single cell chargers using some custom circuitry, but I still need to arrange where I can cheaply generate a DC signal from AC for the simple current-limited linear regulators(It's an SLA charger variant schematic I found online - apparently there's one chip that's exceedingly easy to use to make an adjustable CC-CV charger). I probably should be looking at flyback converters...
 
Hello all,

Seems as if I am a bit late to chime in here but I've read through the entire thread (lengthy is not the word I would choose) and figured I'd add some comments:

To acheive a much better resolution for LVC and HVC, I am considering the following design:

1 x Atmega1280 (16 analog inputs, 10bit) as primary MCU - only handles LVC, HVC, TEMP interrupts from A2D MCU Atmega328P
2 x Atmega328P MCUs(dedicated 1 per 16 channels of voltage monitoring)
4 x 16x multiplexer (2 x per 16x channel)

My design will have the primary MCU generate the Reference voltage for the A2D converter onboard the Atmega328P. This will allow the primary MCU controller to dynamically adjust the BMS range based upon chemistry selected. Inital range will be 0-5v (standard) but if lipo is configured then range of ADC would be recentered between 2.75v and 4.40v for a measured range of 1.65v.

I will be using the crummy 10bit resolution but with prescaling (primary MCU controlled via OpAmp) and limited reference range (lipo use - could really be 2.9 to 4.30 for 1.4 v scale = 0.0013671875 v) to between 2.75 - 4.40v

at 1024 possible values (10bit) the resolution for my voltage window is: (1.65 / 1024 = 0.001611328125)

So .0016v per value - HVC will be centered around 4.20 but with this limited resolution... (4.20 - 2.75 = 1.45) 1.45v / 0.001611328125 = 899.87878787878787878787878787879
901 * 0.001611328125 = 1.451806640625 + 2.75 = 4.201806640625
900 * 0.001611328125 = 1.4501953125 + 2.75 = 4.2001953125
899 * 0.001611328125 = 1.448583984375 + 2.75 = 4.198583984375
890 * 0.001611328125 = 1.43408203125 + 2.75 = 4.18408203125

LVC will be at 3.3v (3.3 - 2.75 = .55) .55v / 0.001611328125 = 341.33333333333333333333333333333
340 * 0.001611328125 = 0.5478515625 + 2.75 = 3.2978515625 v


Does anyone see a issue with this design... I am only interested in monitoring the individual cell level voltages (hence the 32 channels of mux per 16 sample channels, I am muxing ground also to avoid having a very wide pack level voltage sense window. Easier to sum the readings to get pack v than to subtract sums of series voltage.

Any comments, questions, suggestions?

Thanks in advance,
Mike
 
dnmun,

From all I have learned about LiPo packs over the last few months, it seems all the experts agree that using a pack within certain tolerances and limits will extend the number of life cycles of the pack and the health of the cells. What noone seems to agree on is how much more lifetime you will see from your lipo pack (I'm trying to get it tested but I don't have even 12S1P to spare for the test).

The one thing they all seem to agree upon is: Never charge past 98% SOC - Approx 4.17256 v per cell.

Further they recommend widely varying cutout ranges from 3.0v to 3.4v, if my math is right... cutting out at 3.3v is right about the 25% remaining level. Also, LiPos I have seen tend to drop off like rocks when discharged below 3.0v.

Time will tell how effective this is but I have found enough expert testimonials which say about the same thing (cutout between 20% remaining - minimum and 40% remaining).

I hope that answers your question, search out methods and ilovephysics threads on LiPo... then do the industry research.

-Mike
 
I'm looking at using a single MCU to read the voltage across individual cells from an 8 channel differential input MUX. This MUX: http://focus.ti.com/lit/ds/symlink/mpc506.pdf

It promises:
ANALOG OVERVOLTAGE PROTECTION: 70VPP
NO CHANNEL INTERACTION DURING OVERVOLTAGE
BREAK-BEFORE-MAKE SWITCHING
ANALOG SIGNAL RANGE: ±15V
STANDBY POWER: 7.5mW typ
TRUE SECOND SOURCE

Does this mean I can connect the differential inputs across my LiPo pack cells? I connect ground to ground, naturally, and then the first input across my 3.7V cell, the second input across my 7.4V cell, and so on?
 
I don't think so. Although the inputs are protected to higher voltage the outputs are only +/-15 volts so you might get a 30 volt range with a ground at center tap of the battery, but I think that would be more trouble than it is worth. You could resistively divide all voltages by 10 and use a 0-5 volt input range, but in my experience with ATTiny's differential measurements with 10x gain are unreliable when there are large offsets.
What you really want is to switch the microprocessor among the batteries. A bunch of FET's could do that, or maybe reed switches around a rotating magnet. But with microprocessors <$2 each it's hard to imagine anything cheaper than a dedicated processor on each battery!
 
You could probably do at least two cells with an ATtiny. Maybe 4 cells. Then optocouple the cell processors to a main unit. There could be some advantages to one processor per cell however.

I'm real interested in making someting with the ATtiny, but I suck at writing code. Somebody wanna help me? Even a good example of the code might be enough for me to get the hang of it, like something that simply measures the cell voltage and sends it as data. I also need to activate the shunts at a programmed set point.
 
Back
Top