System design of two-wheeled self-balancing intelligent vehicle

Publisher:暮烟微雨Latest update time:2014-01-23 Source: 电子设计工程 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Introduction
    The control technology of two-wheeled self-balancing smart car has a wide range of applications in many fields such as aviation, navigation, security, etc. Various types of inclination sensors and data processing methods have emerged. With the development of modern science and technology, higher requirements are put forward for the response speed and accuracy of self-balancing. Against this background, the electromagnetic group of the 7th National College Student Smart Car Competition requires the design of a two-wheeled upright self-balancing tracking smart car.
    To address this problem, this paper uses the MMA7260 acceleration sensor and the NEC-03 gyroscope to jointly detect the angle information of the car model, and obtains the accurate real-time angle information of the car model through the Kalman filter. The PI control algorithm implemented in the main control chip MC9S12XS128 and two DC motors are used as the control core of the smart car to realize the self-balancing control of the two-wheeled smart car. The advantages of this system are strong adaptability, rapid response and strong anti-interference ability.

1 Design Principle
   
The intuitive experience of controlling the balance of the upright car model comes from people's daily life experience. Most people can keep a straight wooden stick upright on their fingertips through simple practice. This requires two conditions: one is that the palm holding the stick can move; the other is that the eyes can observe the tilt angle and tilt trend (angle and angular velocity) of the stick. The tilt angle and trend of the stick are offset by the movement of the palm, so as to keep the stick upright. These two conditions are indispensable, and are actually the negative feedback mechanism in control.
    The balance control of the car model is also achieved through negative feedback, which is relatively simple compared to keeping the stick upright. Because the car model has two wheels on the ground, the car body will only tilt in the direction of the wheel rolling. Controlling the rotation of the wheels and offsetting the tilt trend in one dimension can keep the car body balanced, as shown in Figure 1.

f.JPG


    As shown in Figure 1, in order to keep the car model upright and self-balancing, the following two conditions need to be met:
    ① The inclination angle and angular acceleration of the car model can be accurately measured to obtain the state and trend of the car model;
    ② The speed and acceleration of the wheels can be controlled to keep the car model upright.

2 Self-balancing intelligent car system structure The
   
self-balancing intelligent car system mainly includes the main control module, angle information acquisition module, motor drive module and power supply module, etc. The self-balancing intelligent car system structure block diagram is shown in Figure 2.

a.JPG


    The main control module uses Freescale's 16-bit main control chip Mc9S12XS128, which has an internal A/D converter with high precision and high sampling frequency, as well as an internal timer module and input capture function, which can well realize the speed measurement of the car model motor; for the processing of the car model angle information, the clock frequency of the main control chip can reach up to 80 MHz, which can quickly respond to the change of the car model angle and control the self-balancing of the car model.

3 Self-balancing smart car hardware design
   
The position information (i.e. angle and angular velocity information) required to control the self-balancing of the car model can be obtained through the accelerometer and gyroscope; due to the limited driving capability of the main control module I/O port, the smart car needs to use a full-bridge drive to drive the motor; in order to achieve accurate closed-loop control of the vehicle speed, a speed measurement module is required.
3.1 Accelerometer
   
The accelerometer can measure the acceleration generated by the earth's gravity or the movement of an object. The self-balancing smart car system uses the Freescale series accelerometer MMA7260. This series of sensors uses semiconductor surface micromachining and integrated circuit technology, with small size and light weight. MMA7260 is a three-axis low-g semiconductor accelerometer that can output acceleration analog signals in three directions at the same time. The circuit is simple to implement and the angle output accuracy is high.
3.2 Gyroscope
   
The angular velocity sensor of the self-balancing smart car system uses a gyroscope, which can be used to measure the rotational angular velocity of an object. According to the accuracy requirements, the ENC-03 series accelerometer produced by Murata was selected. It uses the principle that objects in a rotating coordinate system will be affected by the Coriolis force, and uses piezoelectric ceramics to make a vibration unit in the device. When the device is rotated, the vibration frequency will change to reflect the angular velocity of the object's rotation.
3.3 Motor drive
   
The self-balancing smart car system uses the motor driver chip BTS7960 as the motor driver. When the chip is working, the typical impedance value is 16 mΩ (IOUT=9 A, Ti=25℃), and the maximum drive current it can provide is 43 A. When the chip is overheated, it can be automatically shut down or locked; in the case of overcurrent, the switch mode can limit the current and reduce power consumption; it will automatically shut down when undervoltage and lock when overvoltage. The drive circuit diagram is shown in Figure 3.

b.JPG


3.4 Speed ​​Measurement Module
   
This system uses an optical encoder fixed on the motor output shaft and a photoelectric tube device that cooperates with each other to measure the speed of the wheel, as shown in Figure 4.

c.JPG


    Since the main control chip MC9S12XS128 used in the smart car has only one pulse accumulator port, a data selector is needed to control it to measure only the speed of one motor at the same time and measure the speed of the other wheel at the next moment. At the same time, the program calculates the speed of the two wheels according to the selection signal and the measured speed, so as to give accurate control signals to keep the car model upright and complete acceleration, deceleration and steering. [page]

4 Car model information acquisition and processing
4.1 Processing of position information
   
The position information of the self-balancing smart car is mainly obtained through the acceleration sensor and gyroscope. The acceleration sensor MMA7260 is a three-axis low-g semiconductor accelerometer that can output acceleration analog signals in three directions at the same time. Through software and hardware settings, the maximum output sensitivity of each axis signal of MMA7260 can be 800 mV/g. This signal does not need to be amplified and can be directly sent to the microcontroller for A/D conversion.
    In practical applications, it is only necessary to measure the acceleration value in one direction to calculate the inclination angle of the car model, such as using the acceleration signal in the Z-axis direction. When the car model is upright, the accelerometer is fixed in the horizontal direction of the Z axis, and the output signal is a zero-bias voltage signal. When the car model tilts, the gravity acceleration g will form an acceleration component in the Z axis direction, causing the output voltage of the axis to change. The law of change is:
    △u=k·g·sinθ≈k·g·θ (1)
    In the formula, g is the gravity acceleration, θ is the inclination angle of the car model, and k is the sensitivity coefficient of the acceleration sensor. When the inclination angle θ is relatively small, the change in the output voltage can be approximately proportional to the inclination angle.
    In theory, only an acceleration sensor is needed to obtain the inclination angle of the car model, and then the inclination velocity can be obtained by differentiating this signal. However, in the actual operation of the car model, the acceleration generated by the swing of the car model itself will generate a large interference signal, which is superimposed on the above measurement signal, making the output signal unable to accurately reflect the inclination angle of the car model. The interference signal
    generated by the movement is analyzed below. The acceleration sensor is installed on the car model at a height of h from the axle. The rotation of the car model has an angular acceleration α and a motion acceleration a. Then, the acceleration caused by the car model movement on the Z axis of the acceleration sensor is h·α+a, as shown in Figure 5. In order to reduce the interference caused by the movement, the acceleration sensor is installed as low as possible, but the influence of the car model movement cannot be completely eliminated.

g.JPG


    The acceleration generated by the car model movement causes the output voltage to fluctuate around the actual tilt angle voltage. These fluctuation noises can be filtered out by data smoothing filtering. However, on the one hand, smoothing filtering will make the signal unable to reflect the car model tilt angle change in real time, thereby slowing down the control of the car model wheels, and on the other hand, it will also filter out the car model angular velocity change information. The above two filtering effects make it impossible for the car model to maintain balance. Therefore, the tilt angle information required for the upright control of the car model needs to be obtained through another device, that is, the angular velocity sensor-gyroscope.
    Since the gyroscope outputs the angular velocity of the car model, the inclination angle of the car model can be obtained by integrating the angular velocity signal, and it will not be affected by the movement of the car body. Therefore, the noise in the signal is very small. In addition, the angle of the car model is obtained by integrating the angular velocity, which can further smooth the signal, making the angle signal more stable. Therefore, the angle and angular velocity required for the car model control can use the signal obtained by the gyroscope. Since this angle signal is obtained by integration, if there is a slight deviation and drift in the angular velocity signal, after the integration operation, the change will form an accumulated error. This error will gradually increase over time, eventually leading to circuit saturation and the inability to form a correct angle signal.
    In order to eliminate this cumulative error, the method adopted is to correct it through the angle information obtained by the above acceleration sensor. By comparing the angle obtained by integration with the angle obtained by gravity acceleration, the deviation between them is used to change the output of the gyroscope, so that the integrated angle gradually tracks the angle obtained by the acceleration sensor. The
    angle information θg obtained by the accelerometer is compared with the angle θ after the gyroscope integration, and the compared error signal is amplified by 1/Tg ratio, and then integrated after superposition with the angular velocity signal output by the gyroscope. For the angle θg given by the accelerometer, the angle θ generated after the proportional and integral links must eventually be equal to θg. In order to
    avoid the output angle θ tracking time being too long, the following two measures can be taken:
    ① Carefully adjust the amplifier circuit of the gyroscope so that its zero offset is as close to the set value as possible and stable.
    ② At the beginning of the control circuit and program operation, try to keep the car model in an upright state, so that the output angle θ can be equal to θg at the beginning. After that, the output of the accelerometer only eliminates the offset of the integral, and the output angle will not have too much deviation.

j.JPG


    The Kalman filter model is shown in Figure 6. The angular velocity measured by the gyroscope is used as the control value of the predicted value, and the angle measured by the acceleration sensor is used as the observed value. The formula is as follows: Z(k) is the angle obtained by integrating the acceleration at time k, U(k) is the angular velocity at time k, X(k|k) is the angle after Kalman filtering at time k, X(k|k-1) is the predicted value at time k obtained by the system using the state at time k-1, and Kg(k) is the Kalman gain at time k.
    i.JPG
    Since the self-balancing intelligent vehicle system is a single-input and single-output system, A, B, H, and K are not matrices, and their values ​​are all 1. There are three Kalman filter parameters in the self-balancing intelligent vehicle system. P is the covariance of the Kalman system parameter A. The setting of the initial value P(0) of P needs to be debugged and determined according to the system effect, and the initial value is generally around 1. Q is the covariance of the predicted value Z(k), and R is the covariance of the measured value U(k). The setting principle for Q and R is that the value of Q/(Q+R) is the convergence value of the Kalman gain. For example, if its value is 0.2, then the gain after the Kalman filter will converge to 0.2, that is, if the predicted angle value is 5° and the measured angle value is 10°, then the optimal angle is: 5+0.2*(10-5)=6°. Therefore, the smaller the Kalman gain, the more reliable the predicted value and the closer the optimal angle is to the predicted value; on the contrary, the larger the Kalman gain, the more reliable the measured value and the closer the optimal angle is to the measured value. P/(Q+R) reflects the speed of convergence. The smaller the value is set, the faster the convergence, and the larger the value is, the slower the convergence. Since the convergence of the Kalman gain is generally very fast, the setting of this value has little effect.

d.JPG


    The waveform after Kalman filtering is shown in Figure 7, including the signal output by the accelerometer, the signal output by the gyroscope and the waveform after Kalman filtering. Experiments show that Kalman filtering can restore the signal well, overcome the temperature drift of the accelerometer and gyroscope, and accurately provide the angle information of the car model.
4.2 Processing of speed information
   
The processing method of this system is to measure the speed based on the pulse information of the photoelectric encoder through the input capture function of the single-chip microcomputer. In terms of speed closed-loop control, the incremental PID control algorithm is adopted. The required formula is:
    k.JPG
    Kp-plays a proportional regulation role. Once the system has a deviation, the proportional regulation immediately produces a regulating effect to reduce the deviation.
    Ki-makes the system eliminate steady-state errors and improves the error degree. The introduction of integral regulation will reduce the stability of the system and slow down the dynamic response.
    Kd-reflects the rate of change of the system deviation signal, which can foresee the trend of the deviation change and control the deviation in advance.
    For the motor of the car model, combined with the actual debugging experience, the motor speed regulation scheme adopted in this car model is PI control. The target speed and current speed will be operated again by PI to obtain the motor control information and hand it over to the external device control module for processing, so as to achieve the purpose of controlling the speed.
4.3 Software Design
   
The system mainly uses the A/D conversion module of the main control chip to read the values ​​of the gyroscope and acceleration sensor, so as to obtain the angle information of the car model through the Kalman filter. Since the control goal is to keep the car model upright, the angle of the car model when upright is taken as the control goal, and the measured car model angle information is taken as the current feedback. Through the PID control algorithm, the motor speed that needs to be given is calculated, and the motor closed-loop control is used to make the car model produce the corresponding motion state to keep the car model upright and balanced. The system flow chart of the car model is shown in Figure 8.

e.JPG



Conclusion
   
The experimental results show that this system method is simple and practical, and can well achieve the expected function, that is, to achieve dynamic self-balancing of the car. The magnetic navigation smart car using this self-balancing method achieved excellent results in the 7th "Freescale" Cup National College Student Smart Car Competition. In the application of Kalman filtering in this method, formulas (2) to (6) can be further simplified, and at the same time, the self-balancing of the car model can be better achieved by optimizing various parameters, further improving the stability of the car model.

Reference address:System design of two-wheeled self-balancing intelligent vehicle

Previous article:Underground parking lot voice navigation system based on nanoPAN5375
Next article:A new design of motor vehicle tracking and anti-theft system

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号