Awesome to see something like this out there. A BMS can get very advanced, and it would be very interesting to see a complex open-source system down the road.
I'm not sure I understand the balancing code. It looks to me like the gate is turned on for any cell over 3.509 V (the conditionals all depend on constants). Doesn't this unnecessarily drain your cells?
thats correct. I'm typing this on my phone bare with my short response.
From 20 to 80% state of charge. The cell voltage will be around 3.3v. When the battery gets charged to more than 3.5v, it is pretty much full. The bms will cut the charger off when the first cell reach 3.6v. Most cells will still be around 3.5. So the ones that are above 3.5 will get drain down to 3.5v and in turn balances there battery pack.
balancing battery is tricky, and this is just one simple algorithm I find to work fairly well.
I see, that makes sense. A potentially better (and still simple) algorithm you could use is to take the differences between the cell and the lowest cell, and try to balance to the lowest cell's value. This should give a slightly tighter pack, and has a side benefit of the ability to balance at any state of charge.
I can send a pull request if you'd like to do some benchmarking. :)
That also seems like a small voltage swing. Do you have any more information on the cells you're using? Maybe a voltage vs. SoC chart?
Actually my original algorithm did exactly that. The problem with that approach is the amount of energy required to change the cell voltage by 0.1V goes up exponentially once it's below 3.5V, where the charge curve flattens out. An example would be a 40% state of charge battery could be 3.30V and a 60% state of charge battery would be 3.33V. When the batteries are usually about 1-3% difference in SoC, it become very difficult to balance them based on just looking at the voltage alone. The measuring error is probably more than the actual voltage difference. That why I decided to not bother balancing the battery once they are below 3.5V.
The numbers I'm getting is for LiFePo4. There are many other chemistry of Li-on variant, and LiFePo4 so far is the safest. It does not burn up like the ones in your laptop, but at the cost of slightly less energy density.
A Battery Management System contains all the onboard controls necessary for a battery to manage its components. Depending on the complexity of the battery, this includes when to (dis)charge, temperature control, cell balancing, high voltage connections, safety monitoring, and more. A good BMS is crucial in using a battery efficiently and maintaining a long life.
An open-source BMS could play a huge role in the advancement of battery technology. If only automakers would do the same. :)
Excuse my EEE ignorance, but can this be scaled down to say a small robot (think Roomba size), or even smaller to a Li-on battery backup for something like a Beagleboard/Pandaboard?
This is indeed awesome. I was literally just thinking about the importance and potential of something like this. FLUX Power bms are too expensive but remarkable technology. Thanks for doing this. It is open technology like this that will change the market for electric cars.
I'm not sure I understand the balancing code. It looks to me like the gate is turned on for any cell over 3.509 V (the conditionals all depend on constants). Doesn't this unnecessarily drain your cells?