Skip to main content
Visitor II
November 13, 2020
Solved

Erratic results from magnetometer

  • November 13, 2020
  • 1 reply
  • 864 views

I have an application using a LSM9DS1 with the purpose of accurately measuring the rotational speed of a platter spinning at about 33 rpm.

I measure the speed by taking readings from the gyroscope every 10ms. I did an initial calibration for offset and slope before that, but I would like to increase the accuracy by correlating the initial calibration with data from the magnetometer also.

So I added an initial calibration step by reading the X,Y measures from the magnetometer every 30ms, calculating a heading using atan2(Y, X)*180/PI +180 , and measuring the time it takes to go from heading 50º back to heading 50º again.

However, when I look at a log from the headings obtained, I see a not completely linear sequence of values, sometimes going back for 1,2 steps, before going forward again. Something like: 34, 36, 38, 33, 39, 40, 50, 45, 55, 60.....

Any idea of what may be causing this ? Maybe I'm trying to take readings too fast ?

I've set ODR at 80Hz

    This topic has been closed for replies.
    Best answer by Eleon BORLINI

    Hi @PRebo.1​ ,

    >> Any idea of what may be causing this? Maybe I'm trying to take readings too fast?

    You could try to reduce the reading speed, of course (especially if you set 80Hz ODR but you are reading the gyro at 100Hz).

    For the magnetic sensor calibration, how are you performing it? Are you periodically setting the user offsets (OFFSET_t_REG_w_M registers)? I suggest you to check this guidelines for the magnetic sensor calibration, especially the procedure for the hard iron compensation.

    -Eleon

    1 reply

    ST Employee
    November 16, 2020

    Hi @PRebo.1​ ,

    >> Any idea of what may be causing this? Maybe I'm trying to take readings too fast?

    You could try to reduce the reading speed, of course (especially if you set 80Hz ODR but you are reading the gyro at 100Hz).

    For the magnetic sensor calibration, how are you performing it? Are you periodically setting the user offsets (OFFSET_t_REG_w_M registers)? I suggest you to check this guidelines for the magnetic sensor calibration, especially the procedure for the hard iron compensation.

    -Eleon