# Complete Triaxis Magnetometer Calibration in  the Magnetic Domain

Authors: Valérie Renaudin; Muhammad Haris Afzal; Gérard Lachapelle
Journal: Journal of Sensors
 (2010)

---

## Abstract

This paper presents an algorithm for calibrating erroneous tri-axis magnetometers in the magnetic field domain. Unlike existing algorithms, no simplification is made on the nature of errors to ease the estimation. A complete error model, including instrumentation errors (scale factors, nonorthogonality, and offsets) and magnetic deviations (soft and hard iron) on the host platform, is elaborated. An adaptive least squares estimator provides a consistent solution to the ellipsoid fitting problem and the magnetometer's calibration parameters are derived. The calibration is experimentally assessed with two artificial magnetic perturbations introduced close to the sensor on the host platform and without additional perturbation. In all configurations, the algorithm successfully converges to a good estimate of the said errors. Comparing the magnetically derived headings with a GNSS/INS reference, the results show a major improvement in terms of heading accuracy after the calibration.


---

## Body

## 1. Introduction

To navigate on Earth, knowledge of two fundamental  parameters is required: the actual position and the direction of motion. Over the years, humans have been using a large variety of tools to identify these parameters. They first consisted of natural landmarks, like mountains or stones that early men could easily recognize and remember during their travels. Then navigators adopted celestial objects to orient themselves. More recently, man-made orientation tools have been added. Dedicated signage and a variety of radio frequency (RF) signals, like satellite signals, WiFi, or RF Identification Devices belong to this category. This list would not be complete without considering a natural element, specific to the Earth, the Earth’s magnetic field. Indeed it has been used for several millennia for estimating the orientation relative to the North and South magnetic poles.One of the first magnetic compasses was invented by the Chinese thousands of years ago. It was made of a bowl filled with water, used as a leveling platform, and a magnetic lodestone placed on a plate floating on the water [1]. With the advancements in Integrated Circuit (IC) fabrication and sensor technology, magnetometers are nowadays miniaturized and integrated in handheld devices. Consequently, their use for mobile navigation faces increasing interest. As illustrated in Figure 1, knowing the horizontal component of the Earth’s magnetic field and the local declination, the geographical azimuth φ can be derived as follows:(1)φ=tan-1(hyhx)±D.Figure 1
Earth’s magnetic field in the sensor reference frame.D is the declination angle between the geographic North and the horizontal component. I is the inclination angle between the horizontal plane and the magnetic field vector.However, the measurements of the magnetic field obtained with low cost sensors are corrupted by several errors including sensor fabrication issues and the magnetic deviations induced by the host platform. Therefore proper calibration of the magnetometers is required to achieve high accuracy measurements. The last is generally performed by means of experimentation and calibration parameters estimation techniques. Several procedures and algorithms have been proposed to perform the calibration. However their performances often rely on assumptions that constraint the type of the errors in the measurements and ignore some critical components. In general these hypotheses limit the nature of the magnetic deviation to simplified models. In this paper, a novel and full calibration in the magnetic domain for a single tri-axis magnetometer on a host platform is proposed. It estimates the complete error sources without any simplification regarding the effect of magnetic deviation on the host platform. The proposed calibration algorithm is valid for any tri-axial vector magnetometer. Errors induced by magnetic anomalies from the sources that are external to the platform are changing mainly as a function of the separation. Therefore the proposed calibration technique cannot mitigate these varying errors, and dedicated techniques have to be developed [2].This paper is organized into following sections. In Section2, a state of the art of existing magnetometer calibration techniques is explained. Magnetometer error analysis is conducted in Sections 3 and 4. Major issues identified with Anisotropic Magnetoresistive (AMR) magnetometers are used to derive a proper error model for the sensor. The novel calibration algorithm is detailed in Section 5. Finally, Section 6 presents the results of experimental tests for assessing the performances of the new calibration.


## 2. Review of Calibration Techniques

As magnetic compasses have been used for many years to navigate, the problem of magnetometer calibration has already been addressed in numerous researches. At the beginning of the 19th  century, the navigator Nathaniel Bowditch published a guide dedicated to celestial navigation. It contains the well-known swinging calibration technique [3] that requires leveling the instrument and rotating it in a series of known azimuths. The need for external heading information and the constraint of leveling the platform are the main limitations of this method. Using measurements collected during a full rotation of the leveled sensor in the horizontal plane [4] exploits the minimum and maximum values to estimate the scale factors and biases of the compass. This compensation technique is very practical but ignores several sensor errors.A more complete approach in the magnetic field domain has been proposed [5]. This approach is dedicated to sensor sensing a known linear field that remains constant. During the procedure, the device rotates, and an iterative batch Least Squares (LS) estimates the deviation and the combined scale factors of the sensor. Initial conditions are provided by a nonlinear two-step LS using a change of variables. The limitations of this calibration lay in the hypothesis that misalignments can be neglected and that the soft iron deteriorates only the measurements on the sensor’s axis aligned with the induced magnetic field. In [6], a geometric method based on an iterative Maximum Likelihood Estimator (MLE) best fits the device’s measurements to an ellipsoid manifold. A separate closed-form optimal algorithm computes the misalignment matrix.Instead of using software-based calibrations in the magnetic domain, some techniques consist in using non-magnetic platforms dedicated to the calibration of magnetometer. A system based on piezoelectric motors mounted on a platform made of aluminum, brass, plastic, and glass is proposed in [7]. The equipment has three axes of rotation and uses motors and optical encoders to control the motion and improve the calibration outputs.


## 3. Anisotropic Magnetoresistive Sensors

There are a number of magnetic field sensors available today. These sensors can be classified in accordance with their sensitivities as well as their physical size and power consumption. Some applications requiring magnetic field information can afford size, power, and cost in order to get the desired sensitivities. When it comes to pedestrian navigation, there is no compromise on these parameters. As a result of this, one ends up with medium to low grade sensors. With low grade sensors comes a Pandora’s box full of errors. This section describes such sensors and their associated errors.Anisotropic Magnetoresistive (AMR) Sensors belong to the family of miniaturized magnetic field sensors well suited for portable navigation applications. AMR elements change their effective resistance when they pass through a magnetic field. As the name suggests (anisotropy means direction dependent), their sensitivity to incident magnetic field also depends on the angle of incidence. This property makes them useful for sensing magnetic field vector components for orientation estimation. Inside the sensor module, AMR elements are used as the four primary components of a wheatstone bridge. If no magnetic field exists, the voltage out of the wheatstone bridge will be half of the actual voltage applied. In the presence of a uniform magnetic field, the AMR elements will have different resistances changing the output voltage of the wheatstone bridge from its nominal value (1/2 of the applied voltage). This is further elaborated in Figure2.Figure 2
Wheatstone bridge arrangement for sensing the applied magnetic field [8].Thus a simple relationship between changes in voltage to the applied magnetic field can be used for calculating the magnetic field strength. With three orthogonal magnetic field sensors which are required for sensing the magnetic field in three dimensions, three wheatstone bridges are fabricated in a sensor module.The operating principle of AMR sensors as explained in the preceding paragraph is possible only if all four resistances of the wheatstone bridge have the same values in the ideal condition (absence of magnetic field). Although the manufacturers try to fabricate identical AMR elements, the problem with depositing permalloy (NiFe) evenly and of same density causes these magneto-resistive elements to have slightly different values. These slight errors in AMR elements cause an offset on the voltage output of the wheatstone bridge. This voltage offset is read as a magnetic field which does not exist in reality, thus contributing to the sensor bias errors. Hence calibrating the AMR sensors for this offset voltage is necessary. Other issues associated with AMR sensors are associated with the nonlinearity and hysteresis properties of permalloy. All of the instrumentation errors are discussed in the following subsections.


### 3.1. Offset Error

The bridge offset of a particular AMR sensor remains constant for the entire lifespan of the sensor [8]. Thus one needs to compensate for bridge offset just once. This offset is not like the bias associated with accelerometers and gyroscopes that vary with time as well as with turn on/off. The primary means to calculate this bridge offset is accurate calibration. Often Helmholtz coils are used for offset computation. Helmholtz coils are utilized for offset computation because it is necessary to know the exact information regarding the applied field. Usually the Helmholtz coil is used to cancel the Earth’s field (nullify the total magnetic field in the test region) and then analyze the sensor output which will be the offset itself. An alternate method for offset compensation is to measure the sensor output at different orientations assuming that the applied field is constant (a good assumption in outdoor open environment like a park) and use least squares approach to solve for offset using multiple observations.


### 3.2. Sensitivity Error

The AMR elements are non-linear by nature. This means that the sensitivity of the AMR sensors varies with the variations in the magnitude of the sensed magnetic field. This nonlinearity results in scale factor error. In order to compensate for this error, proper calibration of AMR sensors is necessary. For this purpose, external field needs to be generated with known magnitudes, and a function relating scale factor to the input is estimated. The generated magnetic field needs to be strong enough to cover the complete range of expected magnetic field strength. Again in this case, the Earth’s magnetic field is chosen as the source, and measurements are taken at different orientations ranging from no sensed magnetic field (perpendicular to the field vector) to maximum field strength (parallel to the field vector). Care must be taken as this calibration is valid only if the expected field strengths are within the calibration region.


### 3.3. Cross Axis Sensitivity Errors

With time, the AMR sensors attain uneven magnetization, which changes their sensitivity axis orientation. This is shown in Figure3.Figure 3
AMR sensor element with uneven local magnetizations [9].This phenomenon acts as a misalignment error for a three-axis magnetic field measurement. In order to remedy for this error, an inductor/coil is utilized to create a magnetic field in opposite directions that demagnetizes the AMR sensor as shown in Figure4. This method is similar to the one performed for erasing the memory of magnetic tapes. The coil is usually fabricated along with the sensor elements. Frequent use of this coil rectifies any errors due to hysteresis.Figure 4
Use of an inductor/coil to compensate for hysteresis [9].


### 3.4. Sensor Measurement Noise

All of the above-mentioned errors are deterministic and can be compensated for. But the effect of noise on sensor measurements is a stochastic process and needs to be appropriately modeled. For this purpose Allan variance technique is used for modeling these effects. Figure5 depicts the Allan deviation results for one of the sensor axes. Based on this analysis, following noise Power Spectral Density (PSD) parameters (Table 1) are found. Later on, these PSDs can be utilized for modeling the sensor noise at different sampling frequencies.Table 1
Noise power spectral densities for AMR sensor.
ParameterX-axisY-axisZ-axisWideband noise PSD(Gauss/Hz)3.38e-43.24e-43.12e-4Bias PSD(Gauss/Hz)3.91e-53.9e-53.91e-5Correlation time (sec.)707070Figure 5
Allan deviation plot of AMR sensor.


### 3.5. Magnetic Field Specific Errors

In addition to the instrumentation errors, magnetic field sensors also suffer from errors due to magnetic perturbations. Presence of ferromagnetic materials and electromagnetic systems in the vicinity of the sensor are the main cause of these perturbations, that is, the host platform is responsible for these perturbations. Even with proper compensation of instrumentation errors, these perturbations cause artificial bias, scale factor as well as nonorthogonality errors in the sensor measurements. These errors are called artificial here because the instrument itself has nothing to do with them, rather it is the host platform that causes these errors. They can be categorized as hard and soft iron errors.Hard iron errors on the platform are caused by a magnetic source with permanent field in all orientations. In other words, magnetic fields generated due to different electronic subsystems in the vicinity of the sensor and that do not have any or have negligible dependence on the Earth’s magnetic field are called hard iron magnetic sources. These magnetic fields cause a bias in the sensed magnetic field as shown in Figure6.Figure 6
Effects of hard iron errors on sensed magnetic field. A bias is caused due to presence of hard iron errors.Soft iron errors are caused by much complex magnetic fields that are generated by ferro-magnetic materials. These magnetic fields have a direct relationship with the Earth’s magnetic field. Their magnitude depends on the incident angle of the Earth’s magnetic field on the material. Hence it changes as the host platform changes its orientation with respect to the Earth’s magnetic field. The general trend of this phenomenon can be observed in Figures7 and 8.Figure 7
Negligible effects of soft iron errors at some orientation. The field generated by the ferrous element is parallel to that of the Earth’s.Figure 8
Maximum effect of soft iron errors when Earth's magnetic field is aligned with magnetic poles of perturbation source.Thus even with proper compensation of the instrumentation errors with the help of magnetic coil arrangements as discussed earlier, the magnetic field sensor error model still consists of bias, scale factor errors, and non-orthogonalities which need to be properly calibrated before using the sensor data for estimating the magnetic orientation.


## 3.1. Offset Error

The bridge offset of a particular AMR sensor remains constant for the entire lifespan of the sensor [8]. Thus one needs to compensate for bridge offset just once. This offset is not like the bias associated with accelerometers and gyroscopes that vary with time as well as with turn on/off. The primary means to calculate this bridge offset is accurate calibration. Often Helmholtz coils are used for offset computation. Helmholtz coils are utilized for offset computation because it is necessary to know the exact information regarding the applied field. Usually the Helmholtz coil is used to cancel the Earth’s field (nullify the total magnetic field in the test region) and then analyze the sensor output which will be the offset itself. An alternate method for offset compensation is to measure the sensor output at different orientations assuming that the applied field is constant (a good assumption in outdoor open environment like a park) and use least squares approach to solve for offset using multiple observations.


## 3.2. Sensitivity Error

The AMR elements are non-linear by nature. This means that the sensitivity of the AMR sensors varies with the variations in the magnitude of the sensed magnetic field. This nonlinearity results in scale factor error. In order to compensate for this error, proper calibration of AMR sensors is necessary. For this purpose, external field needs to be generated with known magnitudes, and a function relating scale factor to the input is estimated. The generated magnetic field needs to be strong enough to cover the complete range of expected magnetic field strength. Again in this case, the Earth’s magnetic field is chosen as the source, and measurements are taken at different orientations ranging from no sensed magnetic field (perpendicular to the field vector) to maximum field strength (parallel to the field vector). Care must be taken as this calibration is valid only if the expected field strengths are within the calibration region.


## 3.3. Cross Axis Sensitivity Errors

With time, the AMR sensors attain uneven magnetization, which changes their sensitivity axis orientation. This is shown in Figure3.Figure 3
AMR sensor element with uneven local magnetizations [9].This phenomenon acts as a misalignment error for a three-axis magnetic field measurement. In order to remedy for this error, an inductor/coil is utilized to create a magnetic field in opposite directions that demagnetizes the AMR sensor as shown in Figure4. This method is similar to the one performed for erasing the memory of magnetic tapes. The coil is usually fabricated along with the sensor elements. Frequent use of this coil rectifies any errors due to hysteresis.Figure 4
Use of an inductor/coil to compensate for hysteresis [9].


## 3.4. Sensor Measurement Noise

All of the above-mentioned errors are deterministic and can be compensated for. But the effect of noise on sensor measurements is a stochastic process and needs to be appropriately modeled. For this purpose Allan variance technique is used for modeling these effects. Figure5 depicts the Allan deviation results for one of the sensor axes. Based on this analysis, following noise Power Spectral Density (PSD) parameters (Table 1) are found. Later on, these PSDs can be utilized for modeling the sensor noise at different sampling frequencies.Table 1
Noise power spectral densities for AMR sensor.
ParameterX-axisY-axisZ-axisWideband noise PSD(Gauss/Hz)3.38e-43.24e-43.12e-4Bias PSD(Gauss/Hz)3.91e-53.9e-53.91e-5Correlation time (sec.)707070Figure 5
Allan deviation plot of AMR sensor.


## 3.5. Magnetic Field Specific Errors

In addition to the instrumentation errors, magnetic field sensors also suffer from errors due to magnetic perturbations. Presence of ferromagnetic materials and electromagnetic systems in the vicinity of the sensor are the main cause of these perturbations, that is, the host platform is responsible for these perturbations. Even with proper compensation of instrumentation errors, these perturbations cause artificial bias, scale factor as well as nonorthogonality errors in the sensor measurements. These errors are called artificial here because the instrument itself has nothing to do with them, rather it is the host platform that causes these errors. They can be categorized as hard and soft iron errors.Hard iron errors on the platform are caused by a magnetic source with permanent field in all orientations. In other words, magnetic fields generated due to different electronic subsystems in the vicinity of the sensor and that do not have any or have negligible dependence on the Earth’s magnetic field are called hard iron magnetic sources. These magnetic fields cause a bias in the sensed magnetic field as shown in Figure6.Figure 6
Effects of hard iron errors on sensed magnetic field. A bias is caused due to presence of hard iron errors.Soft iron errors are caused by much complex magnetic fields that are generated by ferro-magnetic materials. These magnetic fields have a direct relationship with the Earth’s magnetic field. Their magnitude depends on the incident angle of the Earth’s magnetic field on the material. Hence it changes as the host platform changes its orientation with respect to the Earth’s magnetic field. The general trend of this phenomenon can be observed in Figures7 and 8.Figure 7
Negligible effects of soft iron errors at some orientation. The field generated by the ferrous element is parallel to that of the Earth’s.Figure 8
Maximum effect of soft iron errors when Earth's magnetic field is aligned with magnetic poles of perturbation source.Thus even with proper compensation of the instrumentation errors with the help of magnetic coil arrangements as discussed earlier, the magnetic field sensor error model still consists of bias, scale factor errors, and non-orthogonalities which need to be properly calibrated before using the sensor data for estimating the magnetic orientation.


## 4. Modeling of the Magnetometer Errors

This section translates the error analysis of low cost magnetometer conducted in the preceding section into a mathematical model. From the analysis of AMR sensors, two categories of errors can be distinguished. The first category represents the instrumentation errors. It includes the scale factor, the sensor offsets, and the nonorthogonality of the sensor axes. These errors are due to fabrication limitations and are common for wider variety of sensors, for example, the Micro Electro Mechanical Systems (MEMS). The second category is specific to magnetometers and consists of a magnetic deviation produced by onboard hardware in the hosting platform. Next section examines each error in the sensor frame. It is worth mentioning that temperature dependence is not modeled in what follows.


### 4.1. Instrumentation Error

Instrumentation errors can be considered as unique and constant for one specific tri-axis magnetometer.


#### 4.1.1. Scale Factor

The first instrumentation error corresponds to constants of proportionality relating the input to the output. The scale factor matrixS can be modeled as(2)S=diag⁡(sxsysz).


#### 4.1.2. Nonorthogonality

LetN be a matrix where the column vectors give the direction of each sensor axis in the sensor frame. The inverse of N can be used to correct for the effect of non-orthogonality including the misalignment errors:(3)M=N-1=[εxεyεz]-1,
where εx, εy, and εz are vectors of size 3 that give the directions of the sensor’s x, y, and z axes, respectively, in the sensor frame.


#### 4.1.3. Bias

The sensor offset introduces a biasbso in the output that can be modeled as one scalar per axis(4)bso=[bsozbsoybsoz]T.


### 4.2. Magnetic Deviation

The magnetic deviation is due to surrounding ferromagnetic compounds on the host platform. It is composed of a permanent magnetism and an induced one. The first one is called the hard iron effect whereas the second is the soft iron effect.


#### 4.2.1. Hard Iron

It results from permanent magnets and magnetic hysteresis, that is, remanence of magnetized iron materials and is equivalent to a bias(5)bhi=[bhixbhiybhiz]T.


#### 4.2.2. Soft Iron

The interaction of ferromagnetic compounds with an external field induces magnetism. This changes the intensity as well as the direction of the sensed field. Soft iron effect can be modeled as a 3 by 3 matrix as follows:(6)Asi=[a11a12a13a12a22a23a13a32a33].Here no simplification is made on the nature of the soft iron to ease the calibration procedure. In existing work, often nondiagonal components are eliminated to minimize the model complexities.


### 4.3. Complete Error Modeling

Combining both instrumentation errors and magnetic deviation, it is possible to derive the complete error model for the triad of magnetometers as follows:(7)ĥ=SM(Asih+bhi)+bso+ε,
where h is the error-free magnetic field in the sensor frame whereas ĥ are the readings from the triad of magnetometers in the sensor frame. ε is Gaussian wideband noise ~N(0,σε2).Expanding (7) and introducing two new variables A and b, the magnetometer error modeling becomes(8)ĥ=Ah+b+ε,
where (9)A=SMAsib=SMbhi+bso.A is a 3×3 matrix combining scale factors, misalignments, and soft iron disturbances. b is the combined bias.


## 4.1. Instrumentation Error

Instrumentation errors can be considered as unique and constant for one specific tri-axis magnetometer.


### 4.1.1. Scale Factor

The first instrumentation error corresponds to constants of proportionality relating the input to the output. The scale factor matrixS can be modeled as(2)S=diag⁡(sxsysz).


### 4.1.2. Nonorthogonality

LetN be a matrix where the column vectors give the direction of each sensor axis in the sensor frame. The inverse of N can be used to correct for the effect of non-orthogonality including the misalignment errors:(3)M=N-1=[εxεyεz]-1,
where εx, εy, and εz are vectors of size 3 that give the directions of the sensor’s x, y, and z axes, respectively, in the sensor frame.


### 4.1.3. Bias

The sensor offset introduces a biasbso in the output that can be modeled as one scalar per axis(4)bso=[bsozbsoybsoz]T.


## 4.1.1. Scale Factor

The first instrumentation error corresponds to constants of proportionality relating the input to the output. The scale factor matrixS can be modeled as(2)S=diag⁡(sxsysz).


## 4.1.2. Nonorthogonality

LetN be a matrix where the column vectors give the direction of each sensor axis in the sensor frame. The inverse of N can be used to correct for the effect of non-orthogonality including the misalignment errors:(3)M=N-1=[εxεyεz]-1,
where εx, εy, and εz are vectors of size 3 that give the directions of the sensor’s x, y, and z axes, respectively, in the sensor frame.


## 4.1.3. Bias

The sensor offset introduces a biasbso in the output that can be modeled as one scalar per axis(4)bso=[bsozbsoybsoz]T.


## 4.2. Magnetic Deviation

The magnetic deviation is due to surrounding ferromagnetic compounds on the host platform. It is composed of a permanent magnetism and an induced one. The first one is called the hard iron effect whereas the second is the soft iron effect.


### 4.2.1. Hard Iron

It results from permanent magnets and magnetic hysteresis, that is, remanence of magnetized iron materials and is equivalent to a bias(5)bhi=[bhixbhiybhiz]T.


### 4.2.2. Soft Iron

The interaction of ferromagnetic compounds with an external field induces magnetism. This changes the intensity as well as the direction of the sensed field. Soft iron effect can be modeled as a 3 by 3 matrix as follows:(6)Asi=[a11a12a13a12a22a23a13a32a33].Here no simplification is made on the nature of the soft iron to ease the calibration procedure. In existing work, often nondiagonal components are eliminated to minimize the model complexities.


## 4.2.1. Hard Iron

It results from permanent magnets and magnetic hysteresis, that is, remanence of magnetized iron materials and is equivalent to a bias(5)bhi=[bhixbhiybhiz]T.


## 4.2.2. Soft Iron

The interaction of ferromagnetic compounds with an external field induces magnetism. This changes the intensity as well as the direction of the sensed field. Soft iron effect can be modeled as a 3 by 3 matrix as follows:(6)Asi=[a11a12a13a12a22a23a13a32a33].Here no simplification is made on the nature of the soft iron to ease the calibration procedure. In existing work, often nondiagonal components are eliminated to minimize the model complexities.


## 4.3. Complete Error Modeling

Combining both instrumentation errors and magnetic deviation, it is possible to derive the complete error model for the triad of magnetometers as follows:(7)ĥ=SM(Asih+bhi)+bso+ε,
where h is the error-free magnetic field in the sensor frame whereas ĥ are the readings from the triad of magnetometers in the sensor frame. ε is Gaussian wideband noise ~N(0,σε2).Expanding (7) and introducing two new variables A and b, the magnetometer error modeling becomes(8)ĥ=Ah+b+ε,
where (9)A=SMAsib=SMbhi+bso.A is a 3×3 matrix combining scale factors, misalignments, and soft iron disturbances. b is the combined bias.


## 5. Calibration Algorithm

### 5.1. Constraint on the Magnitude of the Measured Field

In a perturbation free-environment, the norm of the magnetometer vector measurement should be equal to the magnitude of the Earth’s magnetic field. Consequently while rotating the sensor in space, the locus described by its readings should describe a sphere with a radius equal to the magnitude of the local Earth’s magnetic field [5]. This norm Hm can be extracted from a specific geomagnetic model [10]. The following equation constraints the measurements of a perfect magnetometer in a perturbation free environment:
(10)Hm2-‖h‖2=Hm2-hTh=0.
If the square transformation matrix A and the combined bias b are known, then (8) can be rewritten as
(11)h=A-1(ĥ-b-ε).
Substituting (11) in (10) and omitting the noise term gives(12)(ĥ-b)T(A-1)TA-1(ĥ-b)-Hm2=0.
Introducing the following intermediate parameter:(13)Q=(A-1)TA-1,
equation (12) becomes(14)(ĥ-b)TQ(ĥ-b)=Hm2.
Expanding (14), the following quadratic equation is obtained: (15)ĥTQĥ+uTĥ+k=0,
where
(16)u=-2QTbk=bTQb-Hm2.
This equation represents a general plane of the second order and describes a surface, for example, a hyperboloid, a cone, or an ellipsoid. Because Q is a positive definite matrix, inherited from its definition, if the following condition holds then (15) is an ellipsoid [11]: (17)uTQ-1u>4k.
Differencing the terms on the left and right sides of the inequality gives(18)uTQ-1u-4k=Hm2.
The square of the amplitude of the Earth Magnetic field is strictly positive, thus condition (17) holds. It implies that (15) is the general equation of an ellipsoid. Consequently calibrating a tri-axis magnetometer corresponds to estimating the unknown parameters of (15) knowing that this second-order equation describes an ellipsoid.Consequently using magnetic field measurements collected in a perturbation-free environment, along several orientations that best describe the ellipsoid, it is possible to use the constraint on the norm of the field vector (10) to calibrate the magnetometers for the sensor errors and the hosting platform effect.The proposed calibration algorithm comprises two steps. First the parameters of the ellipsoid equation are estimated, and then the calibration elementsA and b in (11) are derived. To our knowledge, the proposed calibration algorithm is novel for the two following reasons. It does not require any assumption on the magnetic deviation. It calibrates directly the magnetic readings without estimating the geometrical proprieties of the ellipsoid (rotation, translation, and lengths of the semiaxes).


### 5.2. Limitations of Classical Ellipsoid Fitting Algorithms

The first step consists in finding the parametersb and Q that satisfy (15), which is an ellipsoid fitting problem with magnetic field measurements collected along different orientations.Several methods have been developed. Algebraic fitting methods try to solve an optimization problem using least squares techniques [12, 13]. Geometric fitting approaches try to minimize the Euclidian distance from a point to the dataset using orthogonal regression method [14]. However due to the quadratic form in the measurement in (10), these techniques are statistically inconsistent. Indeed, analyzing the derivation of the noise term ε in (10), it is shown that the algorithm’s solution may be biased. Introducing (11) in the quadratic equation, we have(19)‖A-1(ĥ-b)‖2=‖h+A-1ε‖2=‖h‖2+2hTA-1ε+εTQε=‖h‖2+δ.
With the variable h and the noise term ε being independent and zero mean, the new noise term δ has still undesirable proprieties as its expectation can be strictly positive:(20)E(δ)=2E(hTA-1ε)+E(εTQε)≥0.
If the assumption that the noise term ε tends to be null holds for the magnetometer measurements, then previous estimation techniques will provide the exact parameters. However, we consider low grade AMR sensors that have relatively high noise level. Consequently an unbiased ellipsoid fitting algorithm that treats the noise as an additional parameter in the estimation process is considered.


### 5.3. Calibration Algorithm

The next step consists in extracting the elementsA and b defined in (8) and required to calibrate the magnetometers readings.The Adaptive Least Squares (ALS), described in [11], estimates the solution (Q, u, k) from (15) along with the measurement error variance σε2. Correcting for the quadratic nature of the constraint on the norm of the magnetic field measurements in the LS, the ALS algorithm provides a consistent solution to the ellipsoid fitting problem. Therefore it is adapted here for the calibration of low cost magnetometers.The combined biasb, corresponding to the translation of the ellipsoid coordinate system, is computed from (16):(21)b=12Q-1u.Knowing the ALS estimate ofQ, the matrix A can be derived from (13). Because Q is a positive definite matrix, an eigen-decomposition can be applied: (22)Q=αVDVT,
where α∈ℝ, V corresponds to the eigenvectors of QQT, and D is a 3×3 diagonal matrix containing the eigenvalues λi, i∈{1,2,3}. The columns of V form the basis vector directions for Q. Let us define(23)D=[λ1000λ2000λ3]B=VαDVT.
We can then write(24)BTB=VαDVTVαDVT=αVDVT.B corresponds to the matrix square root of Q and gives the solution for A-1. To find α, we apply constraint (18) on the norm of the magnetic field measurement. Expanding (15) while introducing (22) gives (25)ĥTVαDVTĥ+2bTVαDVĥ+bTVαDVb-Hm2=0.
The introduction of α changes the definition of k, and (18) becomes (26)k=bTVDVb-Hm2α.
Expanding (26) using (21) and (22),  it is possible to compute α as follows:(27)α=4Hm24k-(VTu)TD-1(VTu).
Finally (11) can be applied on the magnetic field measurements to calibrate for the host platform influence. Calibrated magnetic field measurements are given by(28)h=VαDVT(ĥ-b-ε).


## 5.1. Constraint on the Magnitude of the Measured Field

In a perturbation free-environment, the norm of the magnetometer vector measurement should be equal to the magnitude of the Earth’s magnetic field. Consequently while rotating the sensor in space, the locus described by its readings should describe a sphere with a radius equal to the magnitude of the local Earth’s magnetic field [5]. This norm Hm can be extracted from a specific geomagnetic model [10]. The following equation constraints the measurements of a perfect magnetometer in a perturbation free environment:
(10)Hm2-‖h‖2=Hm2-hTh=0.
If the square transformation matrix A and the combined bias b are known, then (8) can be rewritten as
(11)h=A-1(ĥ-b-ε).
Substituting (11) in (10) and omitting the noise term gives(12)(ĥ-b)T(A-1)TA-1(ĥ-b)-Hm2=0.
Introducing the following intermediate parameter:(13)Q=(A-1)TA-1,
equation (12) becomes(14)(ĥ-b)TQ(ĥ-b)=Hm2.
Expanding (14), the following quadratic equation is obtained: (15)ĥTQĥ+uTĥ+k=0,
where
(16)u=-2QTbk=bTQb-Hm2.
This equation represents a general plane of the second order and describes a surface, for example, a hyperboloid, a cone, or an ellipsoid. Because Q is a positive definite matrix, inherited from its definition, if the following condition holds then (15) is an ellipsoid [11]: (17)uTQ-1u>4k.
Differencing the terms on the left and right sides of the inequality gives(18)uTQ-1u-4k=Hm2.
The square of the amplitude of the Earth Magnetic field is strictly positive, thus condition (17) holds. It implies that (15) is the general equation of an ellipsoid. Consequently calibrating a tri-axis magnetometer corresponds to estimating the unknown parameters of (15) knowing that this second-order equation describes an ellipsoid.Consequently using magnetic field measurements collected in a perturbation-free environment, along several orientations that best describe the ellipsoid, it is possible to use the constraint on the norm of the field vector (10) to calibrate the magnetometers for the sensor errors and the hosting platform effect.The proposed calibration algorithm comprises two steps. First the parameters of the ellipsoid equation are estimated, and then the calibration elementsA and b in (11) are derived. To our knowledge, the proposed calibration algorithm is novel for the two following reasons. It does not require any assumption on the magnetic deviation. It calibrates directly the magnetic readings without estimating the geometrical proprieties of the ellipsoid (rotation, translation, and lengths of the semiaxes).


## 5.2. Limitations of Classical Ellipsoid Fitting Algorithms

The first step consists in finding the parametersb and Q that satisfy (15), which is an ellipsoid fitting problem with magnetic field measurements collected along different orientations.Several methods have been developed. Algebraic fitting methods try to solve an optimization problem using least squares techniques [12, 13]. Geometric fitting approaches try to minimize the Euclidian distance from a point to the dataset using orthogonal regression method [14]. However due to the quadratic form in the measurement in (10), these techniques are statistically inconsistent. Indeed, analyzing the derivation of the noise term ε in (10), it is shown that the algorithm’s solution may be biased. Introducing (11) in the quadratic equation, we have(19)‖A-1(ĥ-b)‖2=‖h+A-1ε‖2=‖h‖2+2hTA-1ε+εTQε=‖h‖2+δ.
With the variable h and the noise term ε being independent and zero mean, the new noise term δ has still undesirable proprieties as its expectation can be strictly positive:(20)E(δ)=2E(hTA-1ε)+E(εTQε)≥0.
If the assumption that the noise term ε tends to be null holds for the magnetometer measurements, then previous estimation techniques will provide the exact parameters. However, we consider low grade AMR sensors that have relatively high noise level. Consequently an unbiased ellipsoid fitting algorithm that treats the noise as an additional parameter in the estimation process is considered.


## 5.3. Calibration Algorithm

The next step consists in extracting the elementsA and b defined in (8) and required to calibrate the magnetometers readings.The Adaptive Least Squares (ALS), described in [11], estimates the solution (Q, u, k) from (15) along with the measurement error variance σε2. Correcting for the quadratic nature of the constraint on the norm of the magnetic field measurements in the LS, the ALS algorithm provides a consistent solution to the ellipsoid fitting problem. Therefore it is adapted here for the calibration of low cost magnetometers.The combined biasb, corresponding to the translation of the ellipsoid coordinate system, is computed from (16):(21)b=12Q-1u.Knowing the ALS estimate ofQ, the matrix A can be derived from (13). Because Q is a positive definite matrix, an eigen-decomposition can be applied: (22)Q=αVDVT,
where α∈ℝ, V corresponds to the eigenvectors of QQT, and D is a 3×3 diagonal matrix containing the eigenvalues λi, i∈{1,2,3}. The columns of V form the basis vector directions for Q. Let us define(23)D=[λ1000λ2000λ3]B=VαDVT.
We can then write(24)BTB=VαDVTVαDVT=αVDVT.B corresponds to the matrix square root of Q and gives the solution for A-1. To find α, we apply constraint (18) on the norm of the magnetic field measurement. Expanding (15) while introducing (22) gives (25)ĥTVαDVTĥ+2bTVαDVĥ+bTVαDVb-Hm2=0.
The introduction of α changes the definition of k, and (18) becomes (26)k=bTVDVb-Hm2α.
Expanding (26) using (21) and (22),  it is possible to compute α as follows:(27)α=4Hm24k-(VTu)TD-1(VTu).
Finally (11) can be applied on the magnetic field measurements to calibrate for the host platform influence. Calibrated magnetic field measurements are given by(28)h=VαDVT(ĥ-b-ε).


## 6. Experimental Assessment

To assess the new calibration technique, experimental tests have been conducted in an open field on the campus of the University of Calgary. The site’s location was chosen to insure a clean environment in terms of artificial magnetic field anomalies.For these tests, the multimagnetometer platform developed for magnetic indoor surveying was used [15]. It consists of twelve tri-axis HMC5843 AMR sensors  from Honeywell located on two perpendicular circles. The multi-magnetometer hardware and the SPAN HG1700 GNSS/INS system from NovAtel have been rigidly mounted on a plastic platform, as illustrated in Figure 9. The rover GNSS/INS data and the one from a base station have been postprocessed in a tight coupling mode using the Inertial Explorer software from NovAtel. The computed heading is used as a reference to assess the performance of the proposed calibration.Figure 9
Test setup of the field data collection comprising the multi-magnetometer platform and the SPAN HG1700 GPS/INS system.The new calibration algorithm has been tested in three different scenarios portraying different magnetic configurations artificially introduced on the hardware. The first configuration corresponds to the test setup described earlier without any man-made perturbation on it. For the second and third configurations, additional changes of the local magnetic field have been introduced on the platform. The first change consists of a screw that was placed on the platform. This second configuration is depicted in Figure10. For the third configuration, illustrated in Figure 11, the screw was removed and a nut was attached to the platform.Figure 10
Test setup configuration number 2 with a screw taped on the multi-magnetometer device.Figure 11
Test setup configuration number 3 with a nut taped on the multi-magnetometer device.The calibration consists in fitting the magnetometer’s field measurements, collected while rotating the platform along random paths, on the sphere manifold whose radius equals the norm of the local Earth’s magnetic field. The local Earth’s magnetic field vector can be extracted from geomagnetic models. The site location being in Calgary, theCanadian Geomagnetic Reference Field was used in this experiment.Figures12 and 13 depict the measurements from the AMR sensor that is located close to the screw in Figure 10 before and after the calibration. All presented results are computed using the same AMR sensor.Figure 12
Non-calibrated magnetic field measurements plotted on the sphere manifold whose radius equals the norm of the local Earth’s magnetic field.Figure 13
Calibrated magnetic field measurements plotted on the sphere manifold whose radius equals the norm of the local Earth’s magnetic field.The plots correspond to the magnetic pattern of the second configuration with the screw. It is important to notice that all results in this section are presented for this sensor only. Similar results could have been presented for all twelve magnetometers from the multi-magnetometer platform. However for the conciseness of the paper, only the results for this specific sensor, which is the most perturbed one, are presented. As it can be visually observed in Figure12, noncalibrated data are strongly affected by the presence of the screw. The readings in red are not located on the sphere manifold, whose radius equals the norm of the local Earth’s magnetic field. As expected after the calibration, all AMR readings, depicted in blue in Figure 13, are relocated on the sphere manifold providing calibrated data.Tables2, 3, and 4 give the calibration parameters computed with the proposed algorithm. As described in Section 5.2, the standard deviation of the measurement errors is also estimated during the calibration to assess the validity of the ellipsoid fitting. Estimated standard deviation varies between 0.37 and 0.39 microtesla for all three configurations. Using the power spectral density of the wideband noise given in Table 1, it is possible to assess if the estimation of the measurement’s noise lies in the range of the HMC5843 sensor noise. With the 50 Hz sampling rate, the expected sensor noise becomes 0.4 micro Tesla, which is above the upper limit of estimated noise interval. This establishes the validity of the estimated calibration  parameters.Table 2
Calibration parameters for configuration 1 (void).
ParameterCalibration resultsσε: standard deviation of measurement noise [μ Tesla]0.37b: combined bias [μ Tesla]-4.64-0.242.95A: scale factors, soft iron, and misalignments [n.u.]1.0192-0.0059-0.0089-0.00591.0169-0.0032-0.0089-0.00321.0008Table 3
Calibration parameters for configuration 2 (screw).
ParameterCalibration resultsσε: standard deviation of measurment noise [μ Tesla]0.39b: combined bias [μ Tesla]4.2944.15-27.86A: scale factors, soft iron, and misalignments [n.u.]1.03210.0199-0.0241-0.01991.0114-0.0083-0.0241-0.00831.0035Table 4
Calibration parameters for configuration 3 (nut).
ParameterCalibration resultsσε: standard deviation of measurment noise [μ Tesla]0.39b: combined bias [μ Tesla]-5.45-0.144.10A: scale factors, soft iron, and misalignments [n.u.]1.0270-0.0097-0.0050-0.00971.02130.0037-0.0050.00370.9990The combined bias for configuration 2 is completely different from the ones in the other two configurations. The main explanation comes from the shape of the screw that introduces larger variations in the magnetic field than the nut due to magnetization currents, causing a hard iron effect in the local magnetic field. It is also interesting to notice that the off-diagonal values of the combined matricesA vary between each different configuration. Because these elements are unitless, it is difficult to evaluate the variation’s gradient. However, except for the soft iron effects, all other error types are fixed for a specific triad as described in Section 4. Therefore any modification of the off diagonal elements in the matrix A between the different scenarios most probably comes from the soft iron modeling.  This comforts the importance of getting a proper modeling and estimation, not only of the scale factors, but also of the soft iron effect and the non-orthogonality of the sensor axes.Final assessment of the new calibration is done comparing the magnetically derived heading with the reference heading from the GNSS/INS system for all three magnetic configurations. In Figure14, the difference between the two previous headings is plotted using non calibrated magnetic field measurements. In accordance with previous analysis that uses the estimated calibration parameters, the second configuration, with the screw fixed on the platform, shows the maximum heading difference 239 degrees whereas the heading error is reduced to 18 degrees for the two other configurations. Using calibrated magnetic field measurements, this error should be strongly reduced. This can be observed in Figure 15 where the heading errors after calibration for all configurations are depicted. The maximum error is still observed when the screw was introduced, but it is greatly reduced. Indeed its absolute value after calibration is around 5 degrees, which corresponds to a 98% reduction of the azimuth error. Similar improvements are observed for the two other configurations. The heading error is significantly reduced from 18 degrees to a final value of ±2 degrees.Figure 14
Heading difference between the headings from the GNSS/INS reference and the AMR magnetometer before the calibration.Figure 15
Heading difference between the headings from the GNSS/INS reference and the AMR magnetometer after the calibration.


## 7. Conclusion

A calibration algorithm for calibrating low cost tri-axis magnetometer sensors was derived. Unlike existing algorithms it does not require any simplification on the sensor error modeling and estimates directly the following calibration parameters:(i)
a combined bias including hard iron effect and sensor offset,(ii)
a combined matrix including scale factors, non-orthogonality, and soft iron effect.Because the magnetometer should sense a known linear field, the Earth’s magnetic field, which remains constant in unperturbed environments, a constraint on raw measurements can be applied leading to a quadratic form with unknown parameters. It is demonstrated that the quadratic form describes an ellipsoid. The calibration algorithm uses an adaptive least squares estimator to solve for the ellipsoid fitting problem. Because the algorithm is adapted for non linear equation and treats the large noise level of the measurements, it provides a consistent estimate of the ellipsoid parameters. Once the unknowns from the quadratic equation are known, the calibration algorithm is terminated with the derivation of the final calibration parameters.As presented in this paper, the calibration algorithm provides a complete modeling of the sensor errors and is able to correct for strong magnetic deviation on the host platform. Experimental results show how the calibration parameters vary depending on the local magnetic signature of the platform. The results also show a major improvement in terms of heading accuracy after the calibration. While introducing a man-made anomaly (a screw) in the sensor’s surrounding on the host platform, the absolute heading error is reduced from 239 to 5 degrees with the use of this new calibration algorithm.



---

*Source: 967245-2010-12-01.xml*