100% found this document useful (1 vote)
133 views

BE Project

This project deals with designing and testing a prototype ultrasonic radar system. The system uses an ultrasonic transmitter that transmits signals in a 360 degree circle. When an object is detected, the signals reflect back to the receiver. A stepper motor provides directional information to the microcontroller, which sends the distance and direction data to an LCD display. The system was able to successfully display the location of detected objects, including distance and direction. It was tested using embedded C programming and performed satisfactorily during repeated operations.

Uploaded by

Dhruv Gowda
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
133 views

BE Project

This project deals with designing and testing a prototype ultrasonic radar system. The system uses an ultrasonic transmitter that transmits signals in a 360 degree circle. When an object is detected, the signals reflect back to the receiver. A stepper motor provides directional information to the microcontroller, which sends the distance and direction data to an LCD display. The system was able to successfully display the location of detected objects, including distance and direction. It was tested using embedded C programming and performed satisfactorily during repeated operations.

Uploaded by

Dhruv Gowda
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 53

Ultrasonic Detection and Ranging

ABSTRACT

This project deals with the design and testing of a prototype model of a RADAR
using Ultrasonic waves.
The ultrasonic transmitter will transmit the signals in the 360-degree circle, these
signals will reflect back to the receiver when the object is detected in transmitting line.
The stepper motor gives the direction, which is sent to the microcontroller, which in turn
sends to the LCD. Microcontroller sends the direction and the distance to the LCD. In
LCD we can see the plot distance between and object and the sensor and the direction
with respect to the initial position of the module. A torch is used as a countering
equipment in this prototype.
This project has been completed successfully and tested for displaying location of
the object i,e. distance and direction. The programs have been developed using Embedded
C language and performance of the device was also tested. The system works
satisfactorily and confirm with repeated operations.

Dept E & C

PESCE,Mandya.

Ultrasonic Detection and Ranging

CHAPTER 1

INTRODUCTION
AIM:
The main aim of the project is to implement RADAR using ultrasonic waves.

The ultrasonic transmitter will transmit the signals in the 360-degree circle, these
signals will reflect back to the receiver when the object is detected in transmitting line.
The stepper motor gives the direction, which is sent to the microcontroller, which in turn
sends to the LCD. The distance sensor gives the distance of the object from the module
and communicates serially with the microcontroller. Microcontroller sends the direction
and the distance to the LCD. In LCD we can see the plot distance between and object and
the sensor and the direction with respect to the initial position of the module.
In an ultrasonic detection and ranging system, a constant, high frequency acoustic
signal is transmitted by a transducers. The ultrasound waves flood the protected area.
Receiving transducers monitor the ultrasound reflected by objects in the protected zone. If
anything moves, it produces a change in the phase of some of the reflected waves. This
phase change is detected by sensitive electronic circuits, which send signals to the
microcontroller.
In military they are many restricted area where common people are restricted to
enter the place due to security reasons and when an object is detected in that region then
the radar will detect and inform it to the base station along with the direction and
necessary action will be taken.

Dept E & C

PESCE,Mandya.

Ultrasonic Detection and Ranging


1.1 RADAR:
Radar is an acronym for RAdio Detection And Ranging. The name itself
suggests that the radars are used to detect the presence of object and determine its range,
i.e., distance and bearing, using radio frequency waves. The block diagram of a primary
Radar is shown below:

Transmitter:
The radar transmitter produces microwave signal, which is typically short duration
high-power RF- pulses of energy for a pulsed radar.
Duplexer:
Duplexer acts as a switch; it switches the antenna between the transmitter and
receiver. This obviates the need for separate transmitting and receiving antennas.
Duplexer prevents high power energy to go into receiver (high power pulses can damage
the receiver) while transmission and prevents reflected signal to be fed to the transmitter
during reception.

Antenna:
The transmitting antenna radiates the transmitting energy to signals in space, in
desired directions. The radiated energy propagates with constant velocity. When it finds
the target, the energy is scattered, a part of which is reflected towards the transmitting
antenna. The antenna receives the reflected energy and feed it to the duplexer. The
duplexer directs this energy towards the receiver.

Receiver:
Dept E & C

PESCE,Mandya.

Ultrasonic Detection and Ranging


The receiver demodulates the received reflected energy and analyzes the signal to
find target parameters.

Display:
The receiver sends the output to display, which shows the analyzed signal in an
easily understandable user friendly manner.

1.1.1 Types of RADARS:


There are 2 types of radars:

Pulse RADAR

Continuous wave RADAR

Pulse Radar sends out signals in short (few millionths of a second) but powerful
bursts or pulses. Pulse Radar determines distance (range) by measuring the time it takes a
radar wave to get to the target object and to come back (time of flight) and then divides
that time in two (distance to the target). Since all radio waves travel at the same speed of
light, this known speed multiplied by the time of flight can be used to determine distance.
By continuing to track an object with a pulse radar the speed of the object can also be
determined.
Continuous-Wave Radar sends out a continuous signal instead of short bursts. There
are two types of Continuous Wave Radar:
A) Doppler Radar
B) Frequency Modulated (FM radar)
Doppler Radar is used mostly to make precise speed measurements and is most
often utilized by police traffic radars. Doppler Radar transmits a continuous wave of a
constant frequency. When this frequency strikes a moving object the frequency is
changed and the new frequency returning to the radar is used to determine the speed
of the moving target. Examples of Doppler Radar - Decatur Police Radar Guns. A lot
of sports radar guns, such as Bushnell Velocity Speed Gun, are Doppler Radars as
well.

Dept E & C

PESCE,Mandya.

Ultrasonic Detection and Ranging


Frequency-Modulated Radar also transmits a continuous signal, but it rapidly
increases or decreases the frequency of the signal at regular intervals. As a result FM
Radar, unlike Doppler Radar, can determine distance (range) as well as velocity (speed).
1.1.2 USES OF RADAR:
The modern uses of radar are highly diverse, including air traffic control, radar
astronomy, air-defense systems, antimissile systems; marine radars to locate landmarks
and other ships; aircraft anticollision systems; ocean surveillance systems, outer space
surveillance and rendezvous systems; meteorological precipitation monitoring; altimetry
and flight control systems; guided missile target locating systems; and ground-penetrating
radar for geological observations. High tech radar systems are associated with digital
signal processing and are capable of extracting objects from very high noise levels.

1.2

INTRODUCTION TO 8051 MICRO CONTROLLER:


Intel Corporation fabricated the 8 bit microcontroller which was referred as

MCS-51 in 1981. This microcontroller was also referred as system on a chip because it
has 128 bytes of RAM, 4Kbytes of ROM, 2 Timers, 1 Serial port, and four ports on a
single chip. The CPU can work for only 8bits of data at a time because 8051 is an 8-bit
processor. In case the data is larger than 8 bits then it has to be broken into parts so that
the CPU can process conveniently. Most manufacturers have put 4Kbytes of ROM even
though the quantity of ROM can be exceeded upto 64 K bytes.Intel permitted other
manufacturers to fabricate different versions of 8051 but with the limitation that code
compatibility should be maintained. This has added advantage that if the program is
written then it can be used for any version of 8051 despite of manufacturer.
As years passed by, the quality of technology surpassed the expectation of the
greatest minds, with gadgets becoming smaller, sleeker and more efficient.
Microcontrollers were seen as the answer to the requirements raised in advanced
electronics. This is the reason why manufacturers have now focused their production
around the following main developmental aspects:
i.

Ease-of-use

ii.

Market availability

iii.

Less power usage

Dept E & C

PESCE,Mandya.

Ultrasonic Detection and Ranging


iv.

Smaller processing power

v.

More integrated features like RF and USB

vi.

Smaller form factors

1.2.1 ARCHITECTURE:
This microcontroller is also called as System on a chip because it has all the
features on
a single chip. The Block Diagram of 8051 Microcontroller is as shown in Figure 1.2.1

FIG 1.2.1 : ARCHITECTURE

1.2.2 FEATURES:
The main features of 8051 microcontroller are:
i. RAM 128 Bytes (Data memory)
ii. ROM 4Kbytes (ROM signify the on chip program space)
Dept E & C

PESCE,Mandya.

Ultrasonic Detection and Ranging


iii. Serial Port Using UART makes it simpler to interface for serial communication.
iv. Two 16 bit Timer/ Counter
v. Input/output Pins 4 Ports of 8 bits each on a single chip.
vi. 6 Interrupt Sources
vii. 8 bit ALU (Arithmetic Logic Unit)
viii. Harvard Memory Architecture It has 16 bit Address bus (each of RAM and
ROM) and 8 bit Data Bus.
ix. 8051 can execute 1 million one-cycle instructions per second with a clock
frequency of 12MHz.
In our project we are using 8051 based microcontroller manufactured
Philips(p89v51rd2) which has enhanced RAM,ROM and other features.

1.3

ULTRASONIC SENSORS:
Ultrasonic

sensors

are

devices

that

use

electricalmechanical

energy

transformation, the mechanical energy being in the form of ultrasonic waves, to measure
distance from the sensor to the target object. Depending on the type of application, the
range of frequencies has been broadly categorized as shown in the figure below:

FIG 1.3: Frequency Ranges


Dept E & C

PESCE,Mandya.

Ultrasonic Detection and Ranging


1.3.1 History:
The history dates back to 1790, when Lazzaro Spallanzani first discovered that
bats maneuvered in flight using their hearing rather than sight. Jean-Daniel Colladon in
1826 discovered sonography using an underwater bell, successfully and accurately
determining the speed of sound in water. Thereafter, the study and research work in this
field went on slowly until 1881 when Pierre Curies discovery set the stage for modern
ultrasound transducers. He found out the relationship between electrical voltage and
pressure on crystalline material.
The unfortunate Titanic accident spurred rigorous interest into this field as a result
of which Paul Langevin invented the hydrophone to detect icebergs. It was the first
ultrasonic transducer. The hydrophone could send and receive low frequency sound
waves and was later used in the detection of submarines in the World War.
On a note parallel to the SONAR, medical research also started taking interest in
ultrasonics. In late 1930s Dr. Karl Dussik used a technique called hyperphonography
which recorded echoes of ultrasonic waves on a sensitive paper.
This technique was used to produce ultrasound pictures of the brain to help detect
tumors and marked the birth of ultrasound imaging. After that, many scientists like Ian
Donald, Douglas Howry, Joseph Holmes, John Wild and John Reid improved upon the
various aspects of ultrasonic sensors in the medical field which enabled diagnosis of
stomach cancers, ovarian cysts, detection of twin pregnancies, tumors etc. Industry too
did not waste time in jumping on to the bandwagon and soon developed techniques like
ultrasonic welding and non destructive testing at the outset of the 1960s.

1.3.2 How ultrasonic sensor works?


Ultrasonic waves are longitudinal mechanical waves which travel as a succession
of compressions and rarefactions along the direction of wave propagation through the
medium. Any sound wave above the human auditoryrange of 20,000 Hz is called
ultrasound.When ultrasonic waves are incident on an object, diffused reflection of the
energytakes place over a wide solid angle which might be as high as 180 degrees. Thus
some fraction of the incident energy is reflected back to the transducer in the form of
echoes and is detected. The distance to the object (L) can then be calculated through the

Dept E & C

PESCE,Mandya.

Ultrasonic Detection and Ranging


speed of ultrasonic waves (v) in the medium and the time taken by the wave to reach back
to the sensor. If the object is in motion, instruments based on Doppler shift are used.

FIG 1.3.2: Object detection using ultrasonic waves

Dept E & C

PESCE,Mandya.

Ultrasonic Detection and Ranging

CHAPTER 2

BLOCK DIAGRAM

2.1 Block diagram of the Project:

LCD (Display)

Ultrasonic
Transducers

LCD
Driver

LCD
Glass

Transducer
Micro

stepper motor
Controller
Driver(U
LN2003)

(P89V51RD2)

Power Supply
Trans
former
Rectifier

Regulator
(7805)
Filter
(7805)

Fig 2.1 :Block diagram of Ultrasonic detection and Ranging

Dept E & C

10

PESCE,Mandya.

Ultrasonic Detection and Ranging


The above block diagram shows the brief overview of our project.It shows Ultrasonic
transducers,Microcontroller, Stepper motor,LCD display and power supply.The function
of each block is explained below.

2.1 Ultrasonic transducers:


These are the components which send ultrasonic waves(greater than 20khz) continuosly.

2.1.1 Ultrasonic Detection Sensor:


This sensor is used for detection of the object.This is connected to pin P3.2(External
interrupt 0) of the microcontroller.This will provide interrupt to the controller when an
object is detected.This is also connected to a relay (SPST) and the switching of the relay
is controlled by pin P0.7 of the microcontroller.The range of detection is from 2mm to
3m.

2.1.2 Ultrasonic Distance Sensor:


This is another ultrasonic sensor which provides distance between the object and the
sensor to the microcontroller.This communicates serially with the microcontroller via
P3.0 pin at a baud rate of 9600.This is also connected to a DPDT relay which is
controlled by P1.3 pin of the micro controller.The distance is displayed on LCD.
Some of the features of this sensor is as follows,

2.2 Stepper Motor:


The Ultrasonic transducers are placed on a Stepper motor to provide 360 degree
monitoring. The stepper motor is programmed in full step(1.8 degrees) and is connected
to port 0 of the microcontroller(P0.0 to P0.3)through the driver(ULN 2003).The motor
and the driver uses a power supply of 12 volts. When an object is detected,interrupt is
generated and the controller jumps to Interrupt Service Routine(ISR).Here the reading of
the number of steps of the motor multiplied by the degree per step gives the direction of
the object in degrees.The direction is displayed on the LCD. The stepper motor is
programmed to rotate in clockwise and anticlock wise cycles.

Dept E & C

11

PESCE,Mandya.

Ultrasonic Detection and Ranging

2.3 Microcontroller:
Here

we

are

using

8051

flavoured

microcontroller

manufactured

by

Philips(P89V51RD2).This is the heart of the project and it controls all the components
shown in the diagram above.
Features of Philips 89V51RD2 are:

80C51 Central processing unit

5 V operating voltage from 0 to 40 Mhz

16 kB of on-chip flash memory with ISP(In System Programming)

Three 16-bit timers/counters

Serial Peripheral Interface(SPI) and enhanced UART.

2.4 Power Supply:


The microcontroller requires 5 volts for the desired circuit to function and another
12 volts supply for running the stepper motor and relay.
Most of the electronic devices require a stable DC source for its proper
operation.DC power for using rectifier obtains electronic circuit from commercially
available AC line,filter system called as POWER SUPPLY.
The rectifier filter combination constitutes an ordinary power supply.But its DC
voltage output changes if the AC main voltage or the load is altered.But it is desired that
the DC voltage should remain constant irrespective of the AC main voltage or load.For
this purpose regulated power supply is used.

2.5 LCD:
LCD is used in our project to display direction and distance of the object.This is
connected to port 2 of the microcontroller.It makes use of 3 more pins for control
signals.This is provided by pin port 1 of the controller(P1.0-P1.2).The control signals are,

RS(Register Select)

R/W(Read or Write)

Enable

Dept E & C

12

PESCE,Mandya.

Ultrasonic Detection and Ranging


The enable must go from high to low for the data/command coming from the
microcontroller to be latched into the LCD.
If RS=0,then it signifies data is coming through the port.If RS=1, then it is a
command to the LCD.
If R/W =0, it signifies write operation to the LCD. In our project we are only writing
the data to the LCD i,e Distance and direction and hence R/W is grounded.

Dept E & C

13

PESCE,Mandya.

Ultrasonic Detection and Ranging

CHAPTER 3

HARDWARE

3.1 Philips P89V51RD2 Microcontroller


We are using Philips P89V51RD2 as 8051 Microcontroller Unit (MCU). And we
have been developing our code with Opensouce C Compiler SDCC.
The P89V51RD2 is a 80C51 microcontroller with 64 kB Flash and 1024 bytes of data
RAM. A key feature of the P89V51RD2 is its X2 mode option. The design engineer can
choose to run the application with the conventional 80C51 clock rate (12 clocks per
machine cycle) or select the X2 mode (6 clocks per machine cycle) to achieve twice the
throughput at the same clock frequency. Another way to benefit from this feature is to
keep the same performance by reducing the clock frequency by half, thus dramatically
reducing the EMI.
The Flash program memory supports both parallel programming and in serial In-System
Programming (ISP). Parallel programming mode offers gang-programming at high speed,
reducing programming costs and time to market. ISP allows a device to be reprogrammed
in the end product under software control. The capability to field/update the application
firmware makes a wide range of applications possible.

The P89V51RD2 is also In-Application Programmable (IAP), allowing the Flash


program memory to be reconfigured even while the application is running.

3.1.1 Features:

80C51 Central Processing Unit

5 V Operating voltage from 0 to 40 MHz

64 kB of on-chip Flash program memory with ISP (In-System Programming) and

IAP (In-Application Programming)

Supports 12-clock (default) or 6-clock mode selection via software or ISP

SPI (Serial Peripheral Interface) and enhanced UART

Dept E & C

14

PESCE,Mandya.

Ultrasonic Detection and Ranging

PCA (Programmable Counter Array) with PWM and Capture/Compare functions

Four 8-bit I/O ports with three high-current Port 1 pins (16 mA each)

Three 16-bit timers/counters

Programmable Watchdog timer (WDT)

Eight interrupt sources with four priority levels

Second DPTR register

Low EMI mode (ALE inhibit)

TTL- and CMOS-compatible logic levels

Fig 3.1.1 P89v51rd2 block diagram

Dept E & C

15

PESCE,Mandya.

Ultrasonic Detection and Ranging

3.2 General description:


The P89V51RD2 is an 80C51 microcontroller with 64 kB Flash and 1024
bytes of data RAM. A key feature of the P89V51RD2 is its X2 mode option. The
design engineer can choose to run the application with the conventional 80C51
clock rate (12 clocks per machine cycle) or select the X2 mode (6 clocks per
machine cycle) to achieve twice the throughput at the same clock frequency.
Another way to benefit from this feature is to keep the same performance by
reducing the clock frequency by half, thus dramatically reducing the EMI.
The Flash program memory supports both parallel programming and in serial
In-System Programming (ISP). Parallel programming mode offers gangprogramming at high speed, reducing programming costs and time to market. ISP
allows a device to be reprogrammed in the end product under software control.
The capability to field/update the application firmware makes a wide range of
applications possible.
The P89V51RD2 is also In-Application Programmable (IAP), allowing the
Flash program memory to be reconfigured even while the application is running.

Pinning detail

Dept E & C

16

PESCE,Mandya.

Ultrasonic Detection and Ranging

3.3 ULN2003 Driver

ULN2003
HIGH VOLTAGE AND HIGH CURRENT
DARLINGTON TRANSISTOR ARRAY

3.3.1 DESCRIPTION :
The ULN2003 is a monolithic high voltage and high curren Darlington transistor
arrays. It consists of seven NPN darlington pairs that features high-voltage outputs with
common-cathode clamp diode for switching inductive loads. The collector-curren rating
of a single darlington pair is 500mA. The darlington pairs may be parrlleled for higher
current capability.
Applications include relay drivers,hammer drivers, lampdrivers,display drivers(LED gas
discharge),line drivers, and logic buffers. The ULN2003 has a 2.7k series base resistor
for each darlington pair for operation directly with TTL or 5V CMOS devices.
Dept E & C

17

PESCE,Mandya.

Ultrasonic Detection and Ranging


3.3.2 FEATURES :
* 500mA rated collector current(Single output)
* High-voltage outputs: 50V
* Inputs compatible with various types of logic.
* Relay driver application

Dept E & C

18

PESCE,Mandya.

Ultrasonic Detection and Ranging

3.4 RS232 Communication The Level Conversion


As RS232 is such a common protocol there is a dedicated IC designed for this
purpose of "Level Conversion". This IC is MAX232 from Maxim. By using charge
pumps it generates high voltages(12V) and negative voltages(-12V).

S.No

Item

MAX232 IC

Capacitors

Value

Qty

1uF

10uF

DB9 Female Connector

General Purpose PCB

Some Wires

Dept E & C

19

PESCE,Mandya.

Ultrasonic Detection and Ranging

Fig - Schematic for RS232 level converter.

Dept E & C

20

PESCE,Mandya.

Ultrasonic Detection and Ranging

Figure 3.4.1: MAX232 chip

The MAX232 is an integrated circuit that converts signals from an RS-232 serial port
to signals suitable for use in TTL compatible digital logic circuits. The MAX232 is a dual
driver/receiver and typically converts the RX, TX, CTS and RTS signals.
The drivers provide RS-232 voltage level outputs (approx. 7.5 V) from a single + 5 V
supply via on-chip charge pumps and external capacitors. This makes it useful for
implementing RS-232 in devices that otherwise do not need any voltages outside the 0 V
to + 5 V range, as power supply design does not need to be made more complicated just
for driving the RS-232 in this case.
The receivers reduce RS-232 inputs (which may be as high as 25 V), to standard
5 V TTL levels. These receivers have a typical threshold of 1.3 V, and a
typical hysteresis of 0.5 V.
The later MAX232A is backwards compatible with the original MAX232 but may
operate at higher baud rates and can use smaller external capacitors 0.1 F in place of
the 1.0 F capacitors used with the original device.
The newer MAX3232 is also backwards compatible, but operates at a broader voltage
range, from 3 to 5.5 V. Pin to pin compatible: ICL232, ST232, ADM232, HIN232.

Dept E & C

21

PESCE,Mandya.

Ultrasonic Detection and Ranging

3.4.1 Voltage levels

It is helpful to understand what occurs to the voltage levels. When a MAX232 IC


receives a TTL level to convert, it changes a TTL Logic 0 to between +3 and +15 V, and
changes TTL Logic 1 to between -3 to -15 V, and vice versa for converting from RS232
to TTL. This can be confusing when you realize that the RS232 Data Transmission
voltages at a certain logic state are opposite from the RS232 Control Line voltages at the
same logic state. To clarify the matter, see the table below.

RS232 Line Type & Logic Level

RS232 Voltage TTL Voltage to/from MAX232

Data Transmission (Rx/Tx) Logic 0

+3 V to +15 V

0V

Data Transmission (Rx/Tx) Logic 1

-3 V to -15 V

5V

Control Signals (RTS/CTS/DTR/DSR) Logic 0 -3 V to -15 V

5V

Control Signals (RTS/CTS/DTR/DSR) Logic 1 +3 V to +15 V

0V

Table 3.4.1

Dept E & C

22

PESCE,Mandya.

Ultrasonic Detection and Ranging

3.5 RELAY

A relay is an electrically operated switch. Current flowing through the coil of the
relay creates a magnetic field which attracts a lever and changes the switch contacts. The
coil current can be on or off so relays have two switch positions and most have double
throw (changeover) switch contacts as shown in the diagram.
Relays allow one circuit to switch a second circuit which can be completely
separate from the first. For example a low voltage battery circuit can use a relay to switch
a 230V AC mains circuit. There is no electrical connection inside the relay between the
two circuits, the link is magnetic and mechanical.
The coil of a relay passes a relatively large current, typically 30mA for a 12V
relay, but it can be as much as 100mA for relays designed to operate from lower voltages.
Most ICs (chips) cannot provide this current and a transistor is usually used to amplify the
small IC current to the larger value required for the relay coil. The maximum output
current for the popular 555 timer IC is 200mA so these devices can supply relay coils
directly without amplification.
Relays are usually SPDT or DPDT but they can have many more sets of switch
contacts, for example relays with 4 sets of changeover contacts are readily available. For
further information about switch contacts and the terms used to describe them please see
the page on switches.
Most relays are designed for PCB mounting but you can solder wires directly to
the pins providing you take care to avoid melting the plastic case of the relay.
The supplier's catalogue should show you the relay's connections. The coil will be
obvious and it may be connected either way round. Relay coils produce brief high voltage
'spikes' when they are switched off and this can destroy transistors and ICs in the circuit.
To prevent damage you must connect a protection diode across the relay coil.

Dept E & C

23

PESCE,Mandya.

Ultrasonic Detection and Ranging


3.5.1 SPST RELAY:

Fig 3.5.1 SCHEMATIC OF RELAY SPST

3.5.2 Features:

Hermetically Sealed in Surface Mount Package

Low On-resistance

10A Continuous Output Current

Performance over -55C to +125C

Optically Coupled

Input/Output Isolation Tested to 1000 VDC

Shock and Vibration Resistant

3.5.3 Applications:

Military/High Reliability Systems

Power Distribution/Switching

Solenoid Driver

Stepper Motor Driver

Heater Switching

SPST Single Pole Single Throw. These have two terminals which can be connected
or disconnected. Including two for the coil, such a relay has four terminals in total. It is

Dept E & C

24

PESCE,Mandya.

Ultrasonic Detection and Ranging


ambiguous whether the pole is normally open or normally closed. The terminology
"SPNO" and "SPNC" is sometimes used to resolve the ambiguity.

3.5.4 DPST:
Double Pole Single Throw. These have two pairs of terminals. Equivalent to two
SPST switches or relays actuated by a single coil. Including two for the coil, such a relay
has six terminals in total. The poles may be Form A or Form B (or one of each).

Fig 3.5.4 DPST Relay

Dept E & C

25

PESCE,Mandya.

Ultrasonic Detection and Ranging

3.6 LCD

fig 3.6 pin diagram of LCD

3.6.1 FEATURES
5 x 8 dots with cursor
Built-in controller (KS 0066 or Equivalent)
+ 5V power supply (Also available for + 3V)
1/16 duty cycle
B/L to be driven by pin 1, pin 2 or pin 15, pin 16 or A.K (LED)
N.V. optional for + 3V power supply

LCD (Liquid Crystal Display) screen is an electronic display module and find a
wide range of applications. A 16x2 LCD display is very basic module and is very
commonly used in various devices and circuits. These modules are preferred over seven
segments and other multi segment LCD.The reasons being: LCDs are economical.
Dept E & C

26

PESCE,Mandya.

Ultrasonic Detection and Ranging


A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In this
LCD each character is displayed in 5x7 pixel matrix. This LCD has two registers, namely,
Command and Data.
The command register stores the command instructions given to the LCD. A
command is an instruction given to LCD to do a predefined task like initializing it,
clearing its screen, setting the cursor position, controlling display etc. The data register
stores the data to be displayed on the LCD. The data is the ASCII value of the character
to be displayed on the LCD.

Pin Description:

Pin
No
1
2
3

Function

Name

Ground (0V)
Supply voltage; 5V (4.7V 5.3V)
Contrast adjustment; through a variable resistor

Ground
Vcc
VEE

Selects command register when low; and data register


when high

Register
Select

Low to write to the register; High to read from the


register
Sends data to data pins when a high to low pulse is
given

Read/write

6
7
8
9
10
11
12
13
14
15
16

Enable
DB0
DB1
DB2
DB3
DB4
DB5
DB6
DB7
Led+
Led-

8-bit data pins

Backlight VCC (5V)


Backlight Ground (0V)

Table 3.6.1

Dept E & C

27

PESCE,Mandya.

Ultrasonic Detection and Ranging

3.7 Power Supply


The microcontroller requires 5 volts for the desired circuit to function and another
12 volts supply for running the stepper motor.
Most of the electronic devices require a stable DC source for its proper
operation.DC power for using rectifier obtains electronic circuit from commercially
available AC line,filter system called as POWER SUPPLY.
The rectifier filter combination constitutes an ordinary power supply.But its DC
voltage output changes if the AC main voltage or the load is altered.But it is desired that
the DC voltage should remain constant irrespective of the AC main voltage or load.For
this purpose regulated power supply is used.

3.7.1 REGULATED POWER SUPPLY:


A DC power supply whose output remains constant irrespective of any fluctuation
in AC supply or load is known as REGULATED POWER SUPPLY.
It consists of an ordinary power supply with additional voltage regulator.It gives a
constant output irrespective of change in input AC source or change in load current.

3.7.2 NEED FOR REGULATED POWER SUPPLY:


Voltage regulation is poor in ordinary power supply. Its output voltage depends on
load current. Most electronic circuits will not work satisfactorily on such variation in DC
voltage. The internal resistance of an ordinary supply is large, greater than 300 ohms.
Therefore the output is hardly affected by the amount of load current drawn from its
supply. Because of this reason regulated power supply is used.
This regulated power supply forms the main unit for energizing the whole circuit
associated in the project. The regulated power supply consists of the following parts:
1)Transformer
2)Rectifier
3)Filter
Dept E & C

28

PESCE,Mandya.

Ultrasonic Detection and Ranging


4)IC Regulator

3.7.2.4 Regulator 7805

Fig3.7.2.4.1 VOLTAGE REGULATOR 7805


Although designed I t i s a t h r e e t e r m i n a l p o s i t i v e v o l t a g e
r e g u l a t o r . I t i s u s e d t o provide regulated power supply to the board. It looks like a
transistor is actually an integrated circuit with 3 legs.
I t c a n t a k e a h i g h e r , c r a p p y D C voltage and turn it into a nice, smooth 5 volts
DC.
It
has
to
be
fed
with
at
least230VAC
Stepdowntransformer Bridgerectifier f
e
Regulator
8 volts and not more than 30 volts. It can handle around .5 to .75 amps, but itg e t s h o t ,
and hence a heat sink can be used. It is efficient to use in
p o w e r circuits that needs or runs off at 5 volts.
Each

type

employs

internal

current

limiting,thermal

shut

down

and safe operating area protection, making it essentially indestructib


l e . I f adequate heat sinking is provided, they can deliver over 1A output
currentprimarily as fixed voltage regulators, these devices can be used with external
components to obtain adjustable voltages and currents.

FEATURES OF VOLTAGE REGULATOR 7805:


Suitable for C-MOS, TTL and other digital ICs power supply.
Internal thermal overload protection.
Internal short circuit current limiting.
Output current in excess of 1A.
Output Transistor Safe Operating Area Protection.
Dept E & C

29

PESCE,Mandya.

Ultrasonic Detection and Ranging


Output Voltages of 5, 6, 8, 9, 10, 12, 15, 18, 24

Dept E & C

30

PESCE,Mandya.

Ultrasonic Detection and Ranging

CHAPTER 4

SOFTWARE

The software design of our project is done using Embedded-C program using Keil
microvision IDE with which microcontroller is programmed to run the stepper motor,
communicating serially with the distance sensor, lighting the torch and displaying
distance and direction in the LCD. It is converted to HEX file which is machine readable
form so as to load it into the microcontroller. For loading the HEX file into the micro
controller Flash magic utility is used.

4.1 Keil microvision2 IDE


Introduction
KEIL was founded in 1982 by Gnter und Reinhard Keil, initially as a German GbR.
In April 1985 the company was converted to Keil Elektronik GmbH to market add-on
products for the development tools provided by many of the silicon vendors. Keil
implemented the first C compiler designed from the ground-up specifically for the 8051
microcontroller.
KEIL provides a broad range of development tools like ANSI C compiler, macro
assemblers, debuggers and simulators, linkers, IDE, library managers, real-time operating
systems and evaluation boards for 8051, 251, ARM, and XC16x/C16x/ST10 families.
KEIL is a software package specially designed for embedded software engineers and
developers. These software tools have been developed so that developers can achieve
control over their 8051 microcontroller architecture. This software will be highly
appreciated by computer engineering students as well as applications engineers.
KEIL is a range of powerful macro assemblers, debuggers, C compilers, real-time
kernels, emulators and single board computers. These development tools are compatible
with all 8051 microcontroller derivatives. All you need to do when you start a project is
to specify the microcontroller that you are using and the softwares IDE configures the
assembler, linker, compiler and memory options easily and conveniently. The softwares
Dept E & C

31

PESCE,Mandya.

Ultrasonic Detection and Ranging


debugger will simulate your microcontrollers on-chip peripherals, permitting you to test
application even before you download the code on your hardware system. Finally, specify
your target monitors, adapters and system debuggers to download and test the program
code on your hardware system.

Figure 4.1:Window for KEIL Software

Software Development Cycle


When using Keil software tools,the project development cycle is roughly same as
it is for any other development project.

Dept E & C

Create a project and select a target chip from the device.


Create source files in C or Assembly.
Build Application with the project manager.
Correct errors in source files.
Test linked application.

32

PESCE,Mandya.

Ultrasonic Detection and Ranging

4.2 Flash Magic Utility


Flash Magic is an application developed by Embedded Systems Academy to allow
you to easily access the features of a microcontroller device. With this program you can
erase individual blocks or the entire Flash memory of the microcontroller.
This application is very useful for those who work in the electronics field. The
main window of the program is composed of five sections where you can find the most
common functions in order to program a microcontroller device. Using the
Communications section you will be able to choose the way a specific device connects
to your computer. Select the COM port to be used and the baud rate. It is recommended
that you choose a low baud rate first and increase it afterwards. This way you will
determine the highest speed with which your system works. In order to select which parts
of the memory to erase, choose from the items in the Erase section. The third section is
optional. It offers you the possibility to program a HEX file. In the next section you will
be able to find different programming options, such as verify after programming, gen
block checksums, execute and others. When youre done, click the Start button that
can be found in the Start section. The program will start the device, and you will able to
see the progress of the operations at the bottom of the main window.
Using Flash Magic, you are able to perform different operations to a
microcontroller device, operations like erasing, programming and reading the flash
memory, modifying the Boot Vector, performing a blank check on a section of the Flash
memory and many others.

Dept E & C

33

PESCE,Mandya.

Ultrasonic Detection and Ranging

Figure 4.2: Flash Magic Utility


Features
Flash Magic provides a clear and simple user interface to these features and more
as described in the following sections. Under Windows, only one application may have
access the COM Port at any one time, preventing other applications from using the COM
Port. Flash Magic only obtains access to the selected COM Port when ISP operations are
being performed. This means that other applications that need to use the COM Port, such
as debugging tools, may be used while Flash Magic is loaded.

Dept E & C

34

PESCE,Mandya.

Ultrasonic Detection and Ranging

CHAPTER 5

FLOWCHART
5.1 Flowchart for the project:
Start

Initialize Ports,LCD and Start the


stepper motor by giving the
power supply.

IS object
detected(P
3.2)?

Stop the motor when the receive pin


of the detection sensor goes High to
low. Power down the detection sensor
using SPST relay(P0.7).

Power the torch and the distance


sensor to calculate the distance using
DPDT relay(P1.3). Send the distance to
the LCD.

Note down the stepper motor pulse


and calculate the direction and send
it to the LCD.

Dept E & C

35

PESCE,Mandya.

Ultrasonic Detection and Ranging


5.2 WORKING:
After giving the power supply to the module, the LCD is initialized by providing
commands to it. Here microcontroller provides the command. In our project Port 2 is
connected to the LCD and 3 control signals are given from Port 1.
Then stepper motor is started. The starting point is taken as reference in calculating
the direction of the object i,e. starting point is taken as zero degrees. The stepper
motor is connected to lower nibble of Port 0.It is programmed such that it runs
clockwise and anticlockwise in 360 degree cycle and is programmed in full step.
The ultrasonic transducers and a torch is mounted on top of the stepper motor. The
ping ultrasonic sensor is connected pin P3.2 of the controller which is the external
interrupt 0 pin. The microcontroller interrupt is programmed in edge triggered mode
.Whenever an object is detected the ping sensor sends an interrupt. Then this sensor is
turned of using a relay (Single Pull Single Throw) which is controlled by P0.7 pin of
the microcontroller.
The module then aligns itself with the direction of the object.The distance sensor
is then turned on along with the torch. Both of them are simultaneously turned on by
DPDT relay which is controlled by P1.3 pin of the microcontroller. Torch is used as a
counter attack instrument in this prototype.
The distance sensor provides distance between the object and the sensor to the
microcontroller.This communicates serially with the microcontroller via P3.0 pin at a
baud rate of 9600.The microcontroller is programmed at 9600 baud rate to
synchronize with the distance sensor. Here Timer 1 is used in mode 2 to set the baud
rate. The microcontroller receives the data provided by the sensor and sends it to LCD
for displaying distance in inches. This gives the distance of the object from the sensor.
When an object is detected, interrupt is generated and the controller jumps to Interrupt
Service Routine(ISR).Here the reading of the number of steps of the motor multiplied
by the degree per step gives the direction of the object in degrees. The direction is
displayed in the LCD in degrees.

Dept E & C

36

PESCE,Mandya.

Ultrasonic Detection and Ranging

CHAPTER 6

IMPLEMENTATION
The figure 6.1 shows the Ultrasonic transducers and the torch. This is mounted on
a stepper motor and the motor is rotated to provide 360 degree surveillance.

Figure 6.1: Ultrasonic detection and ranging module

Figure 6.2: Module mounted on stepper motor

Dept E & C

37

PESCE,Mandya.

Ultrasonic Detection and Ranging

Figure 6.3: Circuit of Ultrasonic detection and ranging

Figure 6.4: Displaying distance and direction

Dept E & C

38

PESCE,Mandya.

Ultrasonic Detection and Ranging


Our project consists of module shown in the figures above which is the main part of
our project.
Microcontroller used in this project PHILIPS 89V51RD2 which is programmed in
Embedded C program which helps us to write and debug the program easily.It is the
heart of the project and it controls each and every component to provide the accurate
location of the object within its range of operation.
Keil microvision IDE is used for coding and HEX file from it to program the
microcontroller.
Flash magic utility is used to burn the HEX file generated by Keil after compiling
the code into the microcontroller.
Actually this project is meant for providing 360 degree surveillance and can
provide location of the object in terms of direction and distance during day and
night.Though the project is best suited for stationary objects, it also provides direction
and distance of an object moving in a single direction.
This project can be enhanced by using sophisticated equipments and can be
implemented on ships to detect icebergs which are stationary. We have also used a
torch in this prototype model which can be used as a countering equipment. In highly
restricted areas the torch can be replaced by suitable countering equipments.This
prototype can detect any object within its range of operation and can provide distance
and direction of the object. Also it can detect instantaneous objects and provide
direction of that object.

Dept E & C

39

PESCE,Mandya.

Ultrasonic Detection and Ranging

CHAPTER 7

CONCLUSION

This project has been implemented successfully and found that it works as per our
expectations. Thus it fulfills the objective and provides 360 degree surveillance and
provides monitoring during night. However some merits and demerits of the system
implemented

7.1 Merits
1. This system provides accurate distance and direction of the object within it its range
of

operation.

2. Provides location of the object day and night.


3. This system is much cost effective.
4. The system and its operation can be easily understood.
5. It provides direction as well distance of a moving object in its transmission line.

7.2 Demerits
1.

The system cannot provide distance of randomly moving objects but gives the

direction of that object .For instance, instantaneous objects such as birds.


2. The system cannot detect flying objects such as planes.

Dept E & C

40

PESCE,Mandya.

Ultrasonic Detection and Ranging


7.3 Suggestion for improvements
1. This project can be enhanced by using sophisticated equipments such as antennas and
Radio frequency waves to increase the range of operation.
2.Counter attack measures can be implemented by replacing torch with countering
equipments in highly restricted areas.
3.PC interface can be made to continuosly show the location of the object.

Dept E & C

41

PESCE,Mandya.

Ultrasonic Detection and Ranging

CHAPTER 8

APPENDIX A
8.1 Circuit Diagram:

Dept E & C

42

PESCE,Mandya.

Ultrasonic Detection and Ranging

8.2 Source Code:


#include<reg51.h>
sbit rs = P1^0;
sbit rw = P1^1;
sbit en= P1^2;
sbit intr=P3^2;
sbit relay = P1^3;
/*Function Prototype*/
void lcd_intialise();
void lcd_cmd(unsigned char a);
void lcd_data(unsigned char s);
void lcd_string(unsigned char *b);
void dectoascii (unsigned char h);
void delay();

unsigned char p,q,flag1,flag2,a,flag3,flag4,x,y;

/* interupt when obtacle is detected */

void external() interrupt 0


{
unsigned char i,r,b[3];
if(flag3)
{
if(flag4)
{
relay = 1;
Dept E & C

43

PESCE,Mandya.

Ultrasonic Detection and Ranging


flag4 = 0;
if(flag1 == 1 && flag2 == 0)
{
for(i=0;i<6;i++)
{
P0=0x09;
delay();
P0=0x0c;
delay();
P0=0x06;
delay()
P0=0x03;
delay();
}
}
if(flag1 == 0 && flag2 == 1)
{
for(i=0;i<4;i++)
{
P0=0x03;
delay();
P0=0x06;
delay();
P0=0x0c;
delay();
P0=0x09;
delay();
Dept E & C

44

PESCE,Mandya.

Ultrasonic Detection and Ranging


}
}
do
{
RI = 0;
while(!RI);
r = SBUF;
RI = 0;
}while(r != 'R');
for(i=0;i<3;i++)
{
RI = 0;
while(!RI);
b[i] = SBUF;
RI = 0;
}
delay();
delay();
delay();
lcd_cmd(0x01);
lcd_cmd(0x80);
lcd_string("Distance:");
lcd_cmd(0x8B);
for(i=0;i<3;i++)
{
lcd_data(b[i]);
}
Dept E & C

45

PESCE,Mandya.

Ultrasonic Detection and Ranging


lcd_cmd(0xc0);
lcd_string("Direction:");
relay = 0;
if(flag1 == 1 && flag2 == 0)
{
//

x = p - 3;

dectoascii(p);
for(i=0;i<6;i++)
{
P0=0x03;
delay();
P0=0x06;
delay();
P0=0x0c;
delay();
P0=0x09;
delay();
}
}
if(flag1 == 0 && flag2 == 1)
{
//

y = q - 3;

//

y = 50 - q;

dectoascii(q);
for(i=0;i<4;i++)
{
P0=0x09;
Dept E & C

46

PESCE,Mandya.

Ultrasonic Detection and Ranging


delay();
P0=0x0c;
delay();
P0=0x06;
delay();
P0=0x03;
delay();
}
}
}
}
}

/* main function */
void main()
{
relay = 0;
flag3 = 0;
intr=0;
TMOD=0x20;
SCON=0x50;
TH1=0xfd;
TR1=1;
flag1 = 0;
flag2 = 0;
IE = 0x83;
IT0 = 1;
Dept E & C

47

PESCE,Mandya.

Ultrasonic Detection and Ranging

lcd_intialise();
lcd_string("....WELCOME....");
delay();
flag3 = 1;
while(1)
{
flag1 = 1;
flag2 = 0;
for(p=0; p<50; p++)
{
P0=0x03;
delay();
P0=0x06;
delay();
P0=0x0c;
delay();
P0=0x09;
delay();
flag4 = 1;
}
flag1 = 0;
flag2 = 1;
for(q=0; q<50; q++)
{
P0=0x09;
delay();
Dept E & C

48

PESCE,Mandya.

Ultrasonic Detection and Ranging


P0=0x0c;
delay();
P0=0x06;
delay();
P0=0x03;
delay();
flag4 = 1;
}
}
}

/* delay function */
void delay()
{
unsigned int i,m;
for(i=0;i<100;i++)
for(m=0;m<50;m++);
}

/* intialising lcd */
void lcd_intialise()
{
unsigned char i,a[]={0x38,0x0e,0x01,0x06,0x80};
for(i=0;i<5;i++)
{
lcd_cmd(a[i]);
delay();
Dept E & C

49

PESCE,Mandya.

Ultrasonic Detection and Ranging


}
}

/* lcd in command mode function */


void lcd_cmd(unsigned char a)
{
P2=a;
rs=0;
rw=0;
en=1;
delay();
en=0;
}

/* lcd data mode function */


void lcd_data(unsigned char s)
{
P2=s;
rs=1;
rw=0;
en=1;
delay();
en=0;
}
/* lcd string function */
void lcd_string(unsigned char *b)
{
Dept E & C

50

PESCE,Mandya.

Ultrasonic Detection and Ranging


while(*b)
{
lcd_data(*b++);
}
}

/* convertion from dcimal to ascii */


void dectoascii (unsigned char h)
{
unsigned int z;
unsigned char l,m,n,o,v,k;
l = 0;
m = 0;
n = 0;
z = h * 72;
l = z / 100;
m = z % 100;
n = l / 10;
n = n + 0x30;
o = l % 10;
o = o + 0x30;
v = m / 10;
v = v + 0x30;
k = m % 10;
k = k + 0x30;
lcd_data(n);
lcd_data(o);
Dept E & C

51

PESCE,Mandya.

Ultrasonic Detection and Ranging


lcd_data(v);
lcd_string(".");
lcd_data(k);
}

Dept E & C

52

PESCE,Mandya.

Ultrasonic Detection and Ranging

10.Bibiliography

1. Muhammad Ali Mazidi and Janice Gillepsie Mazidi, The 8051 Microcontroller and
Embedded Systems using Assembly and C,3e Pearson Education-2006
2. Kenneth Ayala, The 8051 Microcontroller,3e,Thomas Delmar Learning-2005
3. www.keil.Com
4. www.DatasheetCatalog.com
5. www.iec.com

Dept E & C

53

PESCE,Mandya.

You might also like