You are on page 1of 33

Line

Follower
Robot
Robotics Workshop
Currents 15
th
march 2008
EEE Department
NIT Trichy
Developed By:
Mayur Agarwal
Prashant Agrawal
Krishna Nand Gupta
Hitesh Meghani
To Our Readers

We are glad to have had an opportunity to share our knowledge with
interested robotics enthusiasts. In this book we have attempted to provide a brief
compilation of our experiences in robotics (participating and winning in Technical
Festivals all over the country), extending over last three years.
The prospect of practically implementing engineering concepts is the
hallmark of robotics. By reading the basics in this book you will gain a significant
insight into various tools employed in shaping a robot. However to participate in
technical festivals with ever changing problem statements you will be required to
apply these basics concepts and come up with innovative algorithms and superior
designs.
Do not expect this book to be a panacea for all robotic problems, rather
you will have to sit and work for hours to get a functioning robot. Transform each
failure into a stepping stone instead of stumbling over it. We appreciate the beauty
of diamond but little do we wonder how it became so bright? Its perseverance
extending thousands of years transformed it into its present sparkling state.
We encourage you to plunge further into the field of robotics with
dedicated perseverance, make your own mistakes and gain valuable experience
from them.
ALL THE BEST

Your valuable suggestions and inquisitive doubts are welcome. You can
contact us at

Mayur Agarwal (mayurmagic.nitt@gmail.com )
Krishna Nand Gupta (kng_sweet94@yahoo.com)
Prashant Agarwal (pras_nitt@yahoo.co.in )
Hitesh Meghani (h.nittian@gmail.com )

~ 1 ~

Introduction
The line follower is a self operating robot that detects and follows a line that is
drawn on the floor. The path consists of a black line on a white surface (or vice versa).
The control system used must sense a line and maneuver the robot to stay on course,
while constantly correcting the wrong moves using feedback mechanism, thus
forming a simple yet effective closed loop System. The robot is designed to follow
very tight curves.

Sample Paths
The path is a black line on a white background with width of 3 cm (except at
bends where a little variation may be present). It may contain paths laterally displaced
by around 3 cm and also gap of at most 5 cm. (All these specifications may vary from
one competition to another).

Figure1:BasicSampleArena

Figure2:SampleArenaofKurukshetra08(AnnaUniversity)

Figure3:SampleArenaofPragyan07(NITTrichy)

Figure4:SampleArenaofRoboRelayofKishitij08(IITKGP)

From above images we can conclude that in most of line follower competitions, some additional
taskhastobeperformedapartfromfollowingtheline.

R
o
b
o
t
i
c
s

W
o
r
k
s
h
o
p







N
I
T

T
r
i
c
h
y

Basic
The
consisting
and contr
tracking t
opto-coup
IR LED
of compa
input to
Microcon

Basic
The
1. C
F
is
2. S
th

BlockD
Lets see
design
robot is b
g of a toy
rolling wh
tape. Line
plers moun
and an
arator, LM3
o the mic
ntroller AT
operat
basic oper
Capture lin
For this a c
s used. The
Steer robot
his we use
Diagram
all the sys
and re
built usin
car chassi
heels. It h
position i
nted at the
IR Senso
324 is low
crocontrol
Tmega8L a
tion
rations of th
ne position
ombination
e line sensi
to track t
two motor
stem in det
quirem
g ATmeg
is (or hand
has infrared
is captured
front end
or). When
w, while fo
ler for a
and Motor d
he line foll
with optic
n of IR LE
ing proces
the line wi
rs that gov
ail.
~ 2 ~
ments
ga8L, L29
d made Al
d sensors
d with the
of the robo
n the sen
r white su
accurate c
driver L29
lower are a
cal sensors
ED and Pho
s requires h
ith a suitab
vern the mo
3D, IR se
luminum s
on the bo
help of th
ot. (Each o
nsors detec
rface the o
control a
93D are use
as follows:
s mounted
oto Transis
high resolu
ble steerin
otion of the

ensors, LM
sheet chass
ottom for
hese optica
opto-coupl
ct black
output is h
and steerin
ed to drive
:
d at front e
stor called
ution and h
ng mechani
e wheels on
M324, pla
sis), two m
detecting
al sensors
er consists
surface, o
high. It is s
ng of m
e the motor
end of the
an opto-co
high robust
ism. To ac
n either sid
atform
motors
black
called
s of an
output
sent as
motors.
rs.
robot.
oupler
tness.
chieve
de.

R
o
b
o
t
i
c
s

W
o
r
k
s
h
o
p







N
I
T

T
r
i
c
h
y

INPUT
Sensor
Eac
or photo d
If w
sensed by
hence rec


Photo dio
(from say
divider ci
T SYSTE
rs
ch opto-co
diode.
white surfa
y the receiv
ceiver does
ode has a p
y 150k
ircuit (as sh
EM
oupler has
ace is prese
ver, while
s not sense
property th
to 10k).
hown in fig
one emitte
ent beneath
in case of b
IR rays.
hat if IR lig
For sens
gure below
~ S ~
er (IR LED
h the IR LE
black surfa
ght falls on
ing the ch
w).
D) and one
ED, IR ray
ace, the lig
n it, its elec
hange in r
receiver (P
ys are reflec
ght gets abs
ctrical resis
resistance
Photo-Tran
cted and ar
sorbed and
stance dec
we use v
nsistor
re
d

reases
voltage
R
o
b
o
t
i
c
s

W
o
r
k
s
h
o
p







N
I
T

T
r
i
c
h
y

~ 4 ~


Sample Calculation:
Say Receiver has resistance-
Rs=150k without light (on black surface)
Rs=10k with light (on white surface)
The voltage that goes to comparator

Without light: (on black surface)
Vp=
Rs
Rs+R
- Icc =
150
150+10
*5 V=4.6875 V

With light: (on white surface)
Vp=
Rs
Rs+R
- Icc =
10
10+10
*5 V=2.500 V



Thus we get the variation in voltage, which is sensed by the comparator IC
(LM324). The comparator then, gives logical high or low according to input.
Comparator
Comparator is a device which compares two input voltages and gives
output as high or low. In a circuit diagram it is normally represented by a
triangle having-Inverting (negative) Input (-), Non-Inverting (positive)
Input(+), Vcc, Ground, Output.


Properties of comparator:

If V+ > V-
then Vo=Vcc
(Digital High 1 output)


If V+ < V-
then Vo=0
(Digital Low 0 output)



R
o
b
o
t
i
c
s

W
o
r
k
s
h
o
p







N
I
T

T
r
i
c
h
y

~ S ~

Lets see some examples










Use of comparator in IR sensor
As above we see that two inputs are required for comparator. One input is from
photo-receiver (like photo-diode), other is generated by us using potentiometer
(preset). The second voltage is also called as reference voltage for that sensor.

Setting of reference voltage (Vref)
We can vary reference voltage by using potentiometer, such that it can
vary from 0V to Vcc. We set the reference voltage as mean value of the sensor outputs
measured with and without light.
From above example Vref =
4.675+2.500
2
= 3.5875 V
Lets connect Inverting Input of Comparator to photo- receiver, Non-Inverting Input to
potentiometer (as shown in figure) and output to micro controller.


Sample Calculation:
Let V+ = 3.5875 V

With light :(on white surface)
V- = 0.9090 V
Thus V+>V- and Vo= Vcc = 5 V
Thus we get digital HIGH output.

Without light:(on black surface)
V- = 3.333 V
Thus V+<V- and Vo = 0 V
Thus we get digital LOW output.

R
o
b
o
t
i
c
s

W
o
r
k
s
h
o
p







N
I
T

T
r
i
c
h
y

Note: If w
Inverting
we get Lo

IC LM
IC

You can

Arran
An
the front
We
then the
sharp tu
smooth
program
sensors.
T
we connect
g Input to p
ow output a
M324
LM324 co
see the da
ngemen
n array of
t of the ro
e can use
e robot m
urns. If we
and rel
mming and

he distan
1. Numb
2. Width
3. Distan
logic).

t Inverting
photo- rece
and for bla
ontains fou
tasheet of
t of Sen
f sensors
bot. It is u
any num
movement
e use high
liable fo
d more ha
nce betwee
ber of sens
h of straig
nce betwe
.
Input of C
eiver, the o
ack surface
ur compara
IC LM324
nsors
arranged
used to lo
mber of sen
will not
her numbe
or sharp
ardware. T
en sensor
sors used
ht line
een sensor
~ 6 ~
Comparato
nly differe
e we get Hi
ators.
4 for more
in a stra
cate the p
nsors. If w
be smoo
er of sens
turns,
Thus we m
rs depend

rs may no
or to potent
ence observ
High output.
e details.
ight row
position of
we have le
oth and it
ors robot
however
must choo
ds on
ot be cons
tiometer (p
ved is that
.
pattern is
f line belo
esser num
t may fac
movemen
it requ
ose optim
stant (it d
preset) and
at white su

s bolted u
ow the rob
mber of se
ce problem
nt will be
uires com
mum numb
depends o
d Non-
urface
under
bot.
ensors
ms at
ecome
mplex
ber of
on the
R
o
b
o
t
i
c
s

W
o
r
k
s
h
o
p







N
I
T

T
r
i
c
h
y

Sample f

Tips f
figure:
for Inp
Signifi
connec
Set pr
differe
You ha
on rou
The ad
case w
ambien
To get
we gen
Proper
good v
the oth
If an o
across
photo d
Left
put Sys
cant prob
ctions use P
reset value
ntly and m
ave to adju
ughness of s
dvantage of
we use LDR
nt light.
t a good vo
nerally use
r orientatio
voltage swi
her opto-co
opto-coupl
IR LED i
diode for b
Figur
tem
blems are
PCB.
e for each
may give dif
ust preset
surface.
of IR senso
R as photo
oltage swi
e 10k ress
on of the I
ing. Also I
oupler.
ler is not
is 1.1-1.2
black and w
e 2: Align
~ 7 ~
faced in
h sensor,
fferent volt
value for
or is that it
o detector,
ing, the va
sistance.
IR LED an
IR rays of
working th
V, then ch
white surfa
ment of S
R
input syst
because e
tage on the
new surfa
t is less aff
its sensiti
alue of R1
nd Photo d
one opto-c
hen first c
eck the vo
aces, then s
ensor in a
Right
tem. So to
each sens
e same surf
ce, as refl
ffected by a
vity will h
must be c
diode is mu
coupler sh
check whet
oltage varia
set the refe

an opto-cou
o make re
sor may b
rface.
lectivity de
ambient lig
ighly depe
carefully ch
ust so as to
ould not d
ther the vo
ation acro
erence volt
upler
eliable
behave
epends
ght. In
end on
hosen,
o have
disturb
oltage
oss the
tage.
R
o
b
o
t
i
c
s

W
o
r
k
s
h
o
p







N
I
T

T
r
i
c
h
y

Volta
Voltage r
commonl
voltage is

They hel
input volt

If input v
may be 5
maximum

To identi
writing to
voltage re

age Re
regulators
ly used on
s in betwee
lp to main
tage variat
voltage is <
5V or 4.8V
m output cu
fy the lead
o your sid
egulator.(1
Fig a
Fig
cou
for
use
The
egulato
convert f
nes are 780
en 7.5V to
ntain a stea
tions.
<7.5 V then
V, but the
urrent capa
ds of the 78
de, (see th
1-input,2-g

b shows h
upling capa
it in norm
capacitor,
e mainly av
or 78x
fixed DC
05 and 78
20V.
ady voltag
n regulation
ere are som
ability, line
805, you h
he figure b
gnd,3-outp

how to use
acitors are
mal case. B
, otherwise
vailable 78
~ 8 ~
xx
output vo
12. 7805
ge level de
n won't be
me parame
e regulation
have to kee
below). Yo
put).

e 7805 volt
used for g
But if 7805
e the noise
8xx IC's are
oltage from
gives fixed
espite vary
proper i.e
eters for th
n etc.. , tha
ep the lead
ou can see
Fig b
tage regula
good regula
5 is used in
e in the ou
e 7805, 78
m variable
d 5V DC
ying curren
e. if input is
he voltage
at won't be
downward
e the heat
ator. Here
ation. But
n analog ci
utput volta
809,7812,7
DC. The
voltage if
nt demand
s 6V then o
e regulator
e proper.
d (Fig a) an
sink abov
you can se
there is no
ircuit we s
age will be
815,7824.
most
f input
ds and
output
rs like
nd the
ve the

ee that
o need
should
e high.
R
o
b
o
t
i
c
s

W
o
r
k
s
h
o
p







N
I
T

T
r
i
c
h
y

POTE
Potentiom
shaft. Pot

Potentiom
then you
used to ge
Note: To
resistance
ENTIOM
meter is a v
tentiometer
meter is a v
can get v
enerate ref
reduce th
e.
METER
variable re
rs are avai
voltage div
voltages fro
ference vol
e value of
R (PO
sistor whic
lable from
vider. If we
om 0 to V
ltage for L
f current dr
~ 9 ~
OT ' )
ch is used
m 100 ohm t
e connect L
Vcc by at L
M324.
rawn, use
to vary the
to 470Koh
Lead A to V
Lead W. M
the preset
e resistance
hm (or mor
Vcc and L
Mainly po
ts that hav
e by rotatin
re).

Lead B to g
tentiomete
ve higher o
ng the
ground
ers are
overall
R
o
b
o
t
i
c
s

W
o
r
k
s
h
o
p







N
I
T

T
r
i
c
h
y

Above fi
potentiom
occasiona
Second a
fixed. Th
body of th

igure show
meters are
ally while
and third o
hey are also
he potentio
ws differen
mainly use
the first o
ones are ea
o called P
ometer.

nt types o
ed when y
one is used
asy to inse
Preset. R
~ 1u ~
of potentio
ou only w
d when we
ert in brea
Resistance i
meters av
ant to chan
e have to v
adboard an
is varied b
vailable. Se
nge the val
vary resist
nd PCB, a
by rotating
econd and
lue of resi
ance frequ
also they r
g the shaft

d third
stance
uently.
remain
in the
R
o
b
o
t
i
c
s

W
o
r
k
s
h
o
p







N
I
T

T
r
i
c
h
y

PROCE
Pro
correspon
several
Microchip
robot. It i
WhyA

algorithm
it has fol
1. It
(Bu
No
cod
2. It h
16
3. It
4. It c
A)
ESSING
ocessing sy
nding inpu
companies
p, Intel, M
is an ATM
ATmeg
Line f
ms. We can
llowing ex
is an ISP
urning) of
ote: Progr
de from co
has on chi
and 17). W
has an inbu
consumes l
Hardw
G SYST
ystem acts
uts. For th
s that m
Motorola et
MEL produc
ga8L
follower ro
n use any m
xtra feature
P (In Sys
ATmega8
ramming (B
mputer to
p PWM (
We have ex
uilt RC osc
lesser pow
ware De
TEM
as the Bra
hat we use
manufacture
tc. We wil
ct. It is also
obot requi
microcontr
es:
stem Prog
L IC can b
(Burning)
microcont
Pulse Wid
xplained PW
cillator. (O
wer than oth
etails
~ 11 ~
ain of robo
e microcon
e microco
ll be using
o called AV
ires simple
roller for th
grammabl
be done wit
of a micr
troller .Bur
dth Modu
WM in app
Oscillator i
her microco
t, which ge
ntrollers. I
ontrollers,
g ATmega
VR.
e microcon
hat. But w
le) device
thout remo
rocontrolle
rning is exp
ulation) cir
pendix sec
is a clock g
ontrollers.
enerates de
In present
for exam
a8L microc
ntroller as
we use ATm
. It mean
oving it fro
er means
plained lat
rcuit at thr
tion.
generator c
esired outp
days, the
mple AT
controller
s it uses s
mega8L, be
ns program
om the syst
transferrin
ter.
ree pins (P
circuit).

put for
re are
TMEL,
in our
simple
ecause
mming
tem.
ng the
Pin 15,
R
o
b
o
t
i
c
s

W
o
r
k
s
h
o
p







N
I
T

T
r
i
c
h
y

~ 12 ~

BasichardwareconnectionsofATmega8L
Pin 1 (Reset):
The use of reset pin is to reset the ATmega8L microcontroller. This can be done
by connecting this pin to ground. In normal mode of execution it should have at least
2.7V. Thus it is connected to +5 V through 10k ohm resistance .We should make sure
that its potential be above 2.7 for proper execution of code.
Pin 7 and 20 (Vcc):
Pin 7 and 20 should be connected to Power supply. (2.7 to 5.5 volt for
ATmega8L)
Pin 8 and 22 (Ground):
Pin 8 and 22 should be connected to Ground. This ground should be common to
for the entire circuit.



Input and Output Ports
In ATmega8L we have three I/O (input/output) ports viz. Port B, Port C and
Port D.
One can configure any pin of each of these ports as input or output pin by
appropriate programming.




Pin PORT Connection PWM
14 PB0 Negative of right NO
15 PB1 Positive of right YES
16 PB2 Positive of Left YES
17 PB3 Negative of Left NO

Thus we can use Port C or Port D or remaining Pins of Port B as input. But for the
sake of simplifying hardware connections we choose Port D pins as input pins.
Make sure Ground and Vcc do not get interchanged and Vcc should not exceed 5.5
V. If you connect supply wrongly, ATmega8L will suffer permanent damage.
We will be using Port B pins (PB0 to PB3) as output pins because at pinPB1 and
PB2 we have on-chip PWM output that can control the speed of motors.
R
o
b
o
t
i
c
s

W
o
r
k
s
h
o
p







N
I
T

T
r
i
c
h
y

Burne
Burner (o
microcon
available
We will b


stk200
Requi
Pa
5 P
5 w
Th



er (or p
or program
ntroller IC
Eg stk200
be using st
0 Progr
irements
arallel Port
Pin RMC c
wired Bus
hey are show
rogram
mmer) is t
C. For pro
0, stk500, j
tk200 prog
rammer
t DB 25 co
connector (
wn in follo

mmer)
the circuit
ogramming
tag2 etc.
grammer.
r:
onnector (c
(connects t
owing figu
~ 1S ~
used to t
g AVR th
onnects to
to AVR PC
ure.
transfer th
here are d
the compu
CB).
he code fro
different ty
uter )
om compu
ypes of bu
uter to
urners

R
o
b
o
t
i
c
s

W
o
r
k
s
h
o
p







N
I
T

T
r
i
c
h
y

Conne
Co
Explanat


ections
onnections
tions of Pi
R
are given b
ins of ATm
SCK
MOSI
RESET
MISO
GND
by the follo
mega8L
S
M
M
~ 14 ~
owing figu
SPI Bus M
Master Ou
Re
Master Inp
G
ure.
aster clock
utput/Slave
eset pin
put/Slave O
Ground
k Input
Input
Output

R
o
b
o
t
i
c
s

W
o
r
k
s
h
o
p







N
I
T

T
r
i
c
h
y

~ 1S ~

B) Software Details:
Programming and Simulating
The program code acts as the decision-maker embedded in the micro-
controller i.e. it decides what will be the outputs for particular set of input
combination.
Programs for the AVR series of microcontrollers can be written in assembly
(AVR ASM), C and BASIC. AVR Studio, WinAVR, etc. are some free
development softwares for programming the AVR Microcontrollers. We will be
using winAVR for programming and AVR Studio for simulating (Simulation
means debugging the code on software, one can virtually give the input and
check the output for that code).
In winAVR programmers Notepad we write our C code, after compilation it
generates .hex file which is a hardware level code.
SampleCode:To blink a LEB connecteu at pin 6 (PB4) of ATmega8L.

#include<avr/io.h>//headerfiletoincludeinputoutputport
#include<util/delay.h>//headerfiletoincludedelayfunction
#defineLEDPD4

intmain(void)
{
DDRD=(1<<LED);
/*DDR=DataDirectionregister...itstodefinePD4OUTPUTpin
restbitsofDDRDcanbe0or1doesnotmakeanysignificance*/

while(1)
{
PORTD=(1<<LED);//switchon
_delay_ms(200);
PORTD=(0<<LED);//switchoff
_delay_ms(200);
}
return0;
}

R
o
b
o
t
i
c
s

W
o
r
k
s
h
o
p







N
I
T

T
r
i
c
h
y

MOTO
For movi
Why DC
DC
its operat
supply ac
Use of
Th
connectin
of its spee
Mathema
Ro

Th
Pr is con
inversely

Thus to in
Note:
In
Ge
R OUTP
ing a robot
C motors
C motors ar
tion. If we
cross it. We
gears
he DC mo
ng wheels
ed.
atical inte
otational po
Pr=Tor
hus
stant for D
proportion
ncrease the
toy car, th
eared moto
PUT SY
we have t
s
re most ea
e want to
e can vary
otors don
in it. Gear
erpretation
ower (Pr) i
rque (T) *
DC motor w
nal to spee
e value of t
here is a ge
or has a gea
YSTEM:
wo dc mot
asy to contr
change its
speed by v
t have en
rs used to i
n:
s given by
Rotationa
with cons
ed ().
torque we
ar box that
ar box at it
~ 16 ~
:
tors attache
rol. One dc
s direction
varying the
nough tor
increase th
y:
l Speed (
stant input
have to sa
t contains
ts front end

ed to whee
c motor req
n just reve
e voltage a
rque to dr
he torque o
)

electrical

crifice spe
several com
d.
els and gea
quires only
erse the po
across moto
rive a rob
of dc motor
power. Th
eed.
mbinations
ar system.
y two signa
olarity of p
or.
bot direct
r on the ex
hus torque
s of gears.

als for
power
tly by
xpense
(T) is
R
o
b
o
t
i
c
s

W
o
r
k
s
h
o
p







N
I
T

T
r
i
c
h
y

Why tw
By
mechanis
Lets che


wo mot
y using tw
sm of robot
ck how it w
tors
o motors
t is called d
works
Fi
F
we can m
differentia
gure. Descri
Figure. Mo
~ 17 ~
move the ro
al drive.
iption of var
ovement of
obot in an
rious parts
f Robot
ny direction. This ste

eering

R
o
b
o
t
i
c
s

W
o
r
k
s
h
o
p







N
I
T

T
r
i
c
h
y


The table
Left Mot
Straight
Stop
Reverse
Straight
Straight
Reverse


Use of
Fro
microcon
a current
motor dri
Mo
correspon

IC L293
Th
how we u

e:
tor
f Motor
om micro
ntroller can
t enhancin
iver betwee
otor drive
nding outp
3D
his is a mo
use this IC.
R
S
S
S
S
R
R
r Driver
ocontroller
n not give s
ng device;
en the mot
r takes th
ut for moto
otor driver
.
Right Moto
Straight
Straight
Straight
Stop
Reverse
Reverse
r
we can
sufficient c
it can als
tor and mic
he input
or.
IC that ca
Figure. Pin
~ 18 ~
or
n not co
current to d
so act as a
crocontroll
signals fr
an drive tw
n Details of L
Rob
Stra
Lef
Sha
Rig
Sha
Rev
onnect a
drive the D
a Switchin
ler.
rom micro
wo motor
L293D
bot Movem
aight
ft
arp left
ght
arp Right
verse
motor di
DC motors.
ng Device.
ocontroller
simultane
ment
irectly be
. Motor dr
Thus we
r and gen
ously. Let

ecause
iver is
insert
nerates
ts see
R
o
b
o
t
i
c
s

W
o
r
k
s
h
o
p







N
I
T

T
r
i
c
h
y

~ 19 ~

Electrical Characteristics of L293D


Symbols

Parameter Testing
Condition
Min. Max. Units
Vss LogicSupplyVoltagePin16 4.5 36 V
Vs SupplyVoltagePin8 Vss 36 V
VenL EnableLowVoltagePin1and9 0.3 1.5 V
VenH EnableHighVoltagePin1and9 Vss<=7
Vss>7
2.3
2.3
Vss
7
V
VIL InputLowVoltagePin2,7,10and15 0.3 1.5 V
VIH InputHighVoltagePin2,7,10and15 Vss<=7
Vss>7
2.3
2.3
Vss
7
V
PointsregardingL293D
Supply voltage (Vss) is the Voltage at which we wish to drive the motor.
Generally we prefer 6V for dc motor and 6 to 12V for gear motor, depending
upon the rating of the motor.
Logical Supply Voltage will decide what value of input voltage should be
considered as high or low .So if we set Logical Supply Voltage equal to +5V,
then -0.3V to 1.5V will be considered as Input Low Voltage and 2.3 V to 5V
will be considered as Input High Voltage.
L293D has 2 Channels .One channel is used for one motor.
Channel 1 - Pin 1 to 8
Channel 2 - Pin 9 to 16
Enable Pin is used to enable or to make a channel active. Enable pin is also
called as Chip Inhibit Pin.
All Inputs (Pin No. 2, 7,10and 15) to L293D IC are the respective outputs from
microcontroller (ATmega8L).
E.g.-We connected Pin No. 2, 7, 10 and 15 of L293D IC to Pin No. 14,
15,16and 17 of ATmega8L respectively in our robots, because on pin 15
and 16 of ATmega8L we can generate PWM.
All Outputs (Pin No. 3, 6,11and 14) of L293D IC goes to the inputs of Right
and Left motors.
Output Connections
OUTPUT 1 (Pin No 3) --- Negative Terminal of Right Motor
OUTPUT 2 (Pin No 6) --- Positive Terminal of Right Motor
OUTPUT 3 (Pin No 10) --- Positive Terminal of Left Motor
OUTPUT 4 (Pin No 14) --- Negative Terminal of Left Motor
R
o
b
o
t
i
c
s

W
o
r
k
s
h
o
p







N
I
T

T
r
i
c
h
y

~ 2u ~

For one motor:


Positive Terminal Negative Terminal Motor Output
0 0 No movement
Vss 0 Straight
0 Vss Reverse
Vss Vss No Movement

One channel can control one motor.


Enable pin should be high for activating
the corresponding channel.
Input 1 corresponds to Output 1.

If Enable 1=High (1)
Input1 =High (1), Output1=Vss
Input1 =Low (0), Output1=0

If Enable 1=Low (0)
Input1 =High (1), Output1=0
Input1 =Low (0), Output1=0

if Enable pin low, the output will always
be 0. If its high output depends on input

Lets check the sample outputs for some sample inputs (when both the Enable pins are high):
Input
1
Input
2
Input
3
Input
4
Output
1
Output
2
Output
3
Output
4
Motors Output Movement
Right Left
Low High High Low 0 Vss Vss 0 Straight Straight Straight
Low High Low Low 0 Vss 0 0 Straight No mov Left Turn
Low Low High Low 0 0 Vss 0 No mov Straight Right Turn
Low High Low High 0 Vss 0 Vss Straight Reverse Sharp Left
High Low High Low Vss 0 Vss 0 Reverse Straight Sharp Right
High Low Low High Vss 0 0 Vss Reverse Reverse Backward

You can see the datasheet of that IC for more details.

R
o
b
o
t
i
c
s

W
o
r
k
s
h
o
p







N
I
T

T
r
i
c
h
y

~ 21 ~

Algorithm for Line Follower


There are various line follower algorithms. The main use of the algorithm is to
move the robot on the line in a smooth fashion. Apart from the task, the algorithm also
depends on hardware including number of sensors, type of motors, chassis etc.
Same problem can be approached by different algorithms. Readers are
encouraged to develop their own algorithms.


R
o
b
o
t
i
c
s

W
o
r
k
s
h
o
p







N
I
T

T
r
i
c
h
y

~ 22 ~

Appendix:
1. Print ed Circuit Board
When making the circuit with the electronic parts of the resistors, the
capacitors, the transistors, the ICs and so on, it is necessary to connect the lead line of
each part appropriately. Also, each part must be fixed, too. The printed circuit board is
used to do the wiring among the parts and the fixation of the part.

Advantages:
Reliability and durability due to compact nature of the circuit especially needed
for mobile applications like robotics.
Easy debugging.
Large number of circuits can be made with a greater accuracy and at a cheap
cost.
Chances of loose connections get eliminated.

Disadvantages
Once the circuit is made on a PCB its layout cannot be changed.
PCB leads can burn at higher values of current rendering it useless for further
use
PCB designing can be a tedious and time consuming process.


R
o
b
o
t
i
c
s

W
o
r
k
s
h
o
p







N
I
T

T
r
i
c
h
y

Bottom

PCB
m View
B layou
:
Figure:

ut that w
PCBLayou
Figu
Figure:A
~ 2S ~
will be
utdesigne
ure:Photo
AfterSolde
given i
dbySoftw
o
ering
in Work
ware
kshop

R
o
b
o
t
i
c
s

W
o
r
k
s
h
o
p







N
I
T

T
r
i
c
h
y

Top VView:
Figure:
Figure
Mirrorim
:Afterpla
~ 24 ~
mageofB
acingallC
ottomLa
Compone
ayout
ents
R
o
b
o
t
i
c
s

W
o
r
k
s
h
o
p







N
I
T

T
r
i
c
h
y

Explanation of all compponents:


~ 2S ~
:

R
o
b
o
t
i
c
s

W
o
r
k
s
h
o
p







N
I
T

T
r
i
c
h
y

Bottom
Explan
1) Sen
m Layou
2) Bo
3) To
nation:
nsor PC
ut:
ottom Vi
op View
B
iew:
:
~ 26 ~

R
o
b
o
t
i
c
s

W
o
r
k
s
h
o
p







N
I
T

T
r
i
c
h
y

PWM
Pulse Wi
various fr
Th
frequency

Definitio
From abo

M
idth Modu
requencies
he periodic
y and duty
ons:
ove figure w
Time p
is calle
Frequ
On Tim
Off Ti
Duty C
Avera
ulation (PW
s (time peri
square wa
-cycle.
we can def
period (T)
ed as Time
ency (f):
me (Ton):
ime (Toff)
Cycle ():
ge Value(V
(Vm is val

WM) is a m
iod) or duty
ave has two
fine some t
): The min
e period.
=1/T
Time for
: = T-Ton
=(Ton)/T
Vavg): =V
lue of high
~ 27 ~
method to
y-cycles.
o levels (hi
terms.
nimum tim
which fun
Vm*
h voltage)
generate P
igh or low)
me after wit
ction is at
Periodic Sq
), with som
tch functio
high voltag
quare Wav
me constan

n repeats i
ge.
e of
t
tself
R
o
b
o
t
i
c
s

W
o
r
k
s
h
o
p







N
I
T

T
r
i
c
h
y

~ 28 ~


Examples




R
o
b
o
t
i
c
s

W
o
r
k
s
h
o
p







N
I
T

T
r
i
c
h
y


USE of
For
only has c
resistance
Th
1.
2.

No
pulse, hen
can be va
In
average v
We
PWM in
r example:
constant V
e in series
he drawbac
The resist
There will
ow By adj
nce the 'PW
aried, and h
other word
voltage (Va
e can desig
n DC Mot
: If a perso
Voltage sup
with the m
ks of this c
tance value
l be unnec
justing the
WM') i.e., t
hence the m
ds by varyi
avg) across
gn the syste
tor
on wants to
pply. As an
motor (As s
connection
e cannot be
essary pow
duty cycle
the time fra
motor spee
ing the dut
s the motor
em as show
~ 29 ~
o drive a D
n alternativ
shown in fi
n are:
e varied dy
wer loss ac
e of the sig
action for w
ed.
ty cycle we
r resulting
wn in the f
C motor w
ve for PWM
igure).
ynamically
ross the re
gnal (modu
which it is
e are gettin
in differen
following f
with variabl
M he can ad
(automati
esistor.
ulating the
s "on", the
ng different
nt speeds.
figure:
le speed bu
dd a variab

on is diffic
width of th
average po
t values of

ut he
ble
cult).
he
ower
f
R
o
b
o
t
i
c
s

W
o
r
k
s
h
o
p







N
I
T

T
r
i
c
h
y

~ Su ~

DC Motor Speed
Now

And

Thus

Advantages of PWM:
1. Here the switch is either on or off unlike normal regulation(using variable
resistance), so less power is wasted as heat and smaller heat-sinks can be
used.
2. Since no resistor is used, there is no power loss.
3. Can be easily automated by programmable control.
Disadvantages:
1. We require extra circuitry to implement PWM (in AVR we have in built
PWM-circuitry on chip).
2. Some authorities claim the pulsed power puts more stress on the DC motor
bearings and windings, shortening its life.
Implementation of PWM:
For developing PWM, we require two properties:
1. Time Period (T)
2. On-Time Period (Ton)
Implementation of PWM in microcontroller:
In microcontroller we use clock of several Mega Hz. Thus time of one clock



E.g. In ATmega 8 clock frequency is approximately 1 Mega Hz.

Tclk=1/(1M Hz)=1 s

Vavg
DC Motor Speed Vavg
Tclk =1/(clock frequency)
R
o
b
o
t
i
c
s

W
o
r
k
s
h
o
p







N
I
T

T
r
i
c
h
y

For imple
Nt=
OC
Ni=
cyc




ementation
= Number
CR= Numb
= It is a ind
cle.

When i
And if
n of PWM
of clock c
Nt=
ber of cloc
OCR
dex of cou
if Ni O
f Ni < O
in microco
cycles for o
=T/Tclk
ck cycles fo
R= Ton/T
unter, that c
OCR th
OCR th
~ S1 ~
ontroller w
one time pe
or On Time
Tclk
counts from


hen PW
hen PWM
we require t
eriod of PW
e of PWM
m Nt to zer
WM Outp
M Outp
these varia
WM

ro and Zero
put=Low
put=Hig
ables:
o to Nt in e

w
gh
each
R
o
b
o
t
i
c
s

W
o
r
k
s
h
o
p







N
I
T

T
r
i
c
h
y

You might also like