Design and Implementation of Two-wheeled Vertical Vehicle Based on MC9S12XS128

Abstract : The author takes Freescale's 16-bit single-chip MC9S12XS128 as the core controller and uses the two-wheeled toy car as the control object. It uses the ENC-03RC gyro sensor and the MMA7361 acceleration sensor to realize the tilt angle of the two-wheeled toy model by using the matching filter algorithm. measuring. On this basis, the vertical motion of the two-wheeled toy car is linearly decomposed, and an upright speed controller is designed. Realized the two-wheeled vehicle upright operation.

This article refers to the address: http://

Since the beginning of the 21st century, with the rapid development of China's urban and rural economy and the improvement of people's living standards, more and more people have begun to own private cars, which has caused increasingly serious traffic pressure to a certain extent. In order to solve this problem, people began to study new vehicles. Compared with vehicles such as tricycles and four-wheelers, the two-wheeled vehicle has the characteristics of being easy to operate in a narrow space, light and flexible body and easy to store and manage. It has become a research hotspot in recent years and has broad application prospects. In view of this, this article takes toy car model (hereinafter referred to as car model) as the research object, based on the advanced SMT technology of modern circuit electronics, and uses advanced control theory to conduct in-depth research on two-wheeled vehicles.

The MC9S12XS128 is a cost-effective 16-bit microcontroller from Freescale Semiconductor. The ENC-03RC sensor for measuring angular velocity produced by Murata Co., Ltd. is inexpensive, and the angle measurement can be realized with the three-axis angle measuring sensor MMA7361. In this paper, MC9S12XS128 is used as the core controller, and ENC-03RC and MMA7361 are the main sensors. The advanced PID algorithm is used to design the vertical speed controller to realize the vertical operation of the vehicle model.

1 system overall design

1.1 Measurement of the inclination angle of the model

Through the study of the inverted pendulum, it can be found that to achieve the upright control of the car model, it is necessary to overcome the gravity effect of the car model. To do this, you must obtain the angle at which the car is tilted and the angular velocity. In this way, when the car model is tilted backward, the car model motor is controlled to accelerate backward by the obtained angle and angular velocity. When the car model is tilted forward, the value of the angle and the angular acceleration is used to accelerate the motor forward, thereby keeping the car model standing upright at the balance point.

The angle sensor MMA7361 can be used alone to measure the tilt angle, and then the angular velocity can be obtained by differentiation, but it is not suitable for upright control because of its noise. Based on this, this paper combines two kinds of sensors and uses the matched filtering algorithm to measure the angle and angular velocity. The block diagram of the matched filtering algorithm is shown in Figure 1.

Design and Implementation of Two-wheeled Vertical Vehicle Based on MC9S12XS128

1.2 Upright control of the car model

It can be seen from Fig. 1.1 that the angle of the vehicle model is smoothed by the matched filtering algorithm, and the value of the angular acceleration is obtained by the gyro sensor. The upright control of the car model is controlled by angle negative feedback, enabling it to achieve upright control. With proportional control, you can control the car model to stand upright at the balance point. However, it is necessary to ensure that the car mold has strong anti-interference and has a fast response speed, that is, when the car model encounters interference, it can quickly stabilize to the equilibrium point, and also needs differential control, that is, the angular acceleration of the car model is added. In this way, the use of the angle ratio and the differential control can achieve a rapid stabilization of the car model at the equilibrium point (the actual model of the car model to be drawn). The schematic diagram of the upright control is shown in Figure 2.

Design and Implementation of Two-wheeled Vertical Vehicle Based on MC9S12XS128

1.3 Speed ​​control of the car model

In order to solve the gyro sensor temperature drift and sensor installation problems, the balance point of the car model can be stabilized by adding speed control. Controlling the uprightness of the car model through the angle of the car model is a positive feedback process rather than negative feedback, which is different from other common control methods. The root cause is that the direction of gravity of the car model is opposite to the direction of the force returning to the equilibrium point. When the car model is quickly tilted in one direction, in order to change the direction of motion, that is, change the tilt angle of the car model, positive feedback should be applied to increase the force of the motor and change the tilt angle of the car instead of reducing the motor control. So speed feedback is a positive feedback. Since the actuator of the car model is a DC motor, the motor is upright and speed controlled by controlling the motor. The drag of the motor can be used to know that the relationship between the torque and the current generated by the DC motor is approximately

T=CeφIa (1)

Where Ce is the motor constant, φ is the potential constant, and Ia is the armature current.

From equation (1), the motor can be considered as a linear mechanism. Such upright control and speed control can be seen as two controllers linearly superimposed together and can be approximated as being uncoupled. At this time, the speed controller can be designed separately from the stand-up control. The speed control uses a modified PI controller. Figure 3 shows the block diagram of the speed control:

Design and Implementation of Two-wheeled Vertical Vehicle Based on MC9S12XS128

The key to the upright operation of the car model is upright control and speed control, which can be realized based on gyroscopes and accelerometers and speed sensors. The block diagram of the whole system is shown in Figure 4.

Design and Implementation of Two-wheeled Vertical Vehicle Based on MC9S12XS128

2 system hardware design

The system hardware consists mainly of MC9S12XS128 minimum system, motor drive circuit, speed sensor circuit, gyroscope and accelerometer circuit and debugging circuit. When measuring the motor speed, the single-chip speed measuring module and the counter chip CD4051B are used. The motor driver chip uses the integrated driver chip BTS7960. The debug circuit uses the PL2303 chip to transfer the information in the microcontroller back to the host computer. The hardware system block diagram is shown in Figure 5.

Design and Implementation of Two-wheeled Vertical Vehicle Based on MC9S12XS128

3 system software design

3.1 Digital PID Algorithm

The expression of the analog PID is as shown in equation (2).

Design and Implementation of Two-wheeled Vertical Vehicle Based on MC9S12XS128

At this point, the expression of the digital positional PID has been obtained. The core idea of ​​the upright and speed controllers designed in this paper is from the digital positional PID expression. The following sections describe the various parts of the software.

3.2 Implementation of each part of the software

The software part of the system is mainly composed of sensor signal filtering processing, matching filtering algorithm, vertical control algorithm and speed control algorithm. The sampling of the signal is processed in the interrupt function. In order to reduce noise interference, the program adopts a combination of several methods such as median value and average value. The matched filtering algorithm is used to obtain the tilt and angular acceleration of the vehicle model. The upright control algorithm is used to obtain the vehicle model upright control. The speed control algorithm uses the PI algorithm to achieve the stationary operation of the car model.

4 experimental application

The car model upright walking algorithm of this paper realizes the basic functions. However, there are many parameters that need to be adjusted. First, after using the AD sampling to obtain the gyroscope and accelerometer signal values, the static value is subtracted, and then the acceleration parameters and the gyroscope parameters are required to be normalized to obtain the actual angle. At the same time, there is a scale factor GTA in the matched filtering algorithm that needs to be debugged. Moreover, there are P parameters, D parameters, and speed P parameters, speed I parameters, respectively, in the upright control and the speed control. These parameters require constant debugging to get a better result. After long-term testing, this paper has obtained certain effects. Figure 6 shows the model angle calculated by the matched filtering algorithm.

Design and Implementation of Two-wheeled Vertical Vehicle Based on MC9S12XS128

As can be seen in the figure, the blue line has more burrs, and the other line is significantly smoother, no noise, and also traces the angle of the accelerometer back, indicating that the expected effect is achieved. Using the upright speed control algorithm proposed in this paper, the effect of the car model standing upright is obtained. In Fig. 7, the car model speed is set to 0, and the effect diagram is established in place.

Design and Implementation of Two-wheeled Vertical Vehicle Based on MC9S12XS128

5 Conclusion

Based on the acceleration sensor MMA7361 and the gyro sensor ENC03-RC, the speed and upright control scheme of the two-wheeled vertical vehicle is designed and realized. Experiments show that the whole system has strong anti-interference ability and fast dynamic response characteristics, and the two-wheeled vertical vehicle can achieve upright operation well.

Hengstar offers a range of fully enclosed Industrial Monitors for industrial operator terminals and a variety of factory applications. With a stainless steel or black powder coated enclosure, and IP65 grade connectors, these monitors can be wholly water-proof and dust-proof. Hengstar also offer a variety of industrial keyboard, mounting arms, KVM extender, and fanless Pc Motherboard options to create a full, stand-alone workstation.

Waterproof Monitor

Waterproof Monitor,Waterproof Touch Screen,Waterproof Computer Monitor,Waterproof Touch Screen Monitor

Shenzhen Hengstar Technology Co., Ltd. , https://www.angeltondal.com