cancel
Showing results for 
Search instead for 
Did you mean: 

LIS2MDL appears to output inconsistent values

jspear
Associate

Hi all, 

We have integrated an LIS2MDL magnetometer into our custom PCB. We have recently been running some tests on the boards, and are collection raw data from the sensor via the I2C line. In our testing, we have found that different boards appear to be outputting different raw values in what should be the same conditions. What we have done is taken the raw data from the devices, calculated the magnitude ( sqrt(mag_x^2 + mag_y^2 + mag_z^2) ) which provides the following pieces of information. All devices are placed in the exact same location in the exact same orientation when the data is recorded. Values are in LSBs, where 1LSB = 1.5 mG:

 

DeviceX DirectionY DirectionZ Direction Magnitude
# 1-3-15358163
# 2126-218454519
# 3132-315211404
# 4262-376325561

 

We have been testing the devices with various paramagnetic and ferromagnetic materials, so I'm wondering if there was some sort of bias introduced that I am unaware of. Regardless, I am looking for some explanation as to why the values recorded by four identical devices in identical conditions would be so different.

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Federica Bossi
ST Employee

Hi @jspear ,

As already said by @q3z85d41xqz036d , you need surely an hard iron calibration. You can take a look at our official examples for implementing it.

A soft iron calibration is always suggested but it could be not necessary.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

View solution in original post

5 REPLIES 5

Hi !

I work on IIS2MDC magnetometer and have some a quite similar problem, I will provide you informations that concern my sensor, maybe it can help you :

- My sensor can work in both continuous and single mode. In continuous mode, the OFFSET register (offset-x, y and z) is automatically substract to the output. (offset register is present to correct the magnetic field that we measure)

- In single mode (which I need to use in order to respect a low power design) the OFFSET is not substracted to the output. (I dont know why).

Magnetometer have both soft and hard iron calibration that need to be done. If you plan to measure the earth magnetic field, you will need to include a correction. You can find these information in the datasheet of your sensor (sometimes, there is also some Application Note).

Here an article on what is hard and soft iron calibration.

In the applicatio note (an5080) of the IIS2MDC, you can find more information on how to calculate Magnetometer offset cancellation.

(part 8 : Magnetometer offset cancellation

part 9 : Magnetometer hard-iron compensation)

I saw that end of last week and didnt began to do these calculation as I didnt had the time. I'll probably try these things this week.

I'm a newbie concerning magnetometer, so I hope these little informations can help you. Maybe you already knew all these things ?

Federica Bossi
ST Employee

Hi @jspear ,

As already said by @q3z85d41xqz036d , you need surely an hard iron calibration. You can take a look at our official examples for implementing it.

A soft iron calibration is always suggested but it could be not necessary.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

I always see that "the computation of the hard-iron distortion field should be performed by an external processor."

I use a STEVAL-STWINBX1, does that mean that I have to buy an additionnal sensors, plug it to my board and compute hard-iron with the latter ?

jspear
Associate

@Federica Bossi and @q3z85d41xqz036d , Thank you both for the advice. We are using a fusion algorithm which calculates the Hard and Soft Iron offsets, so once applying those to the raw magnetometer values, the devices all appear to be consistent. I suppose I was thinking that the devices would all have relatively similar field strength values given that they were in the same location and orientation. Is it normal for uncalibrated magnetometers to have varying raw outputs from one device to another, even with the same exact test conditions?

Thanks for the clarification!

Yes, seems normal for uncalibrated devices to output differnts values