Professional Documents
Culture Documents
"Ultrasonic Range Finder Using 8051 Controller": Mahatma Gandhi Mission'S
"Ultrasonic Range Finder Using 8051 Controller": Mahatma Gandhi Mission'S
RANGE
FINDER USING 8051 CONTROLLER
Project Report Presented By:
SR.NO
NAME
NO
1.
2.
3.
4.
NEERAJ KUMAR
RITU KUMARI
SURAJ MALVE
ANAMIKA MANE
ROLL
32
CERTIFICATE
This is to certify that the project ULTRASONIC
RANGE FINDER USING 8051 CONTROLLER is a
work carried out by Mr.NEERAJ KUMAR,
Miss.RITU
KUMARI,
Mr.SURAJ
MANE,
Miss.ANAMIKA MANE from the department of
Electronics and Telecommunication [T.E.] and have
successfully completed the project and its report in
partial fulfillment of the term work for the subject
Electronic Hardware Workshop in MGMs College of
Engineering and Technology, Kamothe.
___________________
Signature of the Guide
__________________
Signature of H.O.D.
______________
Examiner
ABSTRACT
The report details the implementation of distance measurement system using the
ultrasonic waves. As the human ears audible perception range is 20 Hz to 40
kHz, it is insensitive to ultrasonic waves, and hence the ultrasound waves can be
used for applications in industries/vehicles without hindering human activity.
They are widely used as range meters and proximity detectors in industries also
it can be used in parking assistance system. The distance can be measured using
pulse echo and phase measurement method. Here the pulse echo methods used.
The measurement unit uses a continuous signal in the transmission frequency
range of ultrasonic transducers. The signal is transmitted by an ultrasonic
transducer, reflected by an obstacle and received by another transducer where
the signal is detected. The time delay of the transmitted and the received signal
corresponds to the distance between the system and the obstacle.
TABLE OF CONTENTS
CHAPTER NO.
1.
TITLE
PAGE NO.
ABSTRACT
iii
LIST OF FIGURES
vi
INTRODUCTION
1.1
OBJECTIVE
1.2
1.3
2
4
RANGE FINDER
1.4 THEORY OF OPERATION
1.5
1.6
2
ULTRASONIC WAVES
1.5.1 LONGITUDINAL WAVES
CIRCUIT DESCRIPTION
11
12
SOFTWARE
14
14
20
CONCLUSION
23
4.1 APPLICATION
24
APPENDICES
25
APPENDIX-A
25
APPENDIX-B
27
APPENDIX-C
28
APPENDIX-D
31
APPENDIX-E
REFERENCES
49
LIST OF FIGURES
1.
2.
3.
4.
5.
11
6.
13
7.
25
8.
25
9.
29
10
29
11.
35
12.
36
13.
38
38
42
42
14.
15.
16.
43
45
1 INTRODUCTION
2
measurement is subject to
high
of
signal
levels
distance range.
4
5 1.1 OBJECTIVE
taken
to
the
measured
bulky
compact
intelligent
is it needs to be perpendicular
medium
for
and
the
the
pulse
distance
object
position
is
electronically
by
circuits
with
circuits
the
using
Microcontroller.
ultrasonic
receiver
transmitter sensors.
&
amplifier
Ca4M4VI
iM324I
four
inverter
T-segment
FINDER
10
The
measure
distance
without
ultrasonic
transmitter-
Ultrasonic
distance
zinc
measurement.
Ultrasonic
generators
or
lead
use
zirconium
transducers
resonant
frequency
mounted
and
side
ambient
and
shows it on a 7-segment
measurement
medium.
application,
temperature
the
required
for
receiver),
ULN2003,
of
it.
excited
The
in
The
when
by
medical
the
velocity
air
of
temperature.
12 In this project, you excite
(one
transmitter and
current
buffer
operational
expect
an
echo
from the
lasts
of
It
picked
for
approximately
up
ultrasonic
period
0.5
by
ms.
another
unit
tuned
unit.
transducer
The
received
13
ULTRASONIC
FINDER
should
have
level
higher
pulse
excitation
15
16
RANGE
17
29
30 1.5 ULTRASONIC WAVES
31
32 Sound waves with frequency
range from 20 Hz to 20 KHz
23
are
termed
as
means
for
the
measurement of distance of
the target and for different
other applications Ultrasonic
distance sensors are used to
detect the presence of flaw by
measuring the distance. They
do so by evaluating the echo
of a transmitted pulse with
concern to its travel time.
Time dependent control of
sensitivity
is
used
to
distance
compensate
the
dependency
of
amplitude,
while
reflection
properties
the
echo
different
different
resolution.
Such
are
automation
of
industrial
compensated by an automatic
average
echo
amplitude
to
constant.
Echo
amplitude
therefore
has
whether
car
little
the
measurement
conveyor
distance
very
monitor,
belts.
Ultrasonic
35
36 1.5.1 LONGITUDINAL
WAVES
37 Longitudinal
waves
exist
and
relevant
objects
are
presence
different
of
ultrasonic
sensors
the
33
34 A
of
with
operation
38
47
39 1.5.2 TRANSVERSE
WAVES
40 In this case particles of the
medium vibrate at right angle
is
an
ultrasonic
picks
measures
up
the
its
time
echo,
elapsed
is
modulated
measured
proportional
time
to
by
the
which
is
the
distance.
46
49
50 The supporting circuits fabricated
on the module makes it almost
stand alone and what the
programmer need to do is to send
a trigger signal to it for initiating
transmission and receive the echo
signal from it for distance
calculation. The HR-SR04 has
four pins namely Vcc, Trigger,
Echo, GND and they are
explained in detail below.
51 1) VCC : 5V DC supply voltage is
connected to this pin.
52 2) Trigger: The trigger signal for
starting the transmission is given
to this pin. The trigger signal
must be a pulse with 10uS high
time. When the module receives a
valid trigger signal it issues 8
pulses of 40KHz ultrasonic sound
from the transmitter. The echo of
this sound is picked by the
receiver.
53 3)Echo: At this pin, the module
outputs a waveform with high
time proportional to the distance.
54 4) GND: Ground is connected to
this pin.
55 CIRCUIT
DESCRIPTION
58
56
57 A simple ultrasonic range
finder
using
8051
microcontroller is presented in
this article. This ultrasonic
rangefinder
can
measure
ultrasonic
transducer
signal,
necessary
displays
performs
processing
the
and
corresponding
like
parking
sensors,
warning
automotive
systems,
obstacle
terrain
59
62
60
interfaced
to
the
button
switch
S1,
63
64 2.1 POWER SUPPLY
7805
provide
71
72 2.2
CONSTRUCTION
AND TESTING
73 An
actual-size,
single-side
Capacitors C5 bypass
the
ripples
the
supply.
microcontroller
regulated
present
power
in
into
the
supply
and
microcontroller automatically
getting
reset
upon
of
normal
mode.
the
oscilloscope
labeled
cross-assembler. It is well
commented
alternately
the
non-inverting
AT89C2051s
positive
terminal
of
comparator.
The
and
for
easy
to
12.5
negative
connected
preset
enable
to
detection
of
weak
74
this
time,
it
is
Thus,
the
by
changing
this
75
76
78
with
80
suitable
additional
79 3. SOFTWARE
81 The software is written in
Assembly
language
and
It
is
commented
and
easy
well
to
for
12.5
this
time,
it
is
Thus,
the
ASSEMBLY
LANGUAGE PROGRAM
84 PROGRAM :
85
ORG 00H
MOV DPTR,#SSDisplay //
moves the address of LUT to
DPTR
87 MOV P1,#00000000B // sets P1
as output port
88 MOV P0,#00000000B // sets P0
as output port
89 CLR P3.0 // sets P3.0 as output
for sending trigger
90 SETB P3.1 // sets P3.1 as input
for receiving echo
91 MOV TMOD,#00100000B //
sets timer1 as mode 2 auto
reload timer
92 MAIN: MOV TL1,#210D // loads
the initial value to start counting
from
93
MOV TH1,#210D // loads
the reload value
94
MOV A,#00000000B //
clears accumulator
95
SETB P3.0 // starts the
trigger pulse
96
ACALL DELAY1 // gives
10uS width for the trigger pulse
97
CLR P3.0 // ends the
trigger pulse
98 HERE: JNB P3.1,HERE // loops
here until echo is received
99 BACK: SETB TR1 // starts the
timer1
100 HERE1: JNB TF1,HERE1 //
loops here until timer overflows
(ie;48 count)
101
CLR TR1 // stops the
timer
102
CLR TF1 // clears timer
flag 1
103
INC A // increments A
for every timer1 overflow
104
JB P3.1,BACK // jumps
to BACK if echo is still available
105
MOV R4,A // saves the
value of A to R4
106
ACALL DLOOP // calls
the display loop
107
SJMP MAIN // jumps to
MAIN loop
86
108
109 DELAY1:
delay
110 LOOP1:
DJNZ R6,LOOP1
111
RET
112
113 DLOOP:
141
142 DELAY:
MOV R7,#250D //
1mS delay
143 LABEL2: DJNZ R7,LABEL2
144
RET
145
146 DISPLAY:
MOVC
A,@A+DPTR // gets the digit
drive pattern for the content in A
147
RET
148
149 SSDisplay:
DB 0C0H // Hex
code to display DISPLAY 0
150 DB 0F9H // DISPLAY 1
151 DB 0A4H // DISPLAY 2
152 DB 0B0H // DISPLAY 3
153 DB 99H // DISPLAY 4
154 DB 92H // DISPLAY 5
155 DB 82H // DISPLAY 6
156 DB 0F8H // DISPLAY 7
157 DB 80H // DISPLAY 8
158 DB 90H // DISPLAY 9
159
160 END
161
162
163
164
Simply by changing
171
4.CONCLUSION
165
166
Distance Measurement
device. As described in this
report a system is developed
that can detect objects and
calculate the distance of the
tracked object. With respect to
the requirements for an
ultrasonic range finder the
following can be concluded.
range.
The system can calculate the
distance of the obstruction
with
167
168
sufficient accuracy.
used as a secondary
device.
170
This offers a
implement an Ultrasonic
Obstruction Detection and
distance
measurements.
173
motion
production
ultrasonic
relates
detector
in
lines.
The
detection
range
with
size,
figure,
The
bigger
the
distance
is
an
various
circumstances
and
one.
ambient
conditions.
restricted
target
angle
(it
and
which
can
large
beam,
create
poor
Finders
only
area
limitation
and
in
distance
distance
ultrasonic
measurement.
4.1 APPLICATIONS
181
In industry ultrasonic is
1) Flow detection,
184
2) Thickness gauging,
185
3) Measurement of
Applications of
186
4) Extent of corrosion
187
5) Estimation of grain
two categories.
178
1. Ultrasonics in
industry
179
2. Ultrasonics in
medicine
180
sizes in polycrystalline
materials.
188
6) Measurement of
pressure, concentration
temperature, viscosity and
flow rates.
189
7) leak detection
190
192
APPENDIX A
230
193
SEMICONDUCTORS
.No.
233
:
195
NOTATTION
196
198
IC1
199
201
IC2
204
Ultrasonic
module
207
T1,T2,T3
210
DIS1-DIS4- LTS
1.
236
2
COMPONENT
231
Notation
232
234
C1, C2
235
237
C4, C5
238
240
C3
241
No.
239
AT89S52
.
microcontroller
243
202
7805, 5V242
regulator
245
246
248
249
205
HC-SR04
251
252
Table 3: Capacitors
253
208
2N2222 npn
254
MISCELLANEOUS
transistor
255
211
common-anode,
7-
256
S
segment display
Table 1: Semiconductor
.No.
Components
259
213
1.
RESISTORS (all -
542
212
214
257
Notation
258
260
X1
261
to
262
watt, 5% carbon):
215
.No.
218
1.
216
Notation
219
266
224
.
227
228
225
269
XTAL
267
S1
268
270
S2
271
273
TX1
274
RX1
tra
277
R13
.
275
Table 2: Resistors
6
.
278
CAPACITORS
264
272
sec
265
221
229
263
ele
244
247
250
276
rec
279
Table 4: Miscellaneous
280
281
APPENDIX-B
282
PCB
LAYOUT
287
APPENDIX- C
288
RESISTANCE
289
290
291
The electrical
DESIGN
resistance
283
circuit component or
of
device is defined as
the
ratio
of
the
voltage applied to
the electric current
which flows through
it:
292
293
284
285
If the resistance is
constant
over
considerable
of
range
voltage,
then
be
used
to
the
material.
Although
the
definition
above
involves DC current
286
and
same
voltage,
the
definition
294
application
of
resistors.
Whether or
not
297
is
temperature
Over
sizable
predicted
temperature
from
coefficient
of
resistance. \
295
299
The
factor
in
the
RESISTIVITY
AND CONDUCTIVITY
296
298
given geometry.
300
The
inverse
of
resistivity
conductivity.
conductivity
convenient.
is
called
There
is
are
more
upon
these
properties is a straightforward
one for a wide range of
301
Electrical conductivity
= = 1/
302
dependence
RESISTOR
these
properties is a straightforward
COMBINATIONS
303
upon
307
308
304
Resistance = resistivity
x length/area
305
RESISTIVITY
CALCULATION
306
made
Experimentally,
(resistivity).
the
309
APPENDIX-D
310
CAPACITOR
A capacitor consists of
potential difference V = Ed
simple
capacitor.
311
312
electric
field
creates
parallel-plate
by an insulator or dielectric.
The charge is stored at the
surface of the plates, at the
boundary with the dielectric.
Because each plate stores an
equal but opposite charge, the
316
317
always zero.
318
toward
the
process
creates
an
313
314
Figure 9: Capacitor
charge formation
315
annuls
the
field
319
Capacitance
320
conducting)
substance
that
The capacitor's
323
Stored energy
324
As
opposite
charges
In SI units, a capacitor
usually
required
321
expressed
in
to
establish
the
and
therefore
the
electric
The
capacitance
is
given by:
distance
between
the
(that
is,
non-
325
326
327
In electric circuits
328
Circuits
with
DC
sources
329
Electrons
directly
cannot
pass
across
current
all
times
the
electric
accumulation
charge.
of
This
field
to
develop
giving
rise
to
is
the
mathematically as:
the
is
through
330
capacitor
directly
331
332
where
I is the current flowing
dV/dt
is
derivative
the
of
time
voltage,
C is the capacitance in
farads
335
For
circuits
with
voltage
across
the
336
Series
or
parallel
arrangements
337
Capacitors in a parallel
large
resistor
might
connected
same
difference
individual ratings.
potential
343
338
across
be
each
Capacitor/inductor
duality
344
In mathematical terms,
339
340
The
current
voltage-current equations of
through
capacitor
can
be
the
two
devices
can
be
inductors
can
be
coupled
to
of
two
342
348
unit time.
349
350
345
Capacitor symbols
10
11
12
13
14
15
346
351
352
353
354
355
356
357
358
359
360
361
362
APPENDIX-E
363
364
DATASHEET -IC
89C2051
365
366
FEATURES
Compatible with MCS-51
Products
2 Kbytes of Reprogrammable
Flash Memory
367
Endurance: 1,000
Write/Erase Cycles
2.7 V to 6 V Operating Range
Fully Static Operation: 0 Hz
to 24 MHz
Two-Level Program Memory
347
Lock
128 x 8-Bit Internal RAM
15 Programmable I/O Lines
Two 16-Bit Timer/Counters
Six Interrupt Sources
Channel
Direct LED Drive Outputs
On-Chip Analog Comparator
Low Power Idle and Power
Down Modes
interrupt
368
369
370
371
DESCRIPTION
The AT89C2051 is a
high-
and
8-bit
operation
(PEROM).
software
low-voltage,
performance
CMOS
The
device
is
clock
circuitry.
down
to
selectable
In
zero
power
high
density
nonvolatile
the
serial
system
Mode
contents
powerful
which
microcomputer
provides
highly
applications.
AT89C2051
provides
The
the
RAM,
timer/counters,
port
and
to
saves
but
interrupt
continue
the
freezes
hardware reset.
372
373
PIN
CONFIGURATION
RAM
the
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
400
Pin Description
404
405
406
407
408
409
410
411
412
413
VCC
Supply voltage.
GND
Ground.
PORT 1
Port 1 is
an
8-bit
will
source
current
(IIL)
416
used
as
inputs
and
are
source
because
of
current
the
listed below:
(IIL)
417
internal
data
programming
during
and
Flash
program
verification.
414
415
P3.5,
418
PORT 3
Port 3 pins P3.0 to
P3.7
are
seven
420
Table 5: Port 3
Functions
419
Port 3 also receives
and
programming verification.
421
RST
422
XTAL1
424
circuit.
425
XTAL2
426
Output
pF,
from
the
10
pF
for
Ceramic
Resonators
431
432
427
428
OSCILLATOR
CHARACTERISTICS
429
430
the
and
output,
(a)
respectively, of an inverting
amplifier
which
can
be
(b)
433
Figure13:
(a) Oscillator Connections,
434
(b)
External Clock Drive
Configuration
435
436
PROGRAM
MEMORY LOCK BITS
437
438
439
440
On-chip
hardware
Table 6: Program
Memory Lock Bits
the
port
pins
is
not
442
possibility of an unexpected
443
IDLE MODE
444
functions
registers
POWER
DOWN
MODE
447
the
instruction
that
hardware
reset.
Reset
erased electrically.
453
activated
before
454
restored
to
VCC
its
is
normal
INTERNAL
AT89C2051
internal
should be set to 0 if no
are used.
455
448
PROGRAMMING
THE FLASH
The
AT89C2051
is
PEROM
code
address
PROGRAMMING
456
450
452
PEROM
an
ALGORITHM:
449
451
contains
Once
the
array
isprogrammed, to re-program
457
The first part of the
program
sets
the
initial
conditions. Port 0 and P0rt 1 are
set as output ports for sending
digit drive patterns and digit
drive signals respectively. Port
pin 3.0 is set as an output pin for
sending the trigger signal to the
ultrasonic module for starting
transmission and port pin 3.1 is
set as an input pin for receiving
the echo. TMOD register of the
microcontroller is so loaded that
the Timer 1 operates in mode2 8
bit auto-reload mode. Timer 0 of
the microcontroller is not used
here. In the next part of the
458
Notes.
459
1) The LUT used here was
originally made for a common
cathode seven segment display
and here we are using common
anode displays. The CPL A
instruction will just complement
the obtained digit drive pattern
and make is suitable for the
common anode scheme. If you
have time ,then cook up an LUT
for common anode scheme and
replace the current one using it.
By this you can avoid the extra
CPL A instruction and it is the
correct method.
460
2)The entire circuit can be
powered from 5V DC.
4613) Be careful while handling the
Ultrasonic module. There are a
lot of sensitive surface mount
devices fabricated on its back
side.
462
4)Go
through
these
articles: Interfacing
seven
segment display to 8051, Delay
using 8051 timer, Software delay
routines using 8051.
463
464
READY/BUSY:
The
High
programming
during
to
indicate
PROGRAM VERIFY:
AT89C2051
features
Data
469
470
471
2.
Apply
the
478
479
READING
THE
472
address counter.
473
PROGRAMMING
are enabled.
476
477
CHIP ERASE:
The
(2
appropriate combination of
are
entire
PEROM
erased
array
electrically
by
and
completion.All
481
482
once
initiated,
will
major
483
FLASH
490
PROGRAMMING MODES
484
485
486
(a)
Table 7: Flash
Programming Modes
487
488
489
(b)
491
492
(b)Verifying the
499
Flash Memory
493
494
500
506
Table 8:Flash
MAXIMUM POWER
497
VERIFICATION
WAVEFORMS
498
RATING
507
FLASH
PROGRAMMING
ABSOLUTE
508
AND
509
Table 8: Absolute
519
EXTERNAL CLOCK
DRIVE WAVEFORM
510
511
520
DC
CHARACTERSTICS
512
513
521
522
523
EXTERNAL CLOCK
DRIVE
524
525
514
Table 9: DC
526
Characterstics
515
516
517
518
527
528
REFERENCES
529
1)
Electronics
for
530
2)
536
Gadre,
www.electronicsforu.com
www.scribd.com/doc/7370615
538
Programming
and
537
Controller.
8)
Materials.
4)
539
533
V.
Ultrasonic
/Ultrasonic-Distance-Meter
532
Dhananjay
3)
531
7)
9)
David
A.
Bell,
www.atmel.com/atmel/acrob
Electronic
at/doc0368.pdf
5)
Press, 2008.
8051
Microcontroller
540
10)
Devices
and
Sensors
&
6)
Mazidi,
542
Muhammad Ali
Janice
&
Gillispie
Pearson Education.
11)
Alan
Systems,
Andrews,
Barker Limited,
543
Microcontroller
Embedded
49-57
541
544
545
London, 1961.