Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

EE 351: MOpULE 03:-KEEP YoUR DIsTANCE

GaROUP I - Tuesday Tem No -L.

Prachi Sinha olD 063


Hordik Rongla. -RI0l 02044
Kauotubh Kummah 010 2044
Kis ham Kuman
-Q10l0204
DBSECTIVE
duigr ltha-
an autonomous obbtacle detectibn
ayotem oing bonic bnsos bch that
bot takuo a trn aond whn it
he
encounts an
obotale
COM PD NENTS USED
* Andutno Wo R3 * Servo Moto
* L293D Motor oivu Module
* He-SRO4 lthasorie Sndor
* DC motoLs * Breadboard
*
Connucting wie * Fnaiook
CLRCUIT DIAGRAM

R3
Andino
Uno
Vec Owt out 2
LNI
T6 5V D2 IN2
Fand ENABLEI
Gnnd ENABLE 2
INI
Uut 3 out4 GnND
Ao
ulthaDoni A2 (3)
Senso A4
As

Moto

Servo
Noto

BLDCKDIAGRAM

Snput Contholer
Output
Uthasonic An dino
Shvo Motor +
Senso. wiu dueide Dc Moto
Reaoo the is tan ce
wht to d
btw bt Dbstalle aceo nding to diotaned ithl
Servo 2 De both
howCHART
(START Iriaisig
Reacding distanee
nom. he Senson
Mo No
islante
torwad
YES

Stop the
motos

Jurn snsor gh
4 head disace

J n sunbor to
nonal positton

YES Distance
Rinht uost. Jwnn lalt
4t
blay soD ms bulay s0om
DBSERVATION S
Jhe bot wota even on giving sv to he.
moto dhive,but the speed o motors
blowr
ompard to when l2 v was given. Aso,
1Ohen neounted with moviry obbtacle , it
not b able to mavig
avoid it as it oould h
may
Come voy an to the obstacle by the tim it
takeo a t n thetoe wil collide
ANSWERs To &vEs TI DN S
the block
diagamit
implumntt d hen. tue myou have
LooP sysern?
Jnput Contnolw Ouput
masone (Anduino) Senvo Mo ton ano
Sendo De Moto

Jee systm implmented he opin


Loop systm. Jis s buause we ae not
taking any fudback brom the lomponents sovo
moton and / o oto
De M to utn contol tha

Syoiem.hom input, e contol the movement


tu motohs and -twtore th bot.
How do you compute distance inon tu data
obtaind 7nom
Jhe wLt haoonic nso ho to tund out dstane
O cauating the amount ol ime takn to tnanomit
an d ecei ve the
signal
wnen pula is givn to the trigg
Pun toton JOus witnthe help Dl An dino, the
uthaooe waves will b gemated wich wlw
thave sitn at the peed o dond. JI thure il be
objet, gut alcted back to
dnso h which oiu be oletetd and
activate the ccho pin .
Jis drat on wil bee
and tue dist.
measwed
ud woina pulo Inl) fomcton
wil be caleulated witn spud
o sound
YSane nuou]
Ohy d'd not con nct motos M! 4 M2 to
An duimo pino a
and Switehed then on 4

cwnt rom ancuno won'+ be


i) Enough curmt
Supplied to un DC Motos. Low pown]
ü) Chames D bttt damaging Anduino due
to exuive con bumption o< De motos
.

Hee, 5V buppy o Anduino is


40mA D Cuent wheas
Capabl o buppig ondy
De oto totd requihes minimum ol 200o mA to
Cwret s ued, Anduino
buch hgh
nd its pins mignt damage
9t Coutd we have wbed wN222 DA BC 544 tnanisto
to çve moton ta1?
Jhe dsiver we usd
moton dhiver has in ternal tranoito
too. So, w Can se BJT to die the motor
moton
openaing voltag, cuent and poue o
is witnin the o purating imit BUT.
Jhe moton we e wsing has
opuating power in the nanye o.325 - 1-32 Ww and
opuaing vo ltege in nange as- 6v . Jhis natirgs
mone tan te oprating ini ts o BJT. Hene uie
wbn't be ob le tD wae bingle N 222 2
drive te motoh. loing muldi ple Lanaitor Can
wiu
dolve the problen but compluxity o ceuik inneaoe
Jus ttansi stos wil be opUated
as Swithes sD Lse Wse t thanoito
for ach moton
wih oill help in bridg
onltoig
diecion ol motor moennt.
the
So, ultiple tanoisto Suoitchs
oncomplix ut cam be ud to imp mnt.
Jhamistos
5. Could we howe w
as Swi
the L93D mooe to ire
moton HI to implmnt tue objeetives
L293D module can be usd to dive moto
and im plement the objectives LL293D has intunal
Lnansis tors connuted Sueh that it provi des
emogh
Powe and cuhent to dive the moton
smoothly.
Also, chamge in inpub to this modude Chigh on lo
chango oieeti orn o moto Hotati on. Jhu
otator D notos Can aloo be
contolled uoing tis
dto modute i the in put aimsteadig in given
in tom ol PwM sigrals nstad.

36 Explaim the wonkig of te cineuib


drivig the
the mots

’ He to dive the motDs, wt e wsing L293D dive


Jhis io
is a H- bhidge dver that can dhi moto in
bof oi huctions ie tonward t backuo and. on tçs,
4 thanoistos p hhsnt which aets as soitches
e
and thse tnanis tors are in H- shapo
Such that for hevehsing the dietion the polaitieo
ternaly Moton Po usu(t)
Hee wn S, & SA switchs
au closed tve vo Ltage is
be appied aoss the motor.
Also, whin these tuwo are
etos and ot r tw are
ept losed vo ltage oiu S
be app icd crosS5 tue mmoto
thu d eionn.
Moton Gi ound(
al
Dthr
Dn
opuning s
witehes,
ombinaton ahe invalo
the
Dwch
motoh oiU be
can ei the
tiu
btuneat
Hhe moton shot t cineit.

Hos dic gou i minate chabering tect? S gou M


ven u dorn oth bome
contoler
otur than ON- oFF contholrs wweh wOi
s Judueeol ?
Justily youn amowen.
Jhe chatuing 4feet in te systm w
old be
Causd de to apid switehing
Swithing betwun
betun hgh and
lou ales un ON - DFF onth. J s can hap pen
due to teact i w we made design to mone backwardo
to tx ois tanc to tun or elscL foh
ud. Loually
avoid it by giving hange in Lode oh
lont o ler
by woing PID
instead.
PID ontos could b used instea d
ON - DFf
cort oles to iminat
chatening tet.
Juy provide tine
adjustment to systm oeh uotu
duee napid sitehing ta that wa tound in
ON- OFP ontnole tus
minimi zmg chatteing eet
Jhe integhal t
to deivatve parts o contho eA help
maintain
to vad State stability tue system and bring
mini mi si
Adustment in PID
micing chatHuimg.
to ache've desi hed Ptonmanewntho
and
wil help uo
eduee
hatte.
CONC LvsIDN
Chuated an auto nomos
obbtacle duteeti on ystm that moves tON wand
Un il an
obbtacle duteeted in distanc ol JS
cm
wun obstacle is do ecteod it checks lalt and
and tuhs and sght
movs
aceording
CODE FOR THE BoT

#include<Servo.h>
1 Servo
Servo servo;
const int servoPin = 3;

1/ HC-sRO4
const int triggerPin = 13;
const int echoPin = 12;

1/Moto A
const int motorPin1 = 5; // Pin 14 of L293
const int motorPin2 = 6; 1/ Pin 10 of L293
1/Motor B
const int motorPin3 = 10; 1/ Pin 7 of L293
const int motorPin4 = 9; 1/ Pin 2 of L293

void setup () {
/Ultrasonic sensor
pinMode (triggerPin, OUTPUT);
pinMode (echoPin, INPUT) ;
Serial.begin (9600) ;

& Motor B:
1/Motor Control - Motor A: notorPinl , notorpin2
notorpin3, motorpin4
pinMode (motorPinl, OUTPUT);
pinMode (motorPin2, OUTPUT) :
pinMode (motorPin3, OUTPUT);
pinMode(motorPin4, OUTPUT) ;

i/Servo Control - Norma l positi on at angle 47 degrees


pinMode (servoPin, oUTPUT) ;
servo. attach (servoPin) ;
servo.write (47) ;

void forwa rd () {
digitalWrite (motorPinl, HIGH) ;
digitalWrite (motorPin2, LOW) ;
digitalWrite (motorPin3, HIGH) :
digitalWrite (motorPìnd, Lo);

Retuns tEe if
bool checkRight () no obstacle at ight
Riaht turn and check
servo.Write (47-30):
delay (200) :
double dR = checkDist () ;
eSt turh and
check
servo.Write
delay(200):
(47+30):
double dL checkDist ();
Nornal pos&tion
servo.Write (47) ;
delay(200):
if (dR> dL)
else return false
return true;

void turnRight () (
digitalWrite (motorPinl, HIGH) ;
digitalWrite (motorPin2, LOW) ;
digitalWrite (motorPin3, LOW):
digitalWrite
delay (500);
(motor Pin4, HIGH) ;

void turnLeft () {
digitalWrite (motorPinl, LOW) :
digitalWrite (motorPin2, HIGH) ;
digitalWrite(motorPin3, HIGH) :
digitalWrite (motorPin4, LOW) :
delay (5 00) ;

double checkDist () {
digitalWrite (triggerPin, LOW) ;
delayMicroseconds (5) ;
digitalWrite (triggerPin, HIGH) ;
delayMicroseconds (10);
digitalWrite (triggerPin, LOW) :
int duration = pulseIn (echoPin, HIGH);
double dist = (duration / 2) / 29.1;
return dist;

void loop () {
double distance = checkDist () ;
bool isObstacle = distance < 15;
if (is Obstacle) {
checkRight
The Motor stops and will check left and right with
function
digitalWrite (notor Pinl, LOW) :
digitalWrite (motorPin2, LOW);
digitalWrite (moto rPin3, LOW) ;
digitalWrite (motorPin4, LOW) ;

if (checkRight () ) turnRight ):
else turnLe ft () ;
) else forward() ;

You might also like