0% found this document useful (0 votes)
183 views53 pages

Ultrasonic Distance Measurement System: Bachelor of Technology IN Electronics and Communication Engineering

This document describes an ultrasonic distance measurement system project submitted by three students. It includes a cover page with the project title and students' names, a certificate page signed by the guide and head of department, an acknowledgment section thanking those who helped with the project, and a declaration by the students. The aim of the project is to design a prototype for a simple and low-cost ultrasonic distance measurement system using a microcontroller that can be used in applications like obstacle detection.

Uploaded by

Mrinal Shah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
183 views53 pages

Ultrasonic Distance Measurement System: Bachelor of Technology IN Electronics and Communication Engineering

This document describes an ultrasonic distance measurement system project submitted by three students. It includes a cover page with the project title and students' names, a certificate page signed by the guide and head of department, an acknowledgment section thanking those who helped with the project, and a declaration by the students. The aim of the project is to design a prototype for a simple and low-cost ultrasonic distance measurement system using a microcontroller that can be used in applications like obstacle detection.

Uploaded by

Mrinal Shah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 53

ULTRASONIC DISTANCE MEASUREMENT SYSTEM

A mini project report submitted in the partial fulfillment of the requirement


For the award of the degree of

BACHELOR OF TECHNOLOGY

IN

ELECTRONICS AND COMMUNICATION


ENGINEERING

SUBMITTED BY

MONIKA MOHANTY- 15K81A04M4

MRINAL A SHAH- 15K81A04M5

SURAJ KUMAR MAITY-15K81A04N8

Under the Esteemed Guidance of

Mr T.Sudheer Kumar, M.Tech


Associate Professor

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

ST.MARTIN’S ENGINEERING COLLEGE


(NBA Accredited, Permanently Affiliated to JNTUH, Approved by AICTE, ISO 9001:2008 Certified Institute)

Dhulapally, Secunderabad, Telangana, India-500100

2015-2019
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

CERTIFICATE

This is to certify that the Project work embodies in the dissertation entitled ‘ULTRASONIC
DISTANCE MEASUREMENT SYSTEM ’that is being submitted by the following students in
partial fulfillment for the requirement for award of degree of BACHELOR OF TECHNOLOGY in
Electronics and Communication Engineering from St. Martin’s Engineering College,
Secunderabad, is a record of bonafied work carried out during the academic year 2015-2019.

MONIKA MOHANTY- 15K81A04M4

MRINAL A SHAH- 15K81A04M5

SURAJ KUMAR MAITY-15K81A04N8

Under the supervision and the guidance of

Supervised by, Head of the department, ECE


Mr. T.Sudheer Kumar, M.Tech Dr. Rajeev Shrivastava, PhD

Associate professor, ECE

EXTERNAL EXAMINER

i
ACKNOWLEDGEMENT

We are happy to express our deep sense of gratitude to the principal of the college Dr. Santosh
Kumar Patra, Professor for having provided us with adequate facilities to pursue our project.
We would like to thank Mr. Rajeev Srivastava, Associate Professor and Head of the
Department of Electronics and Communication Engineering, St.Martin’s Engineering
College, for having provided the freedom to use all the facilities available in the department,
especially the laboratories and the library.
We are very grateful to our project guide Mr. T.Sudheer Kumar, Associate Professor,
Department of Electronics and Communication Engineering, St.Martin’s Engineering College,
for his extensive patience and guidance throughout my project work.
We are also thankful to Dr.C.Elavarasi, Associate Professor, project co-ordinator in the
Department of Electronics and Communication Engineering, St.Martin’s Engineering College,
for her extensive patience and guidance throughout our project work.
We sincerely thank all the teaching and non-teaching staff of the Department of Electronics
and Communication for their timely suggestions, healthy criticism and motivation during the
course of this work.
We would also like to thank our classmates for always being there whenever we needed help
or moral support. With great respect and obedience, I thank my parents who were the
backbone behind our deeds.
Finally, we express our immense gratitude with pleasure to other individuals who have either
directly or indirectly contributed to our need at right time for the development and success of
this work.

ii
DECLARATION

We, Monika Mohanty, Mrinal A Shah, Suraj Kumar Maity, the students of Bachelor of
Technology in the department of Electronics and Communication Engineering, during the year
2015-2019 of St Martin’s Engineering College, hereby declare that the work presented by this
project entitled “ULTRASONIC DISTANCE MEASUREMENT SYSTEM” is the outcome of
our own bonafied work and it is correct to the best of our knowledge and this has been undertaken
taking care of engineering ethics. The result embodied in this project report has not been submitted
in any of the University for Award of any degree.

MONIKA MOHANTY (15K81A0M4)

MRINAL A SHAH (15K81A04M5)

SURAJ KUMAR MAITY (15K81A04N8)

iii
INDEX

CHAPTER TABLE OF CONTENTS PAGE NO.


CERTIFICATE i
ACKNOWLEDGEMENT ii
DECLARATION iii
INDEX iv
LIST OF FIGURES vi
LIST OF TABLES vii
LIST OF ABBREVATIONS viii
ABSTARCT ix
1 INTRODUCTION 1
1.1 Objective 1
1.2 Aim 1
1.3 Motivation 1
1.4 Distance measurement 2
1.5 Embedded System 3
1.6 Literature Survey 8
2 METHODOLOGY
2.1 Organizational thesis 11
2.2 Block diagram 12
2.3 Schematic Diagram 14
2.4 Hardware components 16
2.4.1 Power Supply 16
2.4.2 Ultrasonic Sensor 17
2.4.3 AtMega16 microcontroller 18
2.4.4 Timer 25
2.4.5 Analog to Digital Converter 25
2.4.6 Real Time Clock 27
2.4.7 Liquid Crystal Display 29
3 SOFTWARE IMPLEMENTATION 32
3.1 AVR Studio 34
3.2 Benefits of AVR 35

iv
4 ADVANTADGES AND APPLICATIONS
4.1 Advantages 36
4.2 APPLICATIONS 36

5 SOFTWARE CODING 37
RESULT 38
CONCLUSION 41
FUTURE SCOPE 42
REFERENCES 43

v
LIST OF FIGURES

Fig No NAME OF FIGURE PAGE.NO

4.1 Block diagram of secured data transfer 17


6.2.3 Timing Diagram 23
6.3.4.1 Architecture of AtMega16 27
6.4 Timer 29
6.7.1 Interfacing of LCD 36

vi
LIST OF TABLES

TABLE NAME PAGE.NO

1. Electrical parameters of HC-SR04 22


2. AT Mega16 microcontroller 26
3. Data Registers 28
4. CPSR Register 28
5. Pin description of ADC 30
6. LCD pin diagram 33
7. LCD Command codes 35

vii
LIST OF ABBREVIATIONS

1) USB Universal Serial Bus


2) IP Internet Protocol
3) HDMI High Definition Multimedia Interface
4) LED Light Emitting Diode
5) IR Infrared
6) LCD Liquid Crystal Display

viii
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 control, blind man walking stick, medical applications, etc. Measurement

using ultrasonic sensors is one of the cheapest among various options. In this project

distance measurement of an obstacle by using ultrasonic sensor and a microcontroller is

presented.

ix
CHAPTER-1

INTRODUCTION

1.1OBJECTIVE OF THE PROJECT:

There is a need to measure the distance between two objects, let it be to moving objects or
two stationary objects or one moving and the other stationary object. If the distance
between the objects is known before hand, then many accidents can be prevented thereby
increasing the mortality rate. The distance measurement is also done for commercial usage,
for example in the packaging industry, if the accurate measurement of the incoming
product and the packet is known, then timely package is expected. Blind people can also
use the blind stick to detect any obstacle , that uses the similar concept of ultrasonic
distance measurement system.

1.2 AIM OF THE PROJECT:

The main aim the project is to design a prototype of the simplest distance measuring system
that can facilitate any complicated applications with minimum complexity. This design is
made using ultrasonic waves that detects the obstacle in its line of sight accurately.

1.3 MOTIVATION OF THE PROJECT:

The main reason for preferring this project is to design a distance measuring system that
can detect the distance of an obstacle accurately with a simple design. The existing models
using complex designs to measure the distance, it is much more easier and feasible to
detect the obstacle using this design.

1.4 INTRODUCTION TO DISTANCE MEASUREMENT

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 systems. 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 ATmega16 microcontroller based system. This microcontroller
is easily available at low cost. A correlation is applied to minimize the error in the
1
measured distance. Ultrasound sensors are very versatile in distance measurement. They
are also providing the cheapest solutions. Ultrasound 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 obstacle can be obtained and then they are observed and analyzed.

The main limitation of these systems is that they cannot tell you the exact distance or
location of the obstacle.
1.4.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.4.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.

1.5 INTRODUCTION TO EMBEDDED SYSTEMS

1.5.1 Embedded System


An embedded system is a special-purpose computer system designed to perform one or a
few dedicated functions, sometimes with real-time computing constraints. It is usually
embedded as part of a complete device including hardware and mechanical parts. In
contrast, a general-purpose computer, such as a personal computer, can do many different
tasks depending on programming. Embedded systems have become very important today
as they control many of the common devices we use.
Since the embedded system is dedicated to specific tasks, design engineers can optimize it,
reducing the size and cost of the product, or increasing the reliability and performance.
Some embedded systems are mass-produced, benefiting from economies of scale.
Physically, embedded systems range from portable devices such as digital watches and
MP3 players, to large stationary installations like traffic lights, factory controllers, or the
systems controlling nuclear power plants. Complexity varies from low, with a single
2
microcontroller chip, to very high with multiple units, peripherals and networks mounted
inside a large chassis or enclosure.
In general, "embedded system" is not an exactly defined term, as many systems have some
element of programmability. For example, Handheld computers share some elements with
embedded systems — such as the operating systems and microprocessors which power
them — but are not truly embedded systems, because they allow different applications to
be loaded and peripherals to be connected.
An embedded system is some combination of computer hardware and software, either fixed
in capability or programmable, that is specifically designed for a particular kind of
application device. Industrial machines, automobiles, medical equipment, cameras,
household appliances, airplanes, vending machines, and toys (as well as the more obvious
cellular phone and PDA) are among the myriad possible hosts of an embedded system.
Embedded systems that are programmable are provided with a programming interface, and
embedded systems programming is a specialized occupation.
Certain operating systems or language platforms are tailored for the embedded market,
such as Embedded Java and Windows XP Embedded. However, some low-end consumer
products use very inexpensive microprocessors and limited storage, with the application
and operating system both part of a single program. The program is written permanently
into the system's memory in this case, rather than being loaded into RAM (random access
memory), as programs on a personal computer are.
1.5.2 Applications of Embedded System
We are living in the Embedded World. You are surrounded with many embedded products
and your daily life largely depends on the proper functioning of these gadgets. Television,
Radio, CD player of your living room, Washing Machine or Microwave Oven in your
kitchen, Card readers, Access Controllers, Palm devices of your work space enable you to
do many of your tasks very effectively. Apart from all these, many controllers embedded in
your car take care of car operations between the bumpers and most of the times you tend to
ignore all these controllers.

In recent days, you are showered with variety of information about these embedded
controllers in many places. All kinds of magazines and journals regularly dish out details
about latest technologies, new devices; fast applications which make you believe that your
basic survival is controlled by these embedded products. Now you can agree to the fact that
these embedded products have successfully invaded into our world. You must be
wondering about these embedded controllers or systems. What is this Embedded System?
The computer you use to compose your mails, or create a document or analyze the

3
database is known as the standard desktop computer. These desktop computers are
manufactured to serve many purposes and applications.
You need to install the relevant software to get the required processing facility. So, these
desktop computers can do many things. In contrast, embedded controllers carryout a
specific work for which they are designed. Most of the time, engineers design these
embedded controllers with a specific goal in mind. So these controllers cannot be used in
any other place.
Theoretically, an embedded controller is a combination of a piece of microprocessor based
hardware and the suitable software to undertake a specific task.
These days designers have many choices in microprocessors/microcontrollers. Especially,
in 8 bit and 32 bit, the available variety really may overwhelm even an experienced
designer. Selecting a right microprocessor may turn out as a most difficult first step and it
is getting complicated as new devices continue to pop-up very often.
In the 8 bit segment, the most popular and used architecture is Intel's 8031. Market
acceptance of this particular family has driven many semiconductor manufacturers to
develop something new based on this particular architecture. Even after 25 years of
existence, semiconductor manufacturers still come out with some kind of device using this
8031 core.

[1] Military and aerospace software applications

From in-orbit embedded systems to jumbo jets to vital battlefield networks, designers of
mission-critical aerospace and defense systems requiring real-time performance,
scalability, and high-availability facilities consistently turn to the LINUX RTOS and the
LynxOS-178 RTOS for software certification to DO-178B.

Rich in system resources and networking services, LINUX OS provides an off-the-shelf


software platform with hard real-time response backed by powerful distributed computing
(CORBA), high reliability, software certification, and long-term support options.

The LynxOS-178 RTOS for software certification, based on the RTCA DO-178B standard,
assists developers in gaining certification for their mission- and safety-critical systems.
Real-time systems programmers get a boost with Linux Works' DO-178B RTOS training
courses.

[2] Communications applications

"Five-nine" availability, Compact PCI hot swap support, and hard real-time response—
4
LINUX OS delivers on these key requirements and more for today's carrier-class systems.
Scalable kernel configurations, distributed computing capabilities, integrated
communications stacks, and fault-management facilities make Linux OS the ideal choice
for companies looking for a single operating system for all embedded telecommunications
applications—from complex central controllers to simple line/trunk cards.

Linux Works Jumpstart for Communications package enables OEMs to rapidly develop
mission-critical communications equipment, with pre-integrated, state-of-the-art, data
networking and porting software components—including source code for easy
customization.

The Lynx Certifiable Stack (LCS) is a secure TCP/IP protocol stack designed especially for
applications where standards certification is required.

[3] Electronics applications and consumer devices

As the number of powerful embedded processors in consumer devices continues to rise, the
Blue Cat Linux operating system provides a highly reliable and royalty-free option for
systems designers.

And as the wireless appliance revolution rolls on, web-enabled navigation systems, radios,
personal communication devices, phones and PDAs all benefit from the cost-effective
dependability, proven stability and full product life-cycle support opportunities associated
with Blue Cat embedded Linux. Blue Cat has teamed up with industry leaders to make it
easier to build Linux mobile phones with Java integration.

For makers of low-cost consumer electronic devices who wish to integrate the Linux OS
real-time operating system into their products, we offer special MSRP-based pricing to
reduce royalty fees to a negligible portion of the device's MSRP.

[4] Industrial automation and process control software

Designers of industrial and process control systems know from experience that Linux
Works operating systems provide the security and reliability that their industrial
applications require.

From ISO 9001 certification to fault-tolerance, POSIX conformance, secure partitioning


and high availability, we've got it all. Take advantage of our 20 years of experience.

5
Wireless Sensor Networks

Wireless sensor networks (WSN), sometimes called wireless sensor and actuator
networks (WSAN) are spatially distributed autonomous sensors to monitor physical or
environmental conditions, such as temperature, sound, pressure, etc. and to cooperatively
pass their data through the network to a main location. The more modern networks are bi-
directional, also enabling control of sensor activity. The development of wireless sensor
networks was motivated by military applications such as battlefield surveillance; today
such networks are used in many industrial and consumer applications, such as industrial
process monitoring and control, machine health monitoring, and so on.

The WSN is built of "nodes" – from a few to several hundreds or even thousands, where
each node is connected to one (or sometimes several) sensors. Each such sensor network
node has typically several parts: a radio transceiver with an internal antenna or connection
to an external antenna, a microcontroller, an electronic circuit for interfacing with the
sensors and an energy source, usually a battery or an embedded form of energy harvesting.
A sensor node might vary in size from that of a shoebox down to the size of a grain of dust,
although functioning "motes" of genuine microscopic dimensions have yet to be created.
The cost of sensor nodes is similarly variable, ranging from a few to hundreds of dollars,
depending on the complexity of the individual sensor nodes. Size and cost constraints on
sensor nodes result in corresponding constraints on resources such as energy, memory,
computational speed and communications bandwidth. The topology of the WSNs can vary
from a simple star network to an advanced multi-hop wireless mesh network. The
propagation technique between the hops of the network can be routing or flooding.

1.4 Wireless Communication


Wireless communication is the transfer of information or power between two or more
points that are not connected by an electrical conductor. The most common wireless
technologies use radio. With radio waves distances can be short, such as a few meters
for television or as far as thousands or even millions of kilometers for deep-space radio
communications. It encompasses various types of fixed, mobile, and portable applications,
including two-way radios, cellular telephones, personal digital assistants (PDAs),
and wireless networking. Other examples of applications of radio wireless
technology include GPS units, garage door openers, wireless computer
mice, keyboards and headsets, headphones, radio receivers, satellite television, broadcast

6
television and cordless telephones.
Somewhat less common methods of achieving wireless communications include the use of
other electromagnetic wireless technologies, such as light, magnetic, or electric fields or
the use of sound. The term wireless has been used twice in communications history, with
slightly different meaning. It was initially used from about 1890 for the first radio
transmitting and receiving technology, as in wireless telegraphy, until the new
word radio replaced it around 1920. The term was revived in the 1980s and 1990s mainly
to distinguish digital devices that communicate without wires, such as the examples listed
in the previous paragraph, from those that require wires or cables. This became its primary
usage in the 2000s, due to the advent of technologies such as LTE, LTE-Advanced, Wi-
Fi and Bluetooth.
Wireless operations permit services, such as long-range communications, that are
impossible or impractical to implement with the use of wires. The term is commonly used
in the telecommunications industry to refer to telecommunications systems (e.g. radio
transmitters and receivers, remote controls, etc.) which use some form of energy (e.g. radio
waves, acoustic energy,) to transfer information without the use of wires.[1] Information is
transferred in this manner over both short and long distances.

1.6 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). This sensor may be
useful for simple requirement but they have following drawbacks:
1. Can’t say anything about the real distance of obstacle.
2. Give different result for different colored 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 these entire problems we can use an Ultrasonic Range Finder Module. An
Ultrasonic Range Finder Module uses ultrasonic waves (inaudible to humans) to measure
distance. These modules consist of an Ultrasonic Transmitter (Tx) that emits the ultrasonic
wave, the waves after striking any obstacle bounces back and reach the Ultrasonic
7
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 an accuracy of 1cm.
These specifications make 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 is:


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 AVR running at
16MIPS(maximum for most AVRs) 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 an ”image” of obstacle in the surrounding
area (like a radar).
3. Finally the wave does not disturb any humans nearby.

1.6.1 Micro controller section forms the control unit of the whole project. This section
basically consists of a Microcontroller with its associated circuitry like Crystal with
capacitors, Reset circuitry, Pull up resistors and so on. The Microcontroller forms the heart
of the project because it controls the devices being interfaced and communicates with the
[2]
devices according to the program being written. ARM7 TDMI , ARM is the
abbreviation of Advanced RISC Machines, it is the name of a class of processors, and is
the name of a kind technology too. The RISC instruction set, and related decode
mechanism are much simpler than those of Complex Instruction Set Computer (CISC)
designs.

8
1.6.2 Liquid-crystal display (LCD) is a flat panel display, electronic visual display that
[3]
uses the light modulation properties of liquid crystals. Liquid crystals do not emit
light directly. LCDs are available to display arbitrary images or fixed images which can
be displayed or hidden, such as preset words, digits, and 7-segment displays as in a
digital clock. They use the same basic technology, except that arbitrary images are
made up of a large number of small pixels, while other displays have larger elements.

1.6.3 Radio-frequency identification (RFID) is the wireless use of electromagnetic fields


to transfer data, for the purposes of automatically identifying and tracking tags attached
to objects. The tags contain electronically stored information. Some tags are powered
by electromagnetic induction from magnetic fields produced near the reader. Some
types collect energy from the interrogating radio waves and act as a passive
transponder. Other types have a local power source such as a battery and may operate at
hundreds of meters from the reader. Unlike a barcode, the tag does not necessarily need
to be within line of sight of the reader, and may be embedded in the tracked object.
RFID is one method for Automatic Identification and Data Capture (AIDC).

1.6.4 GPRS is a packet oriented mobile data service on the 2G and 3G cellular
communication system’s global system for mobile communications GSM [6]. GPRS was
originally standardized by European Telecommunications Standards Institute (ETSI) in
response to the earlier CDPD and packet switched cellular technologies. It is now
maintained by the 3rd Generation Partnership Project (3GPP). GPRS usage is typically
charged based on volume of data transferred, contrasting with circuit switched data,
which is usually billed per minute of connection time.

9
CHAPTER-2
METHODOLOGY

2.1 ORGANISATIONAL THESIS

In this project, firstly we learn about the block diagram part to implement this
application. This gives a very clear idea about the further procedure. Then we put
forward towards the schematics of each and every module in the project. After having
clear overview about the project with the help of schematics and block diagram, we go
through the hardware modules in the project one after the other.

Firstly, micro controller is the base module of the project. We interface other hardware
modules with the help of micro controller only. We used the ultrasonic sensor to detect
the obstacle using ultrasonic waves. LCD is used for the displaying of the data regarding
the distance. All this information from the ultrasonic sensor is transmitted from the
transmitter section and then the radio waves are detected back using echo signals at the
receiving section. The received information from receiver section is given to
microcontroller. The information is stored and displayed in LCD. Now, the software
implementation is done using BASCOM software. The results are followed by the
conclusion, applications and future scope of the project.

10
2.2 BLOCK DIAGRAM EXPLANATION

Fig.2.1 Block Diagram of Secured Data Transfer

The block diagram mainly consist of six parts :

1) Power Supply

2) Ultrasonic Sensor Unit

3) Microcontroller

4) 16X2 LCD Display

5) Object

2.2.1 MICRO CONTROLLER:

In this project work the micro-controller is plays major role. Micro-controllers were
originally used as components in complicated process-control systems. However, because
of their small size and low price, Micro-controllers are now also being used in regulators for
11
individual control loops. In several areas Micro-controllers are now outperforming their
analog counterparts and are cheaper as well.

2.2.2 POWER SUPPLY:

In this project we required operating voltage for ARM controller board is 12V. Hence the
12V D.C. power supply is needed for the ARM board. This regulated 12V is generated by
stepping down the voltage from 230V to 18V now the step downed A.C voltage is being
rectified by the Bridge Rectifier using 1N4007 diodes. The rectified A.C voltage is now
filtered using a ‘C’ filter. Now the rectified, filtered D.C. voltage is fed to the Voltage
Regulator. This voltage regulator provides/allows us to have a Regulated constant Voltage
which is of +12V. Now the output from this section is fed to microcontroller board to supply
operating voltage.

2.2.3 LCD:

LCD is used to display the information about the current process. The LCD’s are
lightweight with only a few millimeters thickness. Since the LCD’s consume less power,
they are compatible with low power electronic circuits, and can be powered for long
durations.

2.2.4 Ultrasonic Sensor Unit:

A good sensor according to the requirements.

2.2.5 Object:

It is that thing whose distance is to be measured from the system

12
2.3 SCHEMATIC EXPLANATION

In this project we required operating voltage for ARM controller board is 12V. Hence
the 12V D.C. power supply is needed for the ARM board. This regulated 12V is
generated by stepping down the voltage from 230V to 18V now the step downed A.C
voltage is being rectified by the Bridge Rectifier using 1N4007 diodes. The rectified
A.C voltage is now filtered using a ‘C’ filter. Now the rectified, filtered D.C. voltage
is fed to the Voltage Regulator provides constant voltage of +12V. The regulated
voltage is again filtered for ripples using an electrolytic capacitor 100μF. Now the
output from this section is fed to microcontroller board to supply operating voltage.

Fig.2.3 Schematic circuit diagram

13
The hardware modules are interfaced to the micro controller as
follows: LCD is interfaced to the controller Port 1 of P1.16 to P
1.21.
RFID READER IS CONNECTED TO THE
P0.22. ZIGBEE IS CONNECTED TO THE
UART0.
GSM is connected to the
UART1. PC is interfaced
using UART1.

2.3.1 SCHEMATIC CIRCUIT DESCRIPTION:

The project will use ARM7 TDMI-S based NXP’s (national semiconductors and
Philips) LPC 2148 microcontroller in LQFP (Liquid Quad Flat package) with 64 pins.
The Power requirement of LPC2148 Microcontroller is 3.3VDC and VSS ground.

The power supply for the LPC2148 is produced by using available 1 Φ 230VAC with
the help of conversion AC to DC supply which includes four most basic steps of step
down the available power to required level of power supply, Rectification of 1Φ supply
to the pulsated DC supply, filtering of Pulsated DC supply to non regulated DC supply
and then through regulator a pure regulated DC supply is produced. Here in this project
every vehicle will be having a unique identification number i.e. a RFID tag attached to
the vehicle. The tag contains the details about the vehicle like name, number, type of
vehicle, license, RC book details etc. At toll gate we have an RFID module, which will
read the RFID tag of the vehicle passing in that way. By using the card we can pay the
tax of the vehicle. The card will be placed in front of the card reader and the card is
checked for validation and sufficient balance then the concerned amount will be
reduced from the card and then the gate will be opened and the vehicle will be allowed.
The details of the vehicle are displayed on LCD and also payment printed copy is
provided to the vehicle driver by printer. All this information from transmitter section is
transmitted to the receiver section by using Zigbee transceiver. The received
information from transmitter section is given to microcontroller. The information is
stored and displayed in PC. Then the official data has be uploaded into server internet
by using GPRS terminal.

14
2.4 HARDWARE DESCRIPTION

2.4.1POWER SUPPLY

In mains-supplied electronic systems the AC input voltage must be converted into a DC


voltage with the right value and degree of stabilization. The common DC voltages that
are required to power up the devices are generally in the range of 3 VDC to 30 VDC.
Typically the fixed types of DC voltages are 5V, 9V, 12V, 15V and 18V DC.

Fig.2.4.1 Power Supply Circuit

In this project we required operating voltage for ARM controller board is 12V. Hence
the 12V D.C. power supply is needed for the ARM board. This regulated 12V is
generated by stepping down the voltage from 230V to 18V now the step downed A.C
voltage is being rectified by the Bridge Rectifier using 1N4007 diodes. The rectified
A.C voltage is now filtered using a ‘C’ filter. Now the rectified, filtered D.C. voltage is
fed to the Voltage Regulator provides constant voltage of +12V. The regulated voltage
is again filtered for ripples using an electrolytic capacitor 100μF. Now the output from
this section is fed to microcontroller board to supply operating voltage.

15
2.4.2 Ultrasonic Ranging Module HC - SR04

2.4.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

2.4.2.2 Electrical Parameters

Table 1:electrical parameters of HCSR04

16
2.4.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.

Fig6.2.3 timing diagram of HCSR04

2.4.3 ATMEGA16 MICROCONTROLLER

ATmega16 is an 8-bit high performance microcontroller of Atmel’s Mega AVR family


with low power consumption. Atmega16 is based on enhanced RISC (Reduced Instruction
Set Computing, Know more about RISC and CISC Architecture) architecture with 131
powerful instructions. Most of the instructions execute in one machine cycle. Atmega16
can work on a maximum frequency of 16MHz.

ATmega16 has 16 KB programmable flash memory, static RAM of 1 KB and EEPROM of


512 Bytes. The endurance cycle of flash memory and EEPROM is 10,000 and 100,000,
respectively.

2.4.3.1 Specifications

1. High-performance, Low-power AVR 8-bit Microcontroller


2. Advanced RISC Architecture
17
a) 131 Powerful Instructions Most Single-clock Cycle Execution
b) 32 x 8 General Purpose Working Registers
c) Fully Static Operation
d) Up to 16 MIPS Throughput at 16 MHz
e) On-chip 2-cycle Multiplier
3. Peripheral Features
a) Two 8-bit Timer/Counters with Separate Prescalers and Compare Modes
b) One 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and Capture Mode
c) Real Time Counter with Separate Oscillator
d) Four PWM Channels
e) 8-channel, 10-bit ADC
f) Master/Slave SPI Serial Interface
g) Programmable Watchdog Timer with Separate On-chip Oscillator
h) On-chip Analog Comparator
4. Special Microcontroller Features
a) Power-on Reset and Programmable Brown-out Detection
b) Internal Calibrated RC Oscillator
c) External and Internal Interrupt Sources
d) Six Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down, Standby and
Extended Standby

18
2.4.3.2 ATMEGA 16 PIN DIAGRAM

1) VCC: Digital supply voltage


2) GND: Ground
3) Port A (PA7..PA0): Port A serves as the analog inputs to the A/D Converter. Port A is
also used as an 8-bit bi-directional I/O port if the analog to digital converter is not used.
The Port A output buffers have symmetrical drive characteristics. When pins PA0 to PA7
are used as inputs, they will source current if the internal pull-up resistors are activated.
When a reset condition becomes active, Port A pins are tri-stated even if the clock is not
running.
4) Port B (PB7..PB0): Port B is an 8-bit bi-directional I/O port with internal pull-up
resistors. The Port B output buffers also have symmetrical drive characteristics with both
high sink and source capability. Port B pins which are externally pulled low will source
current if the pull-up resistors are activated. When a reset condition becomes active and
even if the clock is not running, the Port B pins become tri-stated.
5) Port C (PC7..PC0): Port C is an 8-bit bi-directional I/O port with internal pull-up
resistors (selected for each bit). If the pull-up resistors are activated Port C output buffers
also have symmetrical drive characteristics with both high sink and source capability. Port
C pins which are externally pulled low will source current. When a reset condition
19
becomes active the Port C pins are tristated, even if the clock is not running. The pull-up
resistors on pinsPC5 (TDI), PC3 (TMS) and PC2 (TCK) will be activated if the JTAG
interface is enabled even if a reset occurs.
6) Port D (PD7..PD0): Port D is an 8-bit bi-directional I/O port with internal pull-up
resistors. The Port D output buffers also have symmetrical drive characteristics with both
high sink and source capability. As inputs, Port D pins which are externally pulled low
will source current if the pull-up resistors are activated. When a reset condition becomes
active the Port D pins becomes tri-stated, even if the clock is not running.

I/O , T0 ( Timer0 External Counter Input) ,XCK


PIN1
: USART External Clock I/O

PIN2 I/O, T1 (Timer1 External Counter Input)

I/O, AIN0: Analog Comparator Positive Input ,


PIN3
INT2: External Interrupt 2 Input

I/O, AIN1: Analog Comparator Negative Input,


PIN4
OC0 : Timer0 Output Compare Match Output

PIN9 Reset Pin, Active Low Reset

PIN10 VCC=+5V

PIN11 GND

PIN12 XTAL2

PIN13 XTAL1

(RXD) ,I/O PIN 0,USART Serial


PIN14
Communication Interface

(TXD) ,I/O Pin 1,USART Serial Communication


PIN15
Interface

PIN16 (INT0),I/O Pin 2, External Interrupt INT0

PIN17 (INT1),I/O Pin 3, External Interrupt INT1

PIN18 (OC1B),I/O Pin 4, PWM Channel Outputs

20
PIN19 (OC1A),I/O Pin 5, PWM Channel Outputs

(ICP), I/O Pin 6, Timer/Counter1 Input Capture


PIN20
Pin

(OC2),I/O Pin 7,Timer/Counter2 Output


PIN21
Compare Match Output

PIN22 (SCL),I/O Pin 0,TWI Interface

PIN23 (SDA),I/O Pin 1,TWI Interface

PIN24-
JTAG INTERFACE
27

PIN28 : (TOSC1),I/O Pin 6,Timer Oscillator Pin 1

PIN29 : (TOSC2),I/O Pin 7,Timer Oscillator Pin 2

PIN30 : AVCC (for ADC)

PIN31 : GND (for ADC)

PIN33 –
PAx: I/O,ADCx (Where x is 7 – 0)
PIN40

Table2: pin diagram of AtMega16 microcontroller

2.4.3.3 Data Registers

(A) Core Data path:

Architecture is characterized by Data path and control path.


Data path is organized in such a way that, operands are not fetched directly from
memory locations. Data items are placed in register files. No data processing takes place in
memory locations.
Instructions typically use 3 registers. 2 source registers and 1 destination register.
Barrel Shifter preprocesses data, before it enters ALU.

21
Barrel Shifter is basically a combinational logic circuit, which can shift data to left
or right by arbitrary number of position in same cycle.
Increment or Decrement logic can update register content for sequential access.

(B) Pipeline:

In ARM 7, a 3 stage pipeline is used. A 3 stage pipeline is the simplest form of pipeline
that does not suffer from the problems such as read before write.
In a pipeline, when one instruction is executed, second instruction is decoded and third
instruction will be fetched.
This is executed in a single cycle.

(C) Register Bank:

ARM 7 uses load and store Architecture.


Data has to be moved from memory location to a central set of registers.
Data processing is done and is stored back into memory.
Register bank contains, general purpose registers to hold either data or address.
It is a bank of 16 user registers R0-R15 and 2 status registers.
Each of these registers is 32 bit wide.



Fig 6.3.4.1: Architecture of AtMega16 microcontroller

22
(D) Data Registers- R0-R15:

R0-R12 - General Purpose Registers


R13-R15 - Special function registers of which,

R13 - Stack Pointer, refers to entry pointer of Stack.


R14 - Link Register, Return address is put to this whenever a subroutine is
called.

R15 - Program Counter


Depending upon application R13 and R14 can also be used as GPR. But not commonly used.

Table 3: Data Registers

CPSR - Current program status register, status of current execution is stored.


SPSR - Saved program Status register, includes status of program as well as processor.

CPSR contains a number of flags which report and control the operation of ARM7 CPU.

Table 4: CPSR Register

23
2.4.4 Timer
Timers are standard features of almost every microcontroller. So it is very important to learn
their use. Since an AVR microcontroller has very powerful and multifunctional timers, the
topic of timer is somewhat vast. Moreover there are many different timers on chip. So this
section on timers will be multipart. I will be giving basic introduction first.
What is a timer?
A timer in simplest term is a register. Timers generally have a resolution of 8 or 16 Bits. So a
8 bit timer is 8Bits wide so capable of holding value within 0-255. But this register has a
magical property! Its value increases/decreases automatically at a predefined rate (supplied
by user). This is the timer clock. And this operation does not need CPUs intervention.

Since Timer works independently of CPU it can be used to measure time accurately. Timer
upon certain conditions takes some action automatically or informs CPU. One of the basic
conditions is the situation when timer OVERFLOWS i.e. its counted upto its maximum value
(255 for 8 BIT timers) and rolled back to 0. In this situation timer can issue an interrupt and
you must write an Interrupt Service Routine (ISR) to handle the event.

2.4.5ANALOG-TO-DIGITAL CONVERTE(ADC):

(A) Features:

10 bit successive approximation analog to digital converter (one in LPC2141/2 and two
in LPC2144/6/8).

Input multiplexing among 6 or 8 pins (ADC0 and ADC1).


Power-down mode.
24
Burst conversion mode for single or multiple inputs.
Optional conversion on transition on input pin or Timer Match signal.
Global Start command for both converters (LPC2144/6/8 only).

(B) Description:

Basic clocking for the A/D converters is provided by the VPB clock. A programmable
divider is included in each converter, to scale this clock to the 4.5 MHz (max) clock
needed by the successive approximation process. A fully accurate conversion requires 11
of these clocks.

(C) Pin Description:

Table 5-Pin description of ADC

25
(D) Operation:

Hardware-triggered conversion:

If the BURST bit in the ADCR is 0 and the START field contains 010-111, the ADC will
start a conversion when a transition occurs on a selected pin or Timer Match signal. The
choices include conversion on a specified edge of any of 4 Match signals, or conversion on
a specified edge of either of 2 Capture/Match pins. The pin state from the selected pad or
the selected Match signal, XORed with ADCR bit 27, is used in the edge detection logic

Interrupts:

An interrupt request is asserted to the Vectored Interrupt Controller (VIC) when the
DONE bit is 1. Software can use the Interrupt Enable bit for the A/D Converter in the VIC
to control whether this assertion results in an interrupt. DONE is negated when the ADDR
is read.

2.4.6 REAL TIME CLOCK

(A) Features

 Measures the passage of time to maintain a calendar and clock.


 Ultra Low Power design to support battery powered systems
 Provides Seconds, Minutes, Hours, Day of Month, Month, Year, Day of Week, and Day
of Year
 Dedicated 32 kHz oscillator or programmable pre scaler from VPB clock.
 Dedicated power supply pin can be connected to a battery or to the main 3.3 V

(B) Description:

It uses little power in Power-down mode. On the LPC2141/2/4/6/8, the RTC can be
clocked by a separate 32.768 KHz oscillator, or by a programmable pre scale divider based
on the VPB clock. Also, the RTC is powered by it’s, which can be connected to a battery
or to the same 3.3 V supply used by the rest of the device.

26
(C) RTC interrupts:

Interrupt generation is controlled through the Interrupt Location Register (ILR), Counter
Increment Interrupt Register (CIIR), the alarm registers, and the Alarm Mask
Register(AMR). Interrupts are generated only by the transition into the interrupt state. The
ILR separately enables CIIR and AMR interrupts. Each bit in CIIR corresponds to one of
the time counters. If CIIR is enabled for a particular counter, then every time the counter is
Incremented an interrupt is generated. The alarm registers allow the user to specify a date
and time for an interrupt to be generated. The AMR provides a mechanism to mask alarm
Compares. If all non masked alarm registers match the value in their corresponding time
counter, then an interrupt is generated. The RTC interrupt can bring the microcontroller
out of power-down mode if the RTC is operating from its own oscillator on the RTCX1-2
pins. When the RTC interrupt is enabled for wakeup and its selected event occurs,
XTAL1/2 pins associated oscillator wakeup cycle is started.

Miscellaneous register group:

 Interrupt Location Register (ILR - 0xE002 4000):

The Interrupt Location Register is a 2-bit register that specifies which blocks are
generating an interrupt

 Clock Tick Counter Register (CTCR - 0xE002 4004):

The Clock Tick Counter is read only. It can be reset to zero through the Clock Control
Register (CCR). The CTC consists of the bits of the clock divider counter.

27
2.4.7 LIQUID CRYSTAL DISPLAY

An LCD consists of two glass panels, with the liquid crystal material sand witched in
between them. The inner surface of the glass plates are coated with transparent electrodes
which define the character, symbols or patterns to be displayed polymeric layers are present
in between the electrodes and the liquid crystal, which makes the liquid crystal molecules to
maintain a defined orientation angle.

One each polarisers are pasted outside the two glass panels. These polarisers would rotate
the light rays passing through them to a definite angle, in a particular direction. When the
LCD is in the off state, light rays are rotated by the two polarisers and the liquid crystal,
such that the light rays come out of the LCD without any orientation, and hence the LCD
appears transparent. When sufficient voltage is applied to the electrodes, the liquid crystal
molecules would be aligned in a specific direction. The light rays passing through the LCD
would be rotated by the polarisers, which would result in activating/ highlighting the desired
characters.

The LCD’s are lightweight with only a few millimeters thickness. Since the LCD’s consume
less power, they are compatible with low power electronic circuits, and can be powered for
long durations. The LCD doesn’t generate light and so light is needed to read the display.
By using backlighting, reading is possible in the dark. The LCD’s have long life and a wide
operating temperature range. Changing the display size or the layout size is relatively simple
which makes the LCD’s more customers friendly.

The LCDs used exclusively in watches, calculators and measuring instruments are the
simple seven-segment displays, having a limited amount of numeric data. The recent
advances in technology have resulted in better legibility, more information displaying
capability and a wider temperature range. These have resulted in the LCDs being
extensively used in telecommunications and entertainment electronics. The LCDs have even
started replacing the cathode ray tubes (CRTs) used for the display of text and graphics, and
also in small TV applications. This section describes the operation modes of LCD’s then
describe how to program and interface an LCD to ARM using Assembly and C.

28
(A) LCD PIN DESCRIPTION

The LCD discussed in this section has 14 pins. The function of each pin is given in table.

Pin Symbol I/O Description


1 Vss -- Ground
2 Vcc -- +5V power supply
3 VEE -- Power supply to
control contrast
4 RS I RS=0 to select
command, RS=1to
select data
5 R/W I R/W=0 for write,
R/W=1 for read
6 E I/O Enable
7 DB0 I/O The 8-bit data bus
8 DB1 I/O The 8-bit data bus
9 DB2 I/O The 8-bit data bus
10 DB3 I/O The 8-bit data bus
11 DB4 I/O The 8-bit data bus
12 DB5 I/O The 8-bit data bus
13 DB6 I/O The 8-bit data bus
14 DB7 I/O The 8-bit data bus

Table 6: LCD pin diagram

(B) LCD OPERATION

In recent years the LCD is finding widespread use replacing LEDs. This is due to:

 The declining prices of LCDs.


 The ability to display numbers, characters and graphics. This is in
contract to LEDs, which are limited to numbers and a few characters.

29
 Incorporation of a refreshing controller into the LCD, there by relieving the CPU of
the task of refreshing the LCD. In the contrast, the LED must be refreshed by the CPU
to keep displaying the data.
 Ease of programming for characters and graphics.

(C) LCD Command Codes

Code Command to LCD Instruction


(hex) Register
1 Clear display screen
2 Return home
4 Decrement cursor
6 Increment cursor
5 Shift display right
7 Shift display left
8 Display off, cursor off
A Display off, cursor on
C Display on, cursor off
E Display on, cursor on
F Display on, cursor blinking
10 Shift cursor position to left
14 Shift cursor position to right
18 Shift the entire display to the left
1C Shift the entire display to the right
80 Force cursor to beginning of 1st line
C0 Force cursor to beginning of 2nd line
38 2 lines and 5x7 matrix

TABLE 7: LCD Command Codes

30
(D) Uses of LCD:

The LCDs used exclusively in watches, calculators and measuring instruments are the
simple seven-segment displays, having a limited amount of numeric data. The recent
advances in technology have resulted in better legibility, more information displaying
capability and a wider temperature range. These have resulted in the LCDs being
extensively used in telecommunications and entertainment electronics, for the display of
text and graphics.

(E) LCD INTERFACING

Sending commands and data to LCDs with a time delay:

Fig.: Interfacing of LCD to a micro controller

To send any command from table 2 to the LCD, make pin RS=0.

For data, make RS=1.Then send a high –to-low pulse to the E pin to enable the internal
latch of the LCD.

31
CHAPTER-3
SOFTWARE DESCRIPTION

3.1 AVR Studio


 Introduction
The following softwares were used for programming and feeding in ATmega16 microcontroller.
1.BASCOM AVR: BASCOM AVR is the development platform. BASCOM AVR is required to
write the C-code and generate its HEX code and compile it.
2. ROBOKITS AVR USB PROGRAM : It is used to burn the program and hex file is dumped into
the microcontroller.
3.2 Key Benefits of using BASCOM AVR

 Structured BASIC with labels.


 Structured programming with IF-THEN-ELSE-END IF, DO-LOOP, WHILE-WEND,
SELECT- CASE.
 Fast machine code instead of interpreted code.
 Variables and labels can be as long as 32 characters.
 Bit, Byte, Integer, Word, Long, Single and String variables.
 Compiled programs work with all AVR microprocessors that have internal memory.
 Statements are highly compatible with Microsoft's VB/QB.
 Special commands for LCD-displays, I2C chips and 1WIREchips, PC keyboard, matrix
keyboard, RC5 reception, software UART, SPI , graphical LCD, send IR RC5 or Sony code.
 Local variables, user functions, library support.
 Integrated terminal emulator with download option.
 Integrated simulator for testing.
 Integrated ISP programmer (application note AVR910.ASM).
 Integrated STK200 programmer, STK300 programmer, STK500 and STK500 extended
Programmers.
 Can be used with our Atmel AVR Development Boards
 Editor with statement highlighting.
 Context sensitive help.
 Perfectly matches the DT006 Sim Stick
 FREE Internet Auto Update facility built into software means you can always have the latest
program version

32
1) Install the software.

2) Make a new folder in the desktop.

33
3) Make a new editor file in the software window.

4) Write the code into the editor file.

34
5) Save the file before compiling it.

35
CHAPTER 4
ADVANTAGES AND APPLICATIONS

4.1 ADVANTAGES:

• A ultrasonic sensor’s reaction is not subordinate upon the surface shading


have phenomenal rehash detecting exactness.
• The reaction of simple ultrasonic sensors is direct with distance.
• The entire set up has very less hardware and it is cost effective.

4.2 APPLICATIONS:

• Used to measure the obstacle distance.


• This system used in automotive parking sensors and obstacle warning systems.
• Used in terrain monitoring robots.

36
SOFTWARE CODE

$regfile = "m16def.dat"
$crystal = 8000000
Config Pina.0 = Input
Config Porta.1 = Output
Porta.0 = 0
Porta.1 = 0
Dim Distance As Word , W As Word , I As Byte
Config Lcd = 16 * 2
Config Lcdpin = Pin , E = Portc.4 , Rs = Portc.5 , Db4 = Portc.3 , Db5 = Portc.2 , Db6 = Portc.1 , Db7
= Portc.0
Distance = 0
Cls
Do
Pulseout Porta , 1 , 20 'Min. 10us pulse
'Waitms 100 'meant for testing error
Pulsein W , Pina , 0 , 1 'read distance
Incr I
If Err = 0 Then
W = W * 10 'calcullate to
W = W / 58 ' centimeters
'W = W / 6 ' milimeters
Distance = W
Else
Distance = 0
End If
Locate 1 , 1
If Distance > 0 Then
Lcd "D= " ; Distance ; " "
Locate 1 , 7
Lcd "cm"
Else
Lcd "*ERROR*"
Waitms 200
End If
Loop
End
37
RESULT

 ALGORITHM:
1) The microcontroller and its frequency of 8 KHz is declared in the register.

2) The port A0 and port A1 is declared as input and output respectively and is initialized to
zero.

3) After the variables of distance and words have been declared, the code is dumped into the
microcontroller and the action starts.

4) The ultrasonic pulse is sent out from port A1 and waits for 10 micro seconds.

5) If the ultrasonic wave is not received by the receiver, the pulse is resent.

6) If the ultrasonic wave is received by the receiver, then the port A0 is used to collect the
incoming pulse and is set to 1.

7) The variable I keeps incrementing if error is xero.

8) The variables value are calculated according to the following formulae:

W=W*10

W=W/58 (centimeters)

9) The value of W is assigned to distance.

10) If distance is greater than zero, then the value of the distance received by the echo signal
is displayed on the LCD screen.

11) If the distance is less than zero, then the error is detected and the entire process is
repeated again with the sending of the pulse.

12) The time required to calculate the echo signal to return is :

Time= (distance/2)/speed of light

38
 FLOWCHART:

39
The working model of the proposed AVR Atmega16 microcontroller based range finder
using ultrasonic module was successfully designed and implemented. The performance of
the circuit was analyzed for different conditions. The circuit was able to measure distance
up to 1.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
ATmega16 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.

40
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.

41
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.

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

42
REFERENCES

1) Milan Prokin, University of Belgrade - School of Electrical Engineering, Belgrade, Serbia,


“GPRS Terminals for Reading Fiscal Registers”, 2nd Mediterranean Conference on Embedded
Computing, MECO-2013, Budva, Montenegro.
2) The Insider's Guide to the Philips ARM 7, based microcontrollers, Public Choice, March 2008,
Volume 134, Springer US.
3) Liquid Crystal Display (LCD) Supplied by Highly Integrated Dual-Side Dual-Output with Only
Two Flying Capacitors, Circuits and Systems, IEEE.
4) Faisal A. Al- Nasser, Hosam “Simulation of Dynamic Traffic control system based on RFID”,
IEEE Symposium on Computers & Informatics 2011, pp 40.
5) V. Iic, "Wireless data transfer from taxpayers to the tax administration," Tax; Tribune, Intra-
European Organization of Tax Administrations, 2006/1.
6) Manoj Kumar Jain, M. Balakrishnan and Anshul Kumar, Department of Computer Science and
Engineering Indian Institute of Technology Delhi, India, “GSM Technology for secured data
transactions”, IEEE.
7) Johari J and Khateeb K, “Ubiquitous RFID Network for Highway Monitoring and Management”
IEEE, International Conference on Computer & Communication Engineering (ICCCE), Kuala
Lumpur, 2006.
8) Communication from the commission to the council, the European parliament and the European
economic and social committee, Commission of the European communities, 2005.
9) D. Merriman, "Understand, Measure, and combat tobacco smuggling," World bank, Economics
of tobacco toolkit, 2001.
10) A. Wiedow, "Tackling VAT fraud: Possible ways forward," European Commission, Taxation
and Customs Union, 2007.
11) L. Kovacs, "Tackling VAT fraud: Possible ways forward," speech, European Commission,
Taxation and Customs Union, 2007.
12) Rajat & Nirbhay Kumar (2014) “RFID Resolution: Your cars will be tagged”, The
Economics Times, 25 September.
13) Philip Brisk, Paolo Ienne Processor Architecture Laboratory Ecole Polytechnique Federale de
Lausanne, Switzerland, “Concept of Fiscal Registers using ARM”, IEEE.

43

You might also like