FXOS8700CQ: Is there any solution for calibrating hard iron offset when the device cannot be rotated very much?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FXOS8700CQ: Is there any solution for calibrating hard iron offset when the device cannot be rotated very much?

Jump to solution
2,464 Views
tedhuntington1
Contributor II

I want to determine the direction of the north pole by using an FXOS8700CQ in an object that cannot easily be rotated in 360 degrees (pitch or roll- but can in yaw). Is there a way to calibrate the device without rotating it in 360 (pitch and roll)? I am thinking that the only solution is to just determine the hard iron offset by rotating the PCB the sensor is on, and just using that as a hard coded offset. I see that the magnetic min and max registers are not writeable, so presumably enabling autocalibration would just instantly overwrite my initial M_OFF offset values. It's frustrating that a simple magnetic compass doesn't have as much of a problem finding north as an electronic device does.

Thanks,

Ted

Labels (2)
1 Solution
1,646 Views
anthonyduhamel
NXP Employee
NXP Employee

Yes I know. Use the 3 points calibrations I called "MCU algorithm based on "circle fitting".

Please send me an email (anthony.duhamel at nxp.com)

Anthony

View solution in original post

0 Kudos
12 Replies
1,646 Views
reyes
NXP TechSupport
NXP TechSupport

Hi Ted,

Correct, FXOS8700CQ provides an auto-calibration function that calculates the hard-iron estimate (calibration) and automatically subtracts it (compensation) from the current magnetic-field readings.

For platforms where hard-iron interference is the primary source of error, and soft-iron distortion is minimal or non-existent, the auto-calibration function can serve as the magnetic-calibration algorithm for the system.

Using the Auto-calibration process, you can avoid the rotating calibration.

However, it is important to understand the effects of avoiding soft-iron calibration since it can affect the compass heading angle error if not kept at minimum, please find more details in the application note AN4459

There is also an example code that you can use for the auto-calibration process, you can download it from here.


Have a great day,
Jose

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
1,646 Views
tedhuntington1
Contributor II

Thanks Jose. So are you saying that the hard iron autocalibration of the FXOS8700CQ will work instantly- and doesn't require the device to be initially rotated in order for the device to get a full sense of the magnet field around it relative to its orientation?

0 Kudos
1,646 Views
anthonyduhamel
NXP Employee
NXP Employee

Hello Ted,

If you want the self-calibration works well, you need to rotate the board by 360° (full revolution). It is the only way for the auto-calibration feature to get the correct min/max values.
What is your board rotation abilities? (through Yaw axis)

You can also embed the an homemade calibration into a Mcu. This is more flexible, and several calibration processing could work in your case. Can you share more about your constraints & objectives?

An other question, if your degrees of freedom are pitch and roll, does it male sense to get the orientation (I mean if yaw can't rotate). Can you clarify?

Thanks,

Anthony

1,646 Views
tedhuntington1
Contributor II

Hi Anthony,

My application is a humanoid robot and the FXOS8700CQ is in each joint of the robot. Mostly Roll and pitch are not possible, but yaw is- although it requires the robot to be turned around on power up which I am hoping would not be necessary. Is even just moving the robot 360 degrees in yaw enough? Isn't another 360 of pitch or roll necessary for the device's autocalibration to be accurate?

What about me just recording what the average hard iron offset is, and just writing it there, and going without autocalibration? Would that make the device at least as accurate as a regular magnetic compass?

In particular, the device will not be moving in pitch and roll too much anyway- being in each segment of a two leg, two arm robot.

Thanks,

Ted

0 Kudos
1,645 Views
anthonyduhamel
NXP Employee
NXP Employee

Hello Ted,

Calibration results depend on what  you are expecting for. I mean, what is the final goal? Do you want to know the position for example of the robot arms compare to the North Pole?

If it is, here some avenues for implantation & hard iron corrections:

Calibrate the Hard-Iron offset

  • FXOS8700CQ Autocalibration:

Autocalibration feature implemented in the FXOS8700CQ will not work totally, let me explain why:

I picture the calibration used on only magnetometer 1-axis, but it is applicable to the three one.

If you rotate the magnetometer over 360°, you catch the real Min/Max, so it's working well:

magcalib.PNG

Let re-use the same calibration algorithm but by rotating the magnetometer by 100°:

magwcalib.PNG

Here the calibration brings an important offset error and will degrade the final measurement.

  • MCU algorithm based on a hard iron average:

You will have the same issue as above, it should not work...

  • MCU algorithm based on "circle fitting":

An other method consists to observe the data in a 2D plan. I mean in X/Y or X/Z or Y/Z.

With basic trigonometric equation, you can easily estimate the "circle" center which matched to the offet of 2axis.hardiron.PNG

This algorithm works with only three points and doesn't necessitate to perform a 360° rotation. To get the 3D hardiron, you repeat again the operation on an other plan. Note that this algorithm works only if the soft-iron distortion is small ( if not it's not a circle anymore but an ellipse).

Calibrate the Hard-Iron, but what else?

Regarding you application, calibrate the magnetometer with Hard-iron can be not enough accurate. You can also work on the Soft-Iron distortions, but I'm not sure it is possible.

By the way, as the robot has a lot of moving parts, I'm not sure Hard-Iron&Soft-Iron will solve all heading errors. As the Earth magnetic field is very tinny, the motion and rotation of all the robot parts will probably bring a lot of magnetic disruptions. It is a very tricky application!

Maybe it is better to use the magnetometer with a magnet for example to make a magnetic rotary encoder or otherwise.

Hope my explanations will help.

Thanks,

Anthony

1,645 Views
tedhuntington1
Contributor II

Thanks for all that info Anthony- I think you may be correct on your view that trying to determine the yaw on various robot segments might need some other solution than an electronic magnetometer- maybe something more like an mechanical compass IC. Ultimately I may just use the robots cameras to determine the orientation of each segment- but somehow humans have a sense of the yaw of each of our own segments- so perhaps there is a more practical solution to determining the yaw of each segment- the pitch and roll are just very easy to determine from the accelerometer- but yaw is tougher.

0 Kudos
1,646 Views
anthonyduhamel
NXP Employee
NXP Employee

Hi Ted,

By the way, the FXOS8700CQ accelerometer is needed to "put" the magnetometer data into the Earth plan. I mean, if the magnetometer is on "the Earth plan" the reference to compute the orientation you use the formula:

                                                                 orientation(rad) =  atan(-By_calibrated/Bx_calibrated)

If the magnetometer is tilted, you have to use the accelerometer data as an inclinometer to tilt back Bx/By/Bz (magnetometer data) into the normalized Bx/By plan.

I think you can begin with that, implanting hard-iron correction plus accelerator/magnetometer fusion and checking the results.

Have a good day

Anthony

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

0 Kudos
1,646 Views
tedhuntington1
Contributor II

Thanks Anthony,

I have the Hard iron offset working- from the appnote- but my concern is that, unlike a mechanical compass, I need to rotate the device 360+360 degrees before I get accurate readings.

Ted

0 Kudos
1,647 Views
anthonyduhamel
NXP Employee
NXP Employee

Yes I know. Use the 3 points calibrations I called "MCU algorithm based on "circle fitting".

Please send me an email (anthony.duhamel at nxp.com)

Anthony

0 Kudos
1,646 Views
tedhuntington1
Contributor II

i don't have the time to dedicate to it now, and the 3 point calibration method would take some time to implement and test with perhaps less than very useful results- I don't know it's not super critical that the robot is able to track the yaw of each segment right now so I will put your advice onto the back of my thought-screen to ruminate on and perhaps re-visit in the future.

Thanks,

Ted

0 Kudos
1,646 Views
anthonyduhamel
NXP Employee
NXP Employee

Hello Ted,

I attached source codes for Hard-Iron calculation. I think I replied to your questions, please , send me a mail if you have questions on it.

Thanks,

Anthony

0 Kudos
1,646 Views
tedhuntington1
Contributor II

Thanks for the code and all your help Anthony.

Ted

0 Kudos