cancel
Showing results for 
Search instead for 
Did you mean: 

LIS3MDL calibration

sdianoff
Associate II
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
3 REPLIES 3
Miroslav BATEK
ST Employee
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.

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.

Posted on July 14, 2017 at 10:21

I know why do the hard-iron and soft-iron effect appear. I want to know why the transformation matrix obtained by matlab program outlined

/external-link.jspa?url=https%3A%2F%2Fmy.st.com%2Fresource%2Fen%2Fdesign_tip%2Fdm00286pdf

is wrong?