Design of a microcontroller-based automatic line-following wheeled robot control system
2026-04-06 04:50:23··#1
1 Introduction Wheeled mobile robots are an important part of robot research. They integrate mechanics, electronics, detection technology, and intelligent control. Among various mobile mechanisms, wheeled mobile mechanisms are the most common. The reason why wheeled mobile mechanisms are widely used is mainly because their movement speed and direction are easy to control. Therefore, it is necessary to develop a complete wheeled robot system and conduct corresponding motion planning and control algorithm research. The author designed and developed an automatic line-following wheeled robot control system based on the AT89S52 microcontroller. 2 Overall Design of Control System The robot control system consists of a main control circuit module, a memory module, a photoelectric detection module, a motor and servo drive module, etc. The block diagram of the control system is shown in Figure 1. 3 Main Control Module Design 3.1 CPLD Design In the robot control system, it is necessary to control multiple motors and limit switches, and also to perform photoelectric detection. If all tasks are completed by the AT89S52 microcontroller, the CPU burden will be too heavy, affecting the system's processing speed. Therefore, one CPLD, model EPM7128, is added. It belongs to... The MAX7000 series devices include two general-purpose I/O ports and two dedicated I/O ports. The dedicated I/O ports can be used as high-speed control signals (clock, clear, and output enable, etc.) for each macrocell and input/output pin, and the PWM signal for the motor is also generated by them. The pin arrangement of the EPM7128 is shown in Figure 2. The outputs of the M1P-M4P pins are PWM pulse width modulation signals, the M1FB-M4FB pins are the motor direction control signals, P00-P07 connect to the microcontroller's PO port, 100-1015 are the two extended general-purpose I/O ports, S11-S17 pins are the limit switch input signals, and L11-L17 pins are the photodetector input signals. The CPLD is programmed using VHDL language. The source code for generating one PWM signal is as follows: [align=center] [/align] The microcontroller uses a 24MHz crystal oscillator. The frequency of the ALE signal, fALE=f16=6MHz, and the frequency of the pin MLP that ultimately outputs the PWM signal is: Adjusting the duty cycle of this signal can allow the DC motor to achieve speeds of 0-255 levels. 3.2 Expansion of the Robot Running Parameter Memory The robot's running path and actions can change according to different competition conditions. Therefore, each change in running parameters requires erasing and rewriting the microcontroller's Flash memory. To solve this problem, the program parameter memory was expanded to store the robot's running path and action parameters. The expansion circuit is shown in Figure 3. IC1 is a 24LC08B, a serial E2PROM memory on the I2E bus, capable of storing up to 1KB of data. IC2 is a MAX3232 level converter, which has an internal power supply voltage converter that can convert the computer's voltage level to the standard TTL level, enabling data transmission between the computer and the microcontroller via the serial port, allowing the microcontroller to perform data storage operations on the 24/LC08B. When the microcontroller is running, it directly reads the robot's operating parameters from the 24LC08 to control the robot's operation. 4. Photoelectric Detection Module Design 4.1 Photoelectric Detection Process Design The photoelectric detection module is designed to enable the robot to detect the white guide line on the ground. The photoelectric detection circuit mainly includes a transmitting section and a receiving section, the principle of which is shown in Figure 4. The waveform modulation of the transmitting section uses a frequency modulation method. Because the response speed of the light-emitting diode is fast, its operating frequency can reach several MHz or tens of MHz, while the modulation frequency of the detection system is in the range of tens to hundreds of kHz, which meets the requirements. The light source driver is mainly responsible for amplifying the modulated waveform to sufficient power to drive the light source to emit light. The light source uses an infrared light-emitting diode, which has a high operating frequency and is suitable for emitting modulated light with a square wave waveform. The receiving section uses a photodiode to receive the modulated light and convert the optical signal into an electrical signal. This type of electrical signal is usually weak and requires filtering and amplification before processing. The modulation signal is amplified using AC amplification, which separates the modulated light signal from the background light signal, facilitating signal processing. The modulation signal processing section identifies the amplified signal to determine the characteristics of the object being detected. Therefore, the essence of this module is to separate the useful AC modulated light signal from the useless DC background light signal, thereby achieving anti-interference. 4.2 Photoelectric Probe The photoelectric probe is installed at the front of the robot chassis, with a total of 5 detection points. Theoretically, the more and denser the detection points, the higher the accuracy and reliability of the identification; however, the hardware overhead and software complexity also increase accordingly. This line-following system ensures detection accuracy and saves hardware costs. The modulated light emitted by the LED is reflected from the ground to the photodiode. The photocurrent generated by the photodiode changes linearly with the intensity of the reflected light. By detecting this change, it is possible to determine whether a detection point is above the white guide line, thus determining the relative position of the robot and the white guide line. 5. Motor Drive Module The robot's drive components mainly consist of motors and servo motors, both of which can be speed-regulated and controlled using PWM. The robot's motion state is controlled in real-time based on the feedback signal from the pulse encoder. The control principle of the DC servo motor is shown in Figure 5. Adjustment: The PWM signal can quickly adjust the servo motor's rotation angle, thereby achieving directional control of the robot. 6. Conclusion The automatic line-following wheeled robot control system based on the 5L microcontroller operates smoothly and reliably, with strong anti-interference capabilities. It not only meets the design requirements of the robot competition but also provides a good control platform for intelligent robots.