cancel
Showing results for 
Search instead for 
Did you mean: 

Magnetometer Offset Register making the readings inaccurate

Jumshed Akhtar
Associate II

Hi,

I want to store the initial calibrated offset in Offset Registers of Magnetometer LSM9DS1. After storing the calibrated offset, the actual readings are not changing and they are almost constant .

By doing manual subtraction using calibration offset from the the raw values give me the correct heading from 0-360 and aligned as well. which means the calibrated offset is correct. But saving it in Offset Registers is not giving the correct values automatically. It is not even allowing the variation of heading from 0-360. Any one has used Offset Registers for automatic correction? Any advice?

I saved and in offset register and read back and did manual subtraction and it worked. But it is not doing this automatically.

Thanks,

2 REPLIES 2
Eleon BORLINI
ST Employee

Hi, did you correctly set/save the calibration offset (as a 16-bit integer in two's complement, MSB in the correct order)? Did you re-check if you correctly write the value inside the registers? As you pointed out in your question, the sensor should directly subtract the offset OFFSET_X_REG_L_M... for each of the X, Y, Z axis to the dataout... Do you have the possibility to test another device? Regards

Hi, thanks for your response.

I am saving the offset and reading back, it is correct value saved and read back as 16-bit integer in two's complement . I only have lsm9ds1 chip on my boards.

Here is code from sparkfun to save and I am following the same and saving each axis

https://github.com/sparkfun/SparkFun_LSM9DS1_Arduino_Library/blob/master/src/SparkFunLSM9DS1.cpp

void LSM9DS1::magOffset(uint8_t axis, int16_t offset)

{

    if (axis > 2)

        return;

    uint8_t msb, lsb;

    msb = (offset & 0xFF00) >> 8;

    lsb = offset & 0x00FF;

    mWriteByte(OFFSET_X_REG_L_M + (2 * axis), lsb);

    mWriteByte(OFFSET_X_REG_H_M + (2 * axis), msb);

}

Best Regards,