Mechanical Engineer
Line Following Robot
One of the projects for ME 401 (Mechatronics) was to create a line following robot that could follow contrasting lines on the ground. The robot would be tested against others on a test track with consisting of various curved and straight sections , missing segments of line, and a "T" that the robot must stop at. The robot was judged on stability, smoothness, and speed in following the line, requiring tight integration of the robot's mechanical, electrical, and computer control systems.
In order to allow the robot to "see" the contrasting line an array of optical sensors were used. Each of these sensors included an infrared emitter that shines IR light onto the surface below the sensor and a phototransistor that senses the reflected IR light. An array of 8 optical sensors, along with a weighted algorithm, was used to determine the deviation of the robot from the contrasting line based on which color each sensor reads.
In order to use the data from the optical sensors to keep the robot centered along the line a PID feedback loop was used. In order to reduce tuning time of the Kp, Ki, and Kd constants potentiometers were added to the robot along with an LCD display to allow the PID constants to be adjusted via turn knobs. This allowed for "on the fly" tuning for different line types.
The robot was also required to intelligently find the rest of the line when a small gap in the track was found. Once detecting the gap in the line the robot entered a searching protocol in which it will first turn slightly right, then drive forward a set distance and read the optical sensors to check for a black line. If one of the optical sensors reads black the searching loop is broken and the robot resumes standard PID controlled line following, but if not, the robot will back up to its starting position, turns slightly left then drive forward and check again. The robot stays in this loop until a black line is detected. As the robot moves into unexpected spaces during the searching protocol a piezoelectric buzzer was set to beep rapidly while searching to alert people in the surrounding area to stay clear as the robot does not know where the black line is and will be making irregular movements.
In order to ensure that all electrical and mechanical systems integrated seamlessly, the majority of the mechanical components were custom fabricated. Four DC motors with integrated gearboxes were selected to power the robot drivetrain. The motors were configured in a tank drive configuration in which each motor was directly connected to a wheel and turning was simply performed by increasing the speed on one side of the drivetrain with respect to the other. A tank drive drivetrain was chosen over a traditional Ackermann steering linkage as it is much simpler, requiring fewer parts, and it allows for zero radius turns when quick changes of direction are required.
The chassis of the robot was laser cut from 3mm thick clear polycarbonate plastic, the chassis supports the motors, battery pack, optical sensor array, motor controller, and the body panels. The chassis was designed to allow for the optical sensor array to be mounted on plastic standoffs at the front of the chassis so the robot can read the section of line immediately in front of it.
The body panels were constructed of the same polycarbonate as the chassis and were designed to support an LCD display, Arduino microcontroller, and potentiometer knobs while still allowing access to the Arduino’s USB port for uploading programs. To ensure all manufactured parts would assemble as desired a 3D CAD model of the line follower robot was used to design the parts.To make the robot design more attractive, robot arms, head, neck, and back panel replicating the Wall-E character from the self-titled Pixar animated film were modeled and 3D printed from PLA.
Choosing electrical components to complement the mechanical design was critical to ensure the robot functions as designed. The primary electronic component used was an Arduino Uno Rev3 microcontroller board. The microcontroller allowed for the implementation of the complex control logic needed for the robot to follow the line. In order to drive the 4 DC motors powering the robot’s drivetrain an L298N motor controller was used. The L298N used allowed for the speed and direction control of 2 sets of 2 motors using dual H-bridges.Lastly, an 8 sensor optical sensor array was selected to provide enough data for smooth line tracking. The array used eight TCRT5000 optical sensors and utilizes I2C protocol, allowing the data collected by the eight sensors to be transferred to the microcontroller using just 2 analog pins as opposed to one pin per sensor. With 8 optical sensors a total of 15 unique deviations could be detected by the robot.
With proper tuning of the PD loop performed the line follower was able to track the line at the maximum base pulse width/motor speed of 255 while still exhibiting smooth control without oscillations. The robot displayed a balance of both speed and smoothness while being extremely reliable. When faced with two gaps in the black line, the robot was able to consistently find the continuation of the line and the robot was able to recognize and stop at the “T” shaped stop line. The robot was able to complete the track in a mere 15.47 seconds, the fastest of all robots in the competition running similar voltages to the DC motors, and the overall fourth fastest among the 14 robots that participated in the event (70th percentile). These results were repeatable as in the 3 allowed runs in the competition, the line follower successfully completed each of the three runs in similar fashion.
** Note: full code is included in PDF linked below **
.png)
.png)
.png)

.png)
.png)
.png)
.png)
.png)



