Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Scalar calibration of Vector Magnetometer and Accelerometer

GyroLib August 18, 2011


Abstract Calibration is necessary step when you are trying to build some measurement system from scratch. While commercially available micro-mechanical devices are said to be factory-calibrated there are still lot to calibrate, especially in the case of vector magnetometer. There are several methods to calibrate the three-axial, vector sensors. The easiest one is those when you know exactly the attitude of the sensors module. Unfortunately this is not the case when you are trying to build the AHRS - the reference-class turntables are quite expensive. But there is a method called scalar calibration that is perfectly suitable to calibrate magnetometers and accelerometers used to build an AHRS even in a small lab - so called scalar calibration. In this article we will describe two approaches to calibrate vector sensors by scalar calibration method - batch approach with non-linear least squares (LSQ), and recursive real-time approach with Extended Kalman Filter (EKF).

1 Vector magnetometer calibration - batch processing with non-linear LSQ


Three-axis accelerometer module consists of three accelerometers with mutually orthogonal sensitivity axes. In general main error sources for three-axial accelerometer are biases, scale factors, and axis misalignment. Simple linear model for it can be written as: axmeas Axx Axy Axz ax bx aymeas = Ayx Ayy Ayz ay + by (1) aymeas Azz Azy Azz az bz From geometrical standpoint the apex of calibrated three-axial sensor vector measurement will lay on a spherical surface with radius equal to the module of the 1

vector. Such a surface can be easily illustrated by recording a three channels data from the vector magnetometer while rotating it in 3D. Figure 1 shows the ideal apex sphere for an ideal sensor.

Figure 1: Spherical surface for calibrated vector sensor It can be easily seen that vector sensor with errors will have an ellipsoidal apex surface. From (1) it is obvious that diagonal elements of matrix A are responsible for ellipsoid main axes length, o-diagonal elements are responsible for the orientation of ellipsoid and elements of b matrix for the transfer of ellipsoid centre. Figure 2 shows an example of such ellipsoid.

Figure 2: Ellipsoid surface for vector sensor with errors

For the three-axial accelerometer the diagonal elements of matrix A represent the scale factors, o-diagonal elements - the axis misalignment, and the elements of b matrix - zeros biases. For the vector magnetometer the elements of matrices A and b are represent Poison coecients: A responsible for soft-iron eects and b for the hard-iron ones.

1.1 Scalar calibration


Scalar calibration is an approach to the calibration of vector sensors that require only measurements of the module of the vector. H=
2 2 2 Hx + Hy + Hz

(2)

It can be easily seen that the problem of nding the optimal set of A and b matrices coecients, that will minimize the dierence between measured vector module and desired calibrated module (which in our case is equal to 1 both for the accelerometer and magnetometer) is similar to curve-tting problem done by non-linear LSQ. Let us consider practical example of vector magnetometer calibration using non-linear LSQ and Matlab environment with lsqcurvef it function, that uses Levenberg-Marquardt algorithm. First we need data set, recorded while vector magnetometer was rotated in 3D several times. Figure 3 shows the apex trajectory of measured vector. Figure 4 shows the module of measured magnetic eld during calibration rotation.

0.6 0.4 0.2 0 0.2 0.4 0.6

0.5 0 0 0.5 0.5 0.5

Figure 3: Apex trajectory of uncalibrated magnetometer Its obvious from the above gures that sensor is far from being perfectly calibrated and will inevitably cause signicant errors to the AHRS output angles. 3

Applying Matlabs lsqcurvef it or other non-linear LSQ computational routine one can estimate coecients of error model. From the gures 5 and 6 one can see that scalar non-linear LSQ, batch approach to the calibration of vector magnetometer enables eective estimation of this sensors error model. Same results can be obtained for the three-axis accelerometer.

0.85

0.8

Magnetic field module

0.75

0.7

0.65

20

40

60

80 100 Time, sec

120

140

160

180

Figure 4: Magnetic eld module measured by uncalibrated magnetometer

uncalibrated calibrated

0.5

0.5

1 0.5 0 0.5 1 0.5 0.5 0 1

Figure 5: Apex trajectories of uncalibrated and calibrated magnetometer

1.5 uncalibrated calibrated

Magnetic field module

0.5

20

40

60

80 100 Time, sec

120

140

160

180

Figure 6: Magnetic eld module measured by uncalibrated and calibrated magnetometer

2 Vector magnetometer calibration - recursive processing with EKF


Batch approach described above provides an ecient way to calibrate vector magnetometer or three-axial accelerometer in the laboratory in an o-line fashion: acquire data while rotating corresponding sensor, when nd calibration coecients. But such an approach is not very useful when you need to calibrate sensor in an online mode. For example, the magnetic environment can change during sensors lifetime aboard - so you need to nd new set of coecients by means of correction the factory-dened set. Extended Kalman Filter (EKF) can be easily employed to build the recursive, on-line calibration algorithm for the vector magnetometer. Magnetometer calibration is a parameter estimation problem, so we need to dene state vector for the system. Clearly, the state vector here is nine-element vector (for the sake of simplicity we assume that A matrix in (1) is symmetric), that consists of the elements from corresponding equation (1). So we dene state vector as: X = Axx Ayy Azz Axy Axz Ayz bx by bz
T

(3)

As long as the estimated components of the state are assumed to be constant, the system equation is the following expression: X=0 (4)

Kalman Filter measurements for the scalar calibration case are dened as the dierence between desired eld module (assumed to be 1 here) and measured led module, so the measurement function is dened to be: z = h(X) h(X) =
2 2 2 C1 + C2 + C3

(5)

C1 = (ax Axx + ay Axy + az Axz + bx ) C2 = (ax Axy + ay Ayy + az Ayz + by ) C3 = (ax Axz + ay Ayz + az Azz + bx ) Above equation is a non-linear function of state vector, so we will use an Extended Kalman Filter. Jacobean matrix for the measurement equation is dened as: h H= X H = D1 D2 D3 D4 D5 D6 D7 D8 D9 (6) D1 = D4 = D7 =
mx C1 , 2 2 2 C1 +C2 +C3 my C1 +mx C2

D2 = D5 = D8 =

my C2

2 2 2 C1 +C2 +C3 C1 2 2 2, C1 +C2 +C3

2 2 2 C1 +C2 +C3 mz C1 +mx C3 2 2 2, C1 +C2 +C3 2 C2 2 2 , C1 +C2 +C3

D3 = D6 = D9 =

mz C3 , 2 2 2 C1 +C2 +C3 mz C2 +my C3

2 2 2 C1 +C2 +C3 C3 2 2 2, C1 +C2 +C3

Thus, having dened both state and measurement equation, the standard set of discrete Kalman lter equations can be employed to estimate calibration coefcients: T Pk = Fk Pk1 Fk + Qk
Xk = Fk Xk1 T T Kk = (Pk Hk )/(Hk Pk Hk + Rk ) + Xk = Xk + Kk (zk h(Xk )) + Pk = Pk Kk Hk Pk

2.1 Practical example


Lets consider the same data set for EKF magnetometer calibration that was used for batch LSQ calibration (gures 3 and 4). Discrete Kalman lter matrices are as follows: Discrete system state matrix F = I1515 , where I is identity matrix Discrete system state noise matrix Q = I1515 1e 10 Measurement noise matrix (only one measurement available - vector modulus) R = 1 Initial value for the state vector X0 = 1.0 1.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 Figure 7 shows the evolution of the covariance matrix trace during the estimation process and in gure 8 the evolution of nine calibration coecients can be seen.
10
2

trace(P)

10

log(trace(P))

10

10

10

10

20

40

60

80 100 Time, sec

120

140

160

180

Figure 7: Evolution of covariance matrix trace during estimation process It can be readily seen from above two pictures that EKF calibration of vector magnetometer provides an ecient way to interactive calibration of one aboard of moving object given sucient amount of attitude modulation.

1.6 1.4 1.2 1 Coefs value 0.8 0.6 0.4 0.2 0 0.2

Pxx Pyy Pzz Pxy Pxz Pyz P P


x0 y0

Pz0

20

40

60

80 100 Time, sec

120

140

160

180

Figure 8: Evolution of calibration coecients during estimation process

3 Conclusion
Two approaches to the scalar calibration of vector sensor was presented. Batch approach is based in non-linear LSQ and provides an ecient and robust procedure of calibration. EKF-based recursive estimation is especially eective when one needs to calibrate sensor, especially magnetometers aboard of moving carrier.

You might also like