LTC6802 based 12 cell slave.

Threads relating to the BMS system begun by Peter Perkins

Moderators: GregsGarage, retepsnikrep

GregsGarage
Posts: 870
Joined: Tue Apr 01, 2008 5:27 pm
Location: Galashiels, Scottish Borders
Contact:

Re: LTC6802 based 12 cell slave.

Postby GregsGarage » Thu Feb 28, 2013 11:23 pm

Some of you may recall a while back I proposed a central point for all files related to this bms project. I had opened an account with launchpad.net but never really got my head 'round it. :oops: I'm sure it's fine for programmers, but for the rest of us something simpler is needed. The forum is very simple, but then you have to go trawling through it to find the files you need. So I am trying a new site, github.com. I've made a start with an account and have uploaded my current slave software in the master branch and a testing branch where I am working on a new command "200" that is a simple "tell me the cell voltages". Currently you have to send command $04 to initialize the 6802 and then a $10 to read the cell voltages. A slave that recieves command "200" will first send $04 to the next slave and then $10. This makes the master software a bit simpler. The first slave becames a sort of sudo master, but all slaves have the same software. 8)

The code is here, https://github.com/Greg-Fordyce/evBMS. You don't need an account to view and download files, but it is quite simple to setup one and install the software for the full git experience. :mrgreen:
Greg Fordyce

Daewoo Matiz
http://www.evalbum.com/4191

GregsGarage
Posts: 870
Joined: Tue Apr 01, 2008 5:27 pm
Location: Galashiels, Scottish Borders
Contact:

Re: LTC6802 based 12 cell slave.

Postby GregsGarage » Sat Mar 02, 2013 8:44 pm

I've added a new command "200". Sending the ASCII character 200 on the slave bus will be recieved by the first slave. It will then send command 0x04 to the next slaves (6802 does A/D and loads cell values into its register) and then sends 0x10 to the next slaves which gets the cell data returned to the master. So instead of a 2 step process to read cell voltages, it is now a single command. 8) Of course you still have the option of sending 2 seperate commands if you wanted. :)

Latest code can be found on https://github.com/Greg-Fordyce/evBMS/tree/master/6802Slave

On github you may notice a button labelled branch. At the moment I am using 2 branches. The master branch will always have a version of software that is being used in my vehicle. The testing branch is for development. Of course this could change depending on when you are reading this message. :wink:
Greg Fordyce

Daewoo Matiz
http://www.evalbum.com/4191

GregsGarage
Posts: 870
Joined: Tue Apr 01, 2008 5:27 pm
Location: Galashiels, Scottish Borders
Contact:

Re: LTC6802 based 12 cell slave.

Postby GregsGarage » Mon Mar 04, 2013 11:44 am

GregsGarage wrote:Next item will be a current sensor connected to the master/slave bus. I can use the same basic design but instead of using a 6802 put a allegro or similair current sensor on the slave. The pic can be set to take current readings every 10ms maybe and keep a tally of amp hours in out and then send the data back on the master bus when requested. We can have a separate command for reading current data that is ignored by voltage monitoring slaves (they would just relay the command on the slave bus) and vice-versa for current commands. There is no reason you couldn't have multipile sensors, one for motor, one for charging if you wanted.


I have just realized I don't need to do a seperate current sensor slave. The ICSP header provides +5v, earth and 3 I/O pins. With some clever coding it should be possible to plug in a current sensor to any of the slaves. 8)

EDIT: made a start with some simple code, posted to github.
Greg Fordyce

Daewoo Matiz
http://www.evalbum.com/4191

GregsGarage
Posts: 870
Joined: Tue Apr 01, 2008 5:27 pm
Location: Galashiels, Scottish Borders
Contact:

Re: LTC6802 based 12 cell slave.

Postby GregsGarage » Thu Mar 07, 2013 10:24 am

:D :D :D I've just managed to connect my allegro current sensor to slave 1 and it works! :D :D :D

I am plugging it onto the ICSP header. The code is very crude at the moment, basically just copied and pasted Peter's current sensor routines from master V2 into the slave. The CheckCurrent routine runs directly after the cell voltages are read on the 6802, so voltage and current measurements are as close as possible to being in sync with each other. 8)
I am going to use the MCLR pin as a input to detect a sensor connected to the slave by tying it to Vdd in the connector. So you would be able to connect a current sensor to any slave or even multiple current sensors if you wanted. Only slaves with a current sensor connected would run the commands, no sensor and it will just pass the command along on the slave bus. I'll update github after some more work on the code.
Greg Fordyce

Daewoo Matiz
http://www.evalbum.com/4191

GregsGarage
Posts: 870
Joined: Tue Apr 01, 2008 5:27 pm
Location: Galashiels, Scottish Borders
Contact:

Re: LTC6802 based 12 cell slave.

Postby GregsGarage » Fri Mar 08, 2013 9:06 pm

I've changed direction slightly, instead of getting the slave to calculate current I am sending the raw adc value to the master and converting it into amps there. Several advantages to this approach. Speeds up slave software development and doesn't tie the slave to only working with a particular sensor. As a matter of fact you could tack anything onto a slave as long as it can be read with a analogue input.

I'm going to use the same approach for the last bit of the slave that I need to get working, the temperature measurements. Each slave can output 3 temp readings, 2 cell temp and one die temp. I'll convert the die temp reading to celcius and output the raw cell readings to be converted by the master.

I'm also considering adding some current limiting resistors onto the ICSP port for a bit of protection. I'll experiment and make sure they don't interfere with the programming. Github has latest updates.
Greg Fordyce

Daewoo Matiz
http://www.evalbum.com/4191

GregsGarage
Posts: 870
Joined: Tue Apr 01, 2008 5:27 pm
Location: Galashiels, Scottish Borders
Contact:

Re: LTC6802 based 12 cell slave.

Postby GregsGarage » Sat Mar 09, 2013 6:06 pm

Slave code is finished! :shock: Well not really, :lol: but it is at a level that all the basic functions work. The slaves can report cell voltage, temperature and current to the master. 8) A list of the slave commands are below.

Code: Select all

' Command $01 (WRCFG)  = Write configuration register group      
' Command $02 (RDCFG)  = Read configuration register group
' Command $03          = Report Slave Software Version Number               

' Command $04 (RDCV)   = Read cell voltage register group   
' Command $07          = Turn On Slave Load for 0.5 seconds (Flash Led)
' Command $08 (RDTMP)  = Read Temperature register group
' Command $10 (STCVAD) = Start Cell Voltage A/D conversion
' Command $20 (STOWAD) = Start Open-Wire A/D conversion
' Command $30 (STMPAD) = Start Temperature A/D conversion
' Command 200          = Start Cell A/D and read cell voltages in one command
' Command 201          = Start Temp   A/D and read temperatures in one command
' Command 202          = Start current sensor A/D and read amps in one command


But you only need to use the last 3 commands 200 - 202. So 3 simple commands and you get a comma seperated response on the master bus.

200 returns cell voltages, format is voltage/100 so 334 = 3.34 volts

201 returns temperatures, format is 2 raw adc values for cell temp sensors followed by 6802 temp in Celsius for each slave. The raw adc values means you have to calculate temp in the master depending on your chosen sensor.

202 returns current reading taking at the same time command 200 was received (Always do command 200 followed by 202, not the other way around). This is the raw ADC value from the pic (0 - 1024). Master will need to convert this to amps depending on chosen sensor. Multiole current sensors are possible, one for each slave and with some changes to the slave code 2 sensors per slave are possible. Really any input that can be read by the pic adc is possible. 8)

Next task will be to get the latest slave layout done in kicad and get some boards made.
Greg Fordyce

Daewoo Matiz
http://www.evalbum.com/4191

GregsGarage
Posts: 870
Joined: Tue Apr 01, 2008 5:27 pm
Location: Galashiels, Scottish Borders
Contact:

Re: LTC6802 based 12 cell slave.

Postby GregsGarage » Sun Mar 24, 2013 10:53 pm

Image

PCB layout nearly done, just need to carefully check for errors and I want to add some mounting holes. Size of the pcb is approx 50mm x 80mm. Just need to settle on a suitable enclosure for it.

More images on github along with the kicad files.
Greg Fordyce

Daewoo Matiz
http://www.evalbum.com/4191

ElectricBicycleLove
Posts: 2
Joined: Sat Mar 30, 2013 5:51 pm

Re: LTC6802 based 12 cell slave.

Postby ElectricBicycleLove » Sat Mar 30, 2013 7:42 pm

Hello Greg.

I found your message when searching for LTC6802. I (and others) trying to build an OpenSource cell monitor and seems you just did most of what we are looking for!! Even you use KiCad, which is what I was looking for -- I will reuse your schmatic and PCB symbol :-)
We also use Git/Github :-)

On our planned BMS we will use cheap Bluetooth module so we can monitor de battery with a SmartPhone. We also have I2C communications with a Dash Board.

Thank you for sharing. I did read all the thread and is great all the knowledge your shared about LTC6802.

We plan to use an ARM 32bits microcontroller STM32F100 because it haves specific hardware for Brushless Motor control (I use it on my motor controller) -- we will reuse the firmware and so use the same microcontroller. We will code the firmware in C.

Thank you for sharing!! OpenSource really matters on electric vehicles.

GregsGarage
Posts: 870
Joined: Tue Apr 01, 2008 5:27 pm
Location: Galashiels, Scottish Borders
Contact:

Re: LTC6802 based 12 cell slave.

Postby GregsGarage » Sun Mar 31, 2013 9:38 pm

Looks like a nice project. :D By keeping the slave modules separate from the master means you are free to use whatever communications protocol you like (bluetooth, CAN, RS485, etc.). Just design it into your master or incorporate it into your existing controller. Another advantage of keeping the slaves separate means you aren't tied to just using the 6802. There are other similar chips from various manufactures and if for some reason the 6802-2 becomes scarce and you have to change chips it is only the slaves that have to be redesigned, instead of the everything. Keep us up to date with your progress. I am hoping to have some of these slave boards available in May.
Greg Fordyce

Daewoo Matiz
http://www.evalbum.com/4191

GregsGarage
Posts: 870
Joined: Tue Apr 01, 2008 5:27 pm
Location: Galashiels, Scottish Borders
Contact:

Re: LTC6802 based 12 cell slave.

Postby GregsGarage » Mon Apr 01, 2013 10:32 pm

I couldn't decide on a case for the pcb so I chose 3. :shock: Here's a board outline that will fit several cases.

Image

I'm going to get some prices and check lead times.
Greg Fordyce

Daewoo Matiz
http://www.evalbum.com/4191


Return to “BMS thread”

Who is online

Users browsing this forum: No registered users and 18 guests