What is Line Follower Robot?
It is a machine that follows a
line, either a black line on white surface or vice-versa. For Beginners it is
usually their first robot to play with. In this tutorial, we will teach you to
make the line follower robot move on the line with a type of feedback
mechanism.
Materials Required:
The main electronics/mechanical
components that will be used in making this line follower robot are
· 1.Two sensors made using LDR,
· 2.Motor driver circuit
· 3.Acrylic sheet
· 4.General purpose board
· 5.Two DC motors
· 6.Battery.
Lets start making it:
Step 1:
Chassis
It’s basically the frame of the robot on which motors and wheels are mounted and all the circuitry part is also placed on it.
For base, we will be using Acrylic sheet of square
dimension and thickness of 4mm for our chassis, it can be easily available at
any picture frame shop.
Acrylic sheet
Drive Mechanism
We will be using a three wheel differential drive using two motors and one caster wheel or an Omni directional wheel. The Direction and speed of the two motors can be controlled independently.
Motor, Motor clamp and tyre
Caster wheel
chassis Layout
Our first step would be drilling holes to fix caster and clamps for motors. Though i haven't done any drilling while making this line following robot, just pasted caster and motor clamps with the help of double sided tape!!. But if you are making it for any small college project or competition fix every thing properly with screws. Also solder a 2 pin connector to the motors pins.
Motors with connector
Now fix motors, caster and also attach wheels to the motors. As I said it is to made modular, attach a two pin connector to each motor.
Final chassis
Now the chassis is complete. Lets make its circuit!
Step 2:
Circuit
We will be using light sensors, particularly Light dependent Resistors (LDRs) to detect black line on white surface. The figure below will explain how to detect black line on white surface.
We will be using light sensors, particularly Light
dependent Resistors (LDRs) to detect black line on white surface. Readymade Sensor module is available so that it will be very much accurate than building
with our own components. To control the motor with output from the sensors
microcontroller is needed. For beginners 8051 board will be useful or else u
can also go with Arduino.
8051
MICROCONTROLLER
The 8051 basic microcontroller board
which can be powered by a 9 volts – 12 volts battery (the battery volts varies
the speed of the motor connected to the ports).The board placed must not be in
contact with any insulator (chassis board). Also when placed directly with
battery below the board short circuiting may happen causing the board to stop
working. Hence always be cautious while working with the board
PORTS
OF THE MICROCONTROLLER
There are four ports defined for the
microcontroller. The ports are port 0, 1, 2, 3….for the board we use the ports connected
are as follows
Port 0 and port 1: Sensor input.
Port 2: Motor.
Port 3: Switch
Knowing
the sensor:
The sensor we normally use is a Light
dependent Resistors (LDRs). It consists of an IR
emitter and a LDR receiver .the receiver may give only the output as digital
but the board may accept only analog input .Hence to convert to analog output
we use a convertor .but the convertor may be inbuilt in some other boards. Array
of sensor may be preferred since the distance between two sensors will be
always fixed as 2 cm.
Knowing
the header file:
The header file included in our program
is <reg51.h>.this header file may consist the definition of the ports.
Hence without including this file the ports usage may occur to be illegal. You
are supposed to use the definition of ports only after including the file.
How
to use the inputs:
The inputs from the sensor may be got
and stored in variables and then comparison may be done. The variables for
sensor may be defined using “”SBIT””. sbit is assigning a variable to a
particular bit.in normal line follower or grid follower white and black are
considered as 1’s and 0’s.
Hence
the program will always begin as follows
#include<reg51.h>
Sbit s1=P1^0
Sbit s2=P1^1
Void main
{
……
……
……
…..
}
PROCEEDING
FORWARD:
S1 and s2 used in the above program are
just variables and may vary. The inputs from the pin 0 and 1 of port 1 get
stored in the variables s1 and s2.
Consider that you have 2 sensor (line
follower).the following principle may be used to follow the line
||
||
O || O
||
If both the sensor are white (input s1 1
s2 1) ==go forward
If right sensor becomes black (inputs s1
1 s2 0) ==go right
If left sensor becomes black (inputs s1
0 s2 1) ==go left
If both the sensor senses black (inputs
s1 0 s2 0) == (input depends on your wish)
LEARN
TO FEED THE MOTOR:
To connect a single motor you need to
have two pin of a port (generally port 2).therefore you may connect 4 motors in
a single port. Let us now learn to feed the motor port
To make a motor run forward the positive
wire of the motor is given an input 1 and negative is given 0.
If the motor is connected to pins 0 and
1 of port 2, then the input to port 2 should be as follows
P2=0000 0010
The hexadecimal equivalent of the above
number will be 0X02.
The bot may be turned right if the right
motor stops (or move reverse in acute cases) and the left motor moves as usual.
The bot can be made to move left if the movement is vice versa.
The motor is feed as follows
P2=0x02.
P2 represents port 2.always in code “p”
must be in capital letter.
A
COMPLETE CODE USING 2 SENSOR:
#include<reg51.h>
Sbit s1=P0^0
Sbit s2=P0^1
Void main ()
{
While (1)
{
If ((s1==1) && (s2==1))
P2=0x0A;
If ((s1==0) && (s2==1))
P2=0x80;
If ((s1==1) && (s2==0))
P2=0x20;
Else
P2=0x80;
}
}
The code contains an infinite while loop, this
is to continue the process of taking the inputs. If the code do not contain the
infinite loop, only once the code is executed.
The accuracy of the bot increases with
increase in the number of sensor. If the code is done in the same way, with s1,
s2, s3, s4, the time for execution increases and hence the accuracy decreases,
the sensor input can be also taken in the form of hexadecimal values.
Now all the chassis and circuit part algorithm is
done lets combine them all!
Step 3:
Combining all
Fix the sensor part just in front caster,facing downwards. ensure that there is very less clearance between sensor covering and ground. See the picture below.
Sensor Placement
Now connect the battery to the circuit and also
plugin the motors in there respective connectors. For more information
regarding battery and there charging circuit see this tutorial. I am
using two 3.7V Li-ions cells in series for this robot.
Small cheap 9 V batteries will not be able to drive
this robot for more that 4-5 minutes.
Complete Robot
Adjust the threshold of LDR such that when sensor is on black surface voltage at base of transistor must be less than 0.5Volts. If motors are rotating is reverse direction just change the polarity of that motor. After all this you would be able to make a robot that moves like the one below!.
Watch this video for better understanding.
OR
Hope you liked this tutorial.
