A new anti-interference design in vehicle-mounted electronic compass

Publisher:leader5Latest update time:2011-05-04 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Abstract: This paper introduces the interference suppression and software filtering methods of the dual-axis acceleration sensor ADXL202 in the application of vehicle-mounted electronic compass. Based on the software filtering solution of the VRS51L3074 single-chip microcomputer, only one byte variable is needed to dynamically store the periodic sampling value of one channel, and according to the numerical change of the binary bit of this variable, the rising edge, falling edge and interference spike pulse of the effective signal are judged to achieve the purpose of effective counting and filtering interference. This design idea has achieved good experimental results in the electronic compass test.
Keywords: acceleration sensor; electronic compass; spike pulse; ADXL202

Introduction
With the rapid development and maturity of positioning and navigation technology, electronic compasses have been increasingly widely used in related fields. The function of the on-board 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 article is a kind of strapdown inertial navigation system. 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 angle. 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, which seriously affects 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, an X and Y direction sensor, 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 judge 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 CX and CY 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 period T2 (1 to 10 ms) of T2 can be changed through the external resistor of T2 pin, which is convenient for use in occasions with different accuracy requirements. The duty cycle of the output duty cycle signal can be calculated by the 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 angles 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 (HX, HY, HZ) 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 azimuth of the electronic compass can be obtained by using the pitch angle and roll angle for attitude calculation.

2 Anti-interference design concept of ADXL202
According to the ADXL202 user manual, when the sensor and the microprocessor share the power supply, interference will be caused. Therefore, the solution of suppressing interference 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. Experimental tests show that there is still a situation where the power supply of other parts of the circuit and the sensor power supply affect each other, and the interference suppression effect is not ideal. After repeated tests, the sensor is powered by an independent power supply, and 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 during wiring, and a better interference suppression effect is obtained under laboratory conditions. However, in actual applications, the vibration and instantaneous power changes of the car can not 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 the overall size of the electronic compass and the sensitivity of the magnetoresistive sensor signal to interference, if efficient hardware filtering is used, the system circuit will become very large; if a simple hardware circuit is used, 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 simplify the circuit structure while making fuller use of the system's hardware resources and achieving the requirement 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 (Ramtron) of the United States. VRS51L3074 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 the 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), the variable R has experienced a process from all bits being 1, to 1 and 0 mixed, and then back to all 1. Similarly, in the normal rising edge (Section D), the 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), the variable R has experienced a sampling state change from all bits being 0, to 0 and 1 mixed, and then back to all bits being 0. By judging the different changes in the data in the 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 Analysis of software filtering
According to the design idea of ​​software filtering, the filtering subroutine is called by the main program when the signal state changes and the interrupt is entered. Figure 2 shows the flow of the filtering program. The flow chart 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 high level is recorded as "1", and the sampling of 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. It has been mentioned before that the spike interference processed by the system is about 1 to 2 ms, and each sampling cycle is about 0. 4 ms. The pulse width of its spike interference 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 next 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 in the first 8 sampling cycles, and then add it to the final counting cycle. At this time, the program flow reflects the software filtering function.

3.2 Source code analysis
The corresponding program flow chart gives 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. 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 XOR of the original state and the current sampling state, 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 limitations of conditions and the randomness of interference, the test of the vehicle electronic compass based on ADXL202 cannot accurately calibrate the measured angles and directions. 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.

Reference address:A new anti-interference design in vehicle-mounted electronic compass

Previous article:Design of universal controller for solar water heater based on AFS600
Next article:Design of an Intelligent Home Monitoring System

Latest Industrial Control Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号