Page 1 of 61

Old BMS Software Thread

Posted: Mon Jun 15, 2009 9:38 am
by retepsnikrep
Edit by Peter 10/08/09

Welcome to my opensource free BMS thread.
I have added some basic at a glance specs for the working BMS now. And a few basic pics of the setup. I strongly recommend you read all of this first post and wade through as much of the three threads as you can to understand how it all works, was developed and fits together :wink:

Specs for Modules are as follows.

*********** Slave Module Specification **********

Approx Parts Cost inc pcb $5.00 each.
One slave module per Lithium Cell.
Supply/Cell Voltage 1.75 - 5.00V DC.
Average Supply Current at 3.35v <1ma.
Voltage Ref LM 385 1.235V accuracy 1% Supply/Cell.
Voltage sensing maximum accuracy +/- 20mv.
Maximum balancing/bypass current with 15R resistor 333ma at 5.00V. Maximum Serial Master Bus data rate 4800 baud.
Maximum cell Capacity 65ah. Can be increased to 650ah.
Maximum 128 Slave Modules per Master Module.
Can be increased to 255 Modules using 28X2 Picaxe.
Slave CPU Speed 8mhz with internal resonator.
Permitted Working Cell Voltage Range 1.75 - 4.30V.

************ Master Module Specification *************

Approx Parts Cost inc pcb $100.00 each.
One Master module per complete system.
Supply Voltage 8.00-30.00V DC or as limited by 5.00V 78L05 regulator.
CPU Supply Voltage 5.00V.
CPU Speed 8mhz with internal resonator.
Average Board Supply Current at 12.00v <100ma.
Maximum Serial Master Bus data rate 4800 baud.
Maximum Cell Capacity 65ah. Can be increased to 650ah.
Maximum Pack Voltage 650v.
Maximum Charge/Discharge rate depends on current sensor used.
Maximum 128 Slave Modules per Master Module.
Can be increased to 255 Modules using 28X2 Picaxe.
Battery Pack Temp Sensor Range (-25 to +100C).
Composite Video Display data rate 9600 baud (SV2000 Video Chip).
Composite RCA Video Monitor Output 1V 75ohm PAL/NTSC.
Charger relay output is board supply voltage max 30v at 500ma.
Opto Isolated Charger/Controller Cutback outputs max 50ma 50v.
The Video display is limited to 16x9 characters in a 0-15 & 0-8 matrix.

Pictures & Videos

Digital Slave Schematic.

Early test run of Slaves & Master with display from 2008.

Latest software display showing various info.

Youtube BMS Tour Videos. Note there are several available from 2008.

Hope that helps.


Dear All

This BMS thread had grown a bit too large, so I'm am starting two additional threads to run alongside the original one.

This BMS General thread contains all the work/discussion upto 15/06/09. ... php?t=1245

The BMS Hardware thread will contain any new work/discussion related to the hardware. ... php?t=2059

The BMS Software thread will contain any new work/discussion related to the software. ... php?t=2060

I hope this makes it a bit more manageable.

New readers should work through the General thread first until they reach 15/06/09, they should then look at specific hardware/software/general threads for further info.

Thanks Peter

Posted: Mon Jun 15, 2009 4:17 pm
by retepsnikrep
I've now replaced my bad lifep04 cell with a brand new one which arrived whilst I was away on holiday.

I've done a bit of manual balancing on the bench to bring it in line with the others in the pack.

I've also reprogrammed all my slave BMS boards to allow a slightly wider working cell voltage range.

Maximum Cell Voltage Opto On > 3.80V (High Cell V Alarm On)
Maximum Cell Voltage Opto Off < 3.75V (High Cell V Alarm Off)

Balancing load/bypass cut in Voltage > 3.70V (Load cut in point)
Balancing load/bypass cut out Voltage < 3.65V (Load cut out point)

Minimum Cell Voltage Opto On < 2.30V (Low Cell V Alarm On )
Minimum Cell Voltage Opto Off > 2.35V (Low Cell V Alarm Off)

I also tweaked the Zivan output voltage up another 5 volts to 185V Max during CV stage.

Still working on half a dozen different projects but I will move my cells and upgrade to the Master board system before autumn!!

Posted: Tue Jun 16, 2009 10:34 am
by GregsGarage

Good idea to split the thread up into software and hardware. Maybe you could create links in the first posts to the other threads. Over time they may drift apart in the forum pages, particularly the original thread if it no longer gets any posts.

I have started to look at the master and digital slave software. One thing that will need to be addressed is the 65ah cell limit. How about a multiplyer of some sort that could be set for individual requirements. For example a multiplyer of 2 would suit me for my planned 100 ah cells. A multiplyer of 3 for up to 195ah, etc. I don't know how easy it would be to implement, do you have any other ideas on this?

Curent Counting and 65A limit

Posted: Tue Jun 16, 2009 12:25 pm
by retepsnikrep
The 65.535A limit is based on the max numeric value that can be stored in a 16bit word 65535. I set it to 65A in the Master to allow me the full resolution for current counting as my cells are only 40Ah.

We can just move the decimal point across one to give a 655A capacity and we still have two decimal places of resolution for current counting. Some tweaks will be reqd in software but it should be fairly easy. Small loss of resolution.

You need a Master set up on bench with a known current flowing though your choosen sensor and then we can calibrate/tinker with the software to get the display/counting right.

The Variables Charge & Discharge contain a running total of the charge or discharge for a minute based on current readings taken every second approx. Each current reading is subject to x10 oversampling and an average obtained to reduce errors.

The Variable SocCounter actually counts the number of times the current readings have been taken, and is used as the divisor to calculate the average for each minute.

If the system is charging the charge current reading is added to the running total Charge variable, ditto discharging which is added to the Discharge variable.

At the end of the minute the charge and discharge variables are divided by the variable SocCounter to get the average charge and/or discharge for the last minute.

The charge variable is then added to the variable Soc and the discharge variable is subtracted from the variable Soc

The Soc is only updated each minute, but current readings are taken once a second approx. The system variable Timer increments every second in the background, and is used to determine when a minute has elapsed.

Working with the 16bit word limit 65535 we have to be careful that the running total Charge/Discharge does not exceed the variable limit or an overflow occurs and the data for that minute is corrupted.

As you suggest we could just fake it by setting capacity to 50ah and then multiplying the Soc x 2 before displaying it on the screen! Hmm have to think about that. A lot depends on your choosen current sensor.

The Allegro current sensor I used is now available in a +/- 200A version. ... 8/0758.pdf

Posted: Sat Jun 20, 2009 12:00 am
by steiner

I have been looking at your code for the Master and had a question. In the "check cells" routine you have these two lines of code:

PackVoltage = PackVoltage / 100 ;Get first part of decimal value (Before decimal point)
poke PackV, WORD PackVoltage ;Store Pack Voltage in PackV Ram Word

My question is why are you discarding the value of the battery pack voltage after the decimal value? Is it because you only want to display pack voltage in whole numbers or am I missing something?

Posted: Sat Jun 20, 2009 4:24 am
by retepsnikrep

I can't see any reason to need better than 1v accuracy on a 160v ish pack, anything after the decimal point is discarded once the full pack voltage has been measured. It also makes it easier to fit onto the display and simplifies the display routine. It would be possible to display the full value but that's a bit more complicated.

Posted: Sat Jun 27, 2009 11:45 pm
by steiner

For some reason I am having trouble programming the watchdog IC. I have successfully programmed two of the slaves and the master but all I get is "Hardware not found on Com1" when I try to program the watchdog. I have verified I am getting 5 volts between pins 1 and 8 on the watchdog IC. I verified I have the mode set to 08M and 4 Mhz. I have also tested the Com1 port and it tests positive. I then switched chips for the watchdog IC to see if I possibly had a bad chip. The second one gave the same results.

Any suggestions????


Posted: Sun Jun 28, 2009 5:52 am
by retepsnikrep

THe master board will work without the watchdog, but that is strange.

Do the chips you tried in the watchdog, program in the slave boards ok afterwards?

Triple check the Master board and components for the watchdog especially the 22k and 10k resistors on the prgramming pins. Note the pin orientation on the watchdog prog pins.

Sometimes it won't program if the board is powered up when you press the program button, you have to press the program button in the editor first and then power up the board within a second or so.

Must be something simple, It's possible you have a duff chip of course.

I suggest if all above fails make a small programming board with some veroboard/stripboard.

That only need the two resistors.

Consult the picaxe docs for the minimum 08M operating requirements. Then program them using your little board and re-insert into main board.

Posted: Sun Jun 28, 2009 5:50 pm
by steiner
For now I am just going to rem out the watchdog portion of the code. I had already verified the 10k and 22k resistors. I will see if it will work with one of the two known working chips in the slaves. If not, I will try your power-up trick.

I am about to power everything up and wanted to make certain I had the connections correct.

J11 on master to J2 on the lowest voltage slave (pin1 to pin1)
J4 on lowest slave to J2 on next higher voltage slave (pin1 to pin1)
J13 on master to J3 on the lowest voltage slave (pin1 to pin1)
J3 on each slave to J3 on next higher voltage slave (pin1 to pin1)
Jumper 1 and Jumper 2 connected on each slave

I have left Jumper 4 off of the master since I am currently not operating with the watchdog IC.

Does this sound correct?

Posted: Sun Jun 28, 2009 6:09 pm
by retepsnikrep
J11 on master to J2 on the lowest voltage slave (pin1 to pin1) Correct

J4 on lowest slave to J2 on next higher voltage slave (pin1 to pin1) Correct

J13 on master to J3 on the lowest voltage slave (pin1 to pin1) Correct

J3 on each slave to J3 on next higher voltage slave (pin1 to pin1) Correct

Jumper 1 and Jumper 2 connected on each slave Correct

All correct I think.

Remember to set the Master software Cells constant to the number of Cells/slaves you have.

symbol Cells = 50 ;Number of cells in the battery pack (50) (Max is 128 cells)

Remember to watch out for remed out code. I think the Master version I sent you has the cell check voltage disabled.

Look for (`) at the start of the line "gosub CheckCells ;Gosub CheckCells routine to collect/display Cell V data" it's in the main loop section. Remove the (`) to activate that section

This constant is also important

symbol CutInV = 360 ;Balancing load/bypass cut in Voltage (This must match value set in Slaves)
symbol CutOutV = 355 ;Balancing load/bypass cut out Voltage (This must match value set in Slaves)

Expect some errors I haven't tried the Master & Slave digital code in earnest for 6 months :shock: Just too busy.

Do you have some cells to mount the slaves on?

Use twisted pair wire for the inter slave connections and possibly screened twisted pair for the master bus interconnects.

Good Luck! 8)

Please post some pics, what display are you using?