Share this

Robot Design and Implementation Based on Microcontroller and Sensors

2026-04-06 06:21:51 · · #1

Abstract: This design utilizes a microcontroller and various sensors to create an autonomous mobile robot . The microcontroller serves as the core of the system's detection and control, enabling intelligent control of the robot. A reflective infrared photoelectric sensor detects the guide line, allowing the robot to move autonomously along the track. A Hall effect integrated circuit measures the robot's travel distance by counting the number of wheel rotations. A proximity switch detects metal plates embedded in the track, emitting audible and visual signals for indication and displaying the real-time position of the metal plates from the starting point.

Keywords: microcontroller; robot; sensor

Abstract: This design finished a robot with many functions based on single chip microcomputer and many kinds of sensors. 89C51 is the core of the system, achieving the intelligent control of the robot. Reflected infrared photoelectric sensors can detect the leading line, to make the robot go alone the path all by itself. Using the chip named “Hall IC”, to measure the distance by counting the wheels that the robot has run. Another sensor named “approach switch” can detect metals that embed in the path, and give alarms both sound and light. the robot can show the direction of the metal, tell us how long it is away from the jumping-off point. Key Words: single chip microcomputer robot sensor

1. Introduction

Robotics technology integrates knowledge from many disciplines such as mechanics, electronics, sensors, computers, and artificial intelligence, and involves technologies in many cutting-edge fields today. Some developed countries have adopted robot-making competitions as a strategic means of innovative education. For example, Japan holds various types of robot-making competitions every year, such as the "NHK Cup University Robot Competition", the "All-Japan Robot Sumo Tournament", and the "Robot Soccer Tournament". Most of the participants are students. The aim is to cultivate students' hands-on ability, creativity, cooperation ability and enterprising spirit through the competition, while also popularizing knowledge of intelligent robots. [1]

Conducting robot-making activities is one of the best practices for cultivating college students' innovative spirit and practical abilities, especially for students majoring in mechatronics who want to conduct comprehensive knowledge training. This paper addresses the hot topic of path tracking in a guided-line environment. Based on the principles of microcontroller control and sensors, a robot was built through hardware circuit fabrication and software programming. The robot achieved path tracking and automatic deviation correction functions, and could detect metal and display distance in real time.

2. Functions the robot needs to perform

Select a smooth floor or wooden board, cover it with white paper, and draw arbitrary black lines on the paper (the lines should not intersect) to guide the robot's movement. Randomly bury several thin iron pieces (0.5–1.0 mm thick) along the black lines under the paper. As the robot walks along the path for one revolution, it detects the buried iron pieces, triggers an audible and visual alarm, and displays the distance of the iron pieces from the starting point.

3 Hardware Design Scheme

Overall structure of the robot

Figure 1 Overall structure of the robot

As shown in Figure 1, the robot uses a microprocessor as its core to receive external information from sensors, process it, and control the robot's operation.

System power supply section

Since the robot's motors , sensors, and system CPU all use +5V power, considering the electric vehicle's power, load weight, and frictional resistance, we use the electric vehicle's own dry battery pack, which has low power consumption, small size, light weight, and is relatively easy to install.

Motor drive and PWM speed control section

The robot needs to be controlled to travel at a suitable speed. If the speed is too high, the robot is prone to deviating from the track due to the response and processing time of the microcontroller to the signals from the various sensors. The robot's speed is controlled by the rotational speed of the DC motor on the rear wheels. Changing the DC motor speed is usually achieved by adjusting the voltage or magnetism. Among these methods, voltage adjustment is simple in principle and easy to implement.

An H-type PWM modulation circuit composed of transistors is used. Through the PWM modulation circuit shown in Figure 2, a microcontroller controls the transistors to operate in an adjustable duty cycle state, thereby achieving speed regulation.

Figure 2 Motor drive circuit

When the P1.7 port of the microcontroller is set to low level and the P1.6 port is set to high level, Q1 and Q4 are turned on and Q2 and Q3 are turned off, and the motor works normally. By changing the high level period of the P1.6 port, that is, changing the duty cycle of the PWM modulation pulse, precise speed regulation can be achieved. The pulse frequency affects the motor speed. A high pulse frequency has good continuity, but poor load-carrying capacity; a low pulse frequency has the opposite effect [2]. Experiments have shown that when the pulse frequency is above 30Hz, the motor rotates smoothly, but when the car is moving, the motor speed drops quickly due to friction, and may even stop; when the pulse frequency is below 10Hz, the motor rotation has a jumping phenomenon. Experiments have shown that the pulse frequency of 25 to 35Hz is the best. We selected a pulse frequency of 30Hz.

Guide wire detection module

Based on the different reflectivity of white paper and black lines, a photoelectric detection circuit with a photoelectric sensor at its core distinguishes the two colors of the road surface, converting them into different voltage levels. This voltage level signal is then sent to a microcontroller, which controls the steering motor to steer accordingly, ensuring the car travels along the guide line. Considering the relative position of the car and the road surface, a reflective photoelectric detection circuit is used.

The TCRT1000 infrared photoelectric sensor is a device that uses photoelectronic scanning, photodiode emission, and transistor reception and output. Its features include small size, ease of use, high signal output, and minimal temperature-dependent operation. Its external circuitry is simple (as shown in Figure 3). The collector (C) terminal of the diode and the emitter (E) terminal of the transistor are grounded. The collector (A) terminal of the diode is connected to the power supply through a resistor, forming a bias current circuit. The collector (C) terminal of the transistor is also connected to the power supply through a resistor, forming the output circuit. When the detector detects white, it outputs a low level; when it detects black, it outputs a high level.

To improve detection accuracy, multi-sensor information fusion technology was employed. In the design, three photoelectric sensors were evenly distributed at the front of the vehicle, with the middle one (Q1) mounted in the exact center. The output of Q1 was connected to a single-chip microcontroller via a comparator and a NOT gate.

Figure 3 Photoelectric detection and conversion circuit

A sensor is arranged on both the left and right ends of the P1.3 pin and Q1 of the machine. After passing through the same circuit as in Figure 3, it is also connected to the P1 port of the microcontroller. If a black line is detected by one of the sensors on both sides, it indicates that the car is leaving the track. The results of the three detection points are fused and used as the input of the microcontroller. The robot makes judgments and adjustments according to the information of the P1 port of the microcontroller to achieve path tracking and automatic correction [3].

Metal detection section

Figure 4 Metal detection circuit

As shown in Figure 4, the metal detector uses a proximity switch with an effective detection distance of approximately 4 mm. It is fixed to the robot. When a metal piece is detected, the detector outputs a low level, which, after being inverted, is connected to an LED and a buzzer to emit an audible and visual indication signal. Simultaneously, the inverted output is connected to a microcontroller to count the number of detected metal pieces.

Hall element ranging design

The Hall integrated chip consists of three Hall metal plates. When the magnet is facing the metal plate, the metal plate conducts laterally according to the Hall effect [4]. Therefore, the magnetic plate can be installed on the wheel, while the Hall integrated chip is installed on a fixed shaft, and the distance is measured by counting the pulses. For each rotation of the rear wheel of the car, the pulse generated by the Hall element is sent to the T0 port of the microcontroller for counting, and the microcontroller completes the conversion of the pulse count to the distance. A magnetic pole is installed on the rear wheel, and the measurement error is the circumference of one wheel, which can be compensated in the software.

LCD display

Liquid crystal displays (LCDs) are increasingly widely used in pocket-sized instruments and low-power applications due to their advantages such as low power consumption, small size, rich display content, and ultra-thin and lightweight design. This paper uses a DM-162 LCD module with 2 lines of 16 characters each, connected to a microcontroller and programmed to complete the display function.

4 System Software Flow

The system software flowchart is shown in Figure 5.

Figure 5 System software flowchart

5. Conclusion

This paper, based on the principles of microcontrollers and sensors, uses a microcontroller as the core of the controller, a small DC motor as the driving element, and various types of sensors. Through software programming, a low-cost, modular small robot was created. Extensive walking experiments demonstrate that the robot can successfully track paths, automatically correct deviations, and walk autonomously, while also performing detection and display functions.

The innovation of this paper lies in its focus on the hot topic of path tracking in guided environments. By employing multi-sensor information fusion technology and controlling the robot with a microcontroller, the paper achieves path tracking and automatic correction functions. The method is simple, easy to implement, inexpensive, and effective.

References

[1] Han Jianhai, Zhao Shushang, Zhang Guoyue, et al. Construction of a hexapod robot based on PIC microcontroller. Robotics Technology and Application, 2003, 06

[2] Jiang Changzhang, Yu Wanyuan, Wang Donglei. Design of PWM speed control system for DC motor based on AVR microcontroller. Instrumentation User, 2006, 02

[3] Xue Yanru, Zheng Bing, Hao Xingzhen, et al. Robot navigation system based on fuzzy control information fusion method. Microcomputer Information, 2005, No. 11-2

[4] Zhang Shouan. Application of Hall effect in position control. Journal of Changsha Railway Institute (Social Sciences Edition), 2005, 02

Read next

Precautions for the installation and maintenance of programmable logic controllers

Programmable Logic Controllers (PLCs) are a new type of general-purpose automation control device that integrates tradit...

Articles 2026-02-22