Dyethin
Table of Contents
Table of Contents

Design and Implementation of Intelligent Vehicle Control System Based on 16-bit Embedded Microcontrollers MC9S12DG128

June 16, 2023

The smart car described in this article is designed and produced according to the requirements of the competition rules. The smart car control system uses a 16-bit MC9S12DG128 single-chip microcomputer produced by Freescale Semiconductor as a digital controller, and is controlled by a black and white CMOS camera installed in the front of the car It is responsible for collecting track information, and the collected signal is sent to the single-chip microcomputer after binarization processing. After the single-chip computer judges and processes the signal, the PWM generation module sends out PWM waves to control the steering servo to complete the steering of the smart car. In addition, a rotary encoder is installed on the rear wheel of the smart car to collect the pulse signal of the wheel speed. The single-chip microcomputer uses the control amount processed by the PID control algorithm to change the PWM wave duty cycle of the motor drive module, thereby controlling the driving speed of the smart car.


1. Control scheme design and hardware circuit composition

To design an effective intelligent vehicle control system, we must first grasp the characteristics of the control object. According to the analysis of the characteristics of the intelligent vehicle, it can be considered that the transfer function of the steering control system of the intelligent vehicle is approximately the first-order integral plus pure lag, and the transfer function of the speed control object is approximately the first-order inertia plus pure lag.

The steering control system mainly requires fast response speed, and does not require high precision of steady-state control. Moreover, the control objects only have integral and lag links, and there is no common inertial link. According to the above characteristics, the steering control adopts PD controller.

The significance of speed detection and control is to make the smart car run at the highest speed allowed by the road conditions as much as possible.

In curves, the vehicle speed should be limited to the maximum speed without derailment, and in straight roads, appropriate rapid acceleration should be performed to shorten the running time of one lap. At the same time, the track length information can be obtained by integrating and summing the speed signal, which provides data for the road recognition and memory module. The precision of the smart car speed control system does not need to be too high, the key is how to quickly respond to changes in the road conditions of the track. Therefore, the speed control adopts PID controller. According to different road conditions, the vehicle speed can be changed quickly and accurately to achieve stable cornering.

The hardware circuit of the smart car is mainly composed of a video processing module, a direction control module and a vehicle speed control module. The relationship between each module and the Embedded Microcontrollers is shown in Picture 1.


2. Module function

(1) Video processing module. The video processing module is composed of a CMOS camera, a binarization circuit and a synchronization separation circuit.

(2) Steering control module. The steering control module is mainly completed by the steering gear. The rotation of the steering gear will be converted into the lateral movement of the steering rod of the car model, thereby driving the rotation of the front wheels of the car model and controlling the driving direction of the smart car. The steering control of the steering gear adopts PD control. According to the position of the black line in the center of the track, the Embedded Microcontrollers outputs a PWM signal with a corresponding duty cycle to the steering gear.

(3) Vehicle speed control module. The vehicle speed control module is mainly composed of a DC motor, a drive circuit and a rotary encoder. According to the path information detected by the CMOS camera, the current track condition of the smart car is judged, and the closed-loop control of the driving speed of the smart car is formed according to the actual speed detected by the rotary encoder, and the Kp and Ki of the digital PID control algorithm are reasonably adjusted. , Kd three parameters, to achieve rapid speed response and eliminate the purpose of static error.


3. Circuit design

(1) Power module design. The power module should supply power for the Embedded Microcontrollers, sensors, steering gear and drive motors. Therefore, it is necessary to provide a variety of power supplies to meet the requirements of each module. After the battery is fully charged, the no-load voltage is only about 8v, and as the battery is consumed, the voltage gradually decreases. The current is very large when the motor is started and reversed, and it may also pull the battery voltage to a relatively low level. In order to avoid unstable power supply voltage and affect camera video processing circuit and single chip microcomputer to work abnormally, DC-DC conversion chip MC34063 and low dropout voltage regulator LM2940 are used in this design. MC34063 outputs a stable 8-volt voltage for the CMOS camera, and LM2940 provides a stable 5-volt power supply for the 16-bit MC9S12DG128 Embedded Microcontrollers, video amplification and binarization circuits, ensuring the stable operation of the system under various conditions. The schematic diagram of the power module is shown in Picture 2.

(2) DC motor drive module design. The DC motor drive adopts Freescale's 5A integrated H-bridge chip MC33886. The MC33886 chip has built-in control logic, charge pump, gate drive circuit and low on-resistance MOSFET output circuit, which is suitable for controlling inductive DC loads (such as DC motors). It can provide continuous 5A current, and integrates over-current protection, over-heat protection, and under-voltage protection. By controlling the four input lines of MC33886, the forward rotation of the motor, energy consumption braking and reverse braking can be realized conveniently. Picture 3 is a simplified H-bridge circuit. When S1 and S4 are turned on and S2 and S3 are turned off, the current flows forward through the DC motor, and the smart car moves forward; when S2 and S3 are turned on and S1 and S4 are turned off, the current reverses. If this process is used properly, the car model will be in the state of reverse braking, and the vehicle speed will be reduced rapidly; when S3 and S4 are turned on and S1 and S2 are turned off, no power is applied to the DC motor, and the DC motor armature two The ends are equivalent to being shorted together. Since the motor shaft rotates under the action of external force, the motor can generate electric energy. At this time, the DC motor can be regarded as a generator with a heavy load, and a force will be generated on the motor to hinder the movement of the output shaft. The magnitude of this force is the same as The size of the load is directly proportional, and the motor is in the state of dynamic braking at this time.

 

In this design plan, two MC33886s are connected in parallel, on the one hand, it reduces the influence of the on-resistance on the characteristics of the DC motor, and on the other hand, it reduces the influence of the overcurrent protection circuit inside the MC33886 on the starting and braking of the motor. The schematic diagram of the DC motor drive module circuit is shown in Picture 4.

(3) Sensor circuit design. The smart car uses a CMOS camera as an image sensor to ensure accurate and effective information collection on the track. The output signal of the CMOS camera is a composite full TV signal of PAL standard, outputting 50 frames per second (divided into even field and odd field). When the CMOS camera collects images, the even field and odd field are not collected at the same time, so the path can be identified in each field signal.


(4) Design of wireless data transmission module. The smart car is equipped with a wireless data transmission module based on the radio frequency transceiver chip nRF403, and on this basis, the MODBUS communication protocol is implemented, which is very helpful in the process of testing smart car parameters and program debugging. In the process of running, various parameters of the smart car can be sent up in real time, and the analysis of the running status of the smart car can improve the control program in a more targeted manner. In the process of debugging motion parameters, parameters such as Kp, Ki, and Kd can be changed through the host computer software without reprogramming the program, which is fast and convenient.


4. Software design

The program structure of the intelligent vehicle control system is shown in Picture 5, which is a two-layer hierarchical control system. The bottom control system includes "steering control system" and "vehicle speed control system". The upper main control program schedules the whole control system by changing the set value, control parameters and constraints of the bottom control system. The design of this layered control system refers to the structural characteristics of the distributed control system DCS. The functions of each part of the program are clear and the structure is clear, which is convenient for debugging and maintenance. For the convenience of debugging, the main control program has added the MODBUS communication protocol based on the wireless channel, which provides great convenience for the monitoring and adjustment of the driving parameters of the smart car.


The functions realized by the software are:

① Initialization.


② Data collection and filtering processing. In order to reduce the pure lag time introduced as much as possible, this paper proposes a unique and innovative video signal acquisition method, that is, the SPI port provided by the MC9S12DG128 Embedded Microcontrollers is used to directly read the binarized video signal. The competition rules specify that the width of the black guide line on the track is 2.5 cm, so the width of the guide line collected by the camera should also fall within a certain range under normal circumstances. The pixel width corresponding to the guide line can be measured experimentally, and then the collected guide line width is controlled in the filtering program. If it exceeds the normal range, it is considered invalid data. Experiments have proved that this method can effectively filter out interference.


③Road recognition. The core of the smart car hierarchical control system is the identification of the track. The actual test found that due to the relatively small visual range of the CMOS camera and the trapezoidal field of view, it often happens that part or even all of the track is out of the field of view during fast movement, which brings great difficulties to track recognition. Tao mode is almost impossible. In order to simplify the problem, this scheme only recognizes the straight segments in the track, divides the track into different areas according to the number and length of the straight segments, and optimizes the control parameters in one area.


④Motor control. The single-chip microcomputer detects the number of pulses generated by the rotation of the rear wheel of the smart car by receiving the rotary encoder, and uses the recursive form of the positional PID control algorithm to quickly and accurately control the speed of the DC motor.


The recursive form of the positional PID control algorithm:

Δu(k) = Kp[e(k) -e(k-1)] +Ki×e(k) +Kd[e(k) -2e(k-1) +e(k-2)], u (k) =u(k-1) +Δu(k)

In the formula: u(k) is the output of the controller at time k; e(k) is the deviation at time k; Kp, Ki, Kd are the proportional coefficient, integral constant and differential constant of the positional PID control algorithm respectively [7].


⑤ Servo control. The single-chip microcomputer uses the path information detected by the CMOS camera, and uses the incomplete differential PD control algorithm to control the rotation angle of the steering gear to achieve path tracking.


5.Conclusion

This paper introduces the design and implementation of an intelligent vehicle control system. Figure 5 is a photo of the completed smart car. Through a large number of experimental tests, it is proved that the smart car can quickly and smoothly track the black guide line on the produced track, the tracking effect is good, the speed control response is fast, the dynamic performance is good, the steady-state error is small, the system stability and anti-interference strong ability.



Articles you may also like

What is a waveform? What types of waveforms are there? And the characteristics of the waveform

What is a waveform in detail? and the characteristics of the three waveforms.
Read More >

Build an intelligent UPS power supply

Realize intelligent UPS system by using multiple power sources
Read More >

PIC microcontroller technology and application foresight

Provides an in-depth understanding of the PIC microcontroller architecture, programming language, and application areas, reveals the technical advantages of the PIC microcontroller, and provides developers with detailed introductory and advanced tutorials to help make technical projects a success.
Read More >

Measurement of Air Ionic Conductivity with Double Darlington Tubes

Ⅰ.PrefaceThe introductionMany years ago, TOM Petruzzellis penned the book Electronic Sensor Experiments for Geniuses, which contains a number of fascinating electronic sensor experiments.On the cover, the chamber sensor used to measure air ions should be the author's most impressive and magical invention.It is true that the materials required for this experiment are inexpensive, ...
Read More >
Becky Boresen
Becky Boresen is a senior electronics engineer specializing in switching components such as transistors, capacitors and connectors. During her career, she has been involved in developing several electronic projects and has successfully driven several technological innovations. She is passionate about continually learning about the latest trends in electrical technology to stay competitive in the industry.
Related Parts
Index : 0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z