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, "magn_sweeps.xls," to follow along with the explanation of developing the correction factors, using simulated data. 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:
- Cells E6:I8 provide user inputs for simulated scale, offset, skew and noise errors.
- Cells C16:D51 provide the simulated ellipse response taking into account the amplitude and noise user inputs and cells E16:F51 apply the phase and offset user entries to this simulation data. The following picture provides a partial sample of this data.
- Cells E11:F13 provide minimum, maximum and average measurements for this data.
- The average measurements represent the "hard-iron" errors. Cells K16:L51 remove these offset errors, in preparation for calculating the soft-iron errors. Note that equally spaced points are required in the simulation data in order for the "Average" function to properly recover the "hard-iron" correction terms.
- Cells M3:M9 and N1:Q51 provide a numerical approach for computing the eignen values and vectors, associated with the ellipse from Cells K16:L51.
- Cells T5:T8 compute the skew angle, using the eigen vales and some conditional "IF" statements, to determine the dominant direction.
- Cells S12:T13 compute the soft-iron correction factors, based on the skew angle and the scale factor from cell M9.
- Cells S16:T51 apply the correction factors to the original response (Cells E16:F51) and Cells Y9:Z12 evaluate the effectiveness of the correction.
- Finally, see the plot of both pre and post correction responses.
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!