# Using microcontroller platform for BMS



## dcb (Dec 5, 2009)

I like that they have an actual license statement. Not just another project pretending to be open source.



begers said:


> 16 bit A/D chips


First impression, 16 bits and beagle are probably overkill, but it looks reasonably well thought out. At 8 cells, this sort of topography is fine.


ah, the ads1115. Nice. It looks like they have balance resistors in place as well. 

I see a problem with the resistor network
https://github.com/simat/BatteryMonitor/blob/master/ResistorDivider.pdf
r19, r20, r22, r28, those are crazy low values, I *think* the author meant to put them in series with the higher valued resistors, but they will kill a 10ah battery dead in about a week as is. Also the main dividers are too low, and not scaled to get full effect of aref as you go down the stack.

Basically it is probably a bit premature to get too specific about the hardware, and all the different possibilities and whatnot, without knowing exactly what it is you want the thing to do (and not do) in the first place.

Do you want it to override charging to protect the cells? override discharging? balancing(overrated)? report everything? or just issues, like out of balance or cell too high/low? How about temperature? 

I think, having spotted an issue so quickly, I would set your expectations accordingly on this.


----------



## kennybobby (Aug 10, 2012)

Good catch and good advice. 

Why do you suppose he put those shorting resistors in there, e.g. between cell 8+ and cell 7+? since 7+ is also connected to 8- it looks like a bleed of cell 8...?


----------



## dcb (Dec 5, 2009)

I don't really know, but I have done similiar things to even out the discharge, since cell1 will draw more than the rest otherwise. Perhaps the extra parallel ones were an attempt to use standard resistors or something.

But here is a 6 cell 5v adc example (fwiw, would like to do this @3.3v with an mbed enabled nucleo with 6+ 12 bit adc channels at some point).

so without r13-r17, v1 would drain at 2.4ma and v6 would drain at 0.4ma, and it would create an imbalance.

but with them they all draw 2.4ma (@4v).

Also I modify the dividers for max dynamic range single ended conversion based on cell position. The OP does single ended, but it is leaving a lot of resolution on the table lower in the stack, which has a cumulative effect as you go up the stack.

i.e. here adc4 is 4 volts, but represents 20 volts up the stack, so with 5v aref and 12 bits, each count is 0.0048v. adc5 represents the top of the stack at 24v, scaled to 4v here, so each count is 0.0058v. Which is well more than accurate enough in this sort of application.

fwiw, this particular example should plug right into an arduino uno, @ 10 bits and 6 adc, it is good for 0.023v +-0.019v, which is also probably good enough if you leave some safety margin on charge/discharge. But I think people need to ween off of arduino a bit (it is lacking in hybrid vigor)


----------



## dcb (Dec 5, 2009)

but at some point I started suspecting that "balancing" was a "feature" that various vendors sell you on, because their bms creates the imbalance in the first place...

So I slapped this together, and sleep well at night.
http://www.diyelectriccar.com/forum...-pack-balance-monitor-batt-bridge-165953.html

if I see a significant imbalance, that is my "service engine" light, and I get out the multimeter and fix it, haven't had to yet.


----------



## begers (Dec 23, 2015)

dcb said:


> Basically it is probably a bit premature to get too specific about the hardware, and all the different possibilities and whatnot, without knowing exactly what it is you want the thing to do (and not do) in the first place.
> 
> Do you want it to override charging to protect the cells? override discharging? balancing(overrated)? report everything? or just issues, like out of balance or cell too high/low? How about temperature?


dcb, thank you for your reply! I have to learn a lot!

I need basic BMS functions:
1. HVC cut off
2. LVC cut off
3. Top balancing(shunting) 
+ couple of handy features to have:
4. voltage cell log
5. remote configuration and data accessibility

Temperature i not needed, reporting is not required - just logging that can be remotely accessed.

p.s. i am pretty sure i can cover the software part, it's circuits/hardware that i know nothing about


----------



## dcb (Dec 5, 2009)

begers said:


> p.s. i am pretty sure i can cover the software part, it's circuits/hardware that i know nothing about


You have to understand that microcontrollers are within the margins of hardware and software. You can't really be effective at microcontrollers without understanding both. You have to be a screwdriver carrying programmer.


----------



## simat (Mar 25, 2013)

dcb said:


> I see a problem with the resistor network
> https://github.com/simat/BatteryMonitor/blob/master/ResistorDivider.pdf
> r19, r20, r22, r28, those are crazy low values, I *think* the author meant to put them in series with the higher valued resistors, but they will kill a 10ah battery dead in about a week as is. Also the main dividers are too low, and not scaled to get full effect of aref as you go down the stack.


You are correct that those resistors should have been in series, I made a mistake with the circuit diagram, thanks for pointing it out. I have fixed it and also uploaded the balance resistor calculation spreadsheet.

The main dividers values were chosen to give good noise immunity, while still giving a reasonable current consumption of ~3.3mA which is less than 5% of the total battery monitor consumption. The values I chose were ones I could get at a good price. If you want to use other values you can, just keep the ratios the same. As the monitor can be calibrated you could probably get by with 1% resistors but if you want high accuracy make sure they have low temperature and age drift. I don't see any point in varying the divider gain for different cells in the battery as the resolution is limited by the cell at the positive end of the battery. By keeping all the divider resistors the same values and hopefully from the same manufactured batch you should end up with better overall accuracy.

This project was designed to monitor batteries in off-grid solar powered applications where the batteries are going to get charged every day and will probably be > 100Ah is size.

This project has been installed on two off-grid systems for over a year now. For my own system it is great to be able to check my battery, even when I am away from home and for the other system to be able to monitor the battery and change the software remotely. Of course the detailed logging will be good to see just how well LFP batteries operate over the longer term in this application. So far my nearly three year old battery is doing very well.

Simon


----------



## simat (Mar 25, 2013)

begers said:


> I need basic BMS functions:
> 1. HVC cut off
> 2. LVC cut off
> 3. Top balancing(shunting)
> ...


I think individual cell voltage HVC and LVC or at least some sort of HV and LV alarm are pretty important especially for off-grid power systems where the battery is being cycled continuously.

I agree with dcb regarding automatic balancing. Unless it is done correctly I think it can make matters worse. In my case I have found that my battery goes out of balance very slowly. I don't have any shunt boards on my battery. I do a manual balance only when needed which is about every ten months or so.

Simon


----------



## begers (Dec 23, 2015)

Simon,

thank you for joining the thread.
Will your BMS circuit work with ardruino?

I am thinking about choosing arduino to lower the power consumption.
I will have to rewrite the code though(arduino doesn't work with python very well)

Are the any cons in ardruino based bms?


----------



## browncamaroz28 (May 14, 2014)

begers said:


> Simon,
> 
> thank you for joining the thread.
> Will your BMS circuit work with ardruino?
> ...


There are some challenges but nothing that cant be overcome.

These guys have done some good work on the subject http://blog.fiftythree.com/posts/measuring-battery-voltage


----------



## simat (Mar 25, 2013)

begers said:


> Will your BMS circuit work with ardruino?


Yes, the A/D converters communicate with the micro via I2C bus. I think there is a hardware I2C bus on the Arduino, if not I am sure there is a software implementation. You might have to write the drivers for the A/Ds and then rewrite all the software and fit it in the Arduino memory and then there is all the web based stuff, and ,and, and...



> I am thinking about choosing arduino to lower the power consumption.
> I will have to rewrite the code though(arduino doesn't work with python very well)
> 
> Are the any cons in ardruino based bms?


For this sort of project if you want log or access the battery information remotely I think the Arduino is far too limited, much better going with a board that runs Linux so you get all the web stuff and much easier to program. You could look at some lower power boards like the Raspberry Pi Zero or the Intel Galileo, they might do the job

If you want a standalone really basic BMS with limited opportunities for expansion, I suppose the Arduino is OK.

Simon


----------

