Skip to main content
Visitor II
July 14, 2017
Question

LIS3MDL calibration

  • July 14, 2017
  • 1 reply
  • 1986 views
Posted on July 14, 2017 at 07:24

The magnetometer on my device has different scale and offset on its axes.This is because of influence of hard iron on the board. So, it needs to be calibrated. I've read 

https://my.st.com/resource/en/design_tip/dm00286302.pdf

 and hadn't understood about rotated ellipsoid. Rotated about what? 

I made calculations according this manual with matlab. Offsets and gains are adequate, but rotation matrix is strange. When I fit the data with offsets and gains, the angles (yaw, pitch, roll) I computed are normal. When I fit with offsets, rotation matrix and gains, the angles are strange. 

The second question. When I fit the data with normal calibration values all vectors have magnitude 1. How to convert it back to gauss?

The crosses are the original data, the rounds are transformed data.

Transformation ''offset-rotate-scale'' is on the left side.

Transformation ''offset-scale'' is on the right side.

0690X00000607b8QAA.png

#magnetometer
    This topic has been closed for replies.

    1 reply

    ST Employee
    July 14, 2017
    Posted on July 14, 2017 at 09:39

    In theory if the offset is zero, the scale is the same in all axis and there is no cross axis gain, the data would create perfect sphere with center at [0,0,0].

    Offset (hard-iron error) causes that the sphere wont be centered at [0,0,0] coordinates, but is moved.

    Different scales in each axis (soft-iron error) causes that data not create a sphere but ellipsoid.

    Cross axis gain causes the axis of ellipsoid are not aligned with X, Y, Z axis.

    You can check

    http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-expansion-software/x-cube-mems1.html

     package which contains also MotionMC (Magnetometer Calibration) library for STM32 MCUs.

    This algorithm is able to calculate offset and scale factors and then compensate the hard-iron and soft-iron error.

    sdianoffAuthor
    Visitor II
    July 14, 2017
    Posted on July 14, 2017 at 10:12

    Miroslav, I've seen this product. There is no source code, just static library. (Middlewares\ST\STM32_MotionMC_Library). Library can be used on STM32 only.