Professional Documents
Culture Documents
Microcontroller Based
MUDIT AGARWAL
EM TESTED
EM TESTED
Ultrasonic Range Meter EM TES
TED
MUDIT AGARWAL
Contact-less distance measurement can be done in Memory (RAM),Up to 256 x 8 bytes of EEPROM
many ways. For electrically conductive metal Data Memory.
objects, the eddy current method is an option, and
capacitive sensors that are independent of the LCD Display
metal used in the measured objects can be used. LCD is used for user interaction with the system,
Some products uses infrared light emitters and 16*2 LCD display based on Hitachi HD 44780
receivers that determine object distance by controller. LCD is interfaced to microcontroller by
implementing the optical triangulation method. using four Data lines D7, D6, D5, D4 and control
Other devices have laser-based systems that signals RS, R/W and En.
increase accuracy and precision. I decided to use
ultrasonic waves. My ultrasonic RangeFinder
measures the amount of time it takes for a pulse of Power Source
sound to travel to a particular surface and return. 5V Regulated power supply is required for
Then, the device calculates the distance based on microcontroller, LCD. Ultrasonic sensor is driven by
the estimated speed of sound. +12V DC.
The RangeFinder has numerous applications. You
can use it for the positioning of robots as well as Ultrasonic Transducer
measuring generic distances, liquid levels in tanks, 40KHZ Ultrasonic sensors are used here.
and the depth of snow banks. The device can also
serve as a motion detector in production lines where
surfaces must not be damaged. The RangeFinder
Circuit Description
has a 40-kHz operating frequency, a range of 25 to The PIC Range Finder works by transmitting a short
400 cm. We have tested for a range of 300 cms. pulse of sound at a frequency inaudible to the ear
(ultrasonic sound or ultrasound). Afterwards the
microcontroller listens for an echo. Block Diagram
Microcontroller is shown in fig. 1. The time from transmission to
The PIC 16F877A has 40 pins Operating speed: echo reception lets you calculate the distance from
DC to 20 MHz clock input, Up to 8K x 14 words of the object.
Flash Program Memory, Up to 368 x 8 bytes of Data The time from transmission of the pulse to reception
of the echo is the time taken for the sound energy to
LCD
travel through the air to the object and back again.
Since the speed of sound is constant through air
measuring the echo reflection time lets you
calculate the distance to the object using the
T following equation
TX
A
R
Distance = (Speed X Time Taken )/2
G PIC Microcontroller You need to divide by 2 as the distance is the round
E
T RX trip distance i.e. from transmitter to object and back
again. You can get ultrasonic transducers optimized
Ultrasonic Reflected
Rays for 25kHz, 32kHz, 40kHz or wide bandwidth
Fig. 1 : Block Diagram of Ultrasonic Range Meter
transducers. This project uses a 40kHz transducer.
CONSTRUCTION
Ultrasonicrangmtr 15
09498US 151.755CM VA
C7
PR1
11
VDD
32 RB7
40
VDD 39 C8
RB6 +
38 RX
Rb5
37
R1 RB4
35 R2
RB2
1 RB1
34
MCLR 33
RB0
R3
S1 Ic4
C5 17
13 3 2 9 10
Ic3
XTAL
5 +
4 11 12 TX
14
7
12 6 14 8 15
C6 GND 1
31 GND
C10 R6 R5 C9 R4
3
R7 -
7 6 2
IC5 1
5 3
8 +
4
R8 R9
D2 D1 IC1 IC2
1 3 1 3
230V 2 2
A.C.
D3 D4 C1
C2 C3 C4
The 40KHZ signal is easily generated by the PWM output has a time base (period) and a time
microcontroller but detection requires a sensitive that the output stays high (duty cycle). The
amplifier. To generate 40KHZ signal for Ultrasonic frequency of the PWM is the inverse of the period
transmitter circuit uses PWM module of the (1/period). The PWM period is specified by writing
microcontroller. In Pulse Width Modulation mode, to the PR2 register. The PWM period can be
the CCPx pin produces up to a 10-bit resolution calculated using the following formula:
PWM output. Since the CCP1 pin is multiplexed PWM Period = [(PR2) + 1] X 4 X TOSC X (TMR2
with the PORTC data latch, the TRISC<2> bit must Prescale Value)
be cleared to make the CCP1 pin an output. A When TMR2 is equal to PR2, the following three
CONSTRUCTION
R2
RX- to T2CON.
1
5. Configure the CCP1
R3
8 9 C9
R4
RST module for PWM operation.
XTAL
On the receiver side ultrasonic
R5
C5 C6 Receiver transducer receive the
R6
1 reflected signal, this signal is
IC5 amplified via operational
D2 D1 C3 C4 amplifier LM358 and finally
C1 C2 IC1
C10
INTCON.GIE = 1 ; RESISTORS
R1 4.7K
INTCON.PEIE = 1 ; R2,R4,R7 100K
PIE1.TMR1IE = 0 ; R3,R5,R8,R9 10K
R6 330K
PIR1.TMR1IF = 0 ; Preset PR 1 2K
for(;;) MISCELLANEOUS
{ TXFR 12 volt/500 Ampere
XTAL 4 MHZ
LCD 16 x 2 Liquid Crystal display
TX 40KHZ Ultrasonic Transmitter
RX 40KHZ Ultrasonic Receiver
For rest of the code, S1 Push to ON switches
E-mail at : info@electronicsmaker.com