spi communication error

317 views
Skip to first unread message

Neil Roberts

unread,
Apr 9, 2012, 3:05:30 AM4/9/12
to openBMS
Hey I'm pretty new to spi communication so this may be an obvious one
for the rest of you. one of the electrical guys helped me hook up our
first board with cinch connectors this weekend. we plugged it into the
arduino and after commenting out some openbms lcd code from an old
arduino version, I got it compiling. According to the serial monitor
we're getting 6.14 volts on all cells. I had it print the ltc response
for me and I got a 255 byte coming back from the daughter board for
all cells. does this mean that theres something wrong with our spi
setup?


Again, I apologize for my ignorance but I'd really like to get this
going so we can test boards before I start distributing them.

-Neil

Ricky Gu

unread,
Apr 9, 2012, 3:19:34 AM4/9/12
to ope...@googlegroups.com
inside void readVolts()

there are several Serial.println that is commented out. You can uncomment them for debugging purpose to see if the boards are communicating properly. 

How the communication works is the arduino sends a command, and the board will respond with the voltages.  you can also Serial.println the ltcresponse to see what you are getting back from the daughter board. ltcresponse is the raw response from the daughter board in a byte form that is some what encoded. inside readVoltes(), the for loop decodes the lteresponse byte to get the individual voltage out. refer to the data sheet of ltc6802-2 to see how ltcresponse is encoded. 

if you are not getting any response then chances are it's your wiring not setup or communication is not working correctly. 

hope this helps. 

Ricky. 

Henry Palonen

unread,
Apr 9, 2012, 3:47:03 AM4/9/12
to ope...@googlegroups.com
Hello,

What Arduino board you are using? I ask because Arduino Mega has different spi-pins compared to Uno. If you connect scope to the spi-signals, do you get reasonable results, eg. any traffic in the bus? Does it matter if you have cells connected or not - what if you disconnect some cells, does the value (255) change?

Best regards,

Henkka

Adam Brunette

unread,
Apr 9, 2012, 8:05:23 AM4/9/12
to ope...@googlegroups.com
Hello Neil,

I am actually working on this problem right now as well. I have been using a Chipkit MAX32 board which is a PIC processor that uses the Arduino IDE and code. It is in the form of the Arduino MEGA.

This issue gets difficult to track down because even with nothing attached to the SPI bus, you will get values of 255 per register and 4096 which is 6.1425v. 

I have bought a new logic analyzer and it is coming today. My DSO doesn't have the ability to decode the SPI so its no much help. 

I have written some code for just reading the cells that has been simplified and has alot. It has alot of serial prints for easy debugging. Once I get mine talking tonight, I will share the code.

-Adam

Henry Palonen

unread,
Apr 11, 2012, 3:37:37 AM4/11/12
to ope...@googlegroups.com

Adam Brunette kirjoitti 9.4.2012 kello 15.05:

> I am actually working on this problem right now as well. I have been using a Chipkit MAX32 board which is a PIC processor that uses the Arduino IDE and code. It is in the form of the Arduino MEGA.

Ok, so it has different pins propably compared to Uno but that's ok as long as it's taken care in software also.

>
> This issue gets difficult to track down because even with nothing attached to the SPI bus, you will get values of 255 per register and 4096 which is 6.1425v.

Ok, that sounds like the error is not in the daughter-boards at all, fortunately.

>
> I have bought a new logic analyzer and it is coming today. My DSO doesn't have the ability to decode the SPI so its no much help.

Yes, that a logic-analyzer really should help. I use Logic from Saleae, that has worked great in debugging spi.

>
> I have written some code for just reading the cells that has been simplified and has alot. It has alot of serial prints for easy debugging. Once I get mine talking tonight, I will share the code.

Great! I have only daughter and master PCB's, no components yet. Have to order rest of the components soon.

--
Henkka

Ricky Gu

unread,
Apr 11, 2012, 3:51:31 AM4/11/12
to ope...@googlegroups.com
Kind've off topic, but here is a video I made in july 2010, about 3 weeks before the trip across Canada when I first got the original BMS design to talk with the Arduino.
http://www.youtube.com/watch?v=ckFWKNN4Xz8

Notice how the lights are flashing. It was working it's balancing algorithm to even out the charges. I had a much aggressive balancing algorithm which caused so much flashing.

Some of the technique i used to debug the wiring was to manually assert the spi pins from the arduino, then probing them on the daughter board to make sure there are no wiring problem. Once I worked out all the kinks with the physical linkage, since I was kind've hacking it together with crappy wiring as you can see in the video, it fired up right away.

Also a lot of Serial.println is also helpful in the arduino code.

Good luck with the debugging, it would be fun once you get it all hooked up and talking.

Adam Brunette

unread,
Apr 11, 2012, 8:06:14 AM4/11/12
to ope...@googlegroups.com
Hello Everyone,

Well I was able to get everything working yesterday with great help from my new Logic from Saleae. 

The MAX32 board is pin compatible with with the Arduino Mega, but uses 3.3V logic.

The issue ended up being because of whoever ported the libraries to the Max32 board. There is an error in the SPI library that does not pay attention to the clock division command in the program. I had to edit it in the library file because it was set to 4mhz. I dropped it back to 1 and with a few other small code changes, everything worked perfectly!

I will send the code that I have written to anybody that wants it. Even though its written using this board, its still Arduino compatible. I will also be posting it on my website. It is still early on, just reading the voltages and displaying them through serial. When all the serial prints are removed, The code is designed to as efficient as possible. 

Here is a screenshot of the logic analyzer and the data being read.  http://farm6.staticflickr.com/5279/6921317694_246e69cf33_o.jpg 


Ricky,

Very cool video, I look forward to seeing my test cells balance.

-Adam

Ricky Gu

unread,
Apr 11, 2012, 4:43:44 PM4/11/12
to ope...@googlegroups.com
Great job Adam for getting it work. You can create a folder called MAX32 inside Arduino Code folder of the original github repo and send me a pull request. I can merge it with the master branch and have it available to others. 

Neerav Parasher

unread,
Mar 2, 2015, 6:29:08 AM3/2/15
to ope...@googlegroups.com
Hi Adam Brunette 
could you send me the code at "neerav....@gmail.com" i am also working in a same kind of project but using Beagle Xm with LTC6804 

Neerav Parasher

unread,
Mar 3, 2015, 11:20:39 PM3/3/15
to ope...@googlegroups.com
hello
i am working on LTC6804 from last few month , i was trying to port linux application connected LTC6804 with Beagle

Xm but some issues occur. this is the git application source i am using ("https://github.com/martin-c/beagle-bms" ) . also the video is available ("https://www.youtube.com/watch?v=Ke4MwVpD0xs")

where my beagle xm is connected with LTC6802 ("http://cds.linear.com/docs/en/demo-board-manual/dc1941bf.pdf")

which is connected to LTC6804 DC1942B isoSPI bus ("http://cds.linear.com/docs/en/demo-board-manual/dc1942bf.pdf")

my application gives some junk output on terminal . not as shown is the video also the MISO is not getting any data .
Reply all
Reply to author
Forward
0 new messages