In the balance control of two-wheeled self-balancing electric vehicles, real-time and accurate measurement of the pitch angle of the vehicle body is the premise of the entire balance control. The traditional mechanical attitude measuring instrument is large in size, slow in response speed, and low in measurement accuracy, which is far from meeting the real-time and accuracy requirements of the balance control of two-wheeled self-balancing electric vehicles. The attitude measuring instrument based on optical principles and image processing technology has high accuracy, but is expensive and requires a large number of complex calculations, which generally require computer assistance to complete, and does not meet the cost and vehicle-mounted requirements of two-wheeled self-balancing electric vehicles. This paper adopts the design scheme of ME-MS combined module to realize the measurement of the pitch angle of the vehicle body. This measurement system not only has the characteristics of small size, fast response and low cost, but also effectively reduces the influence of vibration interference in the environment after data fusion processing, and can meet the accuracy requirements of the system in a vehicle body environment with strong vibration.
1 System composition and working principle
1.1 System composition
This attitude measurement system is mainly composed of a single-chip microcomputer PIC16F877, an accelerometer MMA7260 and a gyroscope ADXRS610. The system structure block diagram is shown in Figure 1. The PIC16F877 chip provided by Microchip is used as the control chip, which is responsible for A/D sampling and subsequent data processing of the accelerometer and gyroscope.
ADXRS610 is a cost-effective single-axis gyroscope launched by ADI. ADXRS610 is an analog output device, whose output is linearly proportional to the angular velocity of rotation around the rotation axis. The angle of rotation can be obtained by integrating the angular velocity. The measurement range of ADXRS610 angular velocity is ±300 rad/s, the sensitivity is 6 mV/(rad·s-1), the zero output voltage is 2.50 V, the nonlinear error is ±0.1% F. S., the -3 dB bandwidth is 40 Hz, and the natural frequency is 14 kHz.
1.2 Mathematical application principle of accelerometer
MMA7260 is a cost-effective three-axis analog output accelerometer. The analog output is linearly related to the acceleration in the direction of its sensitive axis. In this paper, MMA7260 is used to measure the static acceleration value, and then the angle between the measured platform and the horizontal plane is calculated. The so-called measurement of static acceleration refers to measuring the magnitude of the component of gravity acceleration on a certain sensitive axis when the platform is stationary. Since the direction of gravity acceleration is always vertically downward, this provides a natural reference coordinate system for the measurement system. There are two ways to indirectly measure the angle through the mathematical principle of accelerometer.
Method 1 is shown in Figure 2. The gravity acceleration component is measured using a single sensitive axis, where the angle θ, gravity acceleration g and sensitive axis component gx form an inverse cosine relationship:
Method 2 is shown in Figure 3.
The gravity acceleration component is measured using dual sensitive axes, where the angle θ, the Y-sensitive axis component gy, and the X-sensitive axis component gx form an inverse tangent relationship:
Method 1 only requires a single-axis accelerometer to achieve angle measurement, and only a single-channel ADC module is required for data acquisition, which has advantages in hardware cost and software programming difficulty. Method 2 uses two sensitive axes to simultaneously collect gravity acceleration components in two directions, and obtains the angle value through the ratio of the components of the two axes. Since the two sensitive axes are in the same environmental factors, they have a certain inhibitory effect on interference from factors such as vibration and temperature changes. In addition, for changes in the value of the gravity acceleration constant in different geographical locations, method 1 will produce corresponding errors, while method 2 can eliminate such errors in principle. After comparison, the second method is selected. [page]
The basic principle of complementary filtering is shown in Figure 4. The idea of complementary filtering is to combine the signals obtained by using different filtering methods for sensors with different output characteristics, thereby overcoming the disadvantage of severe distortion of a single sensor and obtaining more accurate information. The accelerometer signal containing high-frequency noise components is filtered through a low-pass filter, and the gyroscope signal with integral drift effect is filtered through a high-pass filter.
Since the high-pass and low-pass filtering processes of this system are processed by software using PIC16F877 to simulate the functions of electronic circuits, it is necessary to discretize the continuous filtering model formula. The model formula of the continuous low-pass filter is as follows:
Wherein, uin(t) and uout(t) are the input and output voltages respectively, and RC is the time constant. The discretized digital low-pass filter model is as follows:
Wherein, yi represents the output at time i; xi represents the input at time i; yi-1 represents the output at time (i-1); △T is the sampling period. Based on the idea of complementary filtering and combined with the discrete digital low-pass filter model, the following model is constructed:
Wherein, angle is the final output angle value of the system; gyr is the angular velocity value calculated from the gyroscope data, gyrdt is the angle increment within a sampling period; acc is the angle value calculated from the accelerometer data. When the appropriate time constant RC and sampling period △T are selected, this model can simulate the
complementary combination function of high-pass filtering of the gyroscope and low-pass filtering of the accelerometer. At the same time, the time constant and sampling period also determine the system's confidence in the output signals of the gyroscope and accelerometer. When the system selects a time constant of 0.1 ms and a sampling period of 5 ms, the above model is substituted:
Assume that in the initial state, the system angle estimation value angle, the gyroscope output angular velocity value gyr and the accelerometer output angle value acc are all zero. Table 1 shows the change process of the estimated value angle in 10 consecutive sampling cycles when the accelerometer receives a sudden change signal of 10° value.
It can be seen from the table that when the system sampling period is set to 5 ms, if the frequency of this mutation signal is higher than 200 Hz, that is, the duration of the signal does not exceed one sampling period, then the maximum deviation brought by this signal to the system will not exceed 0.9°. At this time, it can be considered that the system does not trust the high-frequency signal of the accelerometer, but trusts the signal of the gyroscope. If the frequency of this mutation signal is lower than 20 Hz, the duration of the signal will reach more than 10 sampling periods. At the 10th sampling period, the estimated value angle of the system is 9.0°. At this time, it can be considered that the system trusts the low-frequency signal of the accelerometer. It can be seen that this model has the low-pass filtering function for the accelerometer and the high-pass filtering function for the gyroscope. [page]
2 Simulation Verification
The data fusion model constructed in this paper is used to simulate the measured raw data through Matlab tools to verify the effectiveness of this model. The original signal of the accelerometer is shown in Figure 5.
This is a comparison of the original signal output of the accelerometer in dynamic and static conditions. It can be seen that the dynamic output of the accelerometer cannot accurately reflect the true attitude value due to the presence of high-frequency interference. The original signal values of the accelerometer and gyroscope collected when the measured platform tilts are shown in Figure 6. It can be seen that before 1.6 s, the measured platform was not disturbed by vibration, and the output signal amplitude of the accelerometer was small at this time. After 1.6 s, the measured platform was disturbed by vibration, the output signal of the accelerometer was seriously disturbed, and the output signal of the gyroscope was almost not disturbed by vibration.
The data fusion result is shown in Figure 7. The accelerometer curve is the angle value calculated by the original accelerometer signal, which still fluctuates greatly. The gyroscope curve is the angle value obtained by integrating the output angular velocity value of the gyroscope. The data fusion curve is the angle value obtained by solving the data fusion model constructed in this paper.
As can be seen from Figure 7, the angle value obtained by a single accelerometer fluctuates greatly and cannot accurately reflect the true value. Although the angle value obtained by a single gyroscope through integration operation does not fluctuate, the integral cumulative effect will be very serious as time increases. From 0 s to 10 s, the integral cumulative deviation generated by the gyroscope is close to 50°, and it accelerates and expands at an average rate of 5°/s. This is also the reason why the gyroscope cannot be used alone for platform attitude detection. The angle value obtained after data fusion processing not only overcomes the shortcomings of the poor dynamic performance of the accelerometer, but also compensates for the integral drift of the gyroscope.
3 System Implementation
3.1 Hardware Design
At the beginning of the circuit board design, it is necessary to determine the installation position and angle of the sensor according to the sensitive axis direction of the accelerometer and gyroscope. The gyroscope and accelerometer should be installed in a close position to minimize the external environment difference between the two sensors, which is conducive to reducing the error of later data processing. Whether the rigid contact surface of the platform is treated with anti-vibration, such as adding anti-vibration gaskets, has a great impact on the output of the sensor, especially the accelerometer. [page]
In order to facilitate the adjustment of the sensor installation position and angle, the modular concept is adopted in the hardware design. The accelerometer and gyroscope are designed on a separate small circuit board, and the positive direction of the X-sensitive axis of the accelerometer points to the horizontal forward direction of the measured platform, while the rotation sensitive axis of the gyroscope needs to be installed perpendicular to the X-axis of the accelerometer and parallel to the Y-axis of the accelerometer. The system is connected to an LCD display screen through a reserved data port, and the attitude data can be directly displayed through simple programming. The power supply of the system is provided by a 7.5 V rechargeable battery, and the voltage regulator circuit composed of L7805 converts it into a stable 5 V power supply to power the entire system. A 4 MHz crystal oscillator is used to provide the system clock. The simplified schematic diagram of the system is shown in Figure 8.
3.2 Software Design
The PIC16F877 has a 10-bit precision analog/digital conversion (ADC) module that supports 8 analog conversion channels. For the accelerometer and gyroscope in this system, the resolution of its 10-bit analog/digital conversion module can fully meet the accuracy requirements of the system. According to the system clock frequency and the conversion time of the analog/digital conversion (ADC) module, 1/8 clock frequency is selected as the analog/digital conversion clock, and the analog signals of the accelerometer and gyroscope are collected by channels AN0, AN1, and AN2 respectively. Since the sampling results of the gyroscope need to be integrated in the subsequent signal processing, the sampling interval of each analog/digital conversion module is required to be as equal as possible to ensure the accuracy of subsequent operations. When the CCP2 module in the PIC16F877 is set to the special event trigger mode, in conjunction with timer 1, the timing interrupt enable function of the analog/digital conversion module can be realized. When using special event trigger to start analog/digital conversion, you need to pay attention to several details to get accurate analog/digital conversion results: First, when the analog/digital conversion module is initialized, the ADON position in the ADCONO register needs to be set to 1, otherwise the analog/digital conversion cannot be started even after the special event is triggered; secondly, in the process of sampling the accelerometer and gyroscope by switching between the three analog channels AN0, AN1, and AN2, the ADIF interrupt response is needed to obtain the analog/digital conversion results and switch channels. After the channel is switched, it must be ensured that there is enough sampling time before the next analog/digital conversion module is triggered. Based on the comprehensive analysis of the entire system requirements, the trigger sampling period of CCP2 is set to 5 ms. The interrupt program flow is shown in Figure 9.
4 System Test
The experiment was conducted in an indoor environment at 25°C. First, the attitude measurement system was fixedly installed on the body of the two-wheeled self-balancing electric vehicle, and then the motor of the two-wheeled self-balancing vehicle was powered on to provide a strong vibration interference environment. Table 2 shows the data of the two-wheeled self-balancing vehicle body being fixed at three positions of 0°, 30°, and 45°.
From the measurement results, it can be seen that as the angle increases, the error increases due to the nonlinear factors of the MEMS device, but the error is kept within 50' between 0° and 30°, and the error accuracy can fully meet the control requirements of the two-wheeled self-balancing electric vehicle. The data shows that the values of the measured data are generally larger than the true value. This is because the initial angle of the tested platform is larger than the true zero initial angle. The error will be further reduced after the initial installation position is corrected. In order to achieve higher accuracy, in addition to correcting the initial position during initial installation, more accurate calibration and appropriate temperature compensation of the MEMS device are required.
5 Conclusions
This paper constructs a data fusion model that meets the requirements of this system, verifies the rationality and effectiveness of the model using Matlab tools, and designs the hardware circuit of this attitude measurement system. Experimental tests show that the error accuracy can fully meet the balance control requirements of the two-wheeled self-balancing electric vehicle. In addition to excellent anti-interference performance, this attitude measurement system also has good portability. It can be connected to an LCD display to form an independent attitude measurement system, and can also provide real-time and accurate attitude data for other platforms. Through simple software expansion, it can also provide measurement of attitude parameters such as angular velocity and angular acceleration.
Previous article:Design of high-speed data acquisition system for weather radar based on Linux platform
Next article:Design and implementation of phase-mode optical fiber measurement circuit system
- Popular Resources
- Popular amplifiers
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Seizing the Opportunities in the Chinese Application Market: NI's Challenges and Answers
- Tektronix Launches Breakthrough Power Measurement Tools to Accelerate Innovation as Global Electrification Accelerates
- Not all oscilloscopes are created equal: Why ADCs and low noise floor matter
- Enable TekHSI high-speed interface function to accelerate the remote transmission of waveform data
- How to measure the quality of soft start thyristor
- How to use a multimeter to judge whether a soft starter is good or bad
- What are the advantages and disadvantages of non-contact temperature sensors?
- 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
- The problem of turning frequency in LC filter circuit design
- Live broadcast at 10 am today [The rapid growth of Renesas RA MCU family members helps build safe and stable industrial control systems]
- Evaluation Weekly Report 20220411: GigaDevice's value-for-money MCU F310 is here, TI's heterogeneous multi-core AM5708 thousand yuan industrial board
- Program space issues
- Buy more time with the Raspberry Pi Pico
- Is this seller a scam?
- RT-Thread device framework learning PIN device
- [Raspberry Pi Pico Review] 4. Connect Pico to the temperature sensor DS18B20 to read the temperature
- Qorvo's leading RF solutions
- The basic physics of ultrasonic sensors and the time difference between received signals