cancel
Showing results for 
Search instead for 
Did you mean: 

Magnetometer difference between LSM9DS0 and LSM9DS1

Mark Williams
Associate II
Posted on April 11, 2017 at 08:08

We are upgrading our IMU from a LSM9DS0 to LSM9DS1. However we are having issues with the magnetometer on the LSM9DS1. Even after min/max calibration it doesn't appear to give correct heading.

We are aware that the orientation has changed and have taking this into consideration.

When using this simple formula, i would expect some usable results (this works perfectly witht he LSM9DS0)... however this is not what we are seeing.

heading = 180 * math.atan2(MAGy,MAGx)/M_PI

To rule out our PCB design, we have purchased products which use LSM9DS1 from Adafruit and Sparkfun, and these also have the same issue.

Below is the code used to initiate the magnetometer

# CTRL_REG1_M (Default value: 0b0001 0000)
# [TEMP_COMP][OM1][OM0][DO2][DO1][DO0][0][ST]
# TEMP_COMP - Temperature compensation
# OM[1:0] - X & Y axes op mode selection
# 00:low-power, 01:medium performance
# 10: high performance, 11:ultra-high performance
# DO[2:0] - Output data rate selection
# ST - Self-test enable
writeMAG(CTRL_REG1_M, 0b01011100)♯

# CTRL_REG2_M (Default value 0x00)
# [0][FS1][FS0][0][REBOOT][SOFT_RST][0][0]
# FS[1:0] - Full-scale configuration
# 00:+/- 4 gauss
# 01:+/- 8 gauss
# 10:+/- 12 gauss
# 11:+/- 16 gauss
# REBOOT - Reboot memory content (0:normal, 1:reboot)
# SOFT_RST - Reset config and user registers (0:default, 1:reset)
writeMAG(CTRL_REG2_M, 0b01000000)♯
# CTRL_REG3_M (Default value: 0x03)
# [I2C_DISABLE][0][LP][0][0][SIM][MD1][MD0]
# I2C_DISABLE - Disable I2C interace (0:enable, 1:disable)
# LP - Low-power mode cofiguration (1:enable)
# SIM - SPI mode selection (0:write-only, 1:read/write enable)
# MD[1:0] - Operating mode
# 00:continuous conversion, 01:single-conversion,
# 10,11: Power-down
writeMAG(CTRL_REG3_M, 0b00000000)♯
# CTRL_REG4_M (Default value: 0x00)
# [0][0][0][0][OMZ1][OMZ0][BLE][0]
# OMZ[1:0] - Z-axis operative mode selection
# 00:low-power mode, 01:medium performance
# 10:high performance, 10:ultra-high performance
# BLE - Big/little endian data
writeMAG(CTRL_REG4_M, 0b00001000)�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

1 REPLY 1
Miroslav BATEK
ST Employee
Posted on April 12, 2017 at 11:07

The principle for heading calculation is not dependent on the used magnetometer, so there should't be any difference between LSM9DS0 and LSM9DS1.

The simple formula which you are using can be used only if the sensor is horizontal position. Any tilt will generate error.

Can you please log magnetometer X,Y axis data during several turns along Z axis. If the hard-iron compensation is done properly it should created circle with center in [0,0].

There will be probably also soft iron error so it will be ellipse instead of circle, but if the distortion won't be  big the formula should work anyway.

If you want to measure earth magnetic field the range 12 Gauss is quite high, I would use 4 Gauss range instead.