BMS based on ltc 6804 and arduino
This thread will document my progress on my personal project for creating a BMS system based on a LTC6804 in combination with an atmega328p-au
Current Status: Beta testing/ Onhold
Microcontroller, the atmega328p-au, This one is chosen because of its possibly to be programmed via the arduino language. Right now I feel the most comfortable programming in this, plus its very well documented. However in future iteration I would like to look into having a micro with integrated canbus controller.
Can controller, MCP2515, this one is chosen because of its proven track record and ease of use with the arduino language.
Cell voltage readout, here i chose for a dedicated chip the ltc6804-1, this removes the complex circuits needed for high voltage isolation and accuracy maintenance. This however this comes at a price of 1.3 euros per cell, seeing the added ability this is taken for granted. The biggest downside however is the availability of this chip, I have 4 chips to test with, one is already in use. Once one circuit is proven to work I will have to look into sourcing them direct from Linear.
Power , using the LTC6804 chip there is a choice to convert the measured voltage down to a stable 5 volts for powering the micorcontroller side of things. However this option is not chosen, it brings with it a higher current draw during sleep mode (or power off), instead the power is fed in via 12 volts and converted to 5 volts then isolated for the microcontroller side. This allows the 12 volts to be removed, by and external microcontroller, in case of system shutdown. This gives you a high voltage drain of below 3 micro amps, which is ideal for projects that remain stationary for along time.
Communication, For the communication between the slaves and the rest of the system I chose for a can bus system due to its robustness and ease of programming and use. Plus the ability to use off the shelf components to read out data.
Price Looking at my bom list setup for amounts of 25 I get a cost of around 27 euro per board, 2,25 euro per cell, which is very acceptable this level of monitoring.
layout 1 18-8.jpg
This is my first pcb design I am having made for me. So i hope this goes well. there are two high voltage connectors, one for the cell voltages (single row) and one for the balance board add-on (dual row). This is done so the size for the balance resistors and transistors can be decided dependent on the battery pack.
Software As a basis i will be using the library written by linear themselves, this has proven to work on my breadboard.
The LTC6804-1 provides the following variables for the micro over an SPI bus;
- 12 16 bit cell voltages
- 5 12 bit auxiliary voltages
- 12 cell discharge controls
These will be used to manage the cells on the slave board, according to the set parameters.
The LTC6804-1 does not automatically switch on or off the discharge resistors, these will be controller by the bms slave board micro. This will allow the programming of balance set points.
Once the bms micro has gotten the data from the LTC6804 it places the following information on the canbus, after boot up.
- Cell voltages
- Aux voltages
- Discharge switches
- Status, containing opmode and errors
The following op-modes have been defined;
- Boot, during initialization after power on checks all cell levels on discharge possible
- Standby, nearly no system discharge; charge and drivetrain off
- Drive, drivetrain engaged, main task is to monitor high and low voltage errors and temperatures (aux voltages)
- Charge, monitor overvoltage and cell drift and temperature
Right now I am planning on spacing the canbus messages from the BMS-slaves in such a way I could have 25 boards on one bus without causing message conflicts, this would give me room for 300 cells in whatever configuration desired. Also the message latency will be minimal.
The "Master" micro will collect the data from all the slave boards and monitor the complete pack variance, under/over voltage signals. These trigger points will be set via can messages dictating charge balance voltage (so you can balance at any desired voltage), under/over voltage (in order to protect the cells). Also these variables can be set for the aux voltage to trigger over temp signals. However the canbus transmitted data will be as raw as possible so any sensors can be used without reprogramming the slaves. My goal is to get the slaves running with as low a calculation load as possible, just total voltage and voltage delta and error handling.
PCB's should arrive this week, which means I can start ordering parts and compiling some code.
If you have any idea's that you would like to contribute please do.
Note: this is not meant as a discussion about having a bms or not...
Last edited by tomdb; 28 May 2016 at 0316.
Post Thanks / Like - 1 Likes
Fun! Keeping a keen eye on this one.
PCB's arrived, time to get testing the boards. Also a good excuse to build up my reflow oven with ofcourse an arduino brain.
Also orders placed for the components I do not have on hand. Now its waiting time.
Last edited by tomdb; 17 September 2015 at 1127.
Good project to tackle! Will keep my eyes on this one
Got the it reflowed, now time for testing and the programming.
Update 7 oct. 2015
Found two flaws, one "broken" trace, turned out to be my own dumb fault accidentally deleted a signal in the schematic, so the board isolated the trace from the pad. Fixed with a lil scratching and solder.
Bootloader burned after a few attempts, due to inexperience. However once the bootloader was on the chip seemed dead. Turns out that the ATmega328 require VccA to be hooked to 5v olts for it to work with the bootloader,
Updated my pcb in eagle, botched the board and it works. This means with a simple serial connection and ftdi-usb I am able to program. Got to finish soldering on the canbus connectors and the DC-DC converters and then the real testing can start.
Post Thanks / Like - 1 Likes
Had some set backs, got alot of noise on the SPI bus, I will have to rebuild the whole pcb. Rerouted the SPI bus for noise reduction and got some pads for pull up resistors and probing.
So kind of disappointing, however a very great experience in pcb design and trouble shooting.
New PCB's ordered. Now i can cannibalize the built pcb to test the separate parts .
Update 13-10-15 : Got the SDO SDI, MOSI, MOSI, SO, SI messed up on the LTC6804, this is why i was seeing the strange behavior.
Lesson learned, always look over you schematic after a week of doing something else before commencing a pcb. Lucky pcb order was not processed so updated the board en resent.
Guess this will teach me to think it all works, now some software making with a breadboard build up.
Last edited by tomdb; 13 October 2015 at 1224.
My code is coming along nicely on my bread board setup.
The "slave" arduino setup nicely listens to the "master" arduino over the canbus and tells him the voltages when requested.
Now its just down to setting up and programming a state machine for both.
Got my new pcb's last week. Built it up to working with the isolated can-bus section. some solder connections were not the best, so some troubleshooting was required.
However this means, i can finish populating the board with my second to last LTC6804, lets hope this goes well. Then i can flash my program from the bread board setup and get to some real testing.
If all goes well, I will have to put an order in for the LTC6804's at something like 13 euro's a piece. So stay tuned for some updates this week.