Share this

Design and Implementation of an Intelligent Vehicle Control System Based on the 16-bit Microcontroller MC9S12DG128

2026-04-06 05:59:16 · · #1
Abstract: The hardware of this intelligent vehicle control system is based on the MC9S12DG128 microcontroller and includes a path detection module, a vehicle speed detection module, a servo steering module, a DC motor drive module, a power supply module, and a communication debugging module. Path detection uses a CMOS camera, and vehicle speed detection uses a rotary encoder mounted on the rear axle, thus forming two closed-loop control systems for steering and vehicle speed, respectively. Steering control uses a partially differential PD controller, and speed control uses a PID controller. The setpoints for both closed-loop control systems are provided by the main control program, forming a hierarchical intelligent vehicle control system. Keywords: smart car; path tracking; controller; sensor Abstract: The hardware of the smart car control system takes a singlechip of MC9S12DG128 as the core, including the path detecting module, the car's speed detecting module, the rudder machine's direction changing module, the direct current motor's drive module, the power supply module and communication debugging module etc. The path detecting adopts the CMOS camera. The car's speed detecting adopts the revolving encoder to be installed in the as the tail shaft of the smart car.Thus they respectively constitute two closed-loop control systems which are the direction changing and the car's speed. The direction changing control adopts the incomplete differential PD controller.The speed control adopts the PID controller.Two given values ​​of two closed-loop control systems are both provided by the master programme, coming into being the smart control system with the layering structure. The National Undergraduate "Freescale Cup" Intelligent Car Competition, held in my country since 2006, integrates scientific rigor, fun, and entertainment. It's a technological innovation competition against the backdrop of the rapidly developing and promising automotive electronics field, encompassing multiple disciplines including automatic control, pattern recognition, sensing technology, electronics, electrical engineering, computer science, mechanics, and automotive engineering. Participating teams build an intelligent car capable of autonomously recognizing routes and automatically navigating a specially designed track based on a car model platform. The intelligent car described in this article was designed and built according to the competition rules. Its control system uses a 16-bit MC9S12DG128 microcontroller from Freescale Semiconductor as the digital controller. A black-and-white CMOS camera mounted at the front of the car collects track information, and the collected signals are binarized before being transmitted to the microcontroller. After processing the signals, the microcontroller generates PWM waves to control the steering servo, thus steering the intelligent car. In addition, a rotary encoder is installed on the rear wheel of the intelligent vehicle to collect the pulse signal of the wheel speed. The microcontroller uses a PID control algorithm to process the control quantity and change the duty cycle of the PWM wave of the motor drive module, thereby controlling the driving speed of the intelligent vehicle. 2. Control Scheme Design and Hardware Circuit Composition Designing an effective intelligent vehicle control system requires first understanding the characteristics of the controlled object. Based on the analysis of the characteristics of the intelligent vehicle, it can be concluded that the transfer function of the intelligent vehicle steering control system is approximately a first-order integral plus pure time delay, and the transfer function of the speed control object is approximately a first-order inertia plus pure time delay. The steering control system mainly requires fast response speed and does not require high steady-state control accuracy. Moreover, the controlled object only has integral and time delay elements, without the common inertial elements. Based on the above characteristics, a PD controller is used for steering control. The significance of speed detection and control is to make the intelligent vehicle travel at the maximum speed allowed by road conditions as much as possible. On curves, the speed should be limited to the maximum speed that will not derail, and on straight roads, appropriate rapid acceleration should be performed to shorten the single-lap time and improve the race performance. At the same time, integrating and summing the speed signal can obtain the track length information, providing data for the road recognition and memory module. The accuracy of the speed control system of the intelligent vehicle does not need to be too high. The key is how to quickly respond to changes in the track conditions. Therefore, the speed control adopts a PID controller. The vehicle speed is changed quickly and accurately according to different road conditions to achieve stable cornering. The hardware circuit of the intelligent vehicle 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 microcontroller is shown in Figure 1. 3 Module functions (1) Video processing module. The video processing module consists of a CMOS camera, a binarization circuit and a synchronization separation circuit. (2) Steering control module. The steering control module is mainly completed by a servo motor. The rotation of the servo motor will be converted into the lateral movement of the steering lever of the car model, thereby driving the rotation of the front wheel of the car model and controlling the driving direction of the intelligent vehicle. The steering control of the servo motor adopts PD control. According to the position of the black line in the center of the track, the microcontroller outputs a PWM signal with a corresponding duty cycle to the servo motor. (3) Vehicle speed control module. The vehicle speed control module is mainly composed of a DC motor, a drive circuit and a rotary encoder. The current track conditions of the intelligent vehicle are determined based on the path information detected by the CMOS camera, and a closed-loop control of the intelligent vehicle's speed is formed based on the actual vehicle speed detected by the rotary encoder. The three parameters Kp, Ki, and Kd of the digital PID control algorithm are reasonably adjusted to achieve rapid vehicle speed response and eliminate static errors. [b]4 Circuit Design[/b] (1) Power Module Design. The power module needs to supply power to the microcontroller, sensors, servo motors, and drive motors. Therefore, multiple power supplies are needed to meet the requirements of each module. After the battery is fully charged, the open-circuit voltage is only about 8V, and the voltage gradually decreases as the battery is consumed. The current is very large when the motor starts and reverse braking, which may also pull the battery voltage down. In order to avoid unstable power supply voltage, which may affect the camera video processing circuit and the microcontroller's normal operation, the DC-DC converter chip MC34063 and the low differential voltage regulator LM2940 are used in this design. The MC34063 outputs a stable 8V voltage to the CMOS camera, and the LM2940 provides a stable 5V power supply to the 16-bit MC9S12DG128 microcontroller, video amplification and binarization circuit, ensuring stable operation of the system under various conditions. The schematic diagram of the power supply module is shown in Figure 2. (2) Design of DC motor drive module. The DC motor drive uses 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 a continuous 5A current and integrates overcurrent protection, overheat protection and undervoltage protection. By controlling the four input lines of the MC33886, forward rotation, energy consumption braking and reverse braking of the motor can be easily realized. Figure 3 shows a simplified H-bridge circuit. When S1 and S4 are on and S2 and S3 are off, current flows forward through the DC motor, propelling the intelligent car forward. When S2 and S3 are on and S1 and S4 are off, current flows backward through the DC motor. This process can be used to put the car model in a reverse braking state, rapidly reducing its speed. When S3 and S4 are on and S1 and S2 are off, no power is applied to the DC motor, effectively shorting the armature terminals. Since the motor shaft generates electrical energy when rotated under external force, the DC motor can be considered a generator with a heavy load. A force opposing the output shaft's movement is generated on the motor, the magnitude of which is proportional to the load. In this case, the motor is in an energy-consumption braking state. This design uses two MC33886 chips connected in parallel. This reduces the impact of the on-resistance on the DC motor's characteristics and minimizes the influence of the MC33886's internal overcurrent protection circuit on motor startup and braking. The schematic diagram of the DC motor drive module circuit is shown in Figure 4. (3) Sensor circuit design. The intelligent car uses a CMOS camera as an image sensor to ensure accurate and effective acquisition of track information. The output signal of the CMOS camera is a composite full television signal in PAL format, outputting 50 frames per second (divided into even field and odd field). When the CMOS camera acquires images, the even field and odd field are not acquired simultaneously, so the path can be identified in each field signal. (4) Wireless data transmission module design. The intelligent car is equipped with a wireless data transmission module based on the RF transceiver chip nRF403, and the MODBUS communication protocol is implemented on this basis, which is very helpful in testing the intelligent car parameters and debugging the program. During operation, various parameters of the intelligent car can be sent up in real time, and the operation status of the intelligent car can be analyzed to make more targeted improvements to the control program. During the debugging of motion parameters, parameters such as Kp, Ki, and Kd can be changed through the host computer software without rewriting the program, which is quick and convenient. 5 Software design The program structure of the intelligent car control system is shown in Figure 5. It is a two-layer hierarchical control system. The underlying control system includes a "steering control system" and a "vehicle speed control system." The upper-level main control program schedules the entire control system by changing the setpoints, control parameters, and constraints of the underlying control system. This hierarchical control system design references the structural characteristics of a Distributed Control System (DCS). Each part of the program has a clearly defined function and structure, facilitating debugging and maintenance. For easier debugging, the main control program incorporates the MODBUS communication protocol based on a wireless channel, greatly simplifying the monitoring and adjustment of the intelligent vehicle's driving parameters. The software implements the following functions: ① Initialization. ② Data acquisition and filtering. To minimize the introduced pure time delay, this paper proposes a unique and innovative video signal acquisition method: directly reading the binarized video signal using the SPI port provided by the MC9S12DG128 microcontroller. The competition rules specify that the width of the black guide line on the track is 2.5 cm; therefore, the width of the guide line captured 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. Then, the width of the acquired guide line is controlled in the filtering program; if it exceeds the normal range, it is considered invalid data. Experiments have shown that this method can effectively filter out interference. ③ Road Recognition. The core of the intelligent vehicle layered control system is track recognition. Actual testing revealed that due to the small field of view of the CMOS camera and its trapezoidal field of view, the track often partially or completely disappears from the field of view during rapid movement, making track recognition very difficult. Therefore, complete track pattern recognition is almost impossible. To simplify the problem, this solution only recognizes straight segments in the track, dividing the track into different regions based on the number and length of the straight segments, and optimizing the control parameters within each region. ④ Motor Control. The microcontroller receives the number of pulses generated by the rotation of the rear wheels of the intelligent vehicle from the rotary encoder and uses a recursive form of position-based PID control algorithm to quickly and accurately control the speed of the DC motor. The recursive form of the positional PID control algorithm is: Δ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) Where: u(k) is the output of the controller at time k; e(k) is the deviation at time k; Kp, Ki, and Kd are the proportional coefficient, integral constant, and derivative constant of the positional PID control algorithm, respectively. ⑤ Servo control. The microcontroller uses the path information detected by the CMOS camera and employs an incomplete differential PD control algorithm to control the steering angle of the servo motor to achieve path tracking. 6 Conclusion This paper introduces the design and implementation of an intelligent vehicle control system. Figure 5 shows a photograph of the completed intelligent vehicle. Extensive experimental testing has proven that the intelligent car can quickly and smoothly follow the black guide line on the constructed track, demonstrating excellent tracking performance, fast speed control response, good dynamic performance, small steady-state error, and strong system stability and anti-interference capabilities. It achieved second prize in the North China region of the 2008 National Undergraduate "Freescale Cup" Intelligent Car Competition, fully demonstrating the effectiveness and stability of the design scheme. References: [1] http://www.smartcar.org.cn [2] Zhuo Qing, Wang Jin, Wang Lei. Path parameter detection method based on area array CCD [J]. Electronic Products World. April 2006 [3] Huang Kaisheng, Jin Huamin, Jiang Dinan. Analysis of technical solution of intelligent model car in South Korea [J]. Electronic Products World. March 2006 [4] MC9S12DT128 Device User Guide [Z] 9S12DT128DGV2/D V02.15 2005 [5] Wang Jingqi, Chen Huiyan, Zheng Pei. Autonomous vehicle steering control using fuzzy adaptive PID and pre-aiming strategy [J]. Automotive Engineering. 25 (4). 2003 [6] Wang Zhizhong, Wang Rongben, Zhang Youkun, Li Bing. Identification and modeling of automatic guided vehicle steering system [J]. Transactions of the Chinese Society of Agricultural Engineering 15 (2). 1999 [7] Lai Shouhong. Microcomputer Control Technology [M]. Beijing: Machinery Industry Press, May 2000 [8] Chen Song, Li Liguo, Huang Kaisheng. A Brief Analysis of Intelligent Model Car Chassis [J]. Electronic Products World, June 2006
Read next

CATDOLL 128CM Sasha

Height: 128cm Weight: 19kg Shoulder Width: 30cm Bust/Waist/Hip: 57/52/63cm Oral Depth: 3-5cm Vaginal Depth: 3-15cm Anal...

Articles 2026-02-22