Ultrasonic Distance Measurement System: Bachelor of Technology IN Electronics and Communication Engineering
Ultrasonic Distance Measurement System: Bachelor of Technology IN Electronics and Communication Engineering
BACHELOR OF TECHNOLOGY
IN
SUBMITTED BY
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.
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.
iii
INDEX
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
vi
LIST OF TABLES
vii
LIST OF ABBREVIATIONS
viii
ABSTRACT
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
presented.
ix
CHAPTER-1
INTRODUCTION
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.
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.
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.
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.
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.
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.
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.
"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.
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.
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.
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.
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.
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.
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.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
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
1) Power Supply
3) Microcontroller
5) Object
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.
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.5 Object:
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.
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.
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 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
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.
2.4.3.1 Specifications
18
2.4.3.2 ATMEGA 16 PIN DIAGRAM
PIN10 VCC=+5V
PIN11 GND
PIN12 XTAL2
PIN13 XTAL1
20
PIN19 (OC1A),I/O Pin 5, PWM Channel Outputs
PIN24-
JTAG INTERFACE
27
PIN33 –
PAx: I/O,ADCx (Where x is 7 – 0)
PIN40
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.
Fig 6.3.4.1: Architecture of AtMega16 microcontroller
22
(D) Data Registers- R0-R15:
CPSR contains a number of flags which report and control the operation of ARM7 CPU.
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).
(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.
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.
(A) Features
(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.
The Interrupt Location Register is a 2-bit register that specifies which blocks are
generating an interrupt
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.
In recent years the LCD is finding widespread use replacing LEDs. This is due to:
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.
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.
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
32
1) Install the software.
33
3) Make a new editor file in the software window.
34
5) Save the file before compiling it.
35
CHAPTER 4
ADVANTAGES AND APPLICATIONS
4.1 ADVANTAGES:
4.2 APPLICATIONS:
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.
W=W*10
W=W/58 (centimeters)
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.
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.
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.
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
43