The function of the vehicle electronic compass is to help users determine the direction of the vehicle, accurately display the azimuth angle and provide correct operating instructions. Therefore, the accuracy of navigation has become an important indicator to measure the performance of the system.
The electronic compass based on AMR magnetoresistive sensor and acceleration sensor ADXL202 introduced in this paper is one of the strapdown inertial navigation systems. In the electronic compass system, the single-chip microcomputer VRS51L3074 counts the pulse width and period of the acceleration sensor output signal to obtain the instantaneous acceleration value of the vehicle, and then uses the trigonometric function relationship to calculate the roll and pitch angles between the current position and the known reference position, and performs attitude calculation to obtain the vehicle's forward direction and azimuth. However, the electromagnetic environment of the car is complex, especially the vibration and instantaneous power change of the car will cause spike pulse interference to the duty cycle signal output by ADXL202, seriously affecting the counting accuracy. Therefore, suppressing pulse interference is particularly important in improving counting accuracy and enhancing system performance.
1 Working principle of ADXL202
The ADXL202 sensor is composed of an oscillator, X and Y direction sensors, a phase detection circuit and a duty cycle modulator, and has a digital output interface and an analog voltage signal output interface. The X and Y direction sensors are two mutually orthogonal acceleration sensors. When the direction of ADXL202 changes relative to the ground plane, the X and Y directions correspond to different outputs, so that dynamically changing acceleration and constant acceleration can be measured. The phase detector connected to the sensor is mainly used to correct the signal and determine the direction of the signal. The signal output by the detector drives the duty cycle modulator through a 32 kΩ resistor. When designing, the bandwidth can be changed by connecting capacitors C
X
and C
Y
to the XFILT and YFILT pins
. At the same time, the external capacitor has a certain effect on filtering noise and suppressing zero drift.
After the signal passes through the low-pass filter, the duty cycle modulator converts the signal into a digital signal output. The external resistor of T2 pin can change the period T2 (1 to 10 ms), which is convenient for use in situations with different accuracy requirements. The duty cycle of the output duty cycle signal can be calculated by a counter. The calculation of acceleration can be obtained by formula (1).
When the acceleration is 0g, the duty cycle of the output signal is 50%; the pulse width duty cycle changes by 1g of sensitivity by 12.5%. In the application, the offset and system error at 0g affect the actual output value. The inclination of the X and Y axes can be obtained according to the measured acceleration value:
when the accelerometer is oriented, its X and Y axes are parallel to the earth's surface and can be used as a dual-axis inclination sensor with two axes of roll and tilt. The pitch angle of the measured object is recorded as γ and the roll angle β. The three sensitive axes of the magnetoresistive sensor are installed along the three coordinate axes of the carrier, and the projection components (H X
,
H
Y
, H
Z
) of the magnetic induction intensity H of the earth's magnetic field on the three coordinates of the carrier coordinate system are measured respectively. Then, the pitch angle and roll angle are used to perform attitude calculation to obtain the azimuth of the electronic compass.
2 Anti-interference design concept of ADXL202
According to the ADXL202 user manual, interference will be caused when the sensor shares a power supply with the microprocessor, so an interference suppression solution is adopted in the circuit design. A 0.1 μF capacitor and a resistor less than or equal to 100 Ω are used to suppress interference during the design. Experimental tests show that there is still a situation where the power supply of other parts of the circuit and the power supply of the sensor affect each other, and the interference suppression effect is not ideal. After repeated tests, the sensor is powered by an independent power supply, and when wiring, the resistors and capacitors of the device and the conditioned signal are placed on a separate board or surrounded by a thick ground wire in a certain area of the circuit board, and a better interference suppression effect is obtained under laboratory conditions. However, in actual applications, the vibration and instantaneous power changes of the car cannot eliminate the spike pulse interference (pulse width of about 1 to 2 ms) generated by the duty cycle signal output by ADXL 202E, which requires more processing. There are many measures to suppress and eliminate the influence of spike pulse interference, and the common ones are hardware methods and software methods, or a combination of the two. Considering that the overall volume of the electronic compass and the magnetoresistive sensor signal are more sensitive to interference, if efficient hardware filtering is used, the system circuit will become very large; using simple hardware circuits, the filtering effect is not thorough. In fact, software filtering can also be used with the help of a microprocessor to eliminate spike pulse interference. The use of software filtering algorithms will undoubtedly make fuller use of the system's hardware resources while simplifying the circuit structure, and meet the requirements of reducing product design costs.
The duty cycle modulation (DCM) cycle of the signal output by ADXL202E is determined by an external resistor, which is generally lower than 1 kHz. Therefore, the duration of the high and low levels of the counting input terminal is as long as several ms or even tens of ms. It can be seen that the high and low levels of the normal counting signal output by the sensor change slowly; while the pulse width counting time of the controller is less than 1μs, and the interference spike pulse is a sudden change, so the interference can be distinguished from the normal count. Therefore, it is feasible to use software filtering to eliminate spike pulse interference.
The VRS51L3074 microcontroller is a member of the 8-bit microcontroller family VRS51L3XXX series launched by Ramtron, USA. VRSS1L3074 provides 2 independent pulse width counter (PWC) modules associated with timers 0 and 1. Users can flexibly control the timer to start or stop counting by configuring the PWC module and the timer, thereby conveniently realizing the counting of the pulse width and cycle output by ADXL202E.
Observe the signal waveform from the counting input terminal of the microcontroller. For the convenience of analysis, several interference spike pulses are set in the high and low level sections, marked as Section A and Section C respectively, and the falling edge and rising edge of the duty cycle signal are marked as Section B and Section D respectively. The single-chip microcomputer samples periodically according to the counting clock. The "1" in the sampled value indicates that the sampled value is a high level, and "0" indicates a low level. The I/O port samples the state in the duty cycle signal output port, and uses a byte variable R to dynamically store the sampled value. Each time the controller samples once, the data in the variable R is shifted to the left by 1 binary bit, the original highest level state of R is removed, and the new sampling state at the current moment is saved to the lowest bit of R, the variable R is updated, and the state memory R saves the sampling values of the last 8 sampling cycles.
In Figure 1, from the normal falling edge process (Section B), it can be seen that the data in variable R has experienced a process from all bits being 1, to 1 and 0 coexisting, and then changing to all 0; however, in the interference part of the high level segment (Section A), variable R has experienced a process from all bits being 1, to a mixture of 1 and 0, and then back to all 1. Similarly, in the normal rising edge (Section D), variable R has experienced a state change process from all bits being 0, to 0 and 1 coexisting, and then changing to all 1; in the interference part of the low level segment (Section C), variable R has experienced a sampling state change process from all bits being 0, to a mixture of 0 and 1, and then back to all bits being 0. By judging the different changes in the data in variable R in these four cases, the purpose of distinguishing interference from normal changes can be achieved. This is the basic idea of the software filtering anti-interference method adopted in this design.
3 Implementation of software filtering algorithm
3.1 Software filtering analysis
According to the software filter design concept, the filter subroutine is called by the main program when the signal state changes and the interrupt is entered. Figure 2 shows the filter program flow. The flowchart is analyzed by comparing the four sections in Figure 1. When an edge or interference signal (signal cycle is greater than the counting clock cycle) arrives, the PWC counting stop condition of the VRS51L3074 microcontroller is met, and the system enters the interrupt service subroutine. In the interrupt subroutine, the pulse width counting condition is reset first, and then the current state is sampled. The sampling is 1, and the state register is shifted left by 1 bit. The sampling of the high level is recorded as "1", and the sampling of the low level is recorded as "0". For example, in the normal falling edge Section B, the front is in the high level segment, and the initial state variable Flag is all 1. When a low level appears, the controller enters the interrupt, and then 16 samples are taken. As mentioned earlier, the spike interference processed by the system is about 1 to 2 ms, and each sampling cycle is about 0.4 ms. The spike interference pulse width does not reach 8 sampling cycles. When the system is designed, the sampling is performed 16 times, and only the last 8 storage states are compared with the original state. If the last sampled state is all "0", it is opposite to the original state, and it can be judged that this is a normal falling edge. If the counting interrupt is caused by an interference signal, the first 8 sampling states are not all "1", and the last 8 states are all "1". The last sampled state is the same as the original state, and it can be judged that this is an interference signal, such as Section A. During the signal state sampling period, the counting condition is met and the PWC continues to count until the real falling edge arrives, the counting stops and is saved, and the counting register is restored to the initial value, so that the interference signal is filtered out. Similarly, in the normal rising edge Section D, the original state of the memory is "0", and the memory state after the rising edge arrives is "1", which is opposite to the original state. The PWC count stops and is saved, the counting register is restored to the initial value, and the interrupt subroutine is exited. After the interference signal appears, the sampling state is the same as the original state, and the interference spike pulse can be filtered out. If you want to make the pulse width count more accurate, you can determine the cycle of abnormal counting of the system in the first 8 sampling cycles, and then add it to the final counting cycle. At this point, the program flow reflects the software filtering function.
3.2 Source code analysis
Corresponding to the program flow chart, the source program of the microcontroller sampling and filtering a certain output channel of ADXL202 through the P4.2 port and completing the pulse width counting is given. The source program is as follows:
Three variables are defined in the source program, among which the variable Flag stores the original state value; FlagReg stores the current sampling value; the variable i records the number of sampling times; changing the value of i can control the waiting time for filtering out the spike pulse. The program determines whether the current signal is a valid signal or an interference signal by the value after the original state and the current sampling state are XORed, so as to deal with the intermediate transition or spike pulse interference of the rising edge and the falling edge accordingly, and exit the interrupt subroutine. The purpose of counting normal signals and filtering out spike pulse interference is achieved.
4 Test results
Due to the restrictions of conditions and the randomness of interference, the test of the vehicle-mounted compass based on ADXL202 cannot accurately calibrate the measured angle and direction angle. During the experiment, the standard deviation of multiple measurements of the same physical quantity under the same conditions was used to evaluate the corresponding algorithm. The test results are listed in Table 1.
From the standard deviation of the experimental test, it can be seen that σ is much smaller after software filtering. This software filtering algorithm is very effective in filtering out spike pulse interference.
Conclusion
The software filtering algorithm proposed in this paper has fast speed, high code efficiency, and ideal filtering effect. It is a practical digital filtering design method that embodies the idea of combining algorithms with specific hardware. On the other hand, when the pulse interference is wide, the memory variables can be appropriately expanded into multi-byte variables. This algorithm can also be combined with FPGA for other applications with high counting accuracy requirements and susceptible to spike pulse interference.
Previous article:Design of network projector system based on ARM9 core and embedded Linux
Next article:Design of audio system based on ARM9
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Flash (STM32) "Big Explanation"
- 【Live FAQ】Develop AI intelligent robots based on TI's newly released Robotics SDK
- ISA bus interface.pdf
- MCU Programming Ideas - State Machine
- Touch screen interface definition
- Overview of 5G System Standard Development
- Could you please tell me how to find the maximum output duty cycle of a DCDC buck IC from its technical manual?
- 2. [Learning LPC1768 library functions] Keystroke experiment
- How to change UDP point-to-point communication to UDP broadcast communication
- Design of a USB reader based on embedded system