Design and Implementation of the Maze Patrolling with Three Branch Roads by the Smart Car Based on 51 Single Chip Microcomputer

With the rapid development of technology, the application of artificial intelligence technology in life is becoming more and more extensive, and intelligent robots play an important role in life. A smart car that can carry out the maze patrolling of three branch roads is designed. This smart car is mainly controlled by the STC89C52 chip and driven by the L298N chip. In this work, the ground information is firstly collected and transformed by the 4-channel TCRT5000 infrared reflection sensor module. Then, TCRT5000 infrared reflection sensor module converts the collected ground information into digital signals and transmits them to the main control chip. Finally, the recognition of the road and the control command such as go forward, turn left and turn right can be implemented through the main control chip. The power system of the smart car is composed of the L298N motor drive module and two DC motors. The main control chip controls the rotation speed and steering of the two DC motors separately, and uses the principle of differential steering to achieve left and right steering. The design uses sensor technology and uses C language for programming, so that the car automatically recognizes the three-way road. This design can be used in driverless vehicles and artificial intelligence related fields.


Introduction
With the rapid development of artificial intelligence and automatic control technology, intelligent robots have played an important role in our life. The patrol smart car is a wheeled robot with simple structure and function [1]. It has been applied suitably in some harsh working environments that human beings can't complete or inconvenience. At present, smart cars also have been applied in multiple fields such as intelligent fire-fighting robots for dangerous fire-fighting environments [2], unmanned delivery smart express cars for unmanned delivery [3], etc., which greatly improve the quality of life. In recent years, smart cars have attracted more and more attention, including tracking smart cars combined with infrared obstacle avoidance function, smart cars with voice recognition, automatic tracking, infrared obstacle avoidance function light-seeking and obstacle-avoiding smart cars that can detect and follow the light source, etc. [4].
There is a lack of research on how to identify complex paths with multiple three-way intersections in the smart car tracking function, which is not conducive to adapting the tracking smart car to the complex and harsh working environment. Moreover, current research related to smart cars has limitations in the field of automation and intelligence. The patrol smart car adopts a 4-way TCRT5000 infrared reflection sensor module as the road surface information detection sensor, in which the inner two-way sensor plays a role in the tracking, and in which the outer two-way sensor plays the role of judging the direction when identifying the three-way intersection. Through the four-channel sensor, the road condition can be recognized by the STC89C52 chip. After analyzing and processing, corresponding control commands are transformed to the L298N motor drive module.
Then, the smart car is driven by two-way DC motor to self-track. And then independently recognizes the three-way intersection and arrives along the correct path. Finally, the three-way maze patrol function is realized. In this paper, a smart car that can travel along the curve without a fork as well as automatically recognize and pass through multiple forks to realize the maze function is designed. It has significance for the application of intelligent car in the complex path of many intersections, as well as the development of intelligent car automation and intelligent direction.

Feature Design
The design diagram of the intelligent trolley track is shown in Figure 1. The track on the ground is designed by 6cm wide black tape. Firstly, the smart car is started at the starting point. Then, the information on the track is detected by the sensors. Finally, the smart car can reach the end point along the track independently. Among this process, human contact, wired or wireless control is not allowed.

Overall System Design
This patrol smart car is mainly composed of three modules, which are STC89C52 single-chip minimum system module, TCRT5000 infrared reflection sensor module and 1298N motor drive module. The system structure block diagram is shown in Figure 2.
When the patrol smart car is started at the beginning position, it will go along with the 6cm wide black track. The smart car is in the linear tracking mode at this time. According to the ground information, which is fed back by the TCRT5000 infrared reflection sensor module installed on the inside of the smart car, the STC89C52 chip sends corresponding control commands to the L298N motor drive module, and then control the left and right DC motors to perform corresponding linear tracking actions; As demonstrated in Figure 1, the smart car must correctly judge and pass the "T" and "L" type intersections, so as to reach the end point successfully. When travelling through the "T" and "L" type intersections, two channels of TCRT5000 infrared reflection sensor module installed outside the intelligent car head feedback signals to the main control chip. And then the STC89C52 chip outputs the control command to the L298N through the I/O port. The motor drive module L298N controls the left and right DC motors to complete left turn ninety degrees or right turn ninety degrees. Finally, the smart car smoothly passes through the three forks, goes out of the maze and reaches the end.

STC89C52 Single-chip Minimum System Module
In the process of hardware design of this patrol smart car, the STC89C52 microcontroller is a CMOS 8-bit ship produced by STC. The chip has the advantages of low power consumption, high performance and capable of the functions that the traditional 51 signal chip does not have [5]. The road information is collected by the 4-channel TCRT5000 infrared reflection sensor module, and which is entered from the P2.0, P2.1, P2.4, P2.5 port to this STC89C52 chip. Then the corresponding control commands are obtained from the P1.2, P1.3, P1.4, P1.5 port in this STC89C52 chip, which are used to control the L298N motor drive module. In turn, the left and right DC motors of the smart car are controlled to perform operations such as go forward, turn left, and turn right.

L298N Motor Drive Module
In this design, the patrol smart car uses two DC motors as the power supply unit, and the DC motor is driven by the L298N motor drive module. The main drive chip of this module is the L298N full-bridge driver chip of STC company, which produces high-voltage, high-current motor. It has the advantages of high response frequency, good stability, low heat generation and strong driving ability [6].
There are two outputs and six inputs in the L298N motor drive module [7]. As known, two DC motors are respectively connected to these two outputs in the L298N ship, and can be driven by the L298N ship at the same time. In addition, among the six outputs, where ENA and ENB are the enable terminals, which can be used to adjust the PWM waveform duty cycle, then the purpose of PWM speed regulation of the motor is

TCRT5000 Infrared Reflection Sensor Module
As an important device for inspecting the road information of the patrol smart car, the sensor plays an indispensable role that whether the correct path can be find by the smart car and this smart car can successfully reach the end point is due to the performance of the sensor. Thus, the 4-way TCRT5000 infrared reflection sensor module is used as a tracking module, which has four pins, VCC/GND/DO/A0. It can detect a reflection distance ranging from 1 to 25 mm. Among these four pins, the input voltage range of VCC/GND is 3.3-5V and the DO pin outputs digital switch 0 or 1. What's more, according to the ambient light intensity, the multi-turn adjustable precision potentiometer can be used to adjust the sensitivity of the sensor on the TCRT5000 infrared reflection sensor module, thus the performance stability of the smart car can be improved. Also the wide voltage LM393 comparator is used to output signal by this sensor, and this sensor has the advantages of strong driving capability, clean output signal and good waveform.
The method used by the TCRT5000 infrared reflection sensor module is the infrared detection method, which means the characteristics of different infrared light intensity reflected back from different color physical surfaces by the infrared [8]. There are two infrared diodes in the TCRT5000 infrared reflection sensor module, one of the infrared emissions emits infrared light continuously. When it encounters the track white road, the emitted infrared light is received by the infrared receiving diode after diffuse reflection, and when the intensity of the reflected infrared light is large enough, the infrared receiving tube is saturated, the output terminal DO of the TCRT5000 infrared reflection sensor module outputs a low level, and the switch indicating diode is illuminated. Conversely, when a black orbit is encountered, the infrared light emitted by the infrared emitting diode is absorbed, and the emitted infrared light is not reflected back or reflected back but the intensity is not large enough, so the infrared receiving tube is always in the off state. At this time, the module outputs a high level, and the switch indicates that the diode is always off. So the track black line is detected by using the performance characteristics of the TCRT5000 infrared reflection sensor module, the function of automatic following the black line and walking the maze is implemented finally.

Tracking State Analysis
The patrol line smart car tracking circuit uses 4 channels of TCRT5000 infrared reflection sensor module to collect the road condition [9]. As it's shown in Figure 3, four copper columns are actually fixed at the bottom of the front at a certain angle. When debugging, the angle and position of the four sensors can be properly adjusted to achieve the best detection effect, so that probability of deviating from the correct path can be reduced and the stability of smart car performance will be improved during the automatic inspection. The tracking status can be divided into five situations: forward, left turn, right turn, left turn 90 degrees, right turn 90 degrees. Turn left to ninety degrees, that is, when the left 1 and left 2 sensors detect the black line, the smart car executes the left turn command until the left 2 sensor detects the white road, and then executes the forward command. Turn right to ninety degrees, that is, when the right 1 and right 2 sensors detect the black line, the smart car executes the right turn command until the right 2 sensor detects the white road surface, and then executes the forward command. The MCU collects the track information through the sensor. After processing, it outputs the corresponding control signal, controls the two DC motors to perform corresponding actions under the use of the motor drive module [10]. The result is that the intelligent car can autonomously track, smoothly identify the three-way intersection, and reach the end point along the correct path. Table 1 shows the relationship between the 4-way TCRT5000 infrared reflection sensor module and the smart car tracking state, where "H" stands for the sensor output high level, and "L" stands for the output low level. When the output is low, the representative sensor detects a white road surface. When the output is high, a black road surface is detected.

System Software
After each software module is initialized, the system enters the tracking mode. The STC89C52 MCU continuously scans the I/O port connected to the 4-way TCRT5000 infrared reflection sensor module to obtain the logic level signal of the sensor output, and determines whether the sensor detects the black line. When the black line is detected, the MCU executes the corresponding processing program. Then it outputs a control signal, making the L298N motor drive module drive the left and right DC motors, so that the car moves along the black line which may requires the car to turn left, turn right, turn 90 degrees to the left, or turn 90 degrees to the right. On the contrary, the forward tracking action is executed, and the smart car can judge the intersection in the process of the three-way maze patrol correctly, without deviating from the operating state of the correct path. The system software flow chart is shown in Figure 4.

Conclusion
In this paper, a smart car that can independently identify and track the three-way intersection to go through the maze is presented. This car is consisted of a 5V DC power supply, a STC89C52 single-chip microcomputer, a L298N motor drive mode and 4 TCRT5000 infrared reflection sensor modules. The use of TCRT5000 infrared reflection sensor module shows stronger anti-interference ability and more steady performance when detecting the road information. Otherwise, the external ambient light effect is reduced to a certain extent, thereby improving the stability and the sensibility of the smart car. It turns out that the smart car can successfully patrol the three-way maze according to the design requirements. In addition, the smart car has the advantages of high running stability, low error probability and little effects on ambient light. All these abilities realize the expected functional design requirements.