Share this

Application of 16-bit microcontroller in intelligent vehicle control system

2026-04-06 03:31:27 · · #1

1 Introduction

The Freescale Cup Intelligent Car Competition, held nationwide by Chinese university students since 2006, integrates scientific rigor, fun, and entertainment. It's a science and technology innovation competition against the backdrop of the rapidly developing and promising field of automotive electronics, encompassing multiple disciplines including automatic control, pattern recognition, sensor technology, electronics , electrical engineering, computer science, mechanical engineering, and automotive engineering. Participating teams build an intelligent car based on a model car platform, capable of autonomously recognizing routes and automatically navigating a specially designed track.

The intelligent car described in this article was designed and manufactured 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. Additionally, a rotary encoder is installed on the rear wheel to collect pulse signals of wheel speed. The microcontroller uses a PID control algorithm to process the control input, which then changes the duty cycle of the PWM wave in the motor drive module, thereby controlling the car's speed.

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 intelligent vehicles, 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, while the transfer function of the speed control object is approximately a first-order inertial plus pure time delay. The steering control system mainly requires fast response speed and does not have high requirements for steady-state control accuracy. Moreover, the controlled object only has integral and time delay elements, without the common inertial elements. Based on these characteristics, a PD controller is used for steering control.

The significance of speed detection and control lies in ensuring the intelligent vehicle travels at the maximum speed permitted by road conditions. On curves, the speed should be limited to the maximum speed to prevent derailment, while on straightaways, appropriate rapid acceleration should be employed to shorten lap times and improve race performance. Simultaneously, integrating and summing the speed signals yields track length information, providing data for the road recognition and memory modules. The precision of the intelligent vehicle's speed control system does not need to be extremely high; the key is how quickly it responds to changes in track conditions. Therefore, a PID controller is used for speed control. This allows for rapid and accurate speed adjustments based on different road conditions, achieving stable cornering. The intelligent vehicle's hardware circuitry mainly consists of a video processing module, a direction control module, and a speed control module.

3-module function

(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 is converted into the lateral movement of the steering lever of the car model, thereby driving the rotation of the front wheels of the car model and controlling the driving direction of the intelligent car. 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 mainly consists of a DC motor, a drive circuit, and a rotary encoder. Based on the path information detected by the CMOS camera, the current track condition of the intelligent vehicle is determined, 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.

4 Circuit Design

(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 required 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 large when the motor starts and during 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 provide 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 the stable operation of the system under various conditions.

(2) DC Motor Drive Module Design. The DC motor drive uses Freescale's 5A integrated H-bridge chip MC33886. The MC33886 chip integrates control logic, charge pump, gate drive circuit, and low on-resistance MOSFET output circuit, making it 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, regenerative braking, and reverse braking of the motor can be easily achieved.

With the 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 state, the motor is in regenerative braking mode.

This design uses two MC33886 chips connected in parallel. On the one hand, this reduces the impact of the on-resistance on the characteristics of the DC motor, and on the other hand, it reduces the impact of the overcurrent protection circuit inside the MC33886 on the motor's starting and braking.

(3) Sensor circuit design. The intelligent vehicle 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 vehicle is equipped with a wireless data transmission module based on the nRF403 RF transceiver chip, and the MODBUS communication protocol is implemented on this basis. This is very helpful in testing the intelligent vehicle's parameters and debugging the program. During operation, various parameters of the intelligent vehicle can be sent up in real time, allowing for more targeted improvements to the control program by analyzing the vehicle's operating status. During the debugging of motion parameters, parameters such as Kp, Ki, and Kd can be changed via the host computer software without rewriting the program, making it quick and convenient.

5. Software Design

The program structure of the intelligent vehicle control system is shown in Figure 5. This is a two-layer hierarchical control system. The lower-level 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 lower-level 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 lag time, 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, and 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 show that this method can effectively filter out interference.

③ Road Recognition. The core of the intelligent vehicle hierarchical control system is track recognition. Actual testing revealed that due to the relatively small field of view of CMOS cameras and their trapezoidal shape, sections or even the entire track often disappear from the field of view during rapid movement, posing significant challenges to track recognition. Therefore, complete track pattern recognition is virtually impossible. To simplify the problem, this solution only recognizes straight segments of the track, dividing the track into different regions based on the number and length of these segments, and optimizing 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 differential constant of the positional PID control algorithm, respectively [7].

⑤ Servo control. The microcontroller uses the path information detected by the CMOS camera and employs an incomplete differential PD control algorithm to control the rotation angle of the servo motor, thereby achieving path tracking.

6 Conclusion

This paper introduces the design and implementation of an intelligent vehicle control system. Extensive experimental testing demonstrates that the intelligent vehicle can quickly and smoothly track the black guide line on a constructed track, exhibiting 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 Vehicle Competition, fully demonstrating the effectiveness and stability of the design scheme.

Read next

CATDOLL 138CM Jing TPE (Customer Photos)

Height: 138cm Weight: 26kg Shoulder Width: 30cm Bust/Waist/Hip: 65/61/76cm Oral Depth: 3-5cm Vaginal Depth: 3-15cm Anal...

Articles 2026-02-22