Basic working principle of magnetometer

Source: Internet
Author: User

Source: Basic working principle of magnetometer

This article is so good that I can't help but turn around.

This article explains in detail the basic working principle of magnetometer, the cause of interference and how to calibrate, how to use the magnetometer and inclination sensor.

Original address: http://www.dzsc.com/data/html/2010-11-29/87454.html

The electronic compass is an important navigation tool which can provide the moving object's heading and posture in real time. With the progress of semiconductor technology and the development of mobile phone operating system, the integration of more and more sensors of the smart phone becomes powerful, many mobile phones have realized the function of electronic compass. E-Compass-based applications (such as Android SkyMap) are also popular on various software platforms.

To realize the electronic compass function, a three-axis magnetic sensor and a triaxial accelerometer are needed to detect the magnetic field. With the maturation of the micro-mechanical process, STMicroelectronics is introducing the two-in-one sensor module LSM303DLH, which integrates a tri-axis magnetometer and a tri-axis accelerometer into a single package, allowing users to design an electronic compass with low cost and high performance in a short period of time. This paper takes LSM303DLH as an example to discuss the working principle, technical parameters and the realization method of electronic compass.

 1. Background knowledge of geomagnetic field and heading angle

As shown in 1, the Earth's magnetic field, like a bar magnet, is pointed to the magnetic north Pole by the magnetic South Pole. At the magnetic poles the magnetic field is perpendicular to the local water level, and the equatorial magnetic field is parallel to the local water level, so the magnetic field in the northern hemisphere tilts toward the ground. The units used to measure the magnetic intensity are Tesla or Gauss (1tesla=10000gauss). As the geographical location is different, the intensity of the usual magnetic field is 0.4-0.6 Gauss. It is important to note that the magnetic Arctic and the geographic Arctic do not coincide, and usually they have an angle of about 11 degrees.

Fig. 1 Map of ground magnetic field

The geomagnetic field is a vector, and for a fixed location, the vector can be decomposed into two components parallel to the local water level and a vertical component to the local water plane. If the electronic compass is kept parallel to the local water level, the three axes of the magnetometer in the compass correspond to these three components, as shown in 2.

Fig. 2 Decomposition of ground magnetic field vectors

In fact, for the two components of the horizontal direction, their vectors and always point to the magnetic north. The heading angle (Azimuth) in the compass is the angle between the current direction and the magnetic north. As the compass remains level, it is possible to calculate the heading angle using 1 of the test data in the horizontal two axes (usually the x and Y axes) of the magnetometer. When the compass rotates horizontally, the yaw angle changes between 0?-360.

 2. St Integrated Magnetometer and Accelerometer sensor module LSM303DLH

2.1 How magnetometer works

In Lsm303dlh, the magnetometer uses anisotropic magnetic contact resistance (Anisotropic magneto-resistance) material to detect the size of the magnetic induction in space. This crystalline structure of the alloy material is sensitive to the external magnetic field, the strength of the magnetic field changes will lead to AMR's own resistance value changes.

In the manufacturing process, a strong magnetic field is added to the AMR to make it magnetized in a certain direction, the establishment of a primary magnetic field, and the main magnetic field perpendicular to the axis is called the AMR sensitive axis, 3 is shown. In order to change the measurement results in a linear manner, the metal conductors on the AMR material are tilted in a 45º angle, and the currents flow from these conductors, as shown in 4. The direction of the main magnetic field and current which is established by the initial strong magnetic field on the AMR material has a 45º angle.

Figure 3 AMR Material

Fig. 4 conductors arranged in 45º angle

When an external magnetic field is ha, the direction of the main magnetic field on the AMR changes and is no longer the initial direction, then the angle θ of the magnetic field direction and current will also change, as shown in 5. For AMR Materials, the change in the θ angle causes AMR to change its own resistance and is linearly related, as shown in 6.

Fig. 5 Angle of the magnetic field direction and current direction

Figure 6θ-r Characteristic curve

St uses the Wheatstone Bridge to detect the change in AMR resistance, as shown in 7. The R1/R2/R3/R4 is the same AMR resistor with the same initial state, but the R1/R2 and R3/R4 have the opposite magnetization characteristics. When the external magnetic field is detected, the R1/R2 resistance increases. R and R3/r4 decrease? R. Thus, the output of the bridge is zero without an external magnetic field, and the output of the bridge is a tiny voltage when there is an external magnetic field. V.

Fig. 7 Wheatstone Bridge

When the r1=r2=r3=r4=r, the resistance changes under the action of the external magnetic field? R, bridge output? V proportional to? R. That's how the magnetometer works.

 2.2 Position/Reset (set/reset) circuit

Due to the influence of external environment, the direction of the main magnetic field on AMR in LSM303DLH will not remain unchanged forever. The LSM303DLH has a built-in/reset circuit that generates a current pulse periodically through the internal metal coils, recovering the initial primary magnetic field, as shown in 8. It is important to note that the position pulse and the reset pulse produce the same effect, but the direction is different.

Figure 8 LSM303DLH position/reset Circuit

The position/reset circuitry brings many advantages to LSM303DLH:

1) Even if the external strong magnetic field interference, after the interference disappears LSM303DLH can also return to normal work without requiring the user to correct again.

2) Even long-time operation can maintain the initial magnetization direction to achieve accurate measurement, not because of the chip temperature changes or internal noise increase to affect the measurement accuracy.

3) Eliminate bridge deviations due to temperature drift.

  Performance parameters of 2.3 lsm303dlh

The LSM303DLH integrates a three-axis magnetometer and a triaxial accelerometer with a digital interface. The measuring range of the magnetometer ranges from 1.3 Gauss to 8.1 gauss with a total of 7 files, which the user is free to choose. Consistent measurement and sensitivity are maintained within the magnetic field within the Gauss. It has a resolution of 8 mgauss and an internal 12-bit ADC to ensure accurate measurement of magnetic field strength. Compared to the hall-effect magnetometer, the LSM303DLH has low power consumption, high accuracy, good linearity, and no temperature compensation required.

The LSM303DLH has automatic detection capability. When control register A is set, the self-test circuit inside the chip produces an excitation signal about the size of the ground magnetic field and outputs it. The user can determine whether the chip is working properly by outputting the data.

As a highly integrated sensor module, LSM303DLH also integrates a high-performance accelerometer in addition to the magnetometer. The accelerometer also uses a 12-bit ADC to achieve 1mg measurement accuracy. The accelerometer operates in a low-power mode with sleep/wake capability, which greatly reduces power consumption. The accelerometer is also integrated with 6-axis direction detection and two programmable interrupt interfaces.

 3. Introduction of St Electronic Compass Scheme

A traditional electronic compass system requires at least one triaxial magnetometer to measure the magnetic field data, a triaxial accelerometer to measure the compass inclination, and the distribution of gravity and the magnetic field data from the three-dimensional space to the processor through the signal hierarchy and Data acquisition section. The processor calculates the azimuth using the magnetic field data and tilts the compensation by gravity data. The azimuth angle of the output is not affected by the space attitude of the electronic compass, as shown in 9.

Figure 9 Electronic Compass structure

The LSM303DLH integrates the accelerometer, magnetometer, A/D converter, and signal-coherent circuitry, and still communicates via the I²C bus and the processor. This only with one chip to achieve 6-axis data detection and output, reduce the customer's design difficulties, reduce the footprint of the PCB board, reduce the cost of the device.

Typical application of LSM303DLH is shown in 10. It requires few peripheral devices, and the connection is simple, and the magnetometer and accelerometer each have an I²C bus and processor communication. If the customer's I/O interface level is 1.8v,vdd_dig_m, vdd_io_a, and Vdd_i2c_bus can be connected to 1.8V power supply, VDD uses more than 2.5V power supply, if the customer interface level of 2.6V, in addition to Vdd_dig_ M requires 1.8V, others can use 2.6V. As mentioned above, the LSM303DLH requires a reset/reset circuit to maintain the main magnetic domain of the AMR. The C1 and C2 are the external matching capacitance of the set/reset circuit, and it is recommended that users do not arbitrarily modify the size of C1 and C2, due to certain requirements for the position pulse and reset pulse.

Figure Ten LSM303DLH typical application circuit diagram

For portable devices, the power consumption of the device is very important and directly affects its standby time. The LSM303DLH can control the power supply mode of the magnetometer and the accelerometer separately, allowing it to enter sleep or low-power mode. And the user can adjust the data update frequency of the magnetometer and accelerometer to adjust the power consumption level. When the magnetometer data Update frequency is 7.5Hz and the accelerometer data update frequency is 50Hz, the typical consumption current is 0.83mA. In standby mode, the current consumption is less than 3uA.

 4. ferromagnetic field Interference and calibration

The electronic compass calculates the direction of the magnetic Arctic by sensing the presence of the Earth's magnetic field. However, since the Earth's magnetic field in general is only a faint 0.5 gauss, and a normal cell phone speaker when the distance between 2 centimeters will still have about 4 gauss magnetic field, a mobile phone motor at 2 centimeters apart will have about 6 Gauss magnetic field, which makes the measurement of the surface of the electronic equipment of the Earth's magnetic field is very susceptible to the electronic device itself.

Magnetic field disturbance refers to the existence of a magnetic material or a substance that can affect the strength of the local magnetic field, which causes the magnetic field to deviate in the position of the magnetic sensor. 11, in the XYZ coordinate system of the magnetic sensor, the green circle represents the trajectory of the Earth's magnetic field vector around the z-axis during the rotation of the XY plane, and without any external magnetic interference, this trajectory will be a standard O (0,0)-centric circle. When there is an external magnetic field disturbance, the measured magnetic field intensity vector α will be the vector of the point earth field β and the interfering magnetic field γ. Recorded as:

Figure 11 Magnetic sensor XY coordinate and magnetic line projection trajectory

It can be thought that disturbing the magnetic field γ at that point can be regarded as a constant vector. There are many factors that can cause magnetic disturbances, such as motors and horns placed on a circuit board, as well as materials such as shields, screws, resistors, LCD backplanes and housings that contain metal such as iron, nickel and cobalt. Also, according to the Ampere law, a conductor with a current passing through will produce a magnetic field, 12.

Fig. 12 Effect of current on magnetic field

In order to calibrate these magnetic field disturbances from the circuit board, the main task is to calculate the gamma by calculation.

4.1 Plane Calibration Method

For the XY axis calibration, the device equipped with a magnetic sensor rotates in the XY plane, 11, equivalent to rotating the Earth's magnetic field vector around the point O (γx,γy) perpendicular to the XY plane, while the red circle is the trajectory of the magnetic field vector projected in the XY plane during the rotation process.  This can be found in the position of the center point ((Xmax + Xmin)/2, (Ymax + ymin)/2). Similarly, rotating the device in the XZ plane can obtain the trajectory circle of the Earth's magnetic field on the XZ plane, which can find the magnetic interference vector γ (γx,γy,γz) in three-dimensional space.

 4.2 Stereo 8-word calibration method

In general, when a device with a sensor rotates in all directions in the air, the spatial geometry of the measured value is actually a sphere, and all the sampling points fall on the surface of the ball, as shown in 13, similar to the circle projected in the two-D plane.

Fig. 13 The Earth's magnetic field space rotates and the sphere is obtained in the sensor space coordinates.

In this case, the Center O (γx,γy,γz), the size and direction of the fixed magnetic interference vector, can be obtained by sufficient sample points. The formula is as follows:

The 8-word calibration requires the user to do 8-word shaking in the air using a device that needs to be calibrated, in principle as much as possible to point the device's normal direction toward all 8 quadrants of space, as shown in 14.

Figure 14 Aerial 8-word calibration of the device

  4.2 10-Side calibration method

Similarly, calibration can be achieved by the following 10-side calibration methods.

Fig. 15 10 steps of the method of registration

16, after the 10-side calibration method, the same can be sampled to the surface of the sphere part of the trajectory, thereby deriving the position of the ball sphere, that is, the size and direction of the fixed magnetic interference vector.

Fig. 16 space trajectory after 10-side calibration

  5. Tilt compensation and deviation calculation

After calibration, the electronic compass can be used normally on the horizontal plane. But more often the phone is not kept level, usually it has an angle to the horizontal surface. This angle affects the accuracy of the yaw angle, which needs to be compensated by the acceleration sensor.

For an object in the air posture, the navigation system has already been defined, 17, Android also adopted this definition. Pitch (Φ) is defined as the angle between the x-axis and the horizontal plane, the direction of the diagram is positive, and the roll (θ) is defined as the angle between the y-axis and the horizontal plane, and the direction of the diagram is the positive direction. The deviation from the yaw angle caused by the pitch angle is 18. It can be seen that the tilt angle of 10 degrees in the x-axis direction can cause the deviation of the maximum 7-8 degrees of the heading angle.

Figure pitch angle and roll angle definition diagram of pitch angle caused by the yaw angle error

Mobile phone in the air tilt Attitude 19, the 3-axis acceleration sensor detects the weight of the gravitational acceleration on three axes, and then through the Formula 2 can calculate the pitch and roll.

Figure 19 Mobile phone tilt stance in the air

Formula 3 can be measured by the magnetometer of the three-axis data (Xm,ym, ZM) through pitch and roll into the Formula 1 to calculate the direction of Hy and HX. Then use Formula 1 to calculate the heading angle.

 6. Implementation of the Android platform Compass

In the current popular Android phones, many are equipped with a compass function. In order to achieve this, it is only necessary to equip the ST with the two-in-one sensor module LSM303DLH,ST to provide a complete solution. The software implementation in Android can be represented by the following block diagram:

These include:

BSP Reference

Linux Kernel Driver (LSM303DLH_ACC + lsm303dlh_mag)

HAL Library (SENSORS_LSM303DLH + liblsm303dlh) for sensors.default.so

Through the library calculation, the upper application can easily be used by Android to define the flight angle information provided by the library for application writing.

Basic working principle of magnetometer (RPM)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.