Do you have any simple tools for understanding hard and soft iron correction for magnetometers?
Successful implementation of magnetometers into an inertial measurement system requires careful management of both sensor and environmental behaviors. Using a fully calibrated inertial measurement unit (IMU), such as the ADIS16480 or ADIS16488, helps address sensor accuracy, but optimal system performance still requires consideration of environmental threats. Even if a perfect magnetometer were available, it still relies on access to the earth’s magnetic field to produce accurate orientation estimates. Any condition that influences the magnitude or direction of the earth’s magnetic field can influence heading accuracy. Magnetic field interference can have both transient and static properties. This post offers principles and techniques that help address static error sources, which typically fall into one of two categories: “hard-iron” and “soft-iron”. Hard iron errors represent magnetic field sources, which add (or subtract) to the earth’s magnetic field. Examples of this type of error are with permanent magnets, power supply currents or when local ferromagnetic material retains residual magnetic fields (become magnetized) from exposure to large magnetic fields. Soft iron errors represent the magnitude and direction change that the earth’s magnetic field experiences when near ferromagnetic objects. Kovar and steel are commonly used materials that can impart soft iron errors on local magnetic fields, as shown in Figure 1 and Figure 2. Note that only distortion sources producing both hard-iron or soft-iron errors can only be compensated for if they remain fixed and rigid relative to the magnetometer as it moved or rotated through space.
Figure 1. Soft-Iron Errors, Example #1
Figure 2, Soft-Iron Errors, Example #2
UNDERSTANDING POTENTIAL ERROR SOURCES
The first step in addressing environmental threats to the earth’s magnetic field is to identify and reduce the impact of potential sources, with respect to the required performance. For the ADIS16480, the performance requirements start with an objective for angle accuracy and the magnetic field intensity at a particular location. For simplicity, let's assume that we are trying to manage against a static heading accuracy of 1 degree and that we are in a location where the horizontal component of the magnetic field is 150mGauss. Use the following relationship to establish our goal for magnetometer accuracy:
Understanding the level of sensitivity, in terms of magnetic field, provides a tool for assessing potential sources of interference. For example, use the following formula to determine the level of magnetic field produced by the power supply current for the ADIS16480, using a single-wire formula and 1cm distance assumption:
This calculation tells us that the power supply cabling and routing can be influential. As a side note, when characterizing this on the ADIS16480, we used a coaxial cable to bring power to the ADIS16480/PCBZ breakout board, which was also raised ~3 feet above the rest of the evaluation hardware, to help manage magnetic field influence in the measurements.
OBSERVING HARD AND SOFT-IRON ERRORS
Once a system design is complete, there are measurement techniques, which identify hard and soft-iron influence in the application environment. While many systems operate in all three inertial axes, starting with two-axis systems will simplify the explanation of these principles. Expansion of these principles to a three-axis system will follow. For a two-axis system, the earth’s magnetic field breaks down into two components: normal and tangential. The tangential component represents the field that magnetometer sensors will measure, while rotating around the “normal” axis as shown in Figure 4. In a perfect situation, the orientation angle of the 2-axis magnetometer will follow this relationship:
Figure 4 provides a graphical representation of this relationship, using a polar plot. When the hard-iron and soft-iron values are equal to zero, this plot will be a perfect circle, with an origin at (0, 0). Using the polar plot representation, hard-iron errors that remain fixed and rigid to the sensor as it is rotated through space will results in the origin moving away from the (0, 0) position on the plot. In Figure 5, the origin in the second plot is at (1,-2). Soft-iron errors that remain fixed and rigid relative to the sensor are illustrated in Figure 6 where the field direction is skewed by ~10° and the field intensity varies by ~±25%.
Figure 4. Ideal X-Y Magnetometer Polar Plot
Figure 5. X-Y Magnetometer Polar Plot with Hard-Iron Errors
Figure 6. X-Y Magnetometer Polar Plot with Soft-Iron Errors
DEVELOPING CORRECTION FACTORS (2-AXIS)
For simplicity, let's start with describing the process of developing correction factors for a two-axis system.
The two axes will be labeled as "X" and "Y." The goal of this process will be to determine the correction factors that are associated with the following equation:
In this relationship, S11 and S22 correct for the scale errors associated with the soft-iron errors. When zero errors exist, they will be equal to 1. The S12 and S21 provide correction for the "skew angle" that is associated with the soft-iron errors. When zero errors exist, they will be equal to 0.
The Hx and Hy factors represent the hard-iron errors and will be equal to zero, when no hard-iron influences are present.
Download the attached Excel file, 488-MagnSweeps-w-RegisterCalc.xlsx to follow along with the explanation of developing the correction factors, using simulated data. This file contains two sheets: 2-Dimensional Model and Register_Worksheet. The 2-Dimensional Model contains the error entry, simulation and correction factor calculations. The sheet contains an automated process for converting them into the hexadecimal codes for the relevant registers in the ADIS16480 or ADIS16488. Note that this file can support the use of real data, assuming that the data represents the same 10 degrees increments during the rotation. Here is a step by step description of this file:
CONVERTING CORRECTION FACTORS INTO REGISTER CODES
The Register_Worksheet sheet in the 488-MagnSweeps-w-RegisterCalc.xlsx file contains an example method for converting the correction factors into the hexadecimal codes for each relevant register. Here are some key highlights:
APPLICATION TO 3-AXIS SYSTEMS
For the 3-axis system, one can use a series of 2-axis processes. The simplest system is one where rotation is limited to rotation within a single plane. Data is captured and the 4-element soft-iron calibration compensation matrix along with the 2-element hard-iron compensation vector are calculated using the attached spreadsheet as noted previously. The 9 element soft-iron and 3 element hard-iron correction registers are then loaded based upon the axis of rotation. An example of a rotation about the X-Y axis is shown below. Note the diagonal elements of the soft-iron matrix are normally set to unity.
In order to fully load the above matrix and vector a more in-depth process is required. If precise positioning of the IMU is available allowing for sweeps about all three axis in sequence then the two-axis calibration process can be repeated for each of the three separate sweeps with portions of the above matrix and vector being calculated and loaded between sweeps. Otherwise, if the motion of the IMU is less controlled a larger random motion contiguous data set can be captured where an ellipse fitting routine such as is available within MATLAB (ellipsoid_fit.m) can be used to derive the calibration coefficients.
More in our next post. Thank you! We look forward to your feedback.
Special thanks to RandyGBO for collaboration on this FAQ!
As a follow-up to this FAQ, click on the following link to access the ellipsoid_fit.m file.
pouya: thank you for your comment. Since your question relates to a different topic that this FAQ presents, can you please start a new discussion and mark it as a question? To be honest, I am not even sure what you are asking either, so a bit more clarity would help us answer your question.
It would appear like the original file location does not exist anymore. Here is the ellipsoid function location:
Thank you for posting this question. I'm actually looking into this right now, but I'm not sure how fast I'll be able to get that done. For the short-term, the "evecs" variable represents the skew angle on all three axes and the "radii" I variable can be used for scaling once you correct for the skew angle on each axis. Posting this as a separate discussion might widen your audience; perhaps somebody else might've already done this. Just an idea.
Could you develop on how to derive the S and H matrices from the output of the ellipsoid_fit function?
Thanks a lot,