https://technoelectronics44.blogspot.com/
ULTRASONIC SENSOR RANGE FIND OUT, it has Implemented by using ULTRASONIC SENSOR, 8051 microcontrollers, LCD display, and a sound indicator.
Biology for Computer Engineers Course Handout.pptx
ULTRASONIC SENSOR DISTANCE CALCULATE
1. ABSTRACT
Distance measurement of an object in the path of a person, equipment, or a vehicle, stationary
or moving is used in a large number of applications such as robotic movement control, vehicle
con-trol, blind mans walking stick, medical applications, etc. Measurement using ultrasonic
sensors is one of the cheapest among various options. In this project distance measurement of
https://technoelectronics44.blogspot.com/
2. Chapter 1
INTRODUCTION
Distance measurement of an object in front or by the side of a moving entity is required in a large
number of devices. These devices may be small or large and also quite simple or complicated. Such
distance measurement systems are available. These use various kinds of sensors and sys-tems.
Low cost and accuracy as well as speed is important in most of the applications.
In this project, we have implemented such a measurement system which uses ultrasonic sensor
unit and a ATmega32 microcontroller based system. This microcontroller is easily available at
low cost. A correlation is applied to minimize the error in the measured distance. Ultrasound
sensors are very versatile in distance measurement. They are also providing the cheapest
solutions. Ultra-sound waves are useful for both the air and underwater. Ultrasonic sensors are
also quite fast for most of the common applications. In simpler system a low cost version of 8-
bit microcontroller can also be used in the system to lower the cost.
The current methods of blockage detection are based on manual visual inspection and
inspection through CCD camera based equipments. In such systems first pictures of
3. obstacle can be obtained and then they are observed and analyzed. The main limitation of
these systems are that they cannot tell you the exact distance or location of the obstacle.
4. 1.1 Problem Statement
As IR sensors distance measurement systems cannot work good in different light
conditions and also cannot work in water,hence build a low cost system to measure the
distance which will work under water and is not affected by varying light conditions.
1.2 Necessity of project
The main objective of this project is to Provide a useful system to measure the distance
which will be easy to configure and handle.
5.
6. EYE TRACKING INTERPRETATION SYSTEM
Chapter 2
LITERATURE SURVEY
Obstacle detecting sensors are one of the most basic type of sensors that electronic
hobbyists use. There are several methods to make cheap obstacle sensors. These
simple sensors are made using a IR Rx/Tx pair or Normal LED and LDR pair(this design
is most basic and is heavily affected by environment lighting conditions). These sensor
may be useful for simple requirement but they have following drawbacks :
1. Cant say anything about the real distance of obstacle.
2. Give different result for different coloured obstacles.
3. Need calibration (like setting up a variable resistor).
To solve these problems initially IR Range Finder Modules(like one made by Sharp)
were used but they have small range.
1. Sharp GP2D12 Distance Measurement Sensor has a maximum range of 80cm
2. Sharp GP2D120 Distance Measurement Sensor has a maximum range of 30cm only.
To solve all these problem we can use an Ultrasonic Range Finder Module. An Ultrasonic Range
Finder Module uses ultrasonic waves (inaudible to humans) to measure distance. These module
consist of an Ultrasonic Transmitter (Tx) that emits the ultrasonic wave, the waves after striking any
obstacle bounces back and reach the Ultrasonic Receiver (Rx). By measuring the time it take for the
whole process to complete and using simple arithmetic we can measure the distance to the
obstacle. The Ultrasonic Range Finder Modules has a wide operating range of 1cm to 400cm with
Department of Electronics and Telecomm. Engineering, MIT Academy of Engineering, Pune 3
7. EYE TRACKING INTERPRETATION SYSTEM
an accuracy of 1cm. These specifications makes it ideal for distance measurement application.
These can be used for:
1. Contact less measurement of liquid level in tanks (even 4m deep tank).
2. Radars for robot.
3. Obstacle sensing in Robotics.
4. Speed check in roads.
5. Handheld units that can be pointed on vehicles to measure their speed.
6. Fixed unit installed in check booths that can click pictures of over speeding vehicles.
The reason for using ultrasonic wave are
1. The speed of Ultra Sonic waves is 343m/s (Speed of Sound) which is not too fast for
MCUs to measure accurately. Compare this with speed of electromagnetic waves (like
light or radio waves) which is 30,00,00,000 m/s! So it takes only 20ns (nano second) to
go and bounce back from an obstacle which is 3m away! An 8051 running at
16MIPS(maximum for most 8051s) takes 62ns to execute a single instruction.
2. Ultrasonic waves travels more narrow, like a beam than normal sound wave. This property helps
the sensor detect the obstacles that are exactly in line with it only. The sensors can be rotated with
steppers or servo motors to get a ”image” of obstacle in the surrounding area (like a radar).
3. Finally the wave do not disturb any humans nearby.
Department of Electronics and Telecomm. Engineering, MIT Academy of Engineering, Pune 4
8. HARDWARE DESCRIPTION
3.1 Related work component selection
1. Ultrasonic Sensor - HC-SR04
2. At89s52
3. 16x2 LCD Display
3.2 Ultrasonic Ranging Module HC - SR04
3.2.1 Features
Ultrasonic ranging module HC - SR04 provides 2cm - 400cm non-contact measurement
function. The modules includes ultrasonic transmitters, receiver and control circuit. The
basic principle of work:
1.Using IO trigger for at least 10us high level signal
2.The module automatically sends eight 40 kHz and detect whether there is a pulse signal back.
3.IF the signal back, through high level , time of high output IO duration is the time from
sending ultrasonic to returning.
4.Test distance = (high level time velocity of sound (340M/S)/2
Figure 3.1: HC SR04
9. 3.2.2 Electrical Parameters
Fig:3.2: Electrical Parameters
3.2.3 Timing Diagram
The Timing diagram is shown below. You only need to supply a short 10uS pulse to the trigger input
to start the ranging, and then the module will send out an 8 cycle burst of ultrasound at 40 kHz and
raise its echo. The Echo is a distance object that is pulse width and the range in proportion
.You can calculate the range through the time interval between sending trigger signal
and receiving echo signal. Formula: uS / 58 = centimeters or uS / 148 =inch; or the
range = high level time * velocity (340M/S) / 2; It is advised to use over 60ms
measurement cycle, in order to prevent trigger signal to the echo signal.
10. Figure 3.3: Timing Diagram of HC SR04
3.4 LCD Display
LCD (Liquid Crystal Display) is an electronic display system. A 16x2 LCD display is a very
basic system and commonly used in various devices and circuits. LCDs are preferred over
seven seg-ments and other multi segment LEDs. The advantages of LCDs are as follows:
1. LCDs are economical.
2. They are easily programmable.
3. A number of characters can be displayed.
4. Very compact and light.
5. Low power consumption
11. Figure 3.7: 16X2 LCD Display
A 16x2 LCD means it can display 16 characters per line and 2 such lines are there. In this
LCD every character is displayed in 5x7 pixel matrix. LCD possesses two registers: Data
and Command registers. The command register stores the command instructions given to
the LCD. A command can be defined as an instruction given to LCD to do a predefined
task. For example, initializing the LCD, clearing the screen, controlling the cursor position,
controlling the display etc. The data register stores the data which is displayed on the LCD
screen. The data is the ASCII value of the character which is displayed on the LCD screen.
3.4.1 Pin Diagram
Figure 3.8: LCD Pin Diagram
12. Pin Descriptions
Figure 3.9: Pin Description of 16X2 LCD
PROGRAMMING OF LCD:
For programming the 16x2 LCD display there are three basic steps.
1. Initialization of LCD
2. Giving command for reading the given data
3. Giving command for writing data and displaying on the screen
LCD COMMANDS:
13. Figure 3.10: LCD Commands Description
At89s52
MICRO CONTROLLERS
Microprocessors vs. Microcontrollers:
• Microprocessors are single-chip CPUs used in microcomputers.
• Microcontrollers and microprocessors are different in three main aspects: hardware architecture,
applications, and instruction set features.
14. • Hardwarearchitecture: A microprocessor isa singlechip CPUwhile a microcontroller is a singleIC contains a CPU
and much of remainingcircuitry of a complete computer (e.g., RAM, ROM, serial interface,parallel interface,timer,
interrupt handling circuit).
• Applications: Microprocessors are commonly used as a CPU in computers while microcontrollers are found in
small, minimum component designs performing control oriented activities.
• Microprocessor instruction sets are processing Intensive.
• Their instructions operate on nibbles, bytes, words, or even double words.
• Addressing modes provide access to large arrays of data using pointers and offsets.
• They have instructions to set and clear individual bits and perform bit operations.
• They have instructions for input/output operations, event timing, enabling and setting priority levels for
interrupts caused by external stimuli.
• Processing power of a microcontroller is much less than a microprocessor.
Difference between 8051 and 8052:
The 8052 microcontroller is the 8051's "big brother." It is a slightly more powerful
microcontroller, sporting a number of additional features which the developer may make use of:
256 bytes of Internal RAM (compared to 128 in the standard 8051).
A third 16-bittimer, capableof a number of new operation modes and 16-bitreloads.
Additional SFRs to support the functionality offered by the third timer.
AT89S52:
Features:
• Compatiblewith MCS-51 Products
• 8K Bytes of In-System Programmable(ISP) Flash Memory
– Endurance: 1000 Write/EraseCycles
• 4.0V to 5.5V OperatingRange
• Fully Static Operation:0 Hz to 33 MHz
• Three-level ProgramMemory Lock
• 256K Internal RAM
15. • 32 Programmable I/O Lines
• 3 16-bit Timer/Counters
• Eight Interrupt Sources
• Full Duplex UART Serial Channel
• Low-power Idleand Power-down Modes
• Interrupt Recovery from Power-down Mode
• WatchdogTimer
• Dual Data Pointer
• Power-off Flag
DESCRIPTION OF MICROCONTROLLER 89S52:
The AT89S52 is a low-power, high-performance CMOS 8-bit micro controller with 8Kbytes
of in-system programmable Flash memory. The device is manufactured
Using Atmel’s high-density nonvolatile memory technology and is compatible with the
industry-standard 80C51 micro controller. The on-chip Flash allows the program memory to be
reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a
versatile 8-bit CPU with in-system programmable flash one monolithic chip; the Atmel AT89S52 is a
powerful micro controller, which provides a highly flexible and cost-effective solution to many
embedded control applications.
16.
17. The AT89S52 provides the followingstandard features: 8K bytes of Flash, 256 bytes of RAM,
32 I/O lines, Watchdog timer, two data pointers, three 16-bit timer/counters, full duplex serial port,
on-chip oscillator, and clock circuitry. In addition, the AT89S52 is designed with static logic for
perationdown to zero frequency and supports two software selectablepower saving modes. The Idle
Mode stops the CPU while allowing the RAM timer/counters, serial port, and interrupt system to
continue functioning. The Power-down mode saves the RAM contents but freezes the oscillator,
disabling all other chip functions until the next interrupt
Or hardware reset.
PIN DESCRIPTION OF MICROCONTROLLER 89S52
VCC
Supply voltage.
GND
Ground.
Port 0
Port 0 is an 8-bit open drain bi-directional I/O port. As an output port, each pin can sink eight
TTL inputs.When 1sarewritten to port 0 pins,the pins can be used as high impedance inputs. Port 0
18. can also beconfigured to be the multiplexed loworder address/data bus duringacces ses to external
program and data memory. In this mode, P0 has internal pull -ups. Port 0 also receives the code
bytes during Flash programming and outputs the code bytes during program verification. External
pull-ups are required during program verification
Port 1
Port 1 is an 8-bitbi-directional I/O portwith internal pull-ups.ThePort 1 Output buffers can sink/sourcefour
TTL inputs.When 1s are written to Port 1 pins,they are pulled high by the internal pull -ups and can beused as
inputs.In addition,P1.0 and P1.1 can be configured to be the timer/counter 2 external count input
(P1.0/T2) and the timer/counter 2 trigger input P1.1/T2EX), respectively, as shown in the following
table. Port 1 also receives the low-order address bytes during Flash programming and verification.
Port 2
Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 2 output buffers can
sink/source four TTL inputs. When 1s are written to Port 2 pins, they are pulled high by the internal
pull-ups and can be used as inputs. Port 2 emits the high-order address byte during fetches from
external program memory and during accesses to external data memory that use 16-bit addresses
(MOVX @DPTR). In this application, Port 2 uses strong internal pull -ups when emitting 1s. During
accesses to external data memory that use 8-bit addresses (MOVX @ RI), Port 2emits the contents of
the P2 Special Function Register. Port 2 also receives the high-order address bits and some control
signals during Flash programming and verification.
Port 3
Port 3 is an 8-bitbi-directional I/O portwith internal pull-ups.ThePort 3 output buffers can sink/sourcefour
TTL inputs.When 1s are writt 1s are written to Port 3 pins,they are pulled high by the internal pull -ups and can be
used as inputs.As inputs,Port 3 pins thatare externally being pulled lowwill sourcecurrent(IIL) becauseof the
pull-ups.Port3 also serves the functions of various special features of the AT89S52, as shown in the following
table.
Port 3 also receives some control signals for Flash programming
And verification.
19. RST
Reset input. A high on this pin for two machine cycles while the oscillator is running resets the
device.
ALE/PROG
Address Latch Enable(ALE) is an output pulsefor latchingthe lowbyte of the address duringaccesses to
external memory. This pin is also theprogrampulseinput (PROG) duringFlash programming.In normal operation,
ALE is emitted at a constant rate of1/6 the oscillator frequency and may be used for external timingor clocking
purposes.Note, however, that one ALE pulseis skipped duringeach access to external data Memory. If desired,
ALE operation can be disabled by setting bit0 of SFR location
8EH. With the bitset, ALE is activeonly duringa MOVX or MOVC instruction.Otherwise, the pin is
weakly pulled high.Setting the ALE-disable bithas no effect if the micro controller is in external
execution mode.
PSEN
Program Store Enable (PSEN) is the read strobe to external program memory. When the
AT89S52 is executing code from external program memory, PSEN is activated twice each machine
cycle, except that two PSEN activations are skipped during each access to external data memory.
EA/VPP
External Access Enable. EA must be strapped to GND in order to enable the device to fetch code
from external program memory locations starting at 0000H up to FFFFH.Note, however, that if lock
bit 1 is programmed, EA will be internally latched on reset. A should be strapped to VCC for internal
program executions. This pin also receives the 12-voltProgramming enables voltage (VPP) during
Flash programming.
XTAL1
Input to the inverting oscillator amplifier and input to the internal clock operating circuit.
XTAL2
20. Output from the inverting oscillator amplifier.
Oscillator Characteristics
XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier that can
be configured for use as an on-chip oscillator,as shown in Figure1. Either a quartz crystal or ceramic
resonator may be used. To drive the device from an External clock source, XTAL2 should be left
unconnected while XTAL1 is driven, as shown in Figure 2.
Figure 1. Oscillator Connections
Special Function Register (SFR) Memory: -
Special Function Registers (SFR s) are areas of memory that control specific functionality of
the 8051 processor.For example, four SFRs permit access to the 8051’s 32 input/output lines.
Another SFR allows the user to set the serial baud rate,control and access timers,and configurethe
8051’s interrupt system.
The Accumulator: The Accumulator, as its name suggests is used as a general register to
accumulatethe results of a largenumber of instructions.Itcan hold 8-bit(1-byte) valueand is the
most versatileregister.
The “R” registers: The “R” registers area set of eight registers that arenamed R0, R1. Etc up to R7.
These registers are used as auxiliary registers in many operations.
The “B” registers: The “B” register is very similar to the accumulator in the sense that it may hold
an 8-bit (1-byte) value.Two only uses the “B” register 8051 instructions:MUL AB and DIV AB.
The Data Pointer: The Data pointer (DPTR) is the 8051’s only user accessible16-bit(2Bytes)
register. The accumulator,“R” registers areall 1-Byte values.DPTR, as the name suggests,is used to
point to data. It is used by a number of commands, which allowthe 8051 to access external memory.
THE PROGRAM COUNTER AND STACK POINTER:
21. The programcounter (PC) is a 2-byte address,which tells the 8051 where the next instruction to
execute is found in memory. The stack pointer likeall registers except DPTR and PC may hold an 8-bit(1-Byte)
value
ADDRESSING MODES:
An “addressingmode” refers that you are addressinga given memory location.In summary,the
addressingmodes are as follows,with an example of each:
Each of these addressing modes provides important flexibility.
Immediate Addressing MOV A, #20 H
Direct Addressing MOV A, 30 H
Indirect Addressing MOV A, @R0
Indexed Addressing
a. External Direct MOVX A, @DPTR
b. Code In direct MOVC A, @A+DPTR
Immediate Addressing:
Immediate addressing is so named because the value to be stored in memory
immediately follows the operation code in memory. That is to say,the instruction itself dictates what
value will be stored in memory. For example, the instruction:
MOV A, #20H:
This instruction uses immediate Addressing because the accumulator will be loaded with
the value that immediately follows in this case 20(hexadecimal). Immediate addressing is very fast
since the value to be loaded is included in the instruction. However, since the value to be loaded is
fixed at compile-time it is not very flexible.
Direct Addressing:
Direct addressingis so named becausethe value to be stored in memory is obtained by
directly retrievingit from another memory location.
For example:
MOV A, 30h
This instruction will read the data out of internal RAM address 30(hexadecimal) and store it in
the Accumulator. Direct addressing is generally fast since, although the value to be loaded isn’t
included in the instruction, it is quickly accessible since it is stored in the 8051’s internal RAM. It is
also much more flexible than Immediate Addressing since the value to be loaded is whatever is
found at the given address which may variable.
22. Also it is important to note that when using direct addressing any instruction that refers to
an address between 00h and 7Fh is referring to the SFR control registers that control the 8051 micro
controller itself.
Indirect Addressing:
Indirect addressing is a very powerful addressing mode, which in many cases provides an
exceptional level of flexibility. Indirect addressing is also the only way to access the extra 128 bytes
of internal RAM found on the 8052. Indirect addressing appears as follows:
MOV A, @R0:
This instruction causes the 8051 to analyze Special Function Register (SFR) Memory:
Special Function Registers (SFRs) are areas of memory that control specific functionality of the
8051 processor. For example, four SFRs permit access to the 8051’s 32 input/output lines. Another
SFR allows the user to set the serial baud rate, control and access timers, and configure the 8051’s
interrupt system.
Timer 2 Registers:
23. Control and status bits are contained in registers T2CON and T2MOD for Timer 2 .
The register pair (RCAP2H , RCAP2L) are the Capture / Reload registers for Timer 2 in
16-bit capture mode or 16-bit auto-reload mode .
Interrupt Registers:
The individual interrupt enable bits are in the IE registe . Two priorities can be set for
each of the six interrupt sources in the IP register.
Timer 2
Timer 2 is a 16-bit Timer / Counter that can operate as either a timer or an event
counter. The type of operation is selected by bit C/T2 in
the SFR T2CON . Timer 2 has three operating Modes : capture , auto-reload ( up or down
Counting ) , and baud rate generator . The modes are selected by bits in T2CON . Timer 2
consists of two 8-bit registers , TH2 and TL2 . In the Timer function , the TL2 register
is incremented every machine cycle . Since a machine cycle consists
24. of 12 oscillator periods, the count rate is 1/12 of the oscillator frequency.In the Counter
function , the register is incremented in response to a 1-to-0 transition at its
corresponding external input pin , T2 .When the samples show a high in one cycle and a
low in the next cycle, the count is incremented . Since two machine cycles (24 Oscillator
periods ) are required to recognize 1-to-0 transition , the maximum count rate is 1 / 24 of
the oscillator frequency . To ensure that a given level is sampled at least once before
it changes , the level should be held for atleast one full machine cycle .
Capture Mode
In the capture mode , two options are selected by bit EXEN2 in T2CON . If EXEN2 = 0,
Timer 2 is a 16-bit timer or counter which upon overflow sets bit TF2 in T2CON . This
bit can then be used to generate an interrupt . If EXEN2 = 1 , Timer 2 performs the same
operation , but a 1-to-0 transition at external input T2EX also causes the current value
in TH2 and TL2 to be captured into RCAP2H and RCAP2L , respectively
Auto-reload (Up or Down Counter)
Timer 2 can be programmed to count up or down when configured in its 16-bit auto-
reload mode. This feature is invoked by the DCEN
(Down Counter Enable) bit located in the SFR T2MOD . Upon reset , the DCEN bit is set to 0 so that
timer 2 will default to count up. When DCEN is set, Timer 2 can count up or down
, depending on the value of the T2EX pin . In this mode , two options are selected by bit EXEN2 in
T2CON . If EXEN2 = 0 , Timer 2 counts up to 0FFFFH and then sets the TF2 bit upon overflow . If EXEN2 =
1 , a 16-bit
25. reload can be triggered either by an overflow or by a 1-to-0 transition at external
input T2EX.
Baud Rate Generator
Timer 2 is selected as the baud rate generator by setting TCLK and/or RCLK in
T2CON . Note that the baud rates for transmit and receive can be different if Timer 2
is used for the receiver or transmitter and Timer 1 is used for the other function .The
baud rates in Modes 1 and 3 aredetermined by Timer 2’s overflow rate according to the
following equation .
Modes 1 and 3 Baud Rates =Timer 2 Overflow Rate
16
The timer operation is different for Timer 2 when it is used as a baud rate generator
.Normally ,as a timer , it increments every machine cycle (at 1/12 the oscillator
frequency).As a baud rate generator , however, it increments every state time ( at 1/2 the
oscillator frequency ) .
Timer 0
Timer 0 functions as either a timer or event counter in four modes of operation . Timer 0 is controlled by
the four lower bits of the TMOD register and bits 0, 1, 4 and 5 of the TCON register
26. Mode 0 ( 13-bit Timer)
Mode 0 configures timer 0 as a 13-bit timer which is set up as an 8-bit
timer (TH0 register) with a modulo 32 prescaler implemented with the lower five bits
of the TL0 register . The upper three bits of TL0 register are indeterminate and should
be ignored . Prescaler overflow increments the TH0 register.
Mode 1 ( 16-bit Timer )
Mode 1 is the same as Mode 0, except that the Timer register is being run with
all 16 bits . Mode 1 configures timer 0 as a 16-bit timer with the TH0 and TL0
registers connected in cascade . The selected input increments the TL0 register .
Mode 2 (8-bit Timer with Auto-Reload)
Mode 2 configures timer 0 as an 8-bit timer ( TL0 register ) that automatically reloads
from the TH0 register . TL0 overflow sets TF0 flag in the TCON register and
reloads TL0 with the contents of TH0 , which is preset by software .
Mode 3 ( Two 8-bit Timers )Mode 3 configures timer 0 so that registers TL0 and TH0
operate as separate 8-bit timers. This mode is provided for applications requiring an
additional 8-bit timer or counter .
Timer 1
Timer 1 is identical to timer 0 , except for mode 3 , which is a hold-count
mode .
Mode 3 ( Halt )
Placing Timer 1 in mode 3 causes it to halt and hold its count . This can be
used to halt Timer 1 when TR1 run control bit is not available i.e. , when Timer 0
is in mode 3 .
Baud Rates :
The baud rate in Mode 0 is fixed. The baud rate in Mode 2 depends on the
value of bit SMOD in Special Functio Register PCON. If SMOD = 0 (which is its
value on reset), the baud rate is 1/64 the oscillator frequency . If SMOD = 1, the baud
rate is 1/32 the oscillator frequency. In the 89S52 , the baud rates in Modes 1 and 3
are determined by the Timer 1 overflow rate. In case of Timer 2 , these baud rates
can be determined by Timer 1 , or by Timer 2 , or by both (one for transmit and the
other for receive ).
TCON REGISTER :Timer/counter Control Register
28. BUZZER
A buzzer or beeper is a signaling device, usually electronic, typically used in automobiles,
household appliances such as a microwave oven, or game shows.
It most commonly consists of a number of switches or sensors connected to a control unit that
determines if and which button was pushed or a preset time has lapsed, and usually illuminates a
light on the appropriate button or control panel, and sounds a warning in the form of a
continuous or intermittent buzzing or beeping sound. Initially this device was based on an
electromechanical system which was identical to an electric bell without the metal gong . Often
these units were anchored to a wall or ceiling and used the ceiling or wall as a sounding board.
Another implementation with some AC-connected devices was to implement a circuit to make
the AC current into a noise loud enough to drive a loudspeaker and hook this circuit up to a
cheap 8-ohm speaker. Nowadays, it is more popular to use a ceramic-based piezoelectric sounder
like a Son alert which makes a high-pitched tone. Usually these were hooked up to "driver"
circuits which varied the pitch of the sound or pulsed the sound on and off.
29. In game shows it is also known as a "lockout system," because when one person
signals ("buzzes in"), all others are locked out from signaling. Several game shows have large
buzzer buttons which are identified as "plungers".
The word "buzzer" comes from the rasping noise that buzzers made when they were
electromechanical devices, operated from stepped-down AC line voltage at 50 or 60 cycles.
Other sounds commonly used to indicate that a button has been pressed are a ring or a beep.
30. SYSTEM DESCRIPTION
Description:
The block diagram mainly consist of six parts
1) Power Supply
2) Ultrasonic Sensor Unit
3) Microcontroller
4) 16X2 LCD Display
5) Object
1)Power Supply:It is a key block in the project which will be powering to the LCD,MCU
and Ultrasonic Sensor
2)Ultrasonic Sensor Unit: A good sensor according to the requirements.
3)Microcontroller: Here we are using Atmega 32 which is used for all the computations needed.
4)16X2 LCD Display:In order to display the distance measured this block is required.
5)Object:It is that thing whose distance is to be measured from the system.
32. 5.2 Flowchart
The flowchart below show for obtaining the time taken before the distance will be calculate.
Figure 5.2: Flowchart
33. Figure 5.3: Flowchart
5.3 Implementation
The technique of distance measurement using ultrasonic in air include continuous wave and
pulse echo technique. In the pulse echo method, a burst of pulses is sent through the
transmission medium and is reflected by an object kept at special distance. The time taken for
the pulse to propagate from transmitter to receiver is proportional to the distance of object. For
contact less measurement of distance, the device has to rely on the target to reflect the pulse
back to itself. The target needs to have a proper orientation that is it needs to be perpendicular
to the direction of propagation of the pulses. The amplitude of the received signal gets
significantly attenuated and is a function of nature of the medium and the distance between the
transmitter and target. The pulse echo or time-of-flight method of range measurement is subject
to high levels of signal attenuation when used in an air medium,thugs limiting its distance range.
34. 5.3.1 Ultrasonic Sensor Interface with Microcontroller
These modules are designed to be used for microcontroller based applications hence
optimized for it. The interface is a single pin called SIG (signal). The MCU is connected to
the Ultrasonic Sensor Module by a single i/o line. The steps required to read distance are :
1. Microcontroller make the i/o line output.
2. The i/o line is made low (this may be the default state of i/o pin)
3. Wait for 10uS
4. Make the i/o line high.
5. Wait for 15uS
6. Make the i/o line low
7. Wait for 20uS
8. Now make it input (by using the DDRx Register in 8051)
9. Module will keep it low. Wait till it is low, as soon as it becomes high start the timer.
10. After that wait till it is high, as soon as it becomes low copy the timer value and stop the timer.
11. Finally we have the time required for the wave to go hit the obstacle and come back
to the module.
Figure 5.4: Ultrasonic sensor interface with MCU
If the pulse width is in microseconds, the distance can be calculated by the following formula :
Distance in cm = Pulse width/58
Distance in inches = Pulse width/148
35. 5.3.2 16X2 LCD Interface with MCU
162 LCD can be interfaced with a microcontroller in 8 Bit or 4 Bit mode. These differs in how
data and commands are send to LCD. In 8 Bit mode character data (as 8 bit ASCII) and
LCD command are sent through the data lines D0 to D7. That is 8 bit data is send at a time
and data strobe is given through E of the LCD.But 4 Bit mode uses only 4 data lines D4 to
D7. In this 8 bit data is divided into two parts and are sent sequentially through the data
lines. The idea of 4 bit communication is introduced to save pins of microcontroller. 4 bit
communication is bit slower than 8 bit but this speed difference has no significance as LCDs
are slow speed devices. Thus 4 bit mode data transfer is most commonly used.
Figure 5.5: LCD interface with MCU
36. SOFTWARE IMPLEMENTATION
Keil Software
InstallingtheKeil software on a Windows PC
Insert the CD-ROMin your computer’s CD drive
On most computers, the CD will “auto run”, and you will see the Keil installation menu.
If the menu does not appear, manually double click on the Setup icon, in the root
directory: you will then see the Keil menu.
On the Keil menu, please select “Install Evaluation Software”. (You will not require a
license number to install this software).
Follow the installation instructions as they appear.
Loadingthe Projects
The example projects for this book are NOT loaded automatically when you install the Keil
compiler.
These files are stored on the CD in a directory “/Pont”. The files are arranged by chapter: for
example, the project discussed in Chapter 3 is in the directory “/Pont/Ch03_00-Hello”.
Rather than using the projects on the CD (where changes cannot be saved), please copy the
files from CD onto an appropriate directory on your hard disk.
Note: you will need to change the file properties after copying: file transferred from the CD will
be ‘read only’.
Configuringthe Simulator
Open the Keil Vision2
Go to Project – Open Project and browse for Hello in Ch03_00 in Pont and open it.
37. Go to Project – Select Device for Target ‘Target1’
Select 8052(all variants) and click OK
38. Now we need to check the oscillator frequency:
Go to project – Options for Target ‘Target1’
Make sure that the oscillator frequency is 12MHz.
39. Buildingthe Target
Build the target as illustrated in the figure below
Running the Simulation
Having successfully built the target, we are now ready to start the debug session and run the
simulator.
First start a debug session
40. The flashing LED we will view will be connected to Port 1. We therefore want to observe the
activity on this port
41. To ensure that the port activity is visible, we need to start the ‘periodic window update’ flag
Go to Debug - Go
42. While the simulation is running, view the performance analyzer to check the delay durations.
43. Go to Debug – Performance Analyzer and click on it
Double click on DELAY_LOOP_Wait in Function Symbols: and click Define button
45. The working model of the proposed 8051 microcontroller based range finder using ultrasonic
module was successfully designed and implemented. The performance of the circuit was
analysed for different conditions. The circuit was able to measure distance up to 2.5m without
interfering in human activity. Circuit was tested for measurement of various distances in different
atmospheric conditions, accurately. It has a fast response. The ultrasonic module works fine. It
responds to the incoming echo accordingly. By using 8052 and HC-SR04 we were able to
reduce the cost and increase efficiency. This implementation has been a major component in
the circuits of major fast consuming electronic goods.
46. Chapter 7
APPLICATIONS
1. Used to measure the obstacle distance.
2. This system used in automotive parking sensors and obstacle warning systems.
3. Used in terrain monitoring robots.
Department of Electronics and Telecomm. Engineering, MIT Academy of Engineering, Pune28
47. Chapter 8
CONCLUSION AND FUTURE SCOPE
8.1 Conclusion
The objective of this project was to design and implement an Ultrasonic Distance
Measurement device. As described in this report a system is developed that can
calculate the distance of the tracked object. With respect to the requirements for an
ultrasonic rangefinder the followings can be concluded.
1. The system can calculate the distance of the obstruction with sufficient accuracy.
2. This device has the capability to interact with other peripheral if used as a secondary device.
3. This can also communicate with PC through its serial port.
4. This offers a low cost and efficient solution for non-contact type distance measurements.
8.2 Future Scope
The range can be considerably increased by using high power drive circuit.
1.Using temperature compensation, it can be used over wide temperature range.
2. The resolution of the measurement can be improved by incorporating phase shift
method along with time of flight method.
48. 3. Can be used as parking assistance system in vehicles with high power ultrasonic transmitter.
4. The 40 kHz signal can be generated using microcontroller itself which will reduce hardware.