Sie sind auf Seite 1von 31

A Project Report on

ULTRASONIC RANGE FINDER


BY

Magwaza N.N (21344957)

Personal e-mail: nonduhnomthah@gmail.com

National Diploma in Electrical Engineering: Heavy Current

At the

Mangosuthu University of Technology

Under the esteemed guidance of


MR S.N Masondo

..
Student Signature/Date Mentor signature/Date
PLAGIARISM DECLARATION
1. I know and understand that plagiarism is using another persons work and pretending it is
ones own, which is wrong.

2. This report is my own work.

3. I have appropriately referenced the work of other people I have used.

4. I have not allowed, and will not allow, anyone to copy my work with the intention of passing
it off as his/her own work.

..
Student Name/Student No Student Signature/Date

2
ACKNOWLEDGEMENT
A humble appreciation to everyone who supported in compiling this project up to the stage of
constructing it, My mentor Mr. S.N Masondo, my friends because there were times where I felt
like giving up but they wouldnt allow me and their knowledge of digital systems III.

The electrical labs were very useful internet and all the hotspot of Wi-Fi on Electrical
Engineering department have been very helpful, the lecturers who are always there when you
come upon a challenge.

My mother settled all the financial buriers I thank her for playing the parental role once again
but without the Almighty God things wouldnt be this possible.

3
ABSTRACT
It is well known that many cars at the car parking spot use crash or collide , with this device it
will be very easy for drivers to see the distance between the car and the obstacle when they
are parking and moving out from the parking slot even when they are driving on the road. This
device is design to measure the distance which in cm. The device have a PIC microcontroller
and displays the measured results on the LCD to be seen by the driver and it use the LED and
buzzer to warn a drive about the distance. This report contain every tool that was used to
construct and build the device Ultrasonic Range Finder.

4
TABLE OF CONTENT

Preliminaries

ACKNOLEDGEMENT....................................................................................................3

ABSTRACT......................................................................................................................4
Table of Content................................................................................................................5
List of figures .................................................................................................................. 6
Constants and abbreviations............................................................................................. 7
CHAPTER 1- INTRODUCTION
1.1 Introduction....................................................................8
1.2 Problem statement..9
1.3 Aim.9
1.4 Literature....9
CHAPTER 2- DESIGN
2.1 Block diagram............................................................................................................10
2.1.1 Block diagram description.....11
2.2 Circuit diagram..........................................................................................................12
2.2.1 Schematic description...12
2.2.2 Methodologist...13
CHAPTER 3- CONSTRUCTION
3.1Flow chart...................................................................................17
3.2 Construction on PCB.....18
CHAPTER 4- TESTING
4.1Software.....................................................................................................................19
CHAPTER 5- RESULTS
5.1 Result on software....................................................................................................21
5.2 Result on PCB board................................................................................................22
CHAPTER 6- CONCLUSION
6.1 Conclusion...............................................................................................................23
REFERENCE
Reference...................................................................................................24
Appendix...................................................................................................25-31

5
LIST OF FIGURES
Table 1 List of figures Page 6

Table 2 Constant and Abbreviations Page 7

Figure 1 Block diagram Page 10

Figure 2 Circuit diagram Page 12

Figure 3 Construction on PCB Page 18

Figure 4 Simulation result Page 19

Figure 5 Prototype Page 20

Figure 6 Prototype result Page 21

Figure 7 Software Results Page 21

Figure 8 PCB Result Page 22

TABLE 1: above shows clearly the location of the tables and figures included in this
document.

6
CONSTANT AND ABBREVIATIONS

AC Alternating Current
DC Direct Current

PIC Programmable Interface Controller


PCB Printed Circuit Board
CM CENTIMETER
UPS Uninterrupted power supply

LCD Liquid crystal display

LED Light Emitting Diode

TABLE 2: above show the constant and abbreviation which are included in this report.

7
CHAPTER 1
1. INTRODUCTION
Ultrasonic range finder is the tool that is very helpful on measuring and detecting the distance
between the two cars or the car and the obstacle, using the LCD that will show the distance that
is remaining before the car crash. This document is going to have the block diagram of the
device that shows the flow of current through the circuit and the schematic that is simulated on
proteus software. The report also include the prototype where the circuit is constructed on the
breadboard and the result of the project is shown in this report.

8
2. PROBLEM STATEMENT
I choose to do this project because it was an interesting design, but there where lot of challenges
as I was going through with it, the first problem was to find the money to print my documents
and to buy the components for my design. This design project is small and easily to construct
but when it comes to proteus simulation it was not easy at all because one of the component
HC-SR04 which is the ultrasonic transducer was not found, so I had to find another component
to replace it and work the same way as a transducer.

3. AIM
The main aim of this project is to detect the distance between two cars or between the car and
the obstacle.

4. LITERATURE REVIEW
This design project is investigational and instructive since it can be accepted in ready-made
modules such as the SR04 which are certainly useful [1]. The priority of this project is to
improve the distance measuring technique to be easier and saving time, the formation of this
project could be applied to other applications such as distance detector for the car reversing
and car parking distance measure [2]. This project is PIC based project that will be using the
PIC microcontroller. Microcontroller is a computer on a chip that is programmed to perform
almost any control, sequencing, monitoring and display the function [3]. Microcontroller is
designed to be all of that in one. It a great advantage that there are no other external components
that are needed for its application because all necessary peripherals are already built into it.
Thus, we can save the time, space and cost which is needed to construct low cost devices [4]

9
CHAPTER 2
DESIGN
2.1 Block Diagram

INDICATOR
LCD
LIGHT
MICRO

CONTROLLE
R

PIC16F88
ULTRASONIC
BUZZER
SENSOR

FIGURE 1: block diagram above is for Ultrasonic Range Finder de vice. The block diagram
illustrates how the circuit operates and how the current flows in the circuit when it is fully
operational.

10
2.1.1 Block Diagram Description
MICROCONTROLLER: This section forms the control unit of the whole project. The
Microcontroller forms the heart of the project because it controls the devices being interfaced
and communicates with the devices according to the program being written. On this project the
PIC16F88 will be used to control the LCD and the functioning of the ultrasonic range finder.
Microcontroller is a computer on a chip that is programmed to perform almost any control,
sequencing, monitoring and display the function. Because of its relatively low cost, it becomes
the natural choice to the designer. Microcontroller is designed to be all of that in one. Its great
advantage; there are no other external components that are needed for its application because
all necessary peripherals are already built into it. Thus, we can save the time, space and cost
which is needed to construct low cost devices.

HC-SR04 (BUZZERS): HC-SR04 is an ultrasonic ranging module designed for embedded


system projects like the ultrasonic range finder. It has a resolution of 0.3 cm and the ranging
distance is from 2 cm to 500 cm. It operates from a 5V DC supply and the standby current is
less than 2mA. The module transmits an ultrasonic signal, picks up its echo, measures the time
elapsed between the two events and outputs a waveform thats high time is modulated by the
measured time which is proportional to the distance.

DC SUPPLY VOLTAGE: It is the direct supply voltage that helps the project to
work/function proper by providing it with voltage power of 5V.
RESISTORS: It limits the current flowing though the switches which are 10k ohms.

LCD: To display the output from the microcontroller this will show the distance or range in
m, mm/cm depending on the settings.

INDICATOR LIGHT: The indicator light in this project is the LED, it going to indicate that
the device is working and to show that the distance between the two cars is decreasing

REGULATOR: It converts the supplied voltage of 220V ac to 5V dc which is the voltage


that is required by the design in order to work properly.
BUZZER: This component is used in this design in order to work as a transmitter and a
receiver to perform the transmission process between the ultrasonic object and the
microcontroller in order for the distance to be displayed on the LCD so that we can observe
how far is the car and alarm to warn the driver.

11
2.2 Circuit Diagram

FIGURE 2: the above circuit shows the construction of an Ultrasonic Range Finder that is
construction software called proteus.

2.2.1 Schematic Description

An ultrasonic pulse is generated in a given direction. If there is an object in the path of this
pulse all the pulses will be reflected back to the transmitter as an echo and can be detected
through the receiver path, by measuring the difference in time between the pulses being
transmitted and echo received. This device is design to work on the vehicles to detect the
distance between the car and the obstacle before collision. This design is designed to warn the
driver when the specific distance is reached between two vehicles or the car and the obstacle.
It is built with buzzers and LEDs which will alarm and light to warn the driver whenever there
is any vehicle near in the indicated distance on the LCD.

12
2.2.2 Methodology
After doing the research about ultrasonic range finder how it works and research on different
schematic some of them were not found on the Proteus tools for schematic drawing and
simulation. The project will first be simulated on Proteus and there after constructed on the
PCB. The components will be bought and tested for the continuity functioning of the whole
project. The chosen schematic have been chosen as the best and the availability of the
components on the Proteus simulation and at the electronic component store.

13
2.2.3 Used Hardware Components

A. POWER SUPPLY (12V BATTERY)

Figure 1: battery

Battery consists of positive and negative terminals where by the energy flows from the low to
high potential. There are two types of batteries namely rechargeable and non-rechargeable; in
this design a non-rechargeable battery is used due to financial reasons. Then a battery will
supply 12Volts.

B. VOLTAGE REGULATOR

Figure 2: integrated circuit

Usually, we start with an unregulated power supply ranging from 9volt to 12volt DC. To
arrange the power to 5V we need 7805 regulator. The 7805 regulator is simple to use, Simply
connect the positive lead form unregulated DC power supply (from 9VDC to 12VDC) to the
input pin, connect the negative lead to the common pin and then turn on the power, a 5 volt
will be produced.

14
C. DISPLAY (LCD)

Figure 3: Display unit

The 16 x 2 intelligent alphanumeric dot matrix displays is capable of displaying 224 different
characters and symbols. This booklet provides all the technical specifications for connecting
the unit, which requires a single power supply (+5V).

D. RESISTORS

Figure 4: pull up resistor

The function of the resistor is to resist the flow of current. Here I have used the 10k pull
up resistors. Pull up resistors are used in electronic logic circuits to ensure that inputs
to logic systems settle at expected logic levels if external devices are disconnected
or high-impedance introduced.

E. CRYSTAL OSCILLATOR

Figure 5: 40MHz crystal

Crystal oscillator used here is 40 Megahertz. The function of an oscillator is to produce


an output that repeats regularly, makes a micro-controller to be stable. In the electronics
field this will be an electrical waveform, often but not always a sine wave. The most
important property of an oscillator is its frequency the rate at which the output repeats.

15
F. HC-SR04 ULTRASONIC MODULE.

Figure 6: HC-SR04 circuit

HC-SR04 is an ultrasonic ranging module designed for embedded system projects like
ultrasonic range finder. It has a resolution of 0.3cm and the ranging distance is from 2cm to
500cm. It operates from a 5V DC supply and the standby current is less than 2mA. The module
transmits an ultrasonic signal, picks up its echo, measures the time elapsed between the two
events and outputs a waveform thats high time is modulated by the measured time which is
proportional to the distance. The supporting circuits fabricated on the module makes it almost
stand alone and what the programmer need to do is to send a trigger signal to it for initiating
transmission and receive the echo signal from it for distance calculation. [2]

G. MICROCONTROLLER PIC18F2550

Figure 7: microcontroller PIC

The microcontroller PIC16F88 is the IC that is programmed to perform desired output,


however in this design it is programmed using assembly language to process the pulses that it
would be receiving. It has 18 pins and each pin has its own function. The purpose of choosing
this particular PIC out of all PICs is that it has a good amount of input and output pins, good
and enough amount of RAM as there is much space needed in order to perform better when
processing received pulses. It also has a good pre-scalar, so by that this PIC can be fast as it is
needed in this design to produce the exact distance.

16
CHAPTER 3

CONSTRUCTION
3.1 Flow Chart

START

ULTRASONIC TRANSDUCER

NO
PULSE
RECEIVED?

YES
MICROCONTROLLER (make decision
based on received pulse)

SEND BACK ECHO

NO
DISTANCE
10cm

YES

DISPLAY (LCD)

17
3.2 Construction on a PCB

FIGURE 3: the above shows the final construction of Ultrasonic range finder on a PCB
soldering iron is used to solder the circuit.

3.2.1Constuction Description
To confirm to the requirement of this project and to show that device will work on final
construction a temporary construction of the prototype was needed before finally transferring
it onto the PCB-board for permanent soldering. The circuit was constructed, tested using the
power supply of 12 volts. In order to achieve accuracy in the design, some necessary
adjustments were made to some of the components used.
3.2.2 Hardware Components
Microcontroller
LCD
Power supply
Ultrasonic sensor
Resistors
Buzzers
Regulator
LED

18
CHAPTER 4
TESTING
4.1 Software
4.1.1 Simulated circuit

FIGURE 4: The simulating circuit of an ultrasonic range finder that is constructed on proteus
software is shown above.

19
4.1.2 Prototype

FIGURE 5: the above figure shows the device constructed on the breadboard for testing.
The testing of the circuit on the breadboard make it easy to see how the circuit is going to
work when is constructed on a PCB.

20
CHAPTER 5
RESULTS
5.1 Prototype Result

Figure 6: The result of a working prototype is shown above and the LCD is demonstrating the
distance in centimeters (cm) that is left before the car crash LED and the speaker they are giving
a warning to a driver.

5.2 Software Result

Figure 7: The proteus software above it a PCB layout that is being printed on a PCB for
soldering.

21
5.3 PCB Result

FIGURE 8: The circuit is now constructed on a PCB and all the components are connected it
complete. The soldering iron was used to solder the circuit.

22
CHAPTER 6
CONCLUSION
By using this project we can detect and sense the range distance from the ultrasonic object.
Transducer (ultrasonic sensor) and micro-controller are the main components in working of the
circuit they are the heart of this design. The conditions have been satisfied the circuit is doing
the desired work according to specific program that was build. The readings and signal has
been successfully controlled by microcontroller. With commands from the controller the signal
will be sent to the LCD display to display the readings. When the distance is less than 10cm
the LED and the buzzer will activated to warn the driver. Doing this design I have learn a lot
on project working and how important it is to follow all the instructions that are brought
forward to work upon.

23
REFERENCES
[1] www.best-microcontroller-projects.com
[2] http://library.utem.edu.my:8000/elmu/index.jsp
[3] www.best-microcontroller-projects.com/ultrasonic-rangefinder.html
[4] Microprocessor Architecture, Programming & Applications
- Ramesh S. Gaonkar
[5] Fundamentals of Microprocessors and Micro computers
-B. Ram

24
APPENDIX

Appendix 1: The Program


_main:

;MyProject.c,32 :: void main ()


;MyProject.c,35 :: ANSEL = 0x01;
MOVLW 1
MOVWF ANSEL+0
;MyProject.c,36 :: TRISA = 0xFF;
MOVLW 255
MOVWF TRISA+0
;MyProject.c,37 :: TRISB = 0x00;
CLRF TRISB+0
;MyProject.c,38 :: PORTB = 0x00;
CLRF PORTB+0
;MyProject.c,39 :: CMCON = 0x07;
MOVLW 7
MOVWF CMCON+0
;MyProject.c,43 :: ADC_Init();
CALL _ADC_Init+0
;MyProject.c,44 :: Lcd_Init(); //
CALL _Lcd_Init+0
;MyProject.c,45 :: Lcd_Cmd(_LCD_CLEAR); //
MOVLW 1
MOVWF FARG_Lcd_Cmd_out_char+0
CALL _Lcd_Cmd+0
;MyProject.c,46 :: Lcd_Cmd(_LCD_CURSOR_OFF); //
MOVLW 12
MOVWF FARG_Lcd_Cmd_out_char+0

25
CALL _Lcd_Cmd+0
;MyProject.c,47 :: Lcd_Out(1,1,"Distance(cm)");
MOVLW 1
MOVWF FARG_Lcd_Out_row+0
MOVLW 1
MOVWF FARG_Lcd_Out_column+0
MOVLW ?lstr1_MyProject+0
MOVWF FARG_Lcd_Out_text+0
CALL _Lcd_Out+0
;MyProject.c,50 :: do
L_main0:
;MyProject.c,52 :: level= ADC_Read(0);
CLRF FARG_ADC_Read_channel+0
CALL _ADC_Read+0
CALL _Word2Double+0
MOVF R0+0, 0
MOVWF _level+0
MOVF R0+1, 0
MOVWF _level+1
MOVF R0+2, 0
MOVWF _level+2
MOVF R0+3, 0
MOVWF _level+3
;MyProject.c,53 :: level=(level*5)/1024;
MOVLW 0
MOVWF R4+0
MOVLW 0
MOVWF R4+1
MOVLW 32
MOVWF R4+2
MOVLW 129

26
MOVWF R4+3
CALL _Mul_32x32_FP+0
MOVLW 0
MOVWF R4+0
MOVLW 0
MOVWF R4+1
MOVLW 0
MOVWF R4+2
MOVLW 137
MOVWF R4+3
CALL _Div_32x32_FP+0
MOVF R0+0, 0
MOVWF _level+0
MOVF R0+1, 0
MOVWF _level+1
MOVF R0+2, 0
MOVWF _level+2
MOVF R0+3, 0
MOVWF _level+3
;MyProject.c,54 :: FloatToStr(level, txt);
MOVF R0+0, 0
MOVWF FARG_FloatToStr_fnum+0
MOVF R0+1, 0
MOVWF FARG_FloatToStr_fnum+1
MOVF R0+2, 0
MOVWF FARG_FloatToStr_fnum+2
MOVF R0+3, 0
MOVWF FARG_FloatToStr_fnum+3
MOVLW _txt+0
MOVWF FARG_FloatToStr_str+0
CALL _FloatToStr+0

27
;MyProject.c,55 :: txt[3]=0;
CLRF _txt+3
;MyProject.c,56 :: Lcd_Out(2,1,txt);
MOVLW 2
MOVWF FARG_Lcd_Out_row+0
MOVLW 1
MOVWF FARG_Lcd_Out_column+0
MOVLW _txt+0
MOVWF FARG_Lcd_Out_text+0
CALL _Lcd_Out+0
;MyProject.c,57 :: delay_ms(1);
MOVLW 3
MOVWF R12+0
MOVLW 151
MOVWF R13+0
L_main3:
DECFSZ R13+0, 1
GOTO L_main3
DECFSZ R12+0, 1
GOTO L_main3
NOP
NOP
;MyProject.c,58 :: if(level<3)
MOVLW 0
MOVWF R4+0
MOVLW 0
MOVWF R4+1
MOVLW 64
MOVWF R4+2
MOVLW 128
MOVWF R4+3

28
MOVF _level+0, 0
MOVWF R0+0
MOVF _level+1, 0
MOVWF R0+1
MOVF _level+2, 0
MOVWF R0+2
MOVF _level+3, 0
MOVWF R0+3
CALL _Compare_Double+0
MOVLW 1
BTFSC STATUS+0, 0
MOVLW 0
MOVWF R0+0
MOVF R0+0, 0
BTFSC STATUS+0, 2
GOTO L_main4
;MyProject.c,60 :: out1=1;
BSF RB0_bit+0, 0
;MyProject.c,61 :: out2=1;
BSF RB1_bit+0, 1
;MyProject.c,62 :: }
GOTO L_main5
L_main4:
;MyProject.c,65 :: out1=0;
BCF RB0_bit+0, 0
;MyProject.c,66 :: out2=0;
BCF RB1_bit+0, 1
;MyProject.c,67 :: }
L_main5:
;MyProject.c,69 :: } while(1);
GOTO L_main0

29
;MyProject.c,70 :: }
L_end_main:
GOTO $+0
; end of _main

30
Appendix 2: PCB Layout

Figure 8: PCB layout

31