cancel
Showing results for 
Search instead for 
Did you mean: 

Tilt compensated heading using LIS2MDL and LSM6DSL

Jeevan_t_raj
Associate

Hi,

In one of our projects we have to use the accelerometer LSM6DSL, and magnetometer LIS2MDL. The tilt-compensated magnetic heading have to be computed in accordance with the values read from these sensors. We have the respective EVKs connected to our microcontroller for trying out and verifying this.

Basically, I am using the below equation for calculating the heading value,

heading = (atan2(y,x) * 180)/3.1415;

And with this, I am getting the heading value properly in a way such that the North is in the direction as marked in red arrow in the below figure.

0693W00000LvvSeQAJ.png 

So I would like to know,

1) the axes direction labeled in the Datasheet is to the -ve direction or not?

2) Do we have to do any calibration procedures other than factory calibration? If so how is that operation? (Because I have observed that, the sensor readings are not reliable when I placed it near to my bench supply[This supply have a thick metallic cover], when I moved it a bit away the values are okay)

Also, if there is any document available that we can refer to implement the tilt-compensated heading calculation, could you share that?

Thanks,

Have a nice day 🙂

1 REPLY 1
Petr S
ST Employee

1) I'm not sure what you're asking.

2) I'd recommend Magnetometer Calibration using MotionMC Middleware Library. You can use MagnetometerCalibration sample application in X-CUBE-MEMS1 package as a reference. Or you can even use combination of our MotionEC and MotionMC Middleware Libraries.

3) Some documents to study:

https://www.st.com/content/ccc/resource/technical/document/design_tip/group0/56/9a/e4/04/4b/6c/44/ef/DM00269987/files/DM00269987.pdf/jcr:content/translations/en.DM00269987.pdf

https://www.st.com/content/ccc/resource/technical/document/design_tip/group0/9e/85/c3/8d/f9/9e/41/b0/DM00513633/files/DM00513633.pdf/jcr:content/translations/en.DM00513633.pdf

https://www.pololu.com/file/0J434/LSM303DLH-compass-app-note.pdf