Skip to main content
Visitor II
August 7, 2019
Question

LSM9DS1 Same value for magnetometer axis X Y Z

  • August 7, 2019
  • 4 replies
  • 1083 views

Hello,

I'm using a LSM9DS1 for a project, accelerometer and gyroscope works well, but the magnetometer have some problems.

Every measure I get the same value for axis X-Y-Z , and it seems to change randomly, see the log :

12:59:38 : ACC : x: 0.142378  y: 0.278774 z: -9.767851

12:59:38 : GYR : x: -0.000305  y: -0.083536 z: 0.003512

12:59:38 : MAG : x: 4.292928  y: 4.292928 z: 4.292928

12:59:39: ACC : x: 0.125628  y: 0.273988 z: -9.792976

12:59:39: GYR : x: 0.004123  y: -0.072693 z: 0.004429

12:59:39: MAG : x: -3.811968  y: -3.811968 z: -3.811968

12:59:39 :TEMP:    25.125000

12:59:40: ACC : x: 0.101699  y: 0.259631 z: -9.781012

12:59:40: GYR : x: -0.001222  y: -0.076205 z: 0.005956

12:59:40: MAG : x: -4.182048  y: -4.182048 z: -4.182048

12:59:40: TEMP:    24.375000

I'm using an SPI 4 wire, and the registers configuration is :

Acc/Gyro:

CTRL_REG1_G           = 0xC0

CTRL_REG4           = 0x38

CTRL_REG5_XL         = 0x38

CTRL_REG6_XL         = 0xD0

Magnetometer:

CTRL_REG1_M         = 0x7C

CTRL_REG2_M         = 0x00

CTRL_REG3_M         = 0x00

CTRL_REG4_M   = 0x0C

Anyone have any idea of the problem ?

Regards

Riccardo

    This topic has been closed for replies.

    4 replies

    ST Employee
    September 10, 2019

    Hi @RStra​ , the magnetometer control registers seems well set... However magnetometer ODR is 80Hz and axl and gyro are at much higher ODR (952Hz). How are you acquiring the data? Is your acquisition at 952Hz also the magnetometer? In this case you'll se the magnetometer data changing very slow with respect to axl and gyro data. (Sorry for the delay in our answer) Regards

    RStraAuthor
    Visitor II
    September 11, 2019

    Hello,

    thank you for your response.

    The data on the log I posted are taken every 1s, and the board was fixed on my desk (no movment), so I think that I should read always the same values, isn't it ?

    Also the three axis of the magnometer read the same value, I don't know if's correct.

    Regards

    Riccardo

    ST Employee
    September 13, 2019

    Hi Riccardo, I was supposing you were in FIFO mode, and you were decoding the data in a wrong way. Btw, are you communicating I2C or SPI? In the SPI case you should write at least '1' in the SIM bit of CTRL_REG3_M.

    0690X00000ARBwbQAH.png

    Regards

    Visitor II
    September 11, 2019

    > board was fixed on my desk (no movment), so I think that I should read always the same values, isn't it ?

    No, it depends on the environment, MEMS sensor's resolution, accuracy, scale, etc. You will get "close" values for accelerometer and gyro, but magnetometer values can vary more so - anything can affect it - your own movements, your mouse's movement, maybe even a nearby passing vehicle or the elevator in the building, etc.

    RStraAuthor
    Visitor II
    September 13, 2019

    Hello,

    I have just solved the problem. I was doing a multiple read (on the magnetometer) without set the MS bit to 1 on the SPI. So I was reading always the same register because the address wasn't auto incremented.

    Have 2 different protocol for accelerometer SPI and magnetometer SPI is a little bit confusing .

    Thanks

    Riccardo