Post on 12-Apr-2018
transcript
I
THE UNIVERSITY OF NAIROBI
SCHOOL OF ENGINEERING
DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING
FINAL YEAR PROJECT
PROJECT NUMBER: 118
PARKING SONAR
By
GICHIA H. NYAGAKI
REGISTRATION NUMBER: F17/29665/2009
SUPERVISOR: DR. GEORGE N. KAMUCHA
EXAMINER: PROF. NICODEMUS ABUNGU ODERO
SUBMITTED ON 24TH
APRIL 2015
THIS PROJECT REPORT WAS SUBMITTED TO THE DEPARTMENT OF ELECTRICAL AND
INFORMATION ENGINEERING IN PARTIAL FULFILLMENT OF THE REQUIREMENTS FOR THE
AWARD OF BACHELOR OF SCIENCE IN ELECTRICAL AND INFORMATION ENGINEERING OF
THE UNIVERSITY OF NAIROBI
© 2015
II
DECLARATION OF ORIGINALITY
1) I understand what plagiarism is and I am aware of the university policy in this regard.
2) I declare that this final year project report is my original work and has not been submitted
elsewhere for examination, award of a degree or publication. Where other people‟s work
or my own work has been used, this has properly been acknowledged and referenced in
accordance with the University of Nairobi‟s requirements.
3) I have not sought or used the services of any professional agencies to produce this work.
4) I have not allowed, and shall not allow anyone to copy my work with the intention of
passing it off as his/her own work.
5) I understand that any false claim in respect of this work shall result in disciplinary action,
in accordance with University anti-plagiarism policy.
Signature: ………………………………………………………………………………………
Date: ……………………………………………………………………………………………
NAME OF STUDENT: GICHIA HELLEN NYAGAKI
REGISTRATION NUMBER: F17/29665/2009
COLLEGE: Architecture and Engineering
FACULTY/SCHOOL/INSTITUTE: Engineering
DEPARTMENT: Electrical and Information Engineering
COURSE NAME: Bachelor of Science in Electrical and Information
Engineering
TITLE OF WORK: PARKING SONAR
III
DEDICATION
To my daughter, Noni, may you be an inspiration to others as you have been to me.
IV
ACKNOWLEDGEMENT
I would like to acknowledge the department of Electrical and Information Engineering for
entrusting me with this project. I thank my supervisor, Dr. G.N Kamucha for guiding me
throughout this endeavour.
I would also like to thank my mother for her hard work and dedication in ensuring that I have the
chance to pursue this degree.
Furthermore, I would like to thank FabLab Nairobi for assisting me in the project and my friends
and fellow students who believed in me and encouraged me to always push on.
Most importantly, I would like to thank God for the gift of life, health and all the blessings that
have enabled me to come this far and to finish this project.
V
TABLE OF CONTENTS
DECLARATION OF ORIGINALITY .................................................................................................................... II
DEDICATION ................................................................................................................................................. III
TABLE OF CONTENTS ..................................................................................................................................... V
LIST OF FIGURES .......................................................................................................................................... VII
LIST OF ACRONYMS .................................................................................................................................... VIII
ABSTRACT ..................................................................................................................................................... IX
CHAPTER 1: INTRODUCTION ......................................................................................................................... 1
1.1 BACKGROUND ..................................................................................................................................... 1
1.2 OBJECTIVES ......................................................................................................................................... 1
1.2.1 OVERALL OBJECTIVE ..................................................................................................................... 1
1.2.2 SPECIFIC OBJECTIVES.................................................................................................................... 1
1.3 JUSTIFICATION .................................................................................................................................... 2
1.4 SCOPE OF WORK ................................................................................................................................. 2
1.5 METHODOLOGY .................................................................................................................................. 2
1.6 REPORT ORGANISATION ..................................................................................................................... 2
CHAPTER 2: LITERATURE REVIEW ................................................................................................................. 4
2.1 INTRODUCTION ................................................................................................................................... 4
2.2 PARKING AID SYSTEMS ....................................................................................................................... 4
2.2.1 IPAS .............................................................................................................................................. 4
2.2.2 USING SENSORS ........................................................................................................................... 5
2.3 SONAR ................................................................................................................................................. 7
2.3.1 ACTIVE SONAR.............................................................................................................................. 7
2.4 MICROCONTROLLERS .......................................................................................................................... 9
VI
2.4.1 CLASSIFICATION OF MICROCONTROLLERS ................................................................................ 11
CHAPTER 3: LITERATURE REVIEW ............................................................................................................... 12
3.1 THEORY ON DEVICES ......................................................................................................................... 12
3.1.1 ATMEGA 328P MICROCONTROLLER .......................................................................................... 12
3.1.2 ULTRASONIC RANGING MODULE HC – SR04 ............................................................................. 13
3.1.3 BUZZER ....................................................................................................................................... 14
3.1.4 LED ............................................................................................................................................. 15
CHAPTER 4: DESIGN .................................................................................................................................... 16
4.1 PROGRAM FLOW CHART ................................................................................................................... 16
4.2 VOLTAGE REGULATOR CIRCUIT ......................................................................................................... 17
4.3 BRAKING CIRCUIT .............................................................................................................................. 18
4.4 ULTRASONIC SENSOR CIRCUIT .......................................................................................................... 18
4.5 LED CIRCUIT ....................................................................................................................................... 18
CHAPTER 5: RESULTS AND ANALYSIS .......................................................................................................... 19
5.1 SIGNAL GENERATOR RESULTS ........................................................................................................... 19
5.2OBSERVATIONS .................................................................................................................................. 20
CHAPTER 6: CONCLUSIONS AND RECOMMENDATIONS ............................................................................. 21
VII
LIST OF FIGURES
Figure 1: Ultrasonic wave projection ............................................................................................................ 9
Figure 2: ATmega 328 pin mapping ........................................................................................................... 12
Figure 3: HC - SR04 ................................................................................................................................... 13
Figure 4: HC - SR04 Timing Diagram ........................................................................................................ 14
Figure 5: Buzzer .......................................................................................................................................... 15
Figure 6: Voltage Regulator Circuit............................................................................................................ 17
Figure 7: Signal generated signal ................................................................................................................ 19
Figure 8: Circuit on Breadboard ................................................................................................................. 20
VIII
LIST OF ACRONYMS
LED Light Emitting Diode
PIR Passive Infra Red
RADAR Radio Detection And Ranging
SONAR Sound Navigation And Ranging
PCB Printed Circuit Board
IPAS Intelligent Parking Assist System
APGS Advanced Parking Guidance System
CPU Central Processing Unit
ALU Arithmetical Logical Unit
ROM Read Only Memory
RAM Random Access Memory
EEPROM Electrically Erasable Programmable ROM (EEPROM)
I/O Input/output
ADC Analog to digital converter
DAC digital to analog converter
CMOS Complementary Metal Oxide Semiconductor
CISC Complex Instruction Set Computer
RISC Reduced Instruction Set Computer
IX
ABSTRACT
This project focuses on the design and implementation of a parking range meter using an
ultrasonic range sensor, and a system to alert the driver when in danger of collision with an
object.
The system will require the use of an ultrasonic sensor to detect the distance between the car and
the obstacle, a computer system to interpret this feedback and peripheral devices to warn the
driver. The sensor will be located at the rear bumper of the car, where it will transmit sonar
waves which are reflected and picked up by the receiver. This system will be activated once the
reverse gear is engaged.
The driver will be visibly alerted whether the car is a safe distance from any object by the
lighting of the green LEDs(Light Emitting Diodes), and as he gets closer, the yellow LEDs light
and when in the danger zone, the red LEDs light indicating that he should stop. A buzzer will
also go on simultaneously when the red LEDs light.
1
CHAPTER 1: INTRODUCTION
1.1 BACKGROUND
Human beings, animals and various objects can all produce sound. This sound is created by the
physical movement of the particular medium independent of the speed of the movement but
rather dependent on the medium itself. Some animals such as bats and dolphins have used sound
for communication and object detection since immemorial. Human use was only first recorded in
1490 by Leonardo da Vinci, whereby a tube inserted in water was said to be used to detect
vessels by placing an ear to the tube. “If you cause your ship to stop and place the head of a long
tube in the water and place the outer extremity to your ear, you will hear ships at a great distance
from you.”[1]
Ultrasonic Sound waves are waves that are above the range of human hearing,
above 20,000 Hertz.
SONAR was originally an acronym for SOund Navigation And Ranging. It is a method of using
sound propagation to communicate with and/or detect objects, usually underwater. This project
deals with using SONAR signals in air as a medium, thus referred to as Ultrasonic Ranging.
1.2 OBJECTIVES
1.2.1 OVERALL OBJECTIVE
To design and implement a device to be used in a car so that parking becomes safe in a busy
parking area. It‟s a range monitor so that bumping into an object or another car behind is
avoided. The distance is computed between the time of transmitted and received pulses and
alarm is given.
1.2.2 SPECIFIC OBJECTIVES
1. To design a system to detect the presence of an obstacle behind a car using an Ultrasonic
Range Sensor.
2
2. To design a system to visibly and audibly inform the driver of the distance between car
and object; either safe, warning or danger zone through the colours of LEDs and a buzzer
respectively.
1.3 JUSTIFICATION
There is need for drivers to be able to gauge the distance between the car and an obstacle when
parking in reverse. Currently, all vehicles are fitted with a rear view mirror and side/fender
mirrors, but these are insufficient for ranging as there are blind spots in the field of view and
sometimes, depending on the type of mirror used, they are prone to misinterpretation. There are
currently many systems built for range sensing which have become very popular for use in
obstacle avoidance and to avoid car collisions. However, some of these systems are insufficient
because they lack accuracy, are affected by the material of the obstacle and are expensive.
1.4 SCOPE OF WORK
The scope of the project encompasses designing, programming and implementing a system to
alert drivers when nearing collision when parking in reverse.
1.5 METHODOLOGY
I. Develop the program for Microcontroller (ATmega 328p using Atmel Studio 6.0).
II. Build the project circuit and simulate it on Proteus 7.0.
III. Develop hardware-software interface.
IV. Implement the circuit on a PCB (Printed Circuit Board).
1.6 REPORT ORGANISATION
The content of the chapters of this project are outlined below:
Chapter 2 focuses on literature review based on journals and other publications.
Chapter 3 further discusses the literature review.
Chapter 4 presents the design of the project.
3
Chapter 5 presents the results and analysis.
Chapter 6 gives the conclusion and recommendations
4
CHAPTER 2: LITERATURE REVIEW
2.1 INTRODUCTION
In this chapter, we aim to describe and discuss the development of this project based on previous
research that has been documented in journals, books and articles.
Parking has proven to be a very tricky task especially in the city, where there are often
demarcated parking spots. There is the high possibility that a driver will collide with an obstacle,
especially when parking in reverse, as the rear view mirror and side mirrors do not provide a
good enough view. Drivers therefore have to estimate the distance, many times underestimating
it and crashing into objects.
A SONAR sensor will be used to transmit and receive SONAR waves to detect the distance
between car and object, which will then be interpreted by a Microcontroller and output via a
buzzer and LEDs.
2.2 PARKING AID SYSTEMS
Currently in the market, there are several systems that have been put in place to aid in parking.
Proximity and ranging sensors are used in tandem with an Intelligent Parking Assist System
(IPAS) to enhance reverse parking capabilities of drivers.
2.2.1 IPAS
Also known as the Advanced Parking Guidance System (APGS) for specific car models, it was
the first production automatic parking system developed by Toyota Motor Corporation in
2004.[2]
This consisted of a screen in the car dashboard which guided the driver to park using
arrows.
Advantages
High accuracy
Emulates vision
5
Disadvantages
Affected by meteorological aspects such as rain and fog.
Costly
Prone to underestimation of distances
2.2.2 USING SENSORS
Sensors are transducers which are used to detect some characteristic in their environment and
provide a corresponding output, usually as an electrical signal. Sensors are used in everyday
common devices such as elevator doors and scanners. Sensors can generally be categorized into
Passive and Active Sensors.
A passive Sensor is a microwave instrument designed to receive and measure natural emissions
produced by constituents of the Earth‟s surface and its atmosphere. An active sensor on the other
hand is a radar instrument used for measuring signals transmitted by the sensor that were
reflected, refracted or scattered by the earth‟s surface or its environment. [3]
Ultrasonic range sensors fall into the category of motion and proximity sensors. Proximity
sensors convert data regarding movement or presence of an object into electrical signals, without
any physical contact. [4]
Examples of other Proximity sensors include:
2.2.2.1 PASSIVE INFRARED (PIR) SENSORS
These work by detecting radiation given off by other objects. These do not generate or transmit
any energy for detection purposes.
2.2.2.2 RADIO DETECTION AND RANGING (RADAR) SENSORS
These use radio waves to determine altitude, direction and speed of objects. For example: in
anti-collision systems for aircraft. This is an active sensor. RADAR sensors transmit 76.5 radar
signals using microwave frequency, thus they are especially efficient in detecting metallic
materials and transmitting waves through insignificant objects without scattering.
6
Advantages
1. A single detector can cover multiple lanes if it is properly placed and appropriate signal
processing techniques are used.
2. Using radar for ranging has been used for military applications for several years thus the
technology is quite mature.
3. They can detect velocity directly
Disadvantages
Unwanted vehicle detection based on reception of side lobe radiation and false detection due to
multipath. Most disadvantages can be overcome in whole or in part, through proper placement of
detectors, signal processing algorithm and antenna design.
2.2.2.3 PHOTOELECTRIC SENSORS
These are made up of an emitter and receiver to detect light reflected directly off an object
2.2.2.4 MAGNETIC SENSORS
These are made up of two low-reluctance ferro-magnetic reeds encased in glass bulbs containing
inert gas. The reciprocal attraction of both reeds in the presence of a magnetic field, because of
magnetic induction causes the occurrence of an electrical contact, which can then be interpreted.
Metallic objects, when moved cause distortions in the earth‟s magnetic field. Magnetic sensors
work by either measuring the change in field caused by the movement of the metallic object or
measuring the subsequent change in flux of the earth‟s magnetic field
Advantages
They can identify minute area location of vehicles.
Disadvantages
Major interference from other metallic objects and the car itself.
2.2.2.5 SONAR SENSORS
These use inaudible sound to locate objects. It is widely discussed below.
7
2.3 SONAR
The use of sound to echo-locate in the same way as bats use sound for aerial navigation was first
used underwater and seems to have been prompted by the Titanic disaster of 1912. [5]
The world's
first patent for an underwater echo ranging device was filed at the British Patent Office by
English meteorologist Lewis Richardson a month after the sinking of the Titanic, and a German
physicist Alexander Behm obtained a patent for an echo sounder in 1913. Since then, Sonar
technology has been used for various applications both on sea on land. Some of these include:
1. Ocean Surveillance
2. Underwater Communications
3. Antisubmarine warfare using helicopters
4. Biomass estimation
5. Water velocity measurement
6. Space applications
7. Fisheries
8. Echo sounding
9. Prosthesis for visually impaired
10. Vehicle location
2.3.1 ACTIVE SONAR
This uses a sound transmitter and a receiver, which when in the same place is known as
monostatic operation and bistatic operation when separated. The sonar sensor produces a sound
pulse, referred to as a „ping‟ and receives the reflected echo, sometimes referred to as „pong‟.
This pulse of sound is generally created electronically using a sonar projector consisting of a
signal generator, power amplifier and electro-acoustic transducer/array. A beamformer is usually
8
employed to concentrate the acoustic power into a beam, which may be swept to cover the
required search angles.
The distance to an object is calculated by measuring the time from transmission of a pulse to
reception and converting into a range by employing the speed of sound (340.29 meters/second
(m/s)).
To measure the bearing, several hydrophones are used, and the set measures the relative arrival
time to each of them, or with an array of hydrophones, by measuring the relative amplitude in
beams formed through a process called beamforming. Use of an array reduces the spatial
response so that to provide wide cover multibeam systems are used.[6]
The target signal (if
present) together with noise is then passed through various forms of signal processing, which for
simple sonar sensors may be just energy measurement. It is then presented to some form of
decision device that calls the output either the required signal or noise. This decision device may
be an operator with headphones or a display, or in more sophisticated sonar technology, this
function may be carried out by software.
The pulse may be at constant frequency or a chirp of changing frequency (to allow pulse
compression on reception). Simple sonar sensors generally use the former with a filter wide
enough to cover possible Doppler changes due to target movement, while more complex ones
generally include the latter technique[7]
. Since digital processing became available pulse
compression has usually been implemented using digital correlation techniques. Military sonar
sensors often have multiple beams to provide all-round cover while simple ones only cover a
narrow arc, although the beam may be rotated, relatively slowly, by mechanical scanning.
Particularly when single frequency transmissions are used, the Doppler effect can be used to
measure the radial speed of a target.
The illustration in the figure below shows how sound waves, transmitted in the shape of a cone,
are reflected from a target back to the transducer. An output signal is produced to perform some
kind of indicating or control function. A minimum distance from the sensor is required to
provide a time delay so that the "echoes" can be interpreted.
9
Figure 1: Ultrasonic wave projection
2.3.1.1 FACTORS AFFECTING THE ACCURACY OF ULTRASONIC SENSING
1. Target surface angle – The angle of the object in relation to the sensor has an effect on
the accuracy in that surfaces which are at 90º from the sensor offer higher accuracy.
2. Surface thickness – Reflective materials such as metal, plastic or glass give a higher
sensing accuracy than materials that absorb the signal such as perforated surfaces.
3. Sensor Placement – The sensor must be placed in a position such that it does not receive
unwanted signals from reflections such as the ground, in the case of vehicle parking.
2.4 MICROCONTROLLERS
A microcontroller is an integrated chip that is often part of an embedded system. It includes:
1. CPU (Central Processing Unit) – This is the part that controls all the processes within the
microcontroller. It consists of smaller subunits which are:
Instruction decoder recognizes program instructions and runs other circuits on this
basis. The abilities of this circuit are expressed in the "instruction set" which is
different for each microcontroller family.
10
Arithmetical Logical Unit (ALU) performs all mathematical and logical operations on
data.
Accumulator is a kind of working desk used for storing all data upon which some
operations should be executed (addition, shift etc.). It also stores the results ready for
use in further processing.
2. Memory – This stores all programs and data. It consists of the following:
Read Only Memory (ROM) is a type of memory used to permanently save the
program being executed. The size of the program that can be written depends on the
size of this memory. ROM can be built in the microcontroller or added as an external
chip, which depends on the type of the microcontroller. The size of ROM ranges from
Random Access Memory (RAM) is a type of memory used for temporary storing data
and intermediate results created and used during the operation of the microcontrollers.
The content of this memory is cleared once the power supply is off.
The Electrically Erasable Programmable ROM (EEPROM) is a special type of
memory not contained in all microcontrollers. Its contents may be changed during
program execution (similar to RAM), but remains permanently saved even after the
loss of power (similar to ROM). It is often used to store values, created and used
during operation which must be saved after turning the power supply off.
3. I/O (Input/output) ports these enable the microcontroller to be accessed by peripheral
devices such as sensors and printers.
4. Timers and counters control timing operations of microcontroller functions such as pulse
generation, modulation and frequency measuring.
5. ADC (Analog to digital converter) converts analog signals to digital signals that can be
interpreted by the microcontroller.
6. DAC (digital to analog converter) converts digital signals to analog signals.
11
7. Interrupt Control gives delayed control for a working program. It can be internal or
external.
Because they are designed to execute only a single specific task to control a single system,
microcontrollers are much smaller, simplified and include all the functions required on a single
chip.
The great advantage of microcontrollers, as opposed to using larger microprocessors, is that the
parts-count and design costs of the item being controlled can be kept to a minimum. They are
typically designed using CMOS (Complementary Metal Oxide Semiconductor) technology, an
efficient fabrication technique that uses less power and is more immune to power spikes than
other techniques.
Architectures used for the Microcontroller include CISC (Complex Instruction Set Computer),
which allows the microcontroller to contain multiple control instructions that can be executed
with a single macro instruction, and RISC (Reduced Instruction Set Computer) architecture,
which implements fewer instructions, but delivers greater simplicity and lower power
consumption.
Microcontrollers have become common in many areas, and can be found in home appliances,
computer equipment, and instrumentation. They are often used in automobiles and have become
a central part of industrial robotics. [7]
2.4.1 CLASSIFICATION OF MICROCONTROLLERS
Microcontrollers can be classified according to the following categories
Internal bus width
Instruction set
Memory architecture
Embedded and external memory microcontroller
12
CHAPTER 3: LITERATURE REVIEW
3.1 THEORY ON DEVICES
The following are the components used in the Sonar Parking system:
3.1.1 ATMEGA 328P MICROCONTROLLER
The Atmel 8-bit AVR(Advanced Virtual RISC) RISC-based microcontroller combines 32 KB
(Kilobyte) ISP (Serial Peripheral Interface) flash memory with read-while-write capabilities,
1 KB EEPROM, 2 KB SRAM, 23 general purpose I/O lines, 32 general purpose
working registers, three flexible timer/counters with compare modes, internal and
external interrupts, serial programmable USART, a byte-oriented 2-wire serial interface, SPI
serial port, 6-channel 10-bit ADC (Analog to Digital Converter) programmable watchdog
timer with internal oscillator, and five software selectable power saving modes. The device
operates between 1.8-5.5 volts.[8]
Figure 2: ATmega 328 pin mapping
The ATmega 328p differs from the standard ATmega 328 in that the former contains picoPower
technology. All picoPower devices are designed from the ground up for lowest possible power
13
consumption from transistor design and process geometry, sleep modes, flexible clocking
options, to intelligent peripherals. Atmel picoPower devices can operate down to 1.62V while
still maintaining all functionality, including analog functions. They have short wake-up time,
with multiple wake-up sources from even the deepest sleep modes. The features of picoPower
microcontrollers are:
On-the-fly user selectable performance levels
Automatic voltage regulator switching with multiple operating modes
Multiple power domains with automatic power domain gating
Automatic low power SRAM switching with optional disable
Low power battery backup mode
3.1.2 ULTRASONIC RANGING MODULE HC – SR04
This Ultrasonic Ranging Sensor provides 2cm-400 cm (centimeters) non-contact measurement
function with a ranging accuracy of about 3mm (millimeters). The module consists of a
transmitter, receiver and a control circuit. [9]
Figure 3: HC - SR04
The basic working principle of the HC – SR04 is as follows
A high level signal is transmitted to the trigger for at least 10µs.
14
i. The Module automatically sends eight 40 kHz pulses and detects whether there is an echo
pulse signal received.
ii. If the signal is received, and indicated by a HIGH, the time from the transmission of the
signal to its receipt is calculated.
The distance between the sensor and object is calculated by using the formula below.
Echo pulse (µS) / 58 = Distance in centimeters
Echo pulse (µS) / 148 = Distance in inch
Distance = (high level time × velocity of sound (340M/S) / 2).
The timing diagram for the HC-SR04 is as shown below.
Figure 4: HC - SR04 Timing Diagram
3.1.3 BUZZER
A buzzer is an audio signaling device, which may be mechanical, electromechanical,
or piezoelectric. Typical uses of buzzers and beepers include alarm devices, timers and
confirmation of user input such as a mouse click or keystroke. A piezoelectric element may be
driven by an oscillating electronic circuit or other audio signal source, driven with a piezoelectric
audio amplifier.
15
Figure 5: Buzzer
3.1.4 LED
A light-emitting diode (LED) is a two-lead semiconductor light source. It is a pn-junction diode,
which emits light when activated. When a suitable voltage is applied to the leads, electrons are
able to recombine with electron holes within the device, releasing energy in the form of photons.
This effect is called electroluminescence, and the color of the light (corresponding to the energy
of the photon) is determined by the energy band gap of the semiconductor.
16
CHAPTER 4: DESIGN
4.1 PROGRAM FLOW CHART
17
4.2 VOLTAGE REGULATOR CIRCUIT
For this project, a voltage regulator was used to step down 12Volts supplied by the car battery to
5V which is fed to the microcontroller and other peripherals. The LM7805 accepts an input
voltage of 7 to 25Volts and a maximum output current of 1.5Amps. The capacitors included in
the circuit are used for „smoothing‟ voltages at are erratic. A reservoir capacitor is
a capacitor that is used to smooth the pulsating DC from an AC rectifier. The reservoir capacitor
releases its stored energy during the part of the AC cycle when the AC source does not supply
any power, that is, when the AC source changes its phase resulting in change in 'direction of flow
of current'. The change in 'direction of flow of current' of the AC source takes a very small
amount of time. In this short gap of time, the continuous flow of current gradually moves to the
state when it ceases. Using a reservoir capacitor, we fill this gap; since the capacitor releases its
stored energy (gets discharged) in that gap of time. This allows the load to be powered at all
times without any interruption. [10]
This circuit is as shown below.
Figure 6: Voltage Regulator Circuit
18
4.3 BRAKING CIRCUIT
The braking system is represented by a switch as shown in the circuit. The resistor used is a pull-
up resistor, which pulls the pin to 5V (HIGH) when the switch is open. When the switch is
closed, the pin is directed to ground (LOW).
4.4 ULTRASONIC SENSOR CIRCUIT
This circuit is only activated when the braking switch is pressed. Once the Microcontroller
identifies a LOW in the brake input pin, a HIGH is triggered on the trigger pin of the Ultrasonic
Sensor. The echo is then received by the Echo pin.
4.5 LED CIRCUIT
These act as an indicator to the driver as to how far from an object they are. Green represents the
safe zone, yellow, the zone where parking should occur and red, the danger zone, where collision
is almost imminent. These were simple 5mm LEDs used.
19
CHAPTER 5: RESULTS AND ANALYSIS
5.1 SIGNAL GENERATOR RESULTS
The circuit was simulated by using a digital oscilloscope and a signal generator as shown below.
Figure 7: Signal generated signal
The signal generator simulator simulated the incoming square wave entering the echo pin. A 5.5v
square wave was observed to be entering the microcontroller. The waves entering the trigger pin
and echo pin were observed in the oscilloscope.
20
5.2OBSERVATIONS
DISTANCE LED
STATUS
BUZZER
STATUS
<=300 GREEN ON OFF
<=250 GREEN ON OFF
<=200 YELLOW
ON
OFF
<=150 YELLOW
ON
OFF
<=100 RED ON ON
<=50 RED ON ON
Figure 8: Circuit on Breadboard
21
CHAPTER 6: CONCLUSIONS AND
RECOMMENDATIONS The objective of the project was achieved and it can be implemented in a working vehicle.
However, some recommendations were formed.
1. Integration of more sensors to accurately obtain the distance could be used, though this
could increase the cost
2. An LCD screen could be used to tell the driver the actual distance between the car and
object
3. An external battery should be used to avoid voltage spikes from damaging the
microcontroller.
4. The position of the sensor should be such that it does not obtain unwanted echo signals
from the ground
22
APPENDIX
/*
SONAR PARKING
HC-SR04 Ping distance sensor:
By: Nyagaki Gichia
*/
#define echoPin 7 // Echo Pin
#define trigPin 9 // Trigger Pin
#define LEDPin1 13 // Onboard LED
#define LEDPin2 12
#define LEDPin3 11
unsigned long int maximumRange = 300; // Maximum range needed
unsigned int minimumRange = 10; // Minimum range needed
volatile long duration, distance; // Duration used to calculate distance
void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(LEDPin1, OUTPUT); // Use LED indicator (if required)
pinMode(LEDPin2, OUTPUT);
pinMode(LEDPin3, OUTPUT);
}
void loop() {
// distance=0;
/* The following trigPin/echoPin cycle is used to determine the
distance of the nearest object by bouncing soundwaves off of it. */
digitalWrite(trigPin, LOW);
delayMicroseconds(5);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
23
Serial.println(duration);
//Calculate the distance (in cm) based on the speed of sound.
distance = duration/58.2;
if (distance <= minimumRange&& distance !=0 ){
/* Send a negative number to computer and Turn LED ON
to indicate "out of range" */
Serial.println("too close");
digitalWrite(LEDPin1,LOW);
digitalWrite(LEDPin2,LOW);
digitalWrite(LEDPin3,LOW);
digitalWrite(2,HIGH);
delay(100);
digitalWrite(2,LOW);
}
if (distance ==0){
/* Send a negative number to computer and Turn LED ON
to indicate "out of range" */
Serial.println("too far");
digitalWrite(LEDPin1,LOW);
digitalWrite(LEDPin2,LOW);
digitalWrite(LEDPin3,LOW);
distance=5;
soft_restart();
}
if(distance > minimumRange && distance <= 50) {
Serial.println(distance);
digitalWrite(LEDPin1, HIGH);
delay(20);
digitalWrite(LEDPin1,LOW);
delay(20);
}
if ((distance > minimumRange && distance > 50) && distance <=100) {
Serial.println(distance);
digitalWrite(LEDPin1, HIGH);
delay(50);
digitalWrite(LEDPin1,LOW);
delay(50);
24
}
if(((distance > minimumRange && distance > 50) && distance >100) && distance <=150) {
Serial.println(distance*3.41);
digitalWrite(LEDPin2, HIGH);
delay(100);
digitalWrite(LEDPin2,LOW);
delay(100);
}
if((((distance > minimumRange && distance > 50) && distance >100) && distance >150) &&
distance <=200) {
Serial.println(distance);
digitalWrite(LEDPin2, HIGH);
delay(200);
digitalWrite(LEDPin2,LOW);
delay(200);
}
if(((((distance > minimumRange && distance > 50) && distance >100) && distance >150) &&
distance >200)&& distance <=250) {
Serial.println(distance);
digitalWrite(LEDPin3, HIGH);
delay(300);
digitalWrite(LEDPin3,LOW);
delay(300);
}
if((((((distance > minimumRange && distance > 50) && distance >100) && distance >150)
&& distance >200)&& distance > 250)&& distance <300) {
Serial.println(distance);
digitalWrite(LEDPin3, HIGH);
delay(400);
digitalWrite(LEDPin3,LOW);
delay(400);
}
//Delay 50ms before next reading.
delay(10);
}
25
REFERENCES
[1] Hill, M. N. (1962). Physical Oceanography. Allan R. Robinson. Harvard University Press.
p. 498.
[2] "Toyota unveils car that parks itself". CNN. September 2003. Retrieved 2009-07-28.
[3] Urick, R. J. Principles of Underwater Sound, 3rd edition. (Peninsula Publishing, Los Altos,
1983)
[4] http://www.sensors-transducers.machinedesign.com/guiEdits/Content/bdeee4/bdeee4_7.aspx
[5] Fahy, Frank (1998). Fundamentals of noise and vibration. John Gerard Walker. Taylor &
Francis. p. 375.
[6] https://books.google.ie/books?id=srREi-
ScbFcC&pg=PA45&lpg=PA45&dq=ww2+sonar+transducers&source=bl&ots=rXPIrlB7Bs&sig
=UT6FI5tw6WdS7oTi-
cs6mZcJ_eM&hl=en&sa=X&ei=JsoxVeTvBsLmaoiTgOgM&ved=0CFsQ6AEwCA#v=onepage
&q=ww2%
[7] Augarten, Stan (1983). The Most Widely Used Computer on a Chip: The TMS 1000. State
of the Art: A Photographic History of the Integrated Circuit (New Haven and New York:
Ticknor & Fields). ISBN 0-89919-195-9. Retrieved 2009-12-23.
[8] Datasheet ATmega 328
[9] Datasheet HC-SR04
[10] www.learningaboutelectronics.com/.../What-is-a-smoothing-capacitor