In order for the robot to move on the right orbit, it is necessary to have a sensor, which is re-sponsible for distinguishing the guide line and the background color of the moving trajec
Trang 1Ho Chi Minh City University of Technology and Education
Faculty for High Quality Training Automation and Control Engineering Technology
Line Following Robot
La Gia Bao Hoang Duong Trinh Nguyen Anh Hao
J anuary 6th, 2021
Trang 21.1 Introducing of line following robot 1
1.2 Objective of Study 2
1.3 General operating principles 2
1.4 Application of line following robot 2
2 Hardware design and software design 4 2.1 Hardware design 4
2.1.1 Idea frame 4
2.1.2 Select electronic appliances 5
2.1.3 Cost estimation 10
2.1.4 Circuit Diagram 10
2.2 Software design 11
2.2.1 A algorithm idea 11
2.2.2 Working principle of Sensor 12
2.2.3 Working principle of Line following robot 12
2.2.4 Code 13
Trang 33.2 Running results and review 19
3.2.1 Running results 19 3.2.2 Review 19
4.1 Advantage 20 4.2 Disadvantage 20 4.3 Future work 20
Trang 4In this project, we develop the line following robot Module L298N is chosen as the main
controller.Arduino uno R3 is the brain which control the robot.We use Closed Loop control
and PID control for this project.Dynamic PID control algorithm has been proposed to improve
the navigation reliability of the wheeled mobile robot which uses differential drive locomotion
system The experimental results show that the dynamic PID algorithm can be performed
under the system real-time requirements
Trang 5List of Figures
2.1 Line following car 4
2.2 Arduino Uno R3 5
2.3 Module L298N 6
2.4 Sensor 7
2.5 Motor V1 8
2.6 Wheel 9
2.7 Li-po battery 9
2.8 Block diagram 11
2.9 Working principle of sensor 12
2.10 Working principle of line following robot 13
3.1 Our line following car 18
Trang 6List of Tables
2.1 Parameter of Arduino Uno R3 5
2.2 Parameter of module L298N 6
2.3 Parameter of sensor 7
2.4 Parameter of motor V1 8
2.5 Parameter of Wheel V1 8
2.6 Parameter of li-po battery 9
2.7 Details of Price of components 10
2.8 Table of Circuit Diagram 10
Trang 7Assignment of work
Member Private work Work in pairs Work together
Nguyen Quoc Vinh Write code Present, write report
Le Tran Vu Hoang Design in Solidworks
Trinh Nguyen Anh Hao Design PowerPoint
Hoang Duong Buying electronic appliance
Trang 8Chapter 1
Overview
1.1 Introducing of line following robot
Automation is a combination of many fields such as mechanics, control, information
tech-nology and mechatronics These fields come together into systems that automate and,
more-over, automate the entire manufacturing process Automation companies play an increasingly
important and essential role to meet economic development goals, especially in today’s
fast-moving work process It asks a highly qualified human resource to operate In the world
today, there are many types of robots: Large-scale such as: Machine arms in production lines,
automatic production systems In addition are robots capable of moving, doing dangerous
jobs to replace humans, robots to help the elderly, sales robots etc In this project I do the
line of detection robots, compared to the above robots Just a small, simple robot, but this
is the foundation for me to make air conditioners, more useful in the process of learning and
doing of me after this A line follower robot is basically a robot designed to follow a line or
path already pre determined by the user This line or path may be as simple as a physical black
straight line on the floor or complex line: circle, the round number eight,zigzag In order to
detect these lines, we use sensor system, it can be individual sensors connected together or
expansive vision systems with many sensors The choice of these schemes is the key to decide
the speed, the accuracy in line detection
Trang 91.2 Objective of Study
We looked up reference on the internet And they did complete this project better than us We
tried to do a robot must be capable of following a line:
• The robot must be capable of following a line
• It must be multitasking ,should be capable of taking various degrees of turns
• The robot must also be capable of following a line even if it has breaks
• It must allow calibration of the line’s darkness threshold
• The robot must be insensitive to environmental factors such as lighting and noise
1.3 General operating principles
The robot moves in a predetermined trajectory thanks to a guide, the two-wheel system is
driven by two DC electric motors through a control circuit and a power circuit Often the
guides will have a different color from the background color of the moving trajectory In
order for the robot to move on the right orbit, it is necessary to have a sensor, which is
re-sponsible for distinguishing the guide line and the background color of the moving trajectory
In order for the robot to move in the right trajectory, it is necessary to have a sensor, which
is responsible for distinguishing the guide line and the background color, bringing the
corre-sponding electrical signal to the control circuit The control circuit is responsible for receiving
feedback from the sensor, thereby controlling the speed and direction of rotation of two DC
electric motors so that the car always sticks and moves according to the guide.[1]
1.4 Application of line following robot
It is applied in technology detection lines such as automatic movement during transportation
From the industrial point of view, line following robot has been implemented in semi to fully
autonomous plants In this environment, these robots functions as materials carrier to deliver
products from one manufacturing point to another where rail, conveyor and gantry solutions
Trang 10are not possible Apart from line following capabilities, these robots should also have the
ca-pability to navigate junctions and decide on which junction to turn and which junction ignore
This would require the robot to have 90 degree turn and also junction counting capabilities
To add on to the complexity of the problem, sensor positioning also plays a role in optimizing
the robots performance for the tasks mentioned earlier Line-following robots with pick-
and-placement capabilities are commonly used in manufacturing plants These move on a
speci-fied path to pick the components from specispeci-fied locations and place them on desired locations
The control principle is still inertia, but the robot path is detected
Trang 11Chapter 2
Hardware design and software design
2.1 Hardware design
2.1.1 Idea frame
In this project, we had a lot of ideas such as buying frame or designing a new frame Then
we decided to make a new frame We used Solidworks to do that The first, we thought about
using screw to connect electronic appliances but it took a lot of time So we decided use glue
to connect them Because it’s very convenient and simple We have referenced but we used
module L298N and Arduino Uno R3 so we can’t stack it We designed a long frame to put
on electronic appliances During the process, we had a problem We forgot about position of
the sensor To repair it, we used Solidworks to design two plates mica And then, we used
glue to connect sensor with frame Because we used a long frame so two wheels were not
unbalanced, so we used multi-purpose wheel to balance
Figure 2.1: Line following car
Trang 122.1.2 Select electronic appliances
Arduino
Nowadays, we have many Arduino such as Arduino Mega R3, Arduino nano V3, Arduino
Leonardo, but in this project we choose Arduino Uno R3.Uno is a great option It has
many feature which we need for this project
Table 2.1: Parameter of Arduino Uno R3
Flash memory 32KB (ATmega328) with 0,5kb used by the bootloader
This is a picture which we used Solidworks to draw model Arduino Uno R3
Figure 2.2: Arduino Uno R3
Trang 13Module L298N
Module L298N can control 2 DC motors or 1 stepper motor Because we used two wheels so
we need 4 holes located at 4 corners and L298N provided it for us It is very convenient for
us And we know there is an anti-heat heatsink for the IC, helping the IC to control the peak
current of 2A The L298N IC is attached to the on-board diodes to help protect the
micropro-cessor against the induced currents from starting or turning off the engine It is very useful
Table 2.2: Parameter of module L298N
Driver L298N integration of two H-bridge circuits
Power dissipation 20W (when temperature T = 75 ° C)
This is a picture which we used Solidworks to draw model L298N
Figure 2.3: Module L298N
Trang 14We decided used 5 sensors We began with TCRT5000 but it is difficult because one TCRT5000
has one sensor Then we used The 5-leds bar line detector It is very convenient It is designed
to detect black and white lines On the sensor bar there are 5 infrared sensors pointing to the
ground to detect the line
Table 2.3: Parameter of sensor
Sensor 5 line detection sensors
This is a picture which we used Solidworks to draw model sensor
Figure 2.4: Sensor
Trang 15We discussed between motor V1 and motor GA25 12V620RPM Motor GA25 12V620RPM
make from metal so it is better than motor V1 but it is more expensive than motor V1 We
reference on the internet and motor V1 is not bad It is very suitable for this project So we
decided to use motor V1 because this line following car is simple
Table 2.4: Parameter of motor V1
Electrical current consumption 110 ∼140mA
This is a picture which we used Solidworks to draw model Motor
Figure 2.5: Motor V1
Wheel
In this project, we used 2 types: wheel V1 and multi-purpose wheel Because our design
needs from 3 wheels to 4 wheels to balance so we used 3 wheels If we used 4 wheels V1, it
would be difficult to code Using 3 wheels is easy It is the same as 2 wheels
Table 2.5: Parameter of Wheel V1 Diameter of wheel 66mm
Trang 16These are two picture which we used Solidworks to draw model wheel
Figure 2.6: Wheel
Battery
According assistant Mr Cuong, Li – po battery ( lithium polymer battery ) is very good They
are light weight and have improved safety It can refresh so we just buy one time We used 2
batteries for this project
Table 2.6: Parameter of li-po battery
Trang 172.1.3 Cost estimation
The details of price of components used in project is given below
Table 2.7: Details of Price of components
We reference on the internet and then we assembled electronic appliances completely This is
our circuit diagram
Table 2.8: Table of Circuit Diagram
Trang 182.2 Software design
2.2.1 A algorithm idea
When the vehicle is operating, the sensor will collect information and convert it into an
elec-trical signal to the microcontroller The received value will be compared with the preset value
Based on the value of the sensor sent, determine the relative deviation between the orbit of the
robot and the desired trajectory, then compare that deviation into levels Based on the
devia-tion levels, adjust the speed of the left and right wheels to return the robot to the fund religion
Specifically, to turn left the robot’s right wheel speed is one value faster than the left one
correspond to the deviation levels (need to test many times), and vice versa This method is
simple, but the robot runs unstable, sometimes very fast, sometimes slowly, Stability is highly
dependent on the robot’s motor and mechanical construction To overcome this drawback, by
applying a position controller PID mind robot
Figure 2.8: Block diagram
Trang 192.2.2 Working principle of Sensor
One sensor head will emit infrared rays If there are no obstacles, the infrared will continue
The other end is the receiver that won’t get anything, it will return -1 In the case of an
obstacle, the infrared rays are reflected back, the receiver will obtain and return the value
0 In the case of a dark surface, the infrared rays will absorb all the returned infrared rays
enough so the receiver returns 1
Figure 2.9: Working principle of sensor
2.2.3 Working principle of Line following robot
If line is centered in front of robot, line following robot goes forward When the center sensor
is high and the remaining sensor is low the center sensor is will always be on the line and as
line is black in color
If line is right of center, the robot turns right When the right sensor is high, the remaining
sensor is low and the center sensor is will always be on the line and as line is black in color
If no line is detected, circle unit is found
Trang 20If line is left of center, beside of the robot, it turns left When the left sensor is high and the
remaining sensor is low the center sensor is will always be on the line and as line is black in
Trang 21#define ENB 11
void read_sensor_values(void); // doc gia tri cam bien
void calculate_pid(void); // tinh PID
void motor_control(void); // kiem soat dong co
void dung();
void chay_thang();
void setup()
{
pinMode (ENA, OUTPUT);
pinMode (ENB, OUTPUT);
pinMode (In1, OUTPUT);
pinMode (In2, OUTPUT);
pinMode (In3, OUTPUT);
pinMode (In4, OUTPUT);
Trang 22if (( sensor[1] == 0) && (sensor[2] == 0)
&& (sensor[3] == 0) && (sensor[4] == 0) && (sensor[5] == 1)) // trai
error = -4;
else if (( sensor[1] == 0) && (sensor[2] == 0)
&& (sensor[3] == 0) &&
(sensor[4] == 1) && (sensor[5] == 1))
error = -3;
else if (( sensor[1] == 0) && (sensor[2] == 0) && (sensor[3] == 1)
&& (sensor[4] == 1)
&& (sensor[5] == 1))
Trang 23&& (sensor[4] == 1) && (sensor[5] == 0))
error = -1;
else if (( sensor[1] == 0) && (sensor[2] == 0) && (sensor[3] == 1) &&
(sensor[4] == 0) && (sensor[5] == 0)) // giua line
error = 0;
else if (( sensor[1] == 0) && (sensor[2] == 1)
&& (sensor[3] == 1) && (sensor[4] == 0)
&& (sensor[5] == 0)) error = 1;
else if (( sensor[1] == 1) && (sensor[2] == 1)
&& (sensor[3] == 1) && (sensor[4] == 0) && (sensor[5] == 0))
error = 2;
else if (( sensor[1] == 1) && (sensor[2] == 1)
&& (sensor[3] == 0) && (sensor[4] == 0) && (sensor[5] == 0))
error = 3;
else if (( sensor[1] == 1) && (sensor[2] == 0)
&& (sensor[3] == 0) && (sensor[4] == 0) && (sensor[5] == 0))
I = I + error; // sai so truoc do cong sai so hien tai
D = error - previous_error; // sai so hien tai tru sai so truoc do
PID_value = (Kp * P) + (Ki * I) + (Kd * D);
previous_error = error;
Trang 24PID_phai = gia_tri_ban_dau + PID_value;
PID_trai = gia_tri_ban_dau - PID_value;
PID_phai = constrain(gia_tri_ban_dau - PID_value, 0, 170);
PID_trai = constrain(gia_tri_ban_dau + PID_value, 0, 170);
analogWrite(ENA, PID_phai);
analogWrite(ENB, PID_trai);
}
Trang 25Chapter 3
Results
Although there are many controversies and disagreements, we did completely this project
Robot completed on schedule Rugged and safe hardware during heavy travel The circuit
inspection part still had errors, but was promptly corrected During the project, we had 2
trou-bles Firstly,when finished assembling the parts together and loading the code The car was
on, but the wheels were not working Secondly, Vehicle was not stable, has much fluctuation
But we fixed it The idea of making a hybrid robot car was inspired by the team from F1
racing And we did it complete Many groups in class buy frame in the store but we designed
it We can control speed by using code
Figure 3.1: Our line following car