Page 1 of 1

Issue with spidev using 2 devices

Posted: Wed Feb 20, 2019 6:33 am
by Unsigned Student
Hello,

because my old post was very unstructured at some point and the initial problem was solved I wanted to create this new post to address my new current problem.

I'm a student and have gathered some experience with multiple programming languages in the past few years but SPI and everything directly related is quite new to me.

My goal with my current project is it to use a raspberry pi to communicate with 2 BMS chips via SPI using Python (spidev). In the end the BMS should give me the current of the Cells (each has 12 Lithium Ion Cells) and I want to use the BMS's balancing function to ensure a equal charge level of all cells.

Problem: When both devices are connected the output for the second device is just a copy of the first one and I have no idea why
When only one of the devices itself are connected to output is completely correct
Update: The problem now also occurred when just one device (device 0) is connected. (repeatedly=

Raspberry: Raspberry Pi 3 Model B
OS: Raspbian
BMS: ISL78600

Wiring is similar to this picture:
SPI master: Raspberry Pi
Slave 0 and 1: BMS chip
Image

Actual wiring:
Image




spidev connection settings:

Code: Select all

# SPI connection
spi0 = spidev.SpiDev()
spi0.open(0, 0)
spi0.bits_per_word = 8
spi0.max_speed_hz = 100000
spi0.mode = 0
spi0.lsbfirst = False

spi1 = spidev.SpiDev()
spi1.open(0, 1)
spi1.bits_per_word = 8
spi1.max_speed_hz = 100000
spi1.mode = 0
spi1.lsbfirst = False

General simplified structure of communication:

Code: Select all

while device < len(devices)
	spi.writebytes(CELL_REGISTER)
        response = spi.readbytes(2)
        CELL_VOLTAGE = single_cell_voltage_calc(response[0], response[1])

print(CELL_VOLTAGE)       

Only device 0 is connected (behavior 1):

Code: Select all

--------------------------------------
SPI INFO: SPI read cell and battery voltage from dev0 and dev1
Dev0-CELL01:	4.075 V	Dev1-CELL01:	ERR V
Dev0-CELL02:	4.073 V	Dev1-CELL02:	ERR V
Dev0-CELL03:	4.073 V	Dev1-CELL03:	ERR V
Dev0-CELL04:	4.075 V	Dev1-CELL04:	ERR V
Dev0-CELL05:	4.074 V	Dev1-CELL05:	ERR V
Dev0-CELL06:	4.075 V	Dev1-CELL06:	ERR V
Dev0-CELL07:	4.075 V	Dev1-CELL07:	ERR V
Dev0-CELL08:	4.075 V	Dev1-CELL08:	ERR V
Dev0-CELL09:	4.073 V	Dev1-CELL09:	ERR V
Dev0-CELL10:	4.071 V	Dev1-CELL10:	ERR V
Dev0-CELL11:	4.074 V	Dev1-CELL11:	ERR V
Dev0-CELL12:	4.074 V	Dev1-CELL12:	ERR V
----	----	----	----
Dev0-BATTERY:	48.843 V	Dev1-BATTERY:	ERR V
--------------------------------------

Only device 1 is connected (behavior 2):

Code: Select all

--------------------------------------
SPI INFO: SPI read cell and battery voltage from dev0 and dev1
Dev0-CELL01:	ERR V	Dev1-CELL01:	4.085 V
Dev0-CELL02:	ERR V	Dev1-CELL02:	4.083 V
Dev0-CELL03:	ERR V	Dev1-CELL03:	4.084 V
Dev0-CELL04:	ERR V	Dev1-CELL04:	4.085 V
Dev0-CELL05:	ERR V	Dev1-CELL05:	4.086 V
Dev0-CELL06:	ERR V	Dev1-CELL06:	4.086 V
Dev0-CELL07:	ERR V	Dev1-CELL07:	4.085 V
Dev0-CELL08:	ERR V	Dev1-CELL08:	4.085 V
Dev0-CELL09:	ERR V	Dev1-CELL09:	4.085 V
Dev0-CELL10:	ERR V	Dev1-CELL10:	4.085 V
Dev0-CELL11:	ERR V	Dev1-CELL11:	4.087 V
Dev0-CELL12:	ERR V	Dev1-CELL12:	4.086 V
----	----	----	----
Dev0-BATTERY:	ERR V	Dev1-BATTERY:	48.975 V
--------------------------------------

How it should look like when both are connected (behavior x):

Code: Select all

--------------------------------------
SPI INFO: SPI read cell and battery voltage from dev0 and dev1
Dev0-CELL01:	4.075 V	Dev1-CELL01:	4.085 V
Dev0-CELL02:	4.073 V	Dev1-CELL02:	4.083 V
Dev0-CELL03:	4.073 V	Dev1-CELL03:	4.084 V
Dev0-CELL04:	4.075 V	Dev1-CELL04:	4.085 V
Dev0-CELL05:	4.074 V	Dev1-CELL05:	4.086 V
Dev0-CELL06:	4.075 V	Dev1-CELL06:	4.086 V
Dev0-CELL07:	4.075 V	Dev1-CELL07:	4.085 V
Dev0-CELL08:	4.075 V	Dev1-CELL08:	4.085 V
Dev0-CELL09:	4.073 V	Dev1-CELL09:	4.085 V
Dev0-CELL10:	4.071 V	Dev1-CELL10:	4.085 V
Dev0-CELL11:	4.074 V	Dev1-CELL11:	4.087 V
Dev0-CELL12:	4.074 V	Dev1-CELL12:	4.086 V
----	----	----	----
Dev0-BATTERY:	48.843 V	Dev1-BATTERY:	48.975 V
----------------------------------------

How it is when both are connected (behavior 3):

Code: Select all

--------------------------------------
SPI INFO: SPI read cell and battery voltage from dev0 and dev1
Dev0-CELL01:	4.075 V	Dev1-CELL01:	4.075 V
Dev0-CELL02:	4.073 V	Dev1-CELL02:	4.073 V
Dev0-CELL03:	4.073 V	Dev1-CELL03:	4.073 V
Dev0-CELL04:	4.075 V	Dev1-CELL04:	4.075 V
Dev0-CELL05:	4.074 V	Dev1-CELL05:	4.074 V
Dev0-CELL06:	4.075 V	Dev1-CELL06:	4.075 V
Dev0-CELL07:	4.075 V	Dev1-CELL07:	4.075 V
Dev0-CELL08:	4.075 V	Dev1-CELL08:	4.075 V
Dev0-CELL09:	4.073 V	Dev1-CELL09:	4.073 V
Dev0-CELL10:	4.071 V	Dev1-CELL10:	4.071 V
Dev0-CELL11:	4.074 V	Dev1-CELL11:	4.074 V
Dev0-CELL12:	4.074 V	Dev1-CELL12:	4.074 V
----	----	----	----
Dev0-BATTERY:	48.843 V	Dev1-BATTERY:	48.843 V
--------------------------------------

Behavior 1 and 2 are correct and as expected. Behavior 3 is wrong and the expected output would be behavior x.


Did anybody already experience a issue like this ? That devices are interfering each other somehow ?

Thank you for any held or advice in advance, if any further information is needed please ask!

Re: Issue with spidev using 2 devices

Posted: Wed Feb 20, 2019 9:33 am
by joan
We need a clear photo or photos of the actual wiring so we can follow the connections from pin to pin.

Re: Issue with spidev using 2 devices

Posted: Wed Feb 20, 2019 1:46 pm
by Unsigned Student
joan wrote: We need a clear photo or photos of the actual wiring so we can follow the connections from pin to pin.
Is the new picture sufficient ?

Re: Issue with spidev using 2 devices

Posted: Wed Feb 20, 2019 3:40 pm
by DirkS
Unsigned Student wrote:
Wed Feb 20, 2019 1:46 pm
joan wrote: We need a clear photo or photos of the actual wiring so we can follow the connections from pin to pin.
Is the new picture sufficient ?
That's not *your* wiring and does
Wiring is similar to this picture:
mean that it's not the same?
You should post a photo of *your* wiring, not an image of what it should be...

Re: Issue with spidev using 2 devices

Posted: Thu Feb 21, 2019 1:33 am
by Unsigned Student
DirkS wrote:
Unsigned Student wrote:
Wed Feb 20, 2019 1:46 pm
joan wrote: We need a clear photo or photos of the actual wiring so we can follow the connections from pin to pin.
Is the new picture sufficient ?
That's not *your* wiring and does
Wiring is similar to this picture:
mean that it's not the same?
You should post a photo of *your* wiring, not an image of what it should be...
The second picture is from the documentation of the actual wiring, it is pretty hard to make picture at this point. Each device has its own plug and all wires are bound in a shrinking tube.