You are on page 1of 33

 

Line 
 

 

Follower 
Robot  
Robotics Workshop
Currents 15th 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 )
 
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,

p
while constantly correcting the wrong moves using feedback mechanism, thus
forming a simple yet effective closed loop System. The robot is designed to follow

ho
very tight curves.
 
 
Sample Paths

ks
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).
   
or

hy
 
   
W

ic
s

Tr
ic

   
t

Figure 1: Basic Sample Arena     Figure 2: Sample Arena of Kurukshetra’08 (Anna University) 
 
IT
bo

   
N
Ro

Figure3: Sample Arena of Pragyan’07 (NIT Trichy)  Figure4: Sample Arena of Robo‐Relay of Kishitij’08 (IIT KGP) 
   
 From  above  images  we  can  conclude  that  in  most  of  line  follower  competitions,  some  additional 
task has to be performed apart from following the line.   
 
~ 1 ~ 
 
 
Basic design and requirem
ments
The robot is built
b using ATmegga8L, L293D, IR seensors, LM M324, plaatform
consistingg of a toy car chassiis (or handd made Alluminum sheet
s chasssis), two motors
m
and contrrolling wh heels. It has
h infraredd sensors on the boottom for detecting black

p
tracking tape.
t Line position is
i capturedd with the help of thhese opticaal sensors called
opto-coupplers moun nted at the front end of the roboot. (Each opto-coupl
o er consistss of an

ho
IR LED and an IR Sensoor). Whenn the sennsors detecct black surface, output o
of compaarator, LM3 324 is loww, while for white surface the output
o is high.
h It is sent
s as
input too the miccrocontroller for accurate
a c
control a
and steerinng of motors.
m
Microconntroller ATTmega8L anda Motor driver
d L2993D are useed to drivee the motorrs.

ks
Basic operattion
The basic operrations of thhe line folllower are as
a follows::
1. Capture
C lin
or
F this a combinationn of IR LE
For
e of the robot.
ne position with opticcal sensorss mountedd at front end
ED and Phooto Transisstor called an opto-cooupler

hy
iss used. Thee line sensiing process requires high
h resoluution and high
h robusttness.
2. Steer
S robot to track the
t line wiith a suitabble steerinng mechaniism. To acchieve
W
thhis we use two motorrs that govvern the mootion of thee wheels onn either sidde.
 

Block D
Diagram
ic
s

Tr
t ic
IT
bo

N
Ro

 

Let’s see all the sysstem in detail.  

~ 2 ~ 
 
 

INPUT
T SYSTE
EM
Sensorrs
Eacch opto-co oupler has one emitteer (IR LED D) and one receiver (P Photo-Trannsistor
or photo diode.
d

p
If white
w surfaace is preseent beneathh the IR LEED, IR rayys are refleccted and arre
sensed byy the receivver, while in case of black
b surfaace, the ligght gets abssorbed andd

ho
hence recceiver doess not sense IR rays.

ks
or

hy
W

ic
s

Tr
t ic
IT
bo

N

Photo dioode has a property
p thhat if IR ligght falls onn it, its elecctrical resisstance decreases
Ro

(from sayy 150kΩ to 10kΩ). For sensing the chhange in resistance r we use voltage
v
divider ciircuit (as sh
hown in figgure below w).

~ 3 ~ 
 
 
Sample Calculation:
Say Receiver has resistance-
Rs=150kΩ without light (on black surface)
Rs=10kΩ with light (on white surface)

p
The voltage that goes to comparator

ho
Without light: (on black surface)
Vp= *5 V=4.6875 V

ks
With light: (on white surface)
Vp= *5 V=2.500 V

or

hy
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.
W
Comparator
Comparator is a device which compares two input voltages and gives

ic
output as high or low. In a circuit diagram it is normally represented by a
triangle having-Inverting (negative) Input (-), Non-Inverting (positive)
s

Tr
Input(+), Vcc, Ground, Output.
ic

Properties of comparator:
t

¾ If V+ > V-
IT
bo

then Vo=Vcc
(Digital High 1 output)
N
Ro

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

 

~ 4 ~ 
 
 
Let’s see some examples

p
ho
ks
Use of comparator in IR sensor
or
As above we see that two inputs are required for comparator. One input is from

hy
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.
W
Setting of reference voltage (Vref)

ic
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
s

Tr
measured with and without light.
. .
ic

From above example Vref =  = 3.5875 V
Lets connect Inverting Input of Comparator to photo- receiver, Non-Inverting Input to
t

potentiometer (as shown in figure) and output to micro controller.
IT
bo

Sample Calculation:
Let V+ = 3.5875 V
N
Ro

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.

~ 5 ~ 
 
 
Note: If we
w connectt Inverting Input of Comparato
C or to potenttiometer (ppreset) andd Non-
Invertingg Input to photo-
p receeiver, the only differeence observved is that at white suurface
we get Loow output and
a for blaack surfacee we get High
Hi output..

IC LM
M324

p
IC LM324 co
ontains fouur comparaators.

ho
ks
or

hy
W

ic
s

Tr
You can see the datasheet of IC LM3244 for moree details.
ic

Arran
ngement of Sen
nsors
t

Ann array off sensors arranged in a straight row pattern iss bolted under u
IT
bo

the frontt of the robot. It is used
u to locate the position
p off line belo
ow the rob bot.
Wee can use any num mber of sen nsors. If we
w have leesser num mber of seensors
then thee robot movement
m will not be smoo oth and itt may facce problem ms at
sharp tu
urns. If wee use high her numbeer of sensors robot movemen nt will beecome
N
Ro

smooth and relliable fo or sharp turns, however it requ uires com mplex
programmming and d more haardware. ThusT we must
m chooose optimmum numb ber of
sensors.
The distan nce betweeen sensorrs depend ds on
1. Numb ber of senssors used
2. Width h of straight line
3. Distan nce betweeen sensorrs may no ot be consstant (it depends
d o the
on
logic)..

~ 6 ~ 
 
 
Sample figure:
f

Left R
Right

p
Tips for
f Inp
put System

ho
Significant probblems are faced in input systtem. So too make reeliable
connecctions use PCB.
P
Set prreset valuee for eachh sensor, because each e senssor may behave
b

ks
differently and may
m give diffferent volttage on thee same surf rface.
You ha ave to adjuust preset value for new surface, as refllectivity deepends
on rouughness of surface.
s
The addvantage of IR sensoor is that itt is less aff
ffected by ambient
a ligght. In
case we
ambien
w use LDR
nt light. or
R as photoo detector, its sensitivity will highly depeend on

hy
To gett a good vooltage swiing, the vaalue of R1 must be carefully
c chhosen,
W
we gennerally usee 10kΩ resssistance.
Properr orientatioon of the IRI LED annd Photo diode
d is muust so as too have

ic
good voltage
v swiing. Also IR
I rays of one opto-ccoupler should not disturb
d
the oth
her opto-cooupler.
If an opto-coupl
o ler is not working thhen first check
c whetther the vooltage
s

Tr
across IR LED is i 1.1-1.2 V, then check the vooltage variaation acrooss the
ic

photo diode
d for black
b and white
w surfaaces, then set
s the refeerence volttage.
t
IT
bo

N
Ro

Figure 2: Alignment of Sensor in an
a opto-cou
upler

~ 7 ~ 
 
 

Voltaage Reegulatoor 78xxx
Voltage regulators
r convert fixed
f DC output vooltage from
m variable DC. The most
commonlly used on nes are 78005 and 7812. 7805 gives fixedd 5V DC voltage iff input
voltage iss in betweeen 7.5V to 20V.

p
They hellp to main ntain a steaady voltagge level deespite varyying currennt demandds and

ho
input volttage variattions.

If input voltage
v is <7.5
< V thenn regulationn won't be proper i.ee. if input iss 6V then output
o

ks
may be 5V 5 or 4.8V V, but theere are som me parameeters for thhe voltagee regulatorrs like
maximum m output cuurrent capaability, linee regulationn etc.. , thaat won't bee proper.

To identify the leadds of the 78805, you have
h to keeep the lead downwardd (Fig a) annd the
writing too your sid
voltage reegulator.(1
or
de, (see thhe figure below).
1-input,2-ggnd,3-outp
b
put).
Yoou can seee the heat sink abovve the

hy
W

ic
s

Tr
t ic
IT
bo

 
N
Ro

Fig a Fig b
Fig b shows how
h to usee 7805 volttage regulaator. Here you can seee that
couupling capaacitors are used for good
g regulaation. But there is noo need
for it in norm
mal case. But
B if 78055 is used inn analog ciircuit we should
s
use capacitor,, otherwisee the noisee in the ouutput voltaage will bee high.
Thee mainly avvailable 788xx IC's aree 7805, 78809,7812,7815,7824.

~ 8 ~ 
 
 
POTE
ENTIOM
METER
R (‘PO
OT ' )
Potentiommeter is a variable
v resistor whicch is used to vary thee resistancee by rotatinng the
shaft. Pottentiometerrs are available from
m 100 ohm to t 470Kohhm (or morre).

p
ho
ks
or

hy
W

ic
s

Tr
t ic
IT
bo

N
Ro

Potentiom
meter is a voltage
v divvider. If wee connect Lead
L A to Vcc
V and Lead
L B to ground
g
then you can get voltages
v froom 0 to Vcc
V by at Lead
L W. Mainly
M potentiometeers are
used to geenerate refference volltage for LM324.
Note: To reduce the value off current drrawn, use the presetts that havve higher overall
o
resistancee.

~ 9 ~ 
 
 

p
ho
ks
or

hy
W

ic
s

Tr
ic

Above fiigure show ws differennt types of
o potentiometers avvailable. Seecond andd third
potentiommeters are mainly useed when you only want to channge the vallue of resistance
t

occasionaally while the first one
o is usedd when wee have to vary v resistance frequuently.
IT
bo

Second and
a third ones
o are eaasy to inseert in breaadboard annd PCB, also
a they remain
r
o called Preset
fixed. Thhey are also P . Resistance
R i varied by
is b rotatingg the shaft in the
body of thhe potentio
ometer.
N
Ro

~ 10 ~ 
 
 

PROCE
ESSING
G SYST
TEM
Proocessing sy
ystem acts as the Braain of robot, which geenerates deesired outpput for
corresponnding inpu uts. For thhat we usee microconntrollers. In
I present days, there are
several companiess that manufacture
m e microcoontrollers, for exam mple AT TMEL,

p
Microchipp, Intel, Motorola
M ettc. We willl be usingg ATmegaa8L microccontroller in our

ho
robot. It is
i an ATMMEL producct. It is alsoo called AVVR.
Why A
ATmeg
ga8L 
    Line follower
f roobot requiires simplee microconntroller ass it uses simple
s

ks
algorithmms. We can n use any microcontr
m roller for thhat. But we
w use ATm mega8L, beecause
it has folllowing ex
xtra featurees:
1. It is an ISP P (In Sysstem Proggrammablle) device. It meanns program mming

or
(Buurning) of ATmega8L IC can be
Noote: Progrramming (Burning)
(B
b done witthout remooving it froom the systtem.
of a micrrocontrolleer means transferrinng the

hy
codde from computer to microconttroller .Burrning is expplained latter.
W
2. It has
h on chip PWM (Pulse Wid dth Modu ulation) cirrcuit at thrree pins (P
Pin 15,
16 and 17). We
W have exxplained PW WM in apppendix section.

ic
3. It has an inbuuilt RC osccillator. (O
Oscillator is
i a clock generator
g c
circuit).
4. It consumes
c lesser
l pow
wer than othher microcoontrollers.
s

Tr
A) Hardw
ware Deetails
t ic
IT
bo

N
Ro

 

~ 11 ~ 
 
 

Basic hardware connections of ATmega8L 
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

p
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. 

ho
Pin 7 and 20 (Vcc):
Pin 7 and 20 should be connected to Power supply. (2.7 to 5.5 volt for
ATmega8L)

ks
Pin 8 and 22 (Ground):
Pin 8 and 22 should be connected to Ground. This ground should be common to
for the entire circuit. 

or

hy
 
W
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.
  
Input and Output Ports
ic
s

Tr
• In ATmega8L we have three I/O (input/output) ports viz. Port B, Port C and
ic

Port D.
• One can configure any pin of each of these ports as input or output pin by
t

appropriate programming.
IT

 
bo

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. 
 
   
N
Ro

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.

~ 12 ~ 
 
 
Burneer (or program
mmer)
Burner (oor program
mmer) is thet circuit used to transfer
t thhe code froom compuuter to
microconntroller IC
C. For proogrammingg AVR thhere are different
d tyypes of buurners

p
available Eg stk200
0, stk500, jtag2 etc.
We will be
b using sttk200 proggrammer.

ho
stk2000 Progrrammerr:

ks
Requiirements
¾ Paarallel Portt DB 25 coonnector (connects to the compuuter )
¾ 5 Pin
P RMC connector
c (
(connects t AVR PC
to CB).
¾ 5 wired
w Bus
Thhey are show
or
wn in folloowing figuure.

hy
W

ic
s

Tr
t ic
IT
bo

N
Ro

~ 13 ~ 
 
 
Conneections
Coonnections are given by
b the folloowing figuure.

p
ho
ks
or

hy
W

ic
s

Tr
ic

Explanattions of Piins of ATm
mega8L

SCK SPI Bus Master clockk Input
S
t

MOSI M
Master Ouutput/Slave Input
IT

RESET
R Reeset pin
bo

MISO M
Master Inpput/Slave Output
O
GND G
Ground
N
Ro

 

~ 14 ~ 
 
 
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

p
combination.

ho
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

ks
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

or
generates ‘.hex’ file which is a hardware level code.

Sample Code: To blink a LED connected at pin 6 (PD4) of ATmega8L. 

hy
 
W
#include <avr/io.h> //header file to include input output port 
#include <util/delay.h>//header file to include delay function 

ic
#define LED PD4  
 
s

Tr
int main(void)  
ic


  DDRD = (1 << LED); 
t

  /* DDR=Data Direction register... its to define PD4 OUTPUT pin 
IT

  rest bits of DDRD can be 0 or 1 does not make any significance */ 
bo

 
  while (1)  
  { 
N
Ro

    PORTD = (1 << LED);    // switch on 
  _delay_ms(200); 
    PORTD = (0 << LED);    // switch off 
    _delay_ms(200); 
  } 
return 0; 
}

~ 15 ~ 
 
 

MOTOR OUTP
PUT SY
YSTEM::
For moviing a robot we have two dc mottors attacheed to wheeels and geaar system.
Why DC
C motorss
DCC motors arre most eaasy to contrrol. One dcc motor reqquires onlyy two signaals for

p
its operattion. If wee want to change itss directionn just reveerse the poolarity of power
p
supply accross it. Wee can vary speed by varying
v thee voltage across
a motoor.

ho
Use of gears
Thhe DC mo otors don’’t have ennough torrque to drrive a robbot directtly by
connectinng wheels in it. Gearrs used to increase
i thhe torque of
o dc motorr on the exxpense

ks
of its speeed.
Mathemaatical inteerpretation n:
ower (Pr) is given byy:
Rootational po
Pr=Torrque (T) * Rotational Speed (ωω)
Thhus
or

hy
W
Pr is constant for DC
D motor withw consstant input electrical power. Thhus torque (T) is
inversely proportion
nal to speeed (ω).

ic
s

Tr
ic

Thus to inncrease thee value of torque
t we have to sacrifice speeed.
Note:
• In toy car, thhere is a gear box thatt contains several commbinationss of gears.
t

• Geeared moto or has a geaar box at itts front endd.
IT
bo

N
Ro

~ 16 ~ 
 
 
Why tw
wo mottors
Byy using two motors we can movem the roobot in anny direction. This steeering
mechanissm of robott is called differentia
d al drive.
Let’s check how it works
w

p
ho
ks
or

hy
W
Figure. Descriiption of varrious parts

ic
s

Tr
t ic
IT
bo

N
Ro

F
Figure. Moovement off Robot

~ 17 ~ 
 
 

The tablee:
Left Mottor Right Motoor
R Rob bot Movemment
Straight S
Straight Straaight

p
Stop S
Straight Lefft
Reverse S
Straight Shaarp left

ho
Straight S
Stop Rigght
Straight R
Reverse Shaarp Right
Reverse R
Reverse Revverse

ks
Use off Motorr Driverr
Froom micro ocontroller we cann not coonnect a motor diirectly beecause
microconntroller can
a currentt enhancin
or
n not give sufficient
s c
current to drive
d the DC
D motors.. Motor driver is
ng device; it can alsso act as a Switchinng Device. Thus we insert

hy
motor driiver betweeen the mottor and miccrocontrolller.
W
Mootor driver takes thhe input signals frrom microocontrollerr and gennerates
corresponnding output for motoor.

ic
IC L2933D
otor driver IC that caan drive tw
Thhis is a mo wo motor simultaneously. Lett’s see
s

Tr
how we use
u this IC..
t ic
IT
bo

N
Ro

Figure. Pin
n Details of L293D
L

~ 18 ~ 
 
 
Electrical Characteristics of L293D
Symbols  Parameter  Testing  Min.  Max.  Units 
  Condition
Vss  Logic Supply Voltage Pin  16    4.5  36  V 

p
Vs  Supply Voltage Pin  8    Vss  36  V 
Ven L  Enable Low  Voltage Pin  1 and 9    ‐0.3  1.5  V 

ho
Ven H  Enable High  Voltage Pin  1 and 9  Vss<=7  2.3  Vss  V 
Vss>7  2.3  7 
VIL  Input Low Voltage Pin  2, 7, 10 and 15    ‐0.3  1.5  V 
VIH  Input High Voltage Pin  2, 7, 10 and 15  Vss<=7  2.3  Vss  V 

ks
Vss>7  2.3  7 
Points regarding L293D 

or
™ 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

hy
upon the rating of the motor.
W
™ 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

ic
will be considered as Input High Voltage.
s

™ L293D has 2 Channels .One channel is used for one motor.
Tr
• Channel 1 - Pin 1 to 8
ic

• Channel 2 - Pin 9 to 16
™ Enable Pin is used to enable or to make a channel active. Enable pin is also
t

called as Chip Inhibit Pin.
IT

™ All Inputs (Pin No. 2, 7,10and 15) to L293D IC are the respective outputs from
bo

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
N
Ro

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
~ 19 ~ 
 
 
For one motor:

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

p
0 Vss Reverse
Vss Vss No Movement

ho
 

  ¾ One channel can control one motor.
¾ Enable pin should be high for activating

ks
 
the corresponding channel.
¾ Input 1 corresponds to Output 1.

or If Enable 1=High (1)
Input1 =High (1), Output1=Vss

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

ic
Input1 =Low (0), Output1=0
s

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

 

 
t
IT

Let’s check the sample outputs for some sample inputs (when both the Enable pins are high):
bo

Input Input Input Input Output Output Output Output Motors Output Movement
1 2 3 4 1 2 3 4 Right Left
Low High High Low 0 Vss Vss 0 Straight Straight Straight
N
Ro

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.
   

~ 20 ~ 
 
 
 

Algorithm for Line Follower
There are various line follower algorithms. The main use of the algorithm is to

p
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.

ho
Same problem can be approached by different algorithms. Readers are
encouraged to develop their own algorithms. 

ks
or

hy
W

ic
s

Tr
t ic
IT
bo

N
Ro

~ 21 ~ 
 
 
Appendix:
1. Printed Circuit Board

p
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

ho
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.

ks
Advantages:
• Reliability and durability due to compact nature of the circuit especially needed
for mobile applications like robotics.
• Easy debugging.
or
• Large number of circuits can be made with a greater accuracy and at a cheap

hy
cost.
W
• Chances of loose connections get eliminated.

Disadvantages

ic
• 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
s

Tr
use
ic

• PCB designing can be a tedious and time consuming process.
t
IT
bo

N
Ro

~ 22 ~ 
 
 
PCBB layou
ut that will
w be given in
i Work
kshop
Bottom
m View:

p
ho
ks
 

or
Figure: PCB Layou ware 
ut designed by Softw

hy
W

ic
s

Tr
ic

 
t

Figu
ure: Photo

IT
bo

N
Ro

 
Figure: A
After Soldeering 

~ 23 ~ 
 
 

Top View:

p
ho
ks
or

hy
W
mage of Bottom Laayout  
Figure: Mirror im

ic
s

Tr
t ic
IT
bo

N
Ro

Componeents  
Figure: After plaacing all C

~ 24 ~ 
 
 
Explanation of all compponents::

p
ho
ks
or

hy
W

ic
s

Tr
t ic
IT
bo

N
Ro

 
~ 25 ~ 
 
 
1) Sennsor PCB
Bottom
m Layou
ut:

p
ho
 

ks
2) Bo
ottom Viiew:

or

hy
W
 
3) Toop View:

ic
s

Tr
t ic
IT
bo

 
Explan
nation:
N
Ro

 
~ 26 ~ 
 
 

PWM
M
Pulse Wiidth Modu ulation (PW WM) is a method
m to generate Periodic
P Sqquare Wave of
various frrequenciess (time periiod) or dutyy-cycles.

p
Thhe periodic square waave has twoo levels (hiigh or low)), with somme constant

ho
frequencyy and duty-cycle.

ks
or

hy
W

ic
s

Tr
t ic
IT
bo

Definitioons:
From aboove figure we w can deffine some terms.
t
ƒ Time period
p (T)): The minnimum timme after wittch function repeats itself
N
Ro

is calleed as Timee period.
ƒ Frequency (f): =1/T
ƒ On Tim me (Ton): Time for which function is at high voltagge.
ƒ Off Tiime (Toff): = T-Ton
ƒ Duty CycleC (δ): =(Ton)/T
ƒ Average Value(V Vavg): =VVm*δ
(Vm is vallue of highh voltage)

~ 27 ~ 
 
 
 
Ro Examples

bo
t ic
s
N W

~ 28 ~ 
IT or
Tr ks
ic ho
hy p
 

USE of PWM in
n DC Mottor
Forr example:: If a persoon wants too drive a DC motor with
w variablle speed buut he
only has constant
c Voltage
V suppply. As ann alternativve for PWM
M he can addd a variabble

p
resistancee in series with the motor
m (As shown
s in fiigure).

ho
ks
or

hy
Thhe drawbacks of this connection
c n are:
W
1. The resisttance valuee cannot bee varied dyynamically (automation is difficcult).
2. There willl be unnecessary pow wer loss across the reesistor.

ic
Noow “By adjjusting the duty cyclee of the siggnal (moduulating the width of thhe
s

Tr
pulse, hennce the 'PW
WM') i.e., the
t time fraaction for which
w it iss "on", the average poower
ic

can be vaaried, and hence
h the motor
m speeed.”
In other wordds by varyiing the dutty cycle wee are gettinng differentt values off
average voltage
v (Vaavg) acrosss the motorr resulting in differennt speeds.
t

Wee can desiggn the systeem as showwn in the following
f f
figure:
IT
bo

N
Ro

~ 29 ~ 
 
 
Now
Vavg α δ 

And

p
DC Motor Speed α Vavg 

ho
Thus

DC Motor Speed α δ 

ks
Advantages of PWM:
1. Here the switch is either on or off unlike normal regulation(using variable

or
resistance), so less power is wasted as heat and smaller heat-sinks can be
used.

hy
2. Since no resistor is used, there is no power loss.
W
3. Can be easily automated by programmable control.
Disadvantages:

ic
1. We require extra circuitry to implement PWM (in AVR we have in built
s

PWM-circuitry on chip).
Tr
2. Some authorities claim the pulsed power puts more stress on the DC motor
ic

bearings and windings, shortening its life.
Implementation of PWM:
t
IT

For developing PWM, we require two properties:
bo

1. Time Period (T)
2. On-Time Period (Ton)

Implementation of PWM in microcontroller:
N
Ro

In microcontroller we use clock of several Mega Hz. Thus time of one clock

Tclk =1/(clock frequency)
E.g. In ATmega 8 clock frequency is approximately 1 Mega Hz.

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

~ 30 ~ 
 
 
For impleementation
n of PWM in microcoontroller we
w require these
t variaables:
™ Nt= = Number of clock cycles
c for one
o time peeriod of PW
WM
Nt==T/Tclk
™ OC
CR= Numb
ber of clocck cycles foor On Timee of PWM

p
OCR R= Ton/T Tclk

ho
™ Ni== It is a ind
dex of couunter, that counts
c from
m Nt to zerro and Zeroo to Nt in each
e
cyccle.

When if
i Ni ≥ OCR
O th
hen PW
WM Outp
put=Loww

ks
And iff Ni < OCR
O th
hen PWM
M Outp
put=Higgh

or

hy
W

ic
s

Tr
t ic
IT
bo

N
Ro

~ 31 ~