Electronic compass automatic calibration method based on MEMS sensor
By collecting the three-axis accelerometer data of the carrier, calculating and correcting the magnetic field error of the electronic compass, the automatic calibration of the electronic compass is achieved, solving the problem of large heading errors after long-term use of the electronic compass in the prior art, and improving the Pointing accuracy.
Patent Information
- Application Number
- CN202411517385.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-29
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2044-10-29
AI Technical Summary
After long-term use or interference, existing electronic compasses have problems such as large heading errors and inaccurate magnetometer direction, mainly because the MEMS sensor cannot effectively perform automatic calibration when the environment changes.
By collecting the three-axis acceleration of the carrier, calculating the attitude angle, and timely updating the theoretical magnetic field strength according to the measured magnetic field strength of the magnetometer, quaternions calculate the magnetic field error. When the comprehensive magnetic field error exceeds the threshold, the magnetic field deviation is automatically corrected to realize the electronic Luojing. automatic calibration.
It effectively solves the problem of inaccurate direction of electronic compass after long-term use or interference, and improves heading accuracy and calibration efficiency of magnetometer.
Smart Images

Figure CN119022905A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of electronic compass automatic calibration, and in particular to an electronic compass automatic calibration method based on a MEMS sensor. Background Art
[0002] MEMS is becoming more and more popular in attitude measurement applications due to its small size, low power consumption, and low cost. However, it has problems such as output noise and zero drift that cannot be eliminated. As the applicable time increases, the error of its output attitude will become larger and larger. Existing electronic compasses generally use the IMU+magnetometer solution, using the short-term accuracy of the gyroscope and the long-term accuracy of the accelerometer and magnetometer for fusion calculation. Due to the characteristics of MEMS, each sensor needs to be calibrated before use. Due to the complexity of calibration, it can often only be calibrated once at the factory. With the change of the applicable environment, especially the change of temperature and geomagnetic field, the sensor will have errors, resulting in excessive error in the heading of the electronic compass. Summary of the invention
[0003] The object of the present invention is to provide an automatic calibration method for an electronic compass based on a MEMS sensor in view of the deficiencies in the prior art.
[0004] To achieve the above object, the present invention provides an automatic calibration method for an electronic compass based on a MEMS sensor, comprising: Collect the acceleration of the carrier in the X-axis, Y-axis, and Z-axis directions, and calculate the carrier's attitude angles in the X-axis and Y-axis directions based on the carrier's acceleration in the X-axis, Y-axis, and Z-axis directions: θx=atan2(-ax,az) θy=atan2(ay,ax*sin(θx)+az*cos(θx)) Among them, θx and θy are the attitude angles of the carrier in the X-axis and Y-axis directions respectively, and ax, ay, and az are the accelerations of the carrier in the X-axis, Y-axis, and Z-axis directions respectively; Get the current measured magnetic field strength of the electronic compass magnetometer, and regularly calculate and update the theoretical magnetic field strength of the carrier in the X-axis, Y-axis, and Z-axis directions in the current posture: bx=cos(θx)*mx+sin(θx)*mz by=cos(θy)*mx–sin(θx)*sin(θy)*my+cos(θx)*sin(θy)*mz bz=sin(θy)*mx+sin(θx)*cos(θy)*my+cos(θx)*cos(θy)*mz Among them, bx, by, and bz are the theoretical magnetic field strengths of the carrier in the X-axis, Y-axis, and Z-axis directions under the current posture, respectively, and mx, my, and mz are the components of the measured magnetic field strength of the electronic compass in the X-axis, Y-axis, and Z-axis directions; According to the theoretical magnetic field strengths bx and by, the attitude angle θz of the carrier in the Z-axis direction is calculated as: θz=atan2(by,bx) According to the relationship between the quaternions q1, q2, q3, q4 and the attitude angles θx, θy, θz of the carrier in the X-axis, Y-axis, and Z-axis directions, the magnetic field errors eMx, eMy, and eMz of the electronic compass in the X-axis, Y-axis, and Z-axis directions are calculated; The comprehensive magnetic field error is calculated according to the magnetic field errors eMx, eMy, and eMz of the electronic compass in the X-axis, Y-axis, and Z-axis directions, and it is determined whether the comprehensive magnetic field error exceeds the set threshold. If it exceeds the set threshold, the magnetic field deviation is corrected, as follows:
[0005] in, , , are the corrected magnetic fields in the X-axis, Y-axis, and Z-axis directions respectively.
[0006] Furthermore, the relationship between the quaternions q1, q2, q3, q4 and the attitude angles θx, θy, θz of the carrier in the X-axis, Y-axis, and Z-axis directions is: .
[0007] Furthermore, the calculation method of the magnetic field errors eMx, eMy, and eMz of the electronic compass in the X-axis, Y-axis, and Z-axis directions is as follows: .
[0008] Furthermore, the acceleration of the carrier in the X-axis, Y-axis and Z-axis directions is collected by a three-axis accelerometer arranged on the carrier.
[0009] Furthermore, the calculation method of the comprehensive magnetic field error is as follows:
[0010] in, is the calculated comprehensive magnetic field error.
[0011] Furthermore, the set threshold is 10.
[0012] Furthermore, the theoretical magnetic field strength of the carrier in the X-axis, Y-axis and Z-axis directions in the current posture is updated every ten minutes.
[0013] Beneficial effects: The present invention collects the three-axis acceleration of the carrier, calculates the pitch angle and roll angle of the carrier according to the three-axis acceleration of the carrier, and then calculates the theoretical magnetic field intensity according to the current measured magnetic field intensity of the magnetometer and the pitch angle and roll angle of the carrier, and calculates the yaw angle according to the theoretical magnetic field intensity, and then calculates the magnetic field error by using the relationship between the quaternion and the attitude angle. When the comprehensive magnetic field error exceeds the set threshold, it can be automatically corrected; the magnetometer can be calibrated regularly during the use of the electronic compass, which solves the problem of inaccurate pointing of the electronic compass after long-term use or interference. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] Figure 1 It is a schematic flow chart of an automatic calibration method for an electronic compass based on a MEMS sensor according to an embodiment of the present invention; Figure 2 It is a schematic diagram of the magnetic field strength obtained by the magnetometer of the electronic compass before calibration; Figure 3 It is a schematic diagram of the magnetic field strength obtained by the magnetometer of the electronic compass after calibration. DETAILED DESCRIPTION
[0015] The present invention is further explained below in conjunction with the accompanying drawings and specific embodiments. The embodiments are implemented based on the technical solution of the present invention. It should be understood that these embodiments are only used to illustrate the present invention and are not used to limit the scope of the present invention.
[0016] like Figure 1 As shown, an embodiment of the present invention provides an automatic calibration method for an electronic compass based on a MEMS sensor, comprising: The acceleration of the carrier in the X-axis, Y-axis, and Z-axis directions is collected, and the attitude angles of the carrier in the X-axis and Y-axis directions are calculated based on the acceleration of the carrier in the X-axis, Y-axis, and Z-axis directions: θx=atan2(-ax,az) θy=atan2(ay,ax*sin(θx)+az*cos(θx)) Among them, θx and θy are the attitude angles of the carrier in the X-axis and Y-axis directions, respectively, and ax, ay, and az are the accelerations of the carrier in the X-axis, Y-axis, and Z-axis directions, respectively. The accelerations of the above-mentioned carrier in the X-axis, Y-axis, and Z-axis directions can be collected by a three-axis accelerometer set on the carrier, and the above-mentioned attitude angle θx is the pitch angle of the carrier, and the attitude angle θy is the roll angle of the carrier.
[0017] Get the current measured magnetic field strength of the electronic compass magnetometer, and regularly calculate and update the theoretical magnetic field strength of the carrier in the X-axis, Y-axis, and Z-axis directions in the current posture: bx=cos(θx)*mx+sin(θx)*mz by=cos(θy)*mx–sin(θx)*sin(θy)*my+cos(θx)*sin(θy)*mz bz=sin(θy)*mx+sin(θx)*cos(θy)*my+cos(θx)*cos(θy)*mz Wherein, bx, by, bz are respectively the theoretical magnetic field strengths of the carrier in the X-axis, Y-axis, and Z-axis directions in the current posture calculated and updated, and mx, my, and mz are the components of the measured magnetic field strength of the electronic compass in the X-axis, Y-axis, and Z-axis directions. Preferably, the theoretical magnetic field strengths of the carrier in the X-axis, Y-axis, and Z-axis directions in the current posture are calculated and updated every ten minutes.
[0018] According to the theoretical magnetic field strength bx, by, the attitude angle θz of the carrier in the Z-axis direction is calculated as: θz=atan2(by,bx) The above-mentioned attitude angle θz is the yaw angle of the carrier.
[0019] According to the relationship between the quaternions q1, q2, q3, q4 and the attitude angles θx, θy, θz of the carrier in the X-axis, Y-axis, and Z-axis directions, the magnetic field errors eMx, eMy, and eMz of the electronic compass in the X-axis, Y-axis, and Z-axis directions are calculated. Specifically, the relationship between the quaternions q1, q2, q3, q4 and the attitude angles θx, θy, and θz of the carrier in the X-axis, Y-axis, and Z-axis directions is as follows:
[0020] Based on the relationship between the above quaternions q1, q2, q3, q4 and the attitude angles θx, θy, θz of the carrier in the X-axis, Y-axis, and Z-axis directions, the method for calculating the magnetic field errors eMx, eMy, and eMz is as follows: .
[0021] After calculating the magnetic field errors eMx, eMy, and eMz of the electronic compass in the X-axis, Y-axis, and Z-axis directions, the comprehensive magnetic field error is calculated based on the magnetic field errors eMx, eMy, and eMz of the electronic compass in the X-axis, Y-axis, and Z-axis directions, as follows:
[0022] in, is the calculated comprehensive magnetic field error.
[0023] Then determine whether the comprehensive magnetic field error exceeds the set threshold. If it exceeds the set threshold, correct the magnetic field deviation as follows:
[0024] in, , , are the corrected magnetic field strength values in the X-axis, Y-axis, and Z-axis directions respectively. The threshold value set above is preferably 10, that is, when the comprehensive error >10, correct the magnetic field deviation, otherwise no correction is performed.
[0025] See also Figure 2 and Figure 3 , Figure 2 and Figure 3 The magnetic field strength in the X-axis, Y-axis, and Z-axis directions is shown in Figure 2, with the unit being uT. Figure 2 shows the magnetic field strength obtained by the magnetometer before the electronic compass is calibrated. It can be seen that its distribution is not spherical, and the center of the sphere is not at the zero point. If this data is used directly, the calculated yaw angle will be wrong. Figure 3 , Figure 3 It shows the corrected magnetic field strength after automatic calibration using the present invention, with the center of the sphere at the zero position and the point basically on the spherical surface. At this time, the yaw angle calculated using the magnetometer will be within the accuracy range.
[0026] The above is only a preferred embodiment of the present invention. It should be noted that for ordinary technicians in this technical field, other parts not specifically described belong to the prior art or common knowledge. Several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered as the protection scope of the present invention.
Claims
1. An automatic calibration method for an electronic compass based on a MEMS sensor. It is characterized in that include: Collect the acceleration of the carrier in the X-axis, Y-axis, and Z-axis directions, and calculate the carrier's attitude angles in the X-axis and Y-axis directions based on the carrier's acceleration in the X-axis, Y-axis, and Z-axis directions: θx=atan2(-ax,az) θy=atan2(ay,ax*sin(θx)+az*cos(θx)) Among them, θx and θy are the attitude angles of the carrier in the X-axis and Y-axis directions respectively, and ax, ay, and az are the accelerations of the carrier in the X-axis, Y-axis, and Z-axis directions respectively; Get the current measured magnetic field strength of the electronic compass magnetometer, and regularly calculate and update the theoretical magnetic field strength of the carrier in the X-axis, Y-axis, and Z-axis directions in the current posture: bx=cos(θx)*mx+sin(θx)*mz by=cos(θy)*mx–sin(θx)*sin(θy)*my+cos(θx)*sin(θy)*mz bz=sin(θy)*mx+sin(θx)*cos(θy)*my+cos(θx)*cos(θy)*mz Among them, bx, by, and bz are the theoretical magnetic field strengths of the carrier in the X-axis, Y-axis, and Z-axis directions under the current posture, respectively, and mx, my, and mz are the components of the measured magnetic field strength of the electronic compass in the X-axis, Y-axis, and Z-axis directions; According to the theoretical magnetic field strengths bx and by, the attitude angle θz of the carrier in the Z-axis direction is calculated as: θz=atan2(by,bx) According to the relationship between the quaternions q1, q2, q3, q4 and the attitude angles θx, θy, θz of the carrier in the X-axis, Y-axis, and Z-axis directions, the magnetic field errors eMx, eMy, and eMz of the electronic compass in the X-axis, Y-axis, and Z-axis directions are calculated; The comprehensive magnetic field error is calculated according to the magnetic field errors eMx, eMy, and eMz of the electronic compass in the X-axis, Y-axis, and Z-axis directions, and it is determined whether the comprehensive magnetic field error exceeds the set threshold. If it exceeds the set threshold, the magnetic field deviation is corrected, as follows: ; in, , , They are the corrected magnetic fields in the X-axis, Y-axis, and Z-axis directions respectively.
2. The method for automatic calibration of an electronic compass based on a MEMS sensor according to claim 1, It is characterized in that The relationship between the quaternions q1, q2, q3, q4 and the attitude angles θx, θy, θz of the carrier in the X-axis, Y-axis, and Z-axis directions is: 。 3. The method for automatic calibration of an electronic compass based on a MEMS sensor according to claim 2, It is characterized in that The calculation method of the magnetic field errors eMx, eMy, and eMz of the electronic compass in the X-axis, Y-axis, and Z-axis directions is as follows: 。 4. The method for automatic calibration of an electronic compass based on a MEMS sensor according to claim 1, It is characterized in that The acceleration of the carrier in the directions of the X-axis, Y-axis and Z-axis is collected by a three-axis accelerometer arranged on the carrier.
5. The method for automatic calibration of an electronic compass based on a MEMS sensor according to claim 1, It is characterized in that The comprehensive magnetic field error is calculated as follows: ; in, is the calculated comprehensive magnetic field error.
6. The method for automatic calibration of an electronic compass based on a MEMS sensor according to claim 1, It is characterized in that The set threshold is 10.
7. The method for automatic calibration of an electronic compass based on a MEMS sensor according to claim 1, It is characterized in that The theoretical magnetic field strength of the carrier in the X-axis, Y-axis and Z-axis directions in the current posture is updated every ten minutes.
Citation Information
Patent Citations
Magneto- electronic compass error compensation method
CN101241009A
Calibration and compensation method of electron compass in cylindrical camera
CN106556384A
Interference-resistant method for heading attitude resolving and compass calibration
CN109238262A
Dynamic calibration method for MEMS electronic compass
CN115046539A
Magnetic sensor correction method and system based on INS / GNSS integrated navigation assistance
CN115507849A
Cited By
Unattended automatic meteorological monitoring system
CN120908903A
