Design and Application of a Simple Intelligent Robot
2026-04-06 02:05:42··#1
Abstract: This design uses the AT89C51 microcontroller as the core for the detection and control of an intelligent robot. Infrared photoelectric sensors are used to detect black lines and obstacles on the road surface, metal sensors are used to detect metal pieces under the road surface, photoelectric encoders are used for distance measurement, photoresistors are used to detect and determine the location of the garage, and PWM (Pulse-Width Modulation) technology is used to dynamically control the rotation direction and speed of the motor. Software programming is used to achieve precise control of the intelligent robot's movement, obstacle avoidance, and stopping, as well as the storage and display of detection data. Keywords: Intelligent robot; Sensor; Control; Modular design With the continuous development of microelectronics technology, the integration level of microprocessor chips is becoming increasingly higher. Microcontrollers can now integrate CPU, memory, timer/counter, parallel and serial interfaces, watchdog timer, preamplifier, and even A/D and D/A converters on a single chip. This makes it easy to combine computer technology with measurement and control technology to form so-called "intelligent measurement and control systems." This has spurred rapid development in robot technology, and now it is entirely possible to design and manufacture simple intelligent robots with certain special functions. 1. Design Concept and Overall Scheme 1.1 Design Concept of the Simple Intelligent Robot This robot can walk along a guide line in any area, automatically avoid obstacles, and walk along a light source when guided by it. Simultaneously, it can detect metal pieces buried underground, emit audible and visual indicators, and store and display the number of detected metal pieces and the distance from each piece to the starting line in real time. Finally, it can stop at a designated location and display the time of the entire operation. 1.2 Overall Design Scheme and Block Diagram This design uses the AT89C51 microcontroller as the core for detection and control. Infrared photoelectric sensors are used to detect black lines and obstacles on the road surface, metal sensors are used to detect metal pieces under the road surface, photoelectric encoders are used for distance measurement, photoresistors are used to detect and determine the garage location, and PWM technology is used to dynamically control the rotation direction and speed of the motor. Software programming is used to achieve precise control of the robot's movement, obstacle avoidance, and stopping, as well as the storage and display of detection data. Through optimized circuit combination, we maximize the use of all the resources of the 51 microcontroller. Port P0 is used for digital tube display, port P1 is used for PWM drive control of the motor, and ports P2 and P3 are used for sensor data acquisition and interrupt control. The advantages of this approach are obvious: it fully utilizes the internal resources of the microcontroller and reduces the overall design cost. The system diagram of this scheme is shown in Figure 1. 2. System Hardware Composition and Principle The hardware of this system consists of a microcontroller unit, sensor unit, power supply unit, audible and visual alarm unit, keyboard input unit, motor control unit, and display unit, as shown in Figure 2. 2.1 Microcontroller Unit This system uses the AT89C51 microcontroller as the central processing unit. Its main tasks are to scan the keyboard input signal to start the robot, continuously read the data collected by the sensors during the robot's movement, process the data, generate PWM pulses with different duty cycles according to different situations to control the motor, and simultaneously send the relevant data to the display unit for dynamic display and generate audible and visual alarm signals. Among them, port P0 is used for dynamic display of the digital tube, P1.0 to P1.5 control two motors, P1.6 and P1.7 are independent keyboard interfaces, port P2 connects to sensors, P3.2 connects to the photoelectric encoder for mileage counting, P3.7 connects to the audible and visual alarm unit, and P3.4, P3.5, and P3.6 connect to LEDs used to display the number of metal pieces. 2.2 Motor Control Unit This robot uses a dual-motor, dual-wheel drive car as its base. Its two motors independently control the left and right wheels, and the turning function is achieved by the different speeds of the two motors. It can also turn on the spot, which is easy to control. Traditional cars are driven by a power motor and a steering motor, and the turning angle is difficult to control, making them inconvenient to use. The motor control circuit uses an H-type drive circuit composed of high-power transistors BD139 and BD140. The microcontroller generates PWM pulses with different duty cycles to precisely adjust the motor speed. This circuit, operating in the saturation or cutoff state of the transistor, avoids transistor power consumption during linear amplification, maximizing efficiency. The H-type circuit ensures simple control of motor speed and direction. The speed and stability of the electronic switch fully meet the requirements. The entire drive circuit is a widely used motor drive technology. The circuit is shown in Figure 3. 2.3 Sensor Unit The entire robot uses a total of 9 sensors, distributed in different parts of the robot, working together to play different roles, as shown in Figure 4. The sensors in Figure 4 are described as follows: Sensor 1: A metal detection sensor placed directly in front of the robot, facing downwards, used to detect metal. Sensor 2: An ultrasonic sensor placed directly in front of the robot, facing forwards, used to detect obstacles. The ultrasonic waves originate from a 40 kHz square wave signal generated by a 555 timer and are emitted by the ultrasonic transmitter. The transmitter continuously emits signals; when it encounters an obstacle, the signal is reflected back, and the receiver receives the signal, sending it to the microcontroller for corresponding judgment and processing. Sensor 3: An infrared photoelectric sensor placed directly in front of the robot, facing downwards, used to detect stop lines. Infrared emitters emit signals that are reflected by different reflective media. The infrared receiver determines whether a signal is received. Sensors 4 and 5 are downward-facing infrared photoelectric sensors located below the robot's base, used to detect ground guide lines; their principle is the same as sensor 3. Sensors 6 and 7 are forward-facing photoresistive sensors located directly in front of the robot, used to locate light sources. When a light source shines in front of the robot, the photoresistance changes. The changes from the two sensors are compared and processed before being sent to the microcontroller, which generates a corresponding adjustment signal to guide the robot towards the direction of the light intensity. Sensor 8 is an outward-facing ultrasonic sensor located on both sides of the robot's rear, used for turning when the robot encounters obstacles, determining whether the robot has completely avoided the obstacle; its principle is the same as sensor 2. Sensor 9, located at the rear of the robot, is an optical encoder for mileage measurement. Utilizing the principle of a mouse, a self-made optical encoder is constructed using a small plastic wheel with a diameter of 2.6 cm. After polishing to a circumference of 8 cm, eight equally spaced holes are drilled into the wheel (as shown in Figure 5). This achieves a minimum distance measurement accuracy of 1 cm, sufficient for the requirements. Optical sensors are mounted on both sides, and the encoder is installed at the rear of the robot to synchronize with its movement. In practice, the distance between the self-made holes cannot be precisely equal, but measurements show that the encoder generates 50 pulses for every 50 cm traveled. Therefore, it is used as the reference unit for distance calculation. In the straight section, the distance between the center line of the track and the starting line can be calculated from the number of pulses generated by this circuit. Furthermore, to clearly and intuitively observe the working status of each sensor, a working indicator light is specifically designed for each sensor, displaying its real-time operating status. 2.4 Keyboard Input Unit The keyboard input unit uses an independent keyboard consisting of two keys: a start key and a display switching key. Pressing this key after the robot has completed its journey will display the total time taken. 2.5 Display Unit The display unit consists of two 7-segment LED displays. To reduce overall system power consumption, a microcontroller-based software decoder dynamically displays the distance from each metal piece to the starting point and the total time taken for the entire journey. 2.6 Audible and Visual Alarm Unit A 555 timer is used as the oscillator. A microcontroller triggers the oscillator to drive an electromagnetic buzzer as the sound indicator and a single LED as the light indicator, thus forming the audible and visual alarm unit. 2.7 Power Supply Unit This system uses two power supplies to separately power the motor and control circuit. The system control circuit uses a 5V output regulated by a 7805 timer, while the motor is powered by four AA batteries. 3. System Software Design The system's software program adopts a modular structure and is written in C language. The system mainly consists of modules such as initialization program, deviation adjustment program, deviation from light source adjustment program, audio-visual indication subroutine, sensor status reading program, display program, interrupt service routine for Timer 0, interrupt service routine for Timer 1, service routine for external interrupt 0, and parking handling. The main flow of the system is shown in Figure 6. 4. Conclusion This robot has achieved the expected results after multiple experiments on a pre-defined track, but its level of intelligence is still far from sufficient. With the continuous research and deepening of artificial intelligence and neural network technologies, the development prospects of intelligent robots will become increasingly broad.