Calibration of low-cost triaxial magnetometer

Heading angle of magnetic compasses is estimated using the triaxial magnetometer readings. The accuracy of these readings is influenced by many factors such as sensor errors (scale factors, non-orthogonality, and offsets), and magnetic deviations (soft-iron and hard-iron interference). To calculate the true heading angle, the magnetic calibration of magnetometer is necessary. This research paper describes a calibration procedure for triaxial low-cost MEMS magnetometer. The proposed calibration method determines twelve calibration parameters in 3D arbitrary rotations of magnetometer.


Introduction
Advances in Micro-Electro-Mechanical System (MEMS) technologies have made a great role in wide range of engineering applications.Magnetometers have been used in geophysical research [1], military defence, mineral resources, drilling and mining practice [2].These sensors measure the strength and direction of the local magnetic field.The measured magnetic field is a combination of the Earth's magnetic field and a magnetic field generated by nearby objects.Nevertheless, the main problem are errors such as zero deviation, scale factors, non-orthogonality, measurement noise, misalignment error, hard-iron and soft-iron interferences.The biggest effect comes from soft-iron and hard-iron interferences in the vicinity of the sensors.Before each application, calibration and compensation of such errors needs to be conducted.
There are two types of soft-iron and hard-iron interference compensation.The first methods use specific instruments like turntable, accelerometers or GPS (Global Positioning System).This method is able to reach high accuracy.The least-square method or ellipsoid fitting compensation method belongs in the second type.The traditional method for error compensation is mapping of the ellipsoid data to a sphere data.
Guo et al. [3] used Extended Kalman filter to compensate the soft-iron and hard-iron interference.
Kok et al. [4] presents a calibration algorithm using a maximum likelihood method and a additional inertial sensor.
Renaudin et al. [5] applied an adaptive least square estimator to ellipsoid fitting problem.
Liu et al. [6] describes calibration method using turntable and ellipsoid fitting method.
Cheuk et al. [7] used an evolutionary algorithm to minimize misalignment, scale and bias errors.
a Corresponding author: kuncar@fai.utb.czThe aim of this paper is to evaluate the calibration method which will account magnetometer sensor errors and magnetic interferences.In absence of magnetic interferences, the magnetometer will measure only the three components of the geomagnetic field.The vector magnitude is equal to the magnitude of geomagnetic field at a different orientation.The locus of the magnetometer readings lies on the surface of the sphere centred in zero field and the radius is equal to the magnitude of the geomagnetic field.
The hard-iron interference adds fixed offset in each axis to all measurements.That results in displacement of the sphere centred to the hard-iron offset; however, the geomagnetic field strength is still the same.The locus of the magnetometer measurements is distorted in each axis differently to a 3D ellipsoid in presence of soft-iron interference (Fig. 1).The reminder of this paper is organized as follows.In section 2, the hardware and software for data collection is briefly introduced.The magnetometer error model and magnetometer calibration method is described in section 3 and section 4, respectively.The experimental results of magnetometer calibration is mentioned in section 5.

Equipment
This section provides an overview of the measurement chain.This chain includes control unit, inertial measurement unit (IMU) and software for data collection.

Control unit
The control unit STEVAL-MKI109V2, also known as "eMotion", is primarily designed to provide platform for the evaluation of STMicroelectronics' MEMS modules.This board consists of DIL24 socket to connect MEMS modules, other passive parts like LED diodes for signalization of its own inner states and "jumpers" to set the specific configuration, The board is controlled by the STM32F103RET6 high-performance 32-bit microcontroller based on ARM technology with 512 kB Flash memory functioning as bridge between the MEMS modules and a PC with graphical user interface (GUI) or dedicated software routines for customized applications.The board also includes: • 16 MHz crystal oscillator

• Low noise voltage regulator lds3985xx30
• Low-capacity surge protector of USB interface • Separating and impedance operational amplifiers for the signal adjustment of the MEMS modules

Inertial measurement unit
The STEVAL-MKI124V1 (Fig. 2) is a 10-axis module with IMU including triaxial gyroscope with intern thermometer (L3GD20), triaxial accelerometer and triaxial magnetometer (LSM303DLHC), and barometer (LPS331AP).All of these sensors are based on MEMS technology and factory tested, and trimmed, so no additional calibration is necessary.However, this factory calibration is appropriate only for basic applications.Advanced calibration had to be provided for application such as navigation systems.
Several different configurations allow for settings regarding specific usage.Sensor specifications are given in Table 1. and [8].

Software for data collection and visualization
The last part of the measurement chain is software Unico STSW-MKI109W.This software is used for interaction with sensors and provides: • GUI for data collection and transfer • subsystems for the storage and interpretation of the collected data in graphical or numerical format • configuration of all the registers and the advanced features • drivers for the data interpretation from the corresponding sensor • drivers for the communication interface of the host computer

Magnetometer error model
The magnetometer readings are influenced by many sources of error like wideband measurement noise, stochastic biases, installation errors and magnetic interferences in the vicinity of the sensors.These magnetic interferences can be divided up into two groups: soft-iron and hard-iron interference.The hard-iron interference is caused by the presence of magnets or materials generating fixed or slightly time-varying magnetic field.The second type, soft-iron interference, occurs when a ferromagnetic materials is in the vicinity of the sensor or it can be even generated by the device itself.This will cause the distortion of magnetic field.The traditional method for compensation of such errors is equivalent to transforming the 3-D ellipsoid to the centre oriented sphere.The magnetometer error model is, In this model, the variables M m , S and S I are matrices which interpret misalignment errors, scale factors and soft-iron biases, respectively.O and n are vectors representing hard-iron biases and wideband noise which distorts the true magnetic field measurements M.

Misalignment error is defined as angles between
the magnetometer axis X s , Y s , Z s and the device body axis X d , Y d , Z d .This caused by imperfect mounting of sensor on the PCB (printed circuit board).2. Scale factor error corresponds to constants of proportional relationship between the input and output of the magnetometer.The scale factor can be modelled as S = diag s x s y s z (3) Hard-Iron is equivalent to a bias and can be represented as

Magnetometer calibration
The magnetometer calibration can be performed by 3 full rotations around each sensitive device body axes or 3D arbitrary rotations.The collected raw magnetometer data are used to determine the twelve unknown calibration parameters.
The relationship between the calibrated magnetometer data and the raw magnetometer measurements is expressed as Equation ( 6) can be simplified to [9] where P i are the twelve unknown calibration parameters.

Experimental results
Data were measured while rotating the sensor in 3D arbitrary orientations.The true magnitude of the geomagnetic field in Zlin, Czech Republic (49.2306827 • N, 17.6566617 • E) is 48,996 nT which is 489.96mGauss.The goal of this magnetometer calibration is to compensate the soft-iron and hard-iron interference.As you can see in Fig. 5, the measured data before calibration shows signs of presence of the hard-iron interference.The effect of the soft-iron interference is very small so it can be ignored; however, it was also accounted for.
The ideal compensation of hard-iron and soft-iron interference changes the 3D ellipsoid to a sphere centred in zero field and radius of local magnetic field strength.

Conclusion
In applications, the effects of the hard-iron and soft-iron interference will distort the local magnetic field especially in low-cost magnetometers.These interferences needs to be accounted for and removed from the magnetometer measurements.Therefore, this paper describes a calibration method for low-cost triaxial magnetometer.This method does not require any additional equipment for data measurement.The data are collected while moving the sensor by the hand in arbitrary rotations.
In future work, we will use evolutionary algorithms for generating the calibration parameters.
where M x , M y , M z are the correct magnetometer outputs, M m is a 3x3 misalignment matrix between the magnetometer axes and the device axes, S x , S y , S z are the scale factors, R x , R y , R z are the raw magnetometer readings, S I is a 3x3 matrix of offsets caused by soft-iron interference, O x , O y , O z are the offsets caused by hard-iron interference.