This application claims priority from Chinese Application for Patent No. 201310172424.1 filed May 8, 2013, the disclosure of which is incorporated by reference.
This invention relates generally to measurement technology, and more particularly to a method and apparatus for calibrating a magnetic sensor.
Magnetic sensors are popular components used in electronic devices. A magnetic sensor operates to measure geomagnetic fields with the measurement results used by electronic devices for navigation, gaming, and other orientation related applications. However, magnetic sensors may be disturbed by soft iron and hard iron interferences. Hard iron interference may be caused by objects that produce magnetic fields, for example, a speaker, a motor, or a piece of magnetized iron. Soft iron interference may be caused by sources inside and/or outside casing of the electronic devices which contain a magnetic sensor, for example metal frames, circuits or shielding with metal such as Fe/Ni/Gu.
Currently, there are several traditional ways to calibrate a magnetic sensor. As illustrate in
Another traditional way to calibrate a magnetic sensor is a horizontal plane rotation method. In this method, the device containing a magnetic sensor is placed on a horizontal desktop and rotated for a plurality of times.
(X−OX)2+(Y−OY)2=R2 (1)
wherein R is the radius of the circle in
O
Z=(Oup+Odown)/2 (2)
wherein Oup and Odown are magnetic measurements obtained when the magnetic sensor faces up and down respectively.
However, most horizontal planes are sustained by a metal holder which can generate additional magnetic interference to the output of the magnetic sensor. Such additional interference can cause asymmetric distortion at different directions, and the plot of the measurements obtained may be illustrated as in
Another traditional method to calibrate a magnetic sensor is to obtain magnetic measurements at various directions and use a sphere model as illustrated in
A further method to calibrate a magnetic sensor is to put it in a Helmholtz cage to cancel the geomagnetic field at the position, and therefore the magnetic measurement obtained is the offset needed for calibration. However, such cages are quite expensive and time consuming when used. Therefore, it is not a practical way to calibrate a magnetic sensor included in consumer electronics.
Due to the above stated problems, a method and an apparatus for a magnetic sensor, in particular, to eliminate hard iron interferences is desired. Such a method and apparatus should be easy to use, with less complexity to implement, and should also take not only hard iron interference but also soft iron interference into consideration.
In an embodiment, a method for calibrating a magnetic sensor comprises: acquiring a plurality of magnetic field measurements; fitting at least part of the plurality of magnetic field measurements to an ellipsoid model to obtain a coordinate of a center of the ellipsoid model; determining a calibration offset according to the coordinate of the center of the ellipsoid model; and calibrating the magnetic sensor using the calibration offset.
Said step of fitting comprises determining an expression of the ellipsoid model containing a plurality of ellipsoid parameters; substituting at least part of the plurality of magnetic field measurements into the expression of the ellipsoid model to obtain a matrix equation including a matrix of the magnetic field measurements and a matrix of the plurality of ellipsoid parameters; solving the matrix equation using Gaussian principle elimination to obtain the plurality of ellipsoid parameters; and determining the coordinate of the center of the ellipsoid model using the plurality of ellipsoid parameters.
Said step of solving comprises traversing the matrix of the magnetic field measurements to determine principles thereof; converting the matrix of the magnetic field measurements into a triangular matrix based on the principles obtained; and solving the matrix equation based on the triangular matrix to obtain the ellipsoid parameters.
The expression of the ellipsoid model is defined by:
a
1
x
2
+a
2
y
2
+a
3
z
2
+a
4
xy+a
5
xz+a
6
yz+a
7
x+a
8
y+a
9
z=1
wherein (x, y, z) represents a point located on the ellipsoid model, and a1-a9 represent the ellipsoid parameters, and the coordinate of the center of the ellipsoid model is defined by (x0, y0, z0), wherein x0, y0 and z0 satisfy the following relationship:
The plurality of magnetic field measurements comprise at least nine different magnetic field measurements.
Each of the plurality of magnetic field measurements is measured along three orthogonal axes.
The calibration offset is equal to a vector from a origin of the three orthogonal axes to the center of the ellipsoid model.
Said step of calibrating comprises subtracting the calibration offset from the magnetic field measurements.
In an embodiment, an apparatus configured to perform the steps of any of the methods above comprises: a magnetic sensor configured to obtain a plurality of magnetic field measurements; and a processing unit coupled with the magnetic sensor, configured to process the plurality of magnetic field measurements for calibration of the magnetic sensor.
The magnetic sensor is located in an electronic compass.
The method described herein does not require an additional device for calibration, for example no golden sample or Helmholtz cage is needed. Also, a more accurate model is adopted for calculation of the offset which may lead to more accurate calibration of the magnetic sensor. Also, the method and apparatus described herein offers a fast and efficient way for calibration.
The foregoing has outlined, rather broadly, features of the present disclosure. Additional features of the disclosure will be described, hereinafter, which form the subject of the claims of the disclosure. It should be appreciated by those skilled in the art that the conception and specific embodiment disclosed may be readily utilized as a basis for modifying or designing other structures or processes for carrying out the same purposes of the present disclosure. It should also be realized by those skilled in the art that such equivalent constructions do not depart from the spirit and scope of the disclosure as set forth in the appended claims.
For a more complete understanding of the present disclosure, and the advantages thereof, reference is now made to the following descriptions taken in conjunction with the accompanying drawings, in which:
Corresponding numerals and symbols in different figures generally refer to corresponding parts unless otherwise indicated.
The making and using of embodiments are discussed in detail below. It should be appreciated, however, that the present invention provides many applicable inventive concepts that may be embodied in a wide variety of specific contexts. The specific embodiments discussed are merely illustrative of specific ways to make and use the invention, and do not limit the scope of the invention. It should also be appreciated that, the steps recorded in the method may be performed in a different order, and/or performed in parallel. Moreover, the methods herein may comprise additional steps and/or omit to perform one or more illustrated steps. The scope of the invention is not limited in such aspects.
As stated in the background section, using a sphere model to calculate the offset caused by magnetic interferences is not accurate. In an embodiment, an ellipsoid is instead used considering the influence of soft iron interference. Also, hard iron interferences may cause a shift of the center of the ellipsoid. Therefore, calculation of an offset of the center of the ellipsoid is performed to cancel the influence of hard iron interference.
At block 504, the plurality of magnetic field measurements are fitted to an ellipsoid model to obtain a coordinate of the center of the ellipsoid model. In one embodiment, an equation may be used to describe the ellipsoid model, for example the equation may be as follows:
a
1
x
i
2
+a
2
y
i
2
+a
3
z
i
2
+a
4
x
i
y
i
+a
5
x
i
z
i
+a
6
y
i
z
i
+a
7
x
i
+a
8
y
i
+a
9
z
i=1 (1)
wherein (xi, yi, zi) is a coordinate of any point on the ellipsoid model, and a1-a9 are the ellipsoid parameters.
Theoretically, the coordinate of the center of the ellipsoid model should be (0, 0, 0). However, under the influence of hard iron interference, the center of the ellipsoid model may shift to a point with a coordinate as (x0, y0, z0). In one embodiment, x0, y0 and z0 may be expressed in terms of the ellipsoid parameters, for example by equations as follows:
Accordingly, to calculate the offset of the center caused by hard iron interference, ellipsoid parameters are obtained. Since there are nine ellipsoid parameters, nine magnetic field measurements are fitted into equation 1 to calculate the nine ellipsoid parameters to establish a matrix equation as follow:
Equation 5 may be expressed as B·A=C, wherein the matrix B has to be full rank so that equation 5 has a unique solution. Therefore, to achieve a full rank of matrix B, nine different magnetic field measurements are chosen from the plurality of measurements obtained at block 502.
A plurality of methods may be adopted to solve equation 5. In one embodiment, the Gaussian principle elimination method may be used to solve equation 5 with a flowchart illustrated in
At block 602, an augmented matrix may be established as B(N, N+1)=[B|C] wherein N=9 for example, and i may start as 1. At block 604, the matrix may be traversed and a maximum value bjk among bmn may be located, wherein i≦m≦N, i≦n≦N. If j does not equal i, the jth row is swapped with the ith row; if k does not equal i, the kth column is swapped with the ith column, so that bjk may be moved to the position of bii.
At block 606, operations are taken to eliminate the values at position bij using the equations as follows:
wherein j=i+1, . . . , N, k=i+1, . . . , N+1. At block 608, i may be incremented by 1. At block 610, the operational flow may be directed back to step 604 if i does not equal N.
Therefore, when i reaches N, the N largest values may be positioned on the diagonal of matrix B known as the principles, and the matrix B may be converted into a triangular matrix with the values positioned left to the diagonal eliminated to 0.
At block 612, the ellipsoid parameters are calculated using the equations as follow:
wherein i=1, . . . , N−1. The ellipsoid parameter may be obtained in an order of aN to a1.
After obtaining the ellipsoid parameters, at block 506, the offset of the center of the ellipsoid model is calculated based on the coordinate (x0, y0, z0). At block 508, the magnetic sensor is calibrated based on the offset obtained at block 506.
In one embodiment, electronic device 700 comprises a magnetic sensor 704 configured to obtain a plurality of magnetic measurements. In one embodiment, magnetic sensor 704 may be located in an electronic compass 702. Electronic device 700 further comprises a processing unit 706 configured to process the magnetic measurements received from magnetic sensor 704 according to the methods described above. In one embodiment, processing unit 706 may be part of magnetic sensor 704, or electronic compass 702, or may be a shared resource in electronic device 700. In yet another embodiment, processing unit 706 may even be a remote module outside electronic device 700, such as a workstation, a personal computer or a server.
It will be readily understood by those skilled in the art that materials and methods may be varied while remaining within the scope of the present invention. It is also appreciated that the present invention provides many applicable inventive concepts other than the specific contexts used to illustrate embodiments. Accordingly, the appended claims are intended to include within their scope such processes, machines, manufacturing, compositions of matter, means, methods, or steps.
Number | Date | Country | Kind |
---|---|---|---|
201310172424.1 | May 2013 | CN | national |