cancel
Showing results for 
Search instead for 
Did you mean: 

LIS3MDL SPI BUS Problem

Sadra nsh
Associate II
Posted on April 11, 2017 at 12:31

Hi,

I have designed a circuit which has 8 LIS3mdl sensor slot on 1 spi bus.

The problem when I connect only one ls3mdl sensor (other 7 are empty) to the board it works well. but most of the when I connect another one ( sometimes 2 and sometimes 3 or 4 and more) all sensor stop working. ( it reads the register values but the wrong parameter get back) in this mode, I am reading sensors one by one.(make one of SS(chip select) 0 talk to sensor and make it 1 and then do the same with next sensor). Immediately when I reduce the number of sensors to 1 it works correctly and when and more sensor it goes wrong.

I myself think that the problem appears because when SS pin for other sensors is high and it means they are in i2c mode and they talk in I2C on the bus and it makes conflicting(i saw wrong data coming in debug mode and in oscilloscope)

I once though the problem is because of low current on spi bus so I enabled only internal pull-up of Microcontroller(stm32f407vgt6) miso mosi sck and ss pins.

my SPI bus is something like the image

http://www.byteparadigm.com/pictures/figure1.jpg

image. 

Can anyone help me?

#lis3mdl #spi #spi-bus
3 REPLIES 3
Miroslav BATEK
ST Employee
Posted on April 11, 2017 at 14:51

Do you have enough blocking capacity on Vdd and Vdd_IO?

Can you check there is no significant voltage drop on Vdd and Vdd_IO?

What is distance between sensors? How long are the SPI tracks? There could be a problem with big capacity load of you microcontroller on SPI pins. You can try reduce the SPI clock speed.

Sadra nsh
Associate II
Posted on April 11, 2017 at 17:03

Batek.Miroslav

Thank you for taking the time to answer me.

I should mention that Ihave 90cm to 100 cables to from sensor to Controller board.

I set Prescaler256 to the baud rate. now it is at 140Kbit/s. I have connected Vddand vdd_io to the same source of 3.3v with 2 10uf bipolar capacitors. with options of the above it best Ican have 6 sensors simultaneously on one spi bus, and when I connect one more some of sensors disconnect or start connecting and disconnecting constantly and some stay connected.

there is another weird issue! I can disconnect adaptor to have some voltage drop(from3.3v to 2.8v for example) in this situation more sensors work

simultaneously(for example 7). Is it normal?

what to do now?

Miroslav BATEK
ST Employee
Posted on April 12, 2017 at 10:15

The 100 cm it is  pretty tough condition for the SPI bus. The SPI is not designed for this long distance. It is not clear to me if there is only one cable between controller board and all sensors or each sensor is connected by separate 100 cm long cable, which would be much worse. I'm afraid that this solution is not suitable for such a long distance. I recommend you to check the signals by scope to try to find a root cause (big capacity, crosstalk, distortion, reflection, ...). Than maybe you wont be able to tune you system, maybe a buffers will be needed on the signal lines.

For the blocking capacitors, each sensor should have own blocking capacitor as it is described in the datasheet as close a possible to the package. Please be aware magnetometer can generate quite big current peaks and they must be covered by the blocking capacitors.