LSM303D module (three-axis magnetic field + three-axis acceleration)
Built-in 12-bit AD converter, 16-bit data output
Adopt high-quality immersion gold PCB, machine welding process to ensure quality
Using the chip: LSM303DLH
- Power supply: 3-5v (internal low dropout voltage regulator)
- Communication method: standard IIC communication protocol
- Magnetic field range:
- ± 1.3 / ± 1.9 / ± 2.5 / ± 4.0 / ± 4.7 /
- ± 5.6 / ± 8.1 gauss
- Acceleration range: ± 2 g / ± 4 g / ± 8 g
LSM303D related introduction
The LSM303DLH chip's accelerometer, magnetometer, A / D converter and signal processing circuit are integrated together, and still communicate with the processor through the I2C bus. In this way, 6-axis data detection and output can be achieved with only one chip, which reduces the design difficulty of customers, reduces the occupied area of PCB boards, and reduces device costs.
The LSM303DLH requires few peripheral devices and the connection is simple. The magnetometer and accelerometer each have an I2C bus to communicate with the processor. If the customer's I / O interface level is 1.8V, Vdd_dig_M, Vdd_IO_A, and Vdd_I2C_Bus can all be powered by 1.8V, and Vdd can be powered by 2.5V or more; if the customer interface level is 2.6V, except Vdd_dig_M requires 1.8V, Others can use 2.6V. As mentioned above, the LSM303DLH requires a set / reset circuit to maintain the main magnetic domain of the AMR. C1 and C2 are external matching capacitors for the set / reset circuit. Due to certain requirements on the set pulse and reset pulse, users are advised not to modify the size of C1 and C2 at will.
To implement the electronic compass function, a three-axis magnetic force sensor and a three-axis acceleration sensor are required to detect the magnetic field. With the maturity of the micromechanical process, STMicroelectronics has launched a two-in-one sensor module LSM303DLH that integrates a three-axis magnetometer and a three-axis accelerometer in a single package, which is convenient for users to design low-cost, high-performance electronics in a short time. compass. This article uses LSM303DLH as an example to discuss the working principle, technical parameters and implementation method of electronic compass of this device.
ST sensor module LSM303DLH with integrated magnetometer and accelerometer
1.1 Magnetometer working principle
In LSM303DLH, the magnetometer uses anisotropic magnetoresistance (Anisotropic Magneto-Resistance) material to detect the magnitude of magnetic induction in space. This kind of alloy material with crystal structure is very sensitive to the external magnetic field. The change in the strength of the magnetic field will cause the resistance of the AMR to change.
In the manufacturing process, a strong magnetic field is added to the AMR to make it magnetize in a certain direction, and a main magnetic domain is established. The axis perpendicular to the main magnetic domain is called the sensitive axis of the AMR, as shown in FIG. 3. In order to make the measurement result change linearly, the metal wires on the AMR material are arranged at an oblique angle of 45 °, and the current flows through these wires. The main magnetic domain established on the AMR material by the initial strong magnetic field and the direction of the current have an angle of 45 °.
When there is an external magnetic field Ha, the direction of the main magnetic domain on the AMR will change instead of the original direction, so the angle θ between the direction of the magnetic field and the current will also change, as shown in Figure 5. For AMR materials, the change of theta angle will cause the change of AMR's own resistance value, and it has a linear relationship.
ST uses a Wheatstone bridge to detect the change of AMR resistance value. R1 / R2 / R3 / R4 are AMR resistors in the same initial state, but R1 / R2 and R3 / R4 have opposite magnetization characteristics. When an external magnetic field is detected, the resistance of R1 / R2 increases by R and R3 / R4 decreases by R. In this way, in the absence of an external magnetic field, the output of the bridge is zero; while in the presence of an external magnetic field, the output of the bridge is a small voltage? V.
1.2 The Set / Reset circuit is
affected by the external environment, so the direction of the main magnetic field on the AMR in the LSM303DLH will not be permanently maintained. The LSM303DLH has a built-in set / reset circuit. The internal metal coil periodically generates a current pulse to restore the original main magnetic domain, as shown in Figure 8. It should be noted that the effect of the set pulse and the reset pulse is the same, but the directions are different.
The set / reset circuit brings a lot of advantages to the LSM303DLH:
1) Even when it encounters interference from a strong external magnetic field, the LSM303DLH can resume normal operation after the interference disappears without the need for the user to correct it again.
2) The initial magnetization direction can be maintained for accurate measurement even when working for a long time, and it will not affect the measurement accuracy due to chip temperature changes or internal noise increase.
3) Eliminate the bridge deviation caused by temperature drift.
1.3 LSM303DLH performance parameters
LSM303DLH integrates three-axis magnetometer and three-axis accelerometer, and adopts digital interface. The magnetometer has a measurement range from 1.3 Gauss to 8.1 Gauss in 7 levels, and users can choose freely. And in the magnetic field environment within 20 Gauss can maintain consistent measurement results and the same sensitivity. Its resolution can reach 8 mGauss and it uses a 12-bit ADC internally to ensure accurate measurement of magnetic field strength. Compared with the magnetometer using the Hall effect principle, the LSM303DLH has low power consumption, high accuracy, good linearity, and does not require temperature compensation.
LSM303DLH has an automatic detection function. When the control register A is set, the self-test circuit inside the chip will generate an excitation signal about the size of the geomagnetic field and output it. Users can judge whether the chip works normally by outputting data.
As a highly integrated sensor module, in addition to the magnetometer, the LSM303DLH also integrates a high-performance accelerometer. The accelerometer also uses a 12-bit ADC, which can achieve a measurement accuracy of 1mg. The accelerometer can run in low power mode and has a sleep / wake function, which can greatly reduce power consumption. At the same time, the accelerometer also integrates 6-axis direction detection and two programmable interrupt interfaces.
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 modes of the magnetometer and accelerometer separately to put them into sleep or low power consumption mode. And users can adjust the data update frequency of magnetometer and accelerometer to adjust power consumption level. When the magnetometer data update frequency is 7.5Hz and the accelerometer data update frequency is 50Hz, the typical current consumption is 0.83mA. In standby mode, the current consumption is less than 3uA.
2.
Ferromagnetic field interference and calibration The electronic compass mainly calculates the direction of the magnetic north pole by sensing the existence of the earth's magnetic field. However, because the earth ’s magnetic field is usually only 0.5 Gauss, a normal mobile phone speaker will still have a magnetic field of about 4 Gauss when it is 2 cm away, and a mobile phone motor will have a magnetic field of about 6 Gauss when it is 2 cm away. This feature makes the measurement of the earth's magnetic field on the surface of electronic equipment very easy to be interfered by the electronic equipment itself.
Magnetic field interference refers to the deviation of the earth's magnetic field at the place where the magnetic sensor is placed due to the presence of magnetic substances or substances that can affect the local magnetic field strength. As shown in Figure 11, in the XYZ coordinate system of the magnetic sensor, the green circle represents the projected trajectory in the XY plane during the rotation of the earth's magnetic field vector around the z-axis. This trajectory will no longer be affected by any external magnetic field. Would be a standard circle centered at O (0,0). When external magnetic field interference exists, the measured magnetic field strength vector α will be the vector sum of the earth's magnetic field β and the interference magnetic field γ at this point. Recorded as:
Generally speaking, the interference magnetic field γ can be regarded as a constant vector at this point. There are many factors that can cause magnetic field interference, such as motors and speakers placed on circuit boards, and materials containing metals such as iron-nickel-cobalt such as shields, screws, resistors, LCD backplanes, and housings. Also according to Ampere's law, a wire through which a current passes will also generate a magnetic field, as shown in Figure 12.
In order to calibrate these magnetic field interferences from the circuit board, the main work is to find γ through calculation.
2.1 Plane calibration method For
the calibration of the XY axis, rotating a device equipped with a magnetic sensor in the XY plane is equivalent to rotating the earth's magnetic field vector around the passing point O (γx, γy) perpendicular to the normal of the XY plane, and The red circle is the trajectory of the magnetic field vector projected in the XY plane during the rotation. This can find the position of the center of the circle as ((Xmax + Xmin) / 2, (Ymax + Ymin) / 2). Similarly, if the device is rotated in the XZ plane, the trajectory circle of the earth's magnetic field on the XZ plane can be obtained, which can be calculated in three dimensions. The magnetic field interference vector γ (γx, γy, γz) in space.
2.2 Stereo 8-character calibration method In
general, when a device with a sensor rotates in all directions in the air, the space geometry composed of the measured values is actually a circle For a sphere, all the sampling points fall on the surface of the sphere, as shown in Figure 13, which is similar to a circle projected in a two-dimensional plane.
In this case, the circle center O (γx, γy, γz) can be obtained from sufficient sample points, that is, the magnitude and direction of the fixed magnetic field interference vector. The formula is as follows:
The 8-character calibration method requires the user to make 8-character shakes in the air using the equipment to be calibrated. In principle, the equipment normal direction should be directed to all 8 quadrants of the space as much as possible.
2.2 Ten-sided calibration method
Similarly, the following ten-sided calibration method can also be used to achieve the purpose of calibration.
3.
After calibration of tilt compensation and yaw angle , the electronic compass can be used normally on the horizontal plane. But more often the phone is not kept horizontal, usually it has an angle with the horizontal plane. This included angle will affect the accuracy of the heading angle, and tilt compensation needs to be performed by the acceleration sensor.
The attitude of an object in the air has been defined in the navigation system for a long time. As shown in Figure 17, this definition is also used in Android. Pitch (Φ) is defined as the angle between the x-axis and the horizontal plane, and the direction shown is positive; Roll (θ) is defined as the angle between the y-axis and the horizontal plane, and the direction shown is positive. The heading angle error caused by the pitch angle is shown in FIG. 18. It can be seen that a tilt angle of 10 degrees in the x-axis direction can cause a maximum error of 7-8 degrees of heading angle.
The tilt attitude of the mobile phone in the air detects the components of gravity acceleration on three axes through a 3-axis acceleration sensor, and then Pitch and Roll can be calculated by Equation 2.
Many of the currently popular android phones are equipped with a compass function. In order to achieve this function, it only needs to be equipped with the 2-in-1 sensor module LSM303DLH provided by ST.