COLLISION AVOIDANCE SYSTEM
THE UNIVERSITY OF NAIROBI
SCHOOL OF ENGINEERING
DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING
FINAL YEAR PROJECT
PROJECT NUMBER:64
COLLISION AVOIDANCE SYSTEM
By
OTIENO VANESSA AMONDI
REGISTRATION NUMBER: F17/28967/2009
SUPERVISOR: DR. GEORGE N. KAMUCHA
EXAMINER: PROF. MBUTHIA
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
i
DECLARATION OF ORIGINALITY
NAME OF STUDENT:
OTIENO VANESSA AMONDI
REGISTRATION NUMBER:
F17/28967/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:
Collision Avoidance System
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: ……………………………………………………………………………………………
ii
DEDICATION
I dedicate this project to my family, for the moral support they gave me during this period. I
would like to dedicate this report to my educational mentors who guided me throughout this
process.
iii
ACKNOWLEDGEMENT
I would like to appreciate I would like parents and my family for the moral support they have
given me.
I would also like to express my sincere gratitude to my supervisor Dr. George N. Kamucha for
critical comments and valuable advice that have guided me in this project.
I also thank Nicholas Kimali for the assistance he provided me so I can finish this project
iv
Contents
DECLARATION OF ORIGINALITY ......................................................................................................... ii
DEDICATION ......................................................................................................................................... iii
ACKNOWLEDGEMENT ........................................................................................................................... iv
LIST OF FIGURES .................................................................................................................................... vii
ABSTRACT................................................................................................................................................. ix
CHAPTER 1: INTRODUCTION ................................................................................................................. 1
1.1 BACKGROUND .................................................................................................................................. 1
1.2 OVERALL OBJECTIVE ...................................................................................................................... 1
1.3 SPECIFIC OBJECTIVES.................................................................................................................... 1
1.4 PROJECT JUSTIFICATION............................................................................................................... 2
1.5 PROJECT SCOPE .............................................................................................................................. 2
CHAPTER 2: LITERATURE REVIEW ...................................................................................................... 3
2.1 INTRODUCTION ............................................................................................................................... 3
2.2 INFRARED SENSORS (IR SENSOR) ................................................................................................. 3
2.3 RADAR SENSORS .............................................................................................................................. 4
2.3.1 DIRECT PROPAGATION METHOD .......................................................................................... 4
2.3.2 SECOND FREQUENCY MODULATED CONTINUOUS WAVE METHOD .............................. 4
2.4 VIDEO PROCESSING IMAGING (VIDEO) SENSOR ....................................................................... 5
2.5 MAGNETO RESISTIVE SENSOR ....................................................................................................... 5
2.6 ACCELOMETERS .............................................................................................................................. 6
2.7 ULTRASONIC SENSORS ................................................................................................................... 6
2.7.1 BASIC ULTRASONIC SENSOR OPERATION ............................................................................ 6
2.7.2 TRANSDUCERS .......................................................................................................................... 7
2.7.3 FACTORS THAT AFFECT THE ACCURACY OF ULTRASONIC SENSOR .............................. 8
2.8 MICROCONTROLLER ............................................................................................................................ 8
2.8.1 MICROCONTROLLER BASICS: ................................................................................................. 9
2.8.2 TYPES OF MICROCONTROLLER: .......................................................................................... 10
2.8.2.3 INSTRUCTION SET ................................................................................................................ 11
CHAPTER 3: LITERATURE REVIEW .................................................................................................... 14
3.1 COMPONENTS AND DEVICES REVIEW. ...................................................................................... 14
3.2 ULTRASONIC SENSOR (HC SR-04) ............................................................................................... 14
v
3.2.1 WORKING ................................................................................................................................. 14
3.3 D.C Motor ......................................................................................................................................... 16
3.4 H-BRIDGE ........................................................................................................................................ 16
CHAPTER 4: DESIGN AND IMPLEMENTATION ................................................................................ 18
4.1 DESIGN ............................................................................................................................................ 18
4.1.2 CENTRAL CONTROL MODULE .............................................................................................. 19
4.1.2 DRIVER CIRCUIT ..................................................................................................................... 19
4.1.3 OBSTACLE SENSING UNIT ..................................................................................................... 21
4.1.4 WARNING SYSTEM................................................................................................................... 22
4.1. 5 SOFTWARE DESIGN ............................................................................................................... 22
4.1.6 FINAL DESIGN ......................................................................................................................... 26
CHAPTER 5: RESULTS AND ANALYSIS .............................................................................................. 29
5.1 SIMULATION OF THE OBSTACLE SENSOR ................................................................................. 29
5.2 OBSERVATION ................................................................................................................................ 29
CHAPTER 6: CONCLUSIONS AND RECOMMENDATIONS ............................................................................. 31
6.1 RECOMMENDATIONS .................................................................................................................... 31
REFERENCES ........................................................................................................................................... 32
APPENDIX ................................................................................................................................................. 33
vi
LIST OF FIGURES
Figure 2. 1: IR sensor [2] .............................................................................................................................. 4
Figure 2. 2:Basic block of transmitter and receiver [4] ................................................................................ 7
Figure 2. 3: Havard Memory Architecture.................................................................................................. 11
Figure 2. 4 Von Newman Architecture ....................................................................................................... 12
Figure 3. 1 HC-SR04 [7] ............................................................................................................................. 14
Figure 3. 2 HC-SR04 [9] ............................................................................................................................. 15
Figure 3. 3 H-bridge [10] ............................................................................................................................ 17
Figure 4. 1 Block diagram of control system .............................................................................................. 18
Figure 4. 2 Atmega 328P Pinout ................................................................................................................. 19
Figure 4. 3 Driver System ........................................................................................................................... 20
Figure 4. 4 Block diagram of ultrasonic sensor .......................................................................................... 21
Figure 4. 5 AVRISP mkII programmer [11] ............................................................................................... 23
Figure 4. 6 AVRISPmkII pin out [12] ........................................................................................................ 24
Figure 4. 7 Program Flow Chart ................................................................................................................. 26
Figure 4. 8 Schematic of the system ........................................................................................................... 27
Figure 4. 9 Component view of PCB .......................................................................................................... 28
Figure 5. 1 System schematic diagram ....................................................................................................... 30
Figure 6. 1 Side View Of Car ..................................................................................................................... 38
Figure 6. 2 Front View Of Car .................................................................................................................... 38
vii
LIST OF ACROYNMS
HIV/AIDS -Human Immunodeficiency Virus/ Acquired Immunodeficiency Syndrome
IR-Infrared
VIP- Video Imaging Processing
CPU- Central Processing Unit
ROM- Read-only memory
RAM- Random-access memory
EPROM- Erasable programmable read only memory
EEPROM- Electrically Erasable Programmable Read-Only Memory
LCD- Liquid-crystal-display
LED- Light-emitting diode
ADC- Analog to digital converter
DAC- Digital to analog converter
DC- Direct current
A/D-Analog to Digital
AVR-Advanced Virtual RISC
RISC- Reduced instruction set computing
SRAM- static random-access memory
IC- integrated circuit
MOSFETS- metal-oxide-semiconductor field-effect transistors
TTL- transistor-transistor logic
PCB- Printed circuit board
PC- Personal Computer
Cm- centimeter
Mm- millimeter
M/s- meters per second
Hz- hertz
KHz- kilohertz
viii
ABSTRACT
This project is about vehicle collision avoidance system using an ultrasonic sensor for a car. We
use the application of electronic systems embedded in automobile which is expected to minimize
the vehicle accident disaster. This project concentrates on developing a model of rear end vehicle
collision avoidance system that will detect the distance between two vehicles moving in the same
lane, in the same direction and alert the driver whenever he or she is in danger range using a
microcontroller. The distance is measured by an ultrasonic sensor used to sense the obstacle
ahead.
ix
CHAPTER 1: INTRODUCTION
1.1 BACKGROUND
The industry strategy for automotive safety systems has been evolving over the last 20 years.
Initially, individual passive devices and features such as seatbelts, airbags, knee bolsters, crush
zones, etc. was developed for saving lives and minimizing injuries when an accident occurs.
Later, preventive measure such as improving visibility, headlights, windshield wipers, tire
traction, etc. were deployed to reduce the probability of getting into an accident. Now we are at
the stage of actively avoiding accidents as well as providing maximum protection to the vehicle
occupants and even pedestrians. The systems that are under intense development include
collision avoidance systems. In this project we concentrate on advanced ideas such as pre-crash
sensing, an ultrasonic sensor is used to sense the object in front of the vehicle and gives the
signal to the microcontroller unit. Based on the signal received from the ultrasonic sensor, the
microcontroller unit sends a signal to the braking unit for applying the brake automatically.
1.2 OVERALL OBJECTIVE
The designing and implementation of an ultrasonic based anti-collision system for vehicles
1.3 SPECIFIC OBJECTIVES
In order to accomplish the overall objective of this project, the following are the specific
objective:
1. To design obstacle sensor system.
2. Develop an algorithm that combines sensor strengths and limits sensor
shortcomings
3. Ensure the system responds in real time.
4. Identify objects that are potential threats
1
1.4 PROJECT JUSTIFICATION
A vehicle or car accident is a road traffic incident which usually involves one road vehicle being
in collision with, either another vehicle, or another road user, or a stationary road side object, and
this may result in death, injury and/or property damage. Road accidents are the third leading [1]
causes of death after malaria and HIVS/AIDS in Kenya more often than not affecting the
economically productive population in Kenya.
It is a well-known fact that the socio economic, physical and psychological crisis caused by
vehicle accidents need to be dealt with seriously. Various research and studies should be
conducted to overcome this problem.
This research will be dedicated to attempt alternative solution for this known problem by
developing low cost domestic anti-collision warning system model that would be mounted on the
existing car models and alert the driver in danger zone.
Therefore, rather than putting aside inbuilt active safety system development to the car
manufacturers, the user shall find ways to solve the problem by developing domestic active
safety system model that would be developed later to be fitted to road vehicle despite their model
and year of make. This initiated the writer of this manuscript to contribute his share by
constructing a model that will enable to conduct further research for finding alternative solution
to minimize this life threatening menace of vehicle accident in Kenya.
1.5 PROJECT SCOPE
The scope of the project entails designing, programming and implementing a vehicle collision
avoidance system that will be able to stop the vehicle before it hits an obstacle. A program is to
be written to make sure the vehicle responds in real time. The project will be implemented using
a toy car.
2
CHAPTER 2: LITERATURE REVIEW
2.1 INTRODUCTION
There is a wide range of sensor technologies available for vehicle collision avoidance systems.
Some of the most common and some developing technologies are described in this section.
2.2 INFRARED SENSORS (IR SENSOR)
This type of sensor uses IR light to detect obstacles. The sensor emits IR light then gives a signal
when it detects the reflected light.
An IR sensor consists of an emitter and detector as the circuitry. The circuit required to make the
IR sensor consists of two parts, the emitter circuitry and the receiver circuit. The detector is
simply an IR photodiode which is sensitive to IR light at the same wavelength as the emitted IR
led. When IR light falls on the photo diode, its resistance and correspondingly, its output voltage
change in proportion to the magnitude of the IR light received. This is the underlying principle of
working an IR sensor.
ADVANTAGES
Used in both day and night and they can be mounted in both side and overhead configuration.
DISADVANTAGES
They are sensitive to weather conditions
3
Figure 2. 1: IR sensor [2]
2.3 RADAR SENSORS
Radar sensors transmit 76.5 radar signals. Radar signals use microwave frequency that means
they are very good at detecting objects that strongly reflect electromagnetic radiation e.g. metal
objects. Because they operate at wavelengths on the order of a few millimeters, automotive radar
systems are pretty good at detecting objects that are several centimeters or larger. They are also
good at looking through i.e. ignoring objects that are small relative to wavelength. (i.e. water
droplets in fog.
They are two ways in which radar sensors are used;
2.3.1 DIRECT PROPAGATION METHOD
This measures the delay associated with the reception of the reflected signal which can be
correlated at the distance of the reflected objects as a function of speed of light and the period or
rather that is the time delay in transmission and receiving of waves.
2.3.2 SECOND FREQUENCY MODULATED CONTINUOUS WAVE
METHOD
For indirect propagation the frequency is sent and received, the difference in the frequency can
be used as well as the relative speed of the object.
Radar signals use microwave frequency that means they are very good at detecting objects that
strongly reflect electromagnetic radiation e.g. metal objects. [3]
4
ADVANTAGE
1. Radar sensors have a mature technology because of past military application.
2. They can detect velocity directly
3. A single detector can cover multiple lanes if it is properly placed and appropriate signal
processing techniques are used.
DISADVANTAGE
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.4 VIDEO PROCESSING IMAGING (VIDEO) SENSOR
An imaging sensor is a conventional camera, like an infrared camera, it can detect speed
occupancy and presence. VIP generally operates as the operator selects vehicle detection zones
within field of view of camera. The image processing algorithms are then placed in real time to
see these zones in order to extract the desired information
ADVANTAGE
It has low cost implementation
DISADVANTAGE
It has not that accurate and it has noise.
2.5 MAGNETO RESISTIVE SENSOR
These sensors are based on magneto resistive effect- i.e. change of resistivity of current in a
ferromagnetic material field. Sensor can be called a magnetically controllable resistor. When
current is passed through the ferromagnetic material it causes internal magnetization. An external
magnetic field can switch the internal direction of the magnetization of the magneto resistive
material in the sensor and thus the effect changes the resistance.
Vehicles are mostly made of metal parts. When the car is moving it distorts the earth’s magnetic
field. Magnetic field distortions made by a moving car can be easily detected and measured.
There are two ways a magnetic sensors work, they can measure the change in the magnetic field
caused by the passage of the vehicle or it can simply measure the change in flux of the earth’s
5
magnetic field caused by the passage of a vehicle. These sensors detect moving vehicles and
cannot be used as presence sensors. They have a fairly large detection range thus can be used in
multiple lanes.
ADVANTAGES
They can be used to point a small area location of a vehicle
DISADVANTAGE
Multiple detectors are needed to be installed to detect smaller vehicles.
2.6 ACCELOMETERS
Accelometer is an electromechanical device used to measure acceleration forces. Such forces
may be static, like the continuous force of gravity or they could be dynamic.
By measuring the amount of static acceleration due to gravity you can find out the amount of
static acceleration due to gravity, you can find to the earth. Bu sensing the amount of
acceleration one can analyse the way the device is moving. Usually used in left turn collision
counter measure.
2.7 ULTRASONIC SENSORS
Ultrasonic sensors are electronic devices that emit acoustic wave beyond audible range, between
20Hz to 20,000Hz to determine the distance between sensor and object based on the time it takes
to send the signal and to receive the echo.
2.7.1 BASIC ULTRASONIC SENSOR OPERATION
Ultrasonic sensors use a vibrating device known as a transducer to emit ultrasonic pulses that
travel on a cone shape beam range of an ultrasonic is determined by the frequency of the
transducer. As the frequency increases, sound waves transmit for progressively shorter distances,
conversely as frequency decreases the sound waves transmit for progressively longer distances.
6
• Ultrasonic Transmitter – Before transmitting the ultrasonic wave, transducer is used to generate
the ultrasonic waves. The transducer is given a signal to intermittently produce ultrasonic waves.
After that the ultrasonic transmitter sends the waves at a predetermined distance frontward. The
maximum range for which obstacle can be detected depends on the range of ultrasonic sensors
used.
• Ultrasonic Receiver – If the ultrasonic wave detects the obstacle, it will produce a reflected
wave. An ultrasonic receiver is used for receiving the ultrasonic waves reflected from the
obstacle. The received ultrasonic wave is converted into a reception signal with the help of a
transducer. The signal is amplified by an amplifier (operational amplifier). The amplified signal
is compared with the reference signal, to detect components in amplified signal due to obstacles
on the road.
Figure 2. 2:Basic block of transmitter and receiver [4]
2.7.2 TRANSDUCERS
They are used to convert electrical energy into ultrasonic energy and vice versa. Piezoelectric
transducers are used, they create ultrasonic vibration through the piezoelectric materials. Their
working is based on piezoelectric effect. This effect refers to the voltage produced between
surfaces of a solid (non-conducting substance) when a mechanical stress is applied to it.
Conversely when a voltage is applied across surfaces of a solid [5]
7
2.7.3 FACTORS THAT AFFECT THE ACCURACY OF ULTRASONIC
SENSOR
2.7.3.1 CONFIGURATION
Ultrasonic sensors come in a variety of configurations typically one or more transducers,
depending on the application. The spacing of the transducers is important, if the transducers are
spaced too closely the cone shaped beams emitted may cause unwanted interference. They work
best when positioned in front of materials that readily reflect ultrasonic waves, such as metal,
plastic and glass. This enables the sensor to give an accurate reading at greater distances.
2.7.3.2 ANGLE
The angle of the object also has an impact on the accuracy of the reading with a flat surface at
right angle sensor offering best sensing range. This accuracy decreases with a change in the
angle of an object in relation to the sensor.
2.7.3.3 MATERIAL OF REFLECTING SURFACE
Ultrasonic sensors work best when positioned in front of materials that readily reflect ultrasonic
waves, such as metal, plastic and glass. This enables the sensor to give an accurate reading at a
greater distance from the object in front of it. However, when the sensor is placed in front of an
object that readily absorbs ultrasonic waves, such as fiber material, the sensor must move closer
2.8 MICROCONTROLLER
A microcontroller (μC) is a small computer on a single integrated circuit containing a processor
core, memory, and programmable input/output peripherals. . A microcontroller is also known as
embedded controller. Today various types of microcontrollers are available in market with
different word lengths such as 4bit, 8bit, 64bit and 128bit microcontrollers. Microcontroller are
used to make embedded systems in offices, machines, robots, home appliances, motor vehicles,
and a number of other gadgets. Microcontrollers are basically employed in devices and the
computer is hidden from the user.
8
2.8.1 MICROCONTROLLER BASICS:
Any electric appliance that stores, measures, displays information or calculates has a
microcontroller chip inside it. The basic structure of a microcontroller comprises of:1.
CPU – Microcontroller is a unit which monitors and controls all processes within the
microcontroller. It consists of an instruction decoder that recognizes the program instructions and
runs the circuits on the basis of the instructions. It also has an arithmetical logical unit (ALU)
that performs all mathematical and logical operations for the microcontroller.
2.
Memory – In a microcontroller memory chip works same as microprocessor. Memory
chip stores all programs & data. Microcontrollers are built with certain amount of ROM or RAM
(EPROM, EEPROM, etc.) or flash memory for the storage of program source codes.
3.
Input/output ports – I/O ports basically connect the microcontroller to external appliances
such as- printers, LCD’s, LED’s, etc.
4.
Serial Ports – These ports give serial interfaces the microcontroller & various other
peripherals such as parallel port.
5.
Timers – A microcontroller may be in-built with one or more timer or counters. The
timers & counters control all counting & timing operations within a microcontroller. Timers are
employed to count external pulses. The main operations performed by timers’ are- pulse
generations, clock functions, frequency measuring, modulations, making oscillations, etc.
6.
ADC (Analog to digital converter) – ADC converts analog signals to digital ones. Some
of the input signals that need to read by the microcontroller are analog. The ADC converts the
signal to its digital equivalent so it can be analysed by the microcontroller.
7.
DAC (digital to analog converter) – this converter executes opposite functions that ADC
perform. This device is generally employed to supervise analog appliances like- DC motors, etc.
8.
Interrupt Control- This controller is employed for giving delayed control for a working
program. The interrupt can be internal or external.
9
Special Functioning Block – Some special microcontrollers manufactured for special
9.
appliances like- space systems, robots, etc, comprise of this special function block. This special
block has additional ports so as to carry out some special operations.
2.8.2 TYPES OF MICROCONTROLLER:
Microcontrollers can be classified according to the categories below




Internal bus width
Instruction set
Memory architecture
Embedded and external memory microcontroller
2.8.2.1 BITS
•
8 bit microcontrollers execute logic & arithmetic operations. Examples of 8 bits
microcontroller is Intel 8031/8051.
•
16 bit microcontrollers executes with greater accuracy and performance in contrast to 8-
bit. Example of 16 bit microcontroller is Intel 8096.
•
32 bit microcontrollers are employed mainly in automatically controlled appliances such
as office machines, implantable medical appliances, etc. They require 32-bit instructions to carry
out any logical or arithmetic function.
2.8.2.2 MEMORY
•
External Memory Microcontroller – When an embedded structure is built with a
microcontroller which does not comprise of all the functioning blocks existing on a chip it is
named as external memory microcontroller. For example the 8031 microcontroller does not have
program memory on the chip.
•
Embedded Memory Microcontroller – When an embedded structure is built with a
microcontroller which comprise of all the functioning blocks existing on a chip it is named as
10
embedded memory microcontroller. For illustration- 8051 microcontroller has all program &
data memory, counters & timers, interrupts, I/O ports and therefore its embedded memory
microcontroller.
2.8.2.3 INSTRUCTION SET:
•
CISC- CISC means complex instruction set computer, it allows the user to apply 1
instruction as an alternative to many simple instructions.
•
RISC- RISC means Reduced Instruction Set Computers. RISC reduces the operation time
by shortening the clock cycle per instruction.
2.8.2.4 MEMORY ARCHITECTURE:
•
Harvard Memory Architecture Microcontroller
Harvard architecture has separate data and instruction buses, allowing two simultaneous
fetching. As long as data and instructions can be fed in at the same time, then it doesn't matter
whether it comes from a cache or memory. The processor can complete an instruction in one
cycle if appropriate pipelining strategies are implemented. Most of the modern computing
architectures are based on Harvard architecture. [6]
Program Memory
Processor
Data Memory
Figure 2. 3: Havard Memory Architecture

Von Neumann Architecture Microcontroller
Von Neumann architecture has only one bus that is used for both data transfer and instruction
fetches, and therefore data transfers and instruction fetched must be scheduled – they cannot be
performed at the same time. The processor needs two clock cycles to complete an instruction.
Thus pipelining is not possible.
11
Program and data
memory
Processor
Figure 2. 4 2.8.2.5
Von Newman
Architecture
8051 MICROCONTROLLER:
Most microcontrollers originate from the 8051 family. 8051 Microcontrollers persist to be an
ideal choice for a huge group of hobbyists and experts. In the course of 8051, the humankind
became eyewitness to the most ground-breaking set of microcontrollers. The original 8051
microcontroller was initially invented by Intel. 8051 microcontroller brings into play 2 different
sorts of memory such as- NV-RAM, UV-EPROM and Flash.
8051 Microcontroller Architecture
8051 microcontroller is an eight bit microcontroller launched in the year 1981 by Intel
Corporation. It has 4kb of ROM (on-chip programmable space) and 128 bytes of RAM space
which is inbuilt, if desired 64KB of external memory can be interfaced with the microcontroller.
There are four parallel 8 bits ports which are easily programmable as well as addressable. An onchip crystal oscillator is integrated in the microcontroller which has crystal frequency of 12MHz.
In the microcontroller there is a serial input/output port which has 2 pins. Two timers of 16 bits
are also incorporated in it; these timers can be employed as timer for internal functioning as well
as counter for external functioning.
2.8.2.6 PIC MICROCONTROLLER
Peripheral Interface Controller (PIC) provided by Micro-chip Technology to categorize its
solitary chip microcontrollers. These appliances have been extremely successful in 8 bit microcontrollers. The foremost cause behind it is that Micro-chip Technology has been constantly
upgrading the appliance architecture and included much required peripherals to the microcontroller to go well with clientele necessities. PIC microcontrollers are very popular amid
hobbyists and industrialists; this is only cause of wide availability, low cost, large user base &
serial programming capability.
PIC Microcontroller Architecture:
12
The architecture of the 8 bit PIC microcontrollers can be categorized as below 1.
Base Line
2.
Mid Range Architecture
3.
High Performance Architecture
2.8.2.7 AVR MICROCONTROLLER
AVR also known as Advanced Virtual RISC, is a customized Harvard architecture 8 bit RISC
solitary chip micro-controller. It was invented in the year 1966 by Atmel. Harvard architecture
signifies that program & data are amassed in different spaces and are used simultaneously. It was
one of the foremost micro-controller families to employ on-chip flash memory basically for
storing program, as contrasting to one time programmable EPROM, EEPROM or ROM, utilized
by other micro-controllers at the same time. Flash memory is a non-volatile (constant on power
down) programmable memory.
AVR Microcontroller Architecture:
AVR microcontrollers’ architecture was developed by Alf-Egil Bogen and Vegard Wollan. The
name AVR is derived from the names of the architecture developers of the microcontroller. The
SRAM, Flash and EEPROM all are incorporated on a single chip, thereby eliminating the
requirement of any other external memory in maximum devices. Several appliances comprise of
parallel external bus.to the object to give an accurate reading.
13
CHAPTER 3: LITERATURE REVIEW
3.1 COMPONENTS AND DEVICES REVIEW.
Common electronic components and devices used in the design of the vehicle collision
avoidance system are discussed below.
3.2 ULTRASONIC SENSOR (HC SR-04)
Ultrasonic Sensor (HC SR-04) module is low cost, high performance sensor and provides stable
and high ranging accuracy. It's ranging distance is 2cm to 350cm with 3mm accuracy. The
module includes ultrasonic transmitter, receiver and control circuit. The module is relatively
inexpensive, accurate, and easy to interface with a micro-controller. The HC-SR04 range makes
it ideally suited for developing object detection and avoidance schemes.
Figure 3. 1 HC-SR04 [7]
3.2.1 WORKING
Sensor works on trigger (TTL-10usec) pulse provided by any device. [8] When trigger pulse
sends to the trigger pin of sensor. Then sensor module will send the 8 cycle of 40 KHz ultrasonic
pulses and receives echo signal after striking on object & reflect back. Which is explained in the
below timing diagram shown below. The distance between the sensor and the object is calculated
14
by measuring high level time of the Echo pulse which can be retrieved from ECHO pin of the
sensor module and processing the high level time with the following formula,
Echo pulse (uS) / 58 = Distance in centimeters
Echo pulse (uS) / 148 = Distance in inch
Distance = (high level time×velocity of sound (i.e. 340M/S) / 2).
Figure 3. 2 HC-SR04 [9]
Ultrasonic sensor interfacing:1. Send high impulse to trigger input for minimum 10us
2. Sonar automatically sends eight 40 kHz impulses
3. Sonar rises high on Echo output and then after some time output to low.
4. Based on output time difference deltaT = lowT-highT calculate:
distance = [ deltaT * sound_speed(340m/s) ] / 2
5. Make a delay before starting the next cycle to compensate for late echoes
15
3.3 D.C Motor
Electrical DC Motors are continuous actuators that convert electrical energy into mechanical
energy. The DC motor achieves this by producing a continuous angular rotation that can be used
to rotate pumps, fans, compressors, wheels, etc. As well as conventional rotary DC motors, linear
motors are also available which are capable of producing a continuous liner movement. DC
Motors are used in many electronics, positional control, microprocessor, and robotic circuits.
The DC Motor is the most commonly used actuator for producing continuous movement and
whose speed of rotation can easily be controlled, making them ideal for use in applications were
speed control, servo type control, and/or positioning is required. A DC motor consists of two
parts, a “Stator” which is the stationary part and a “Rotor” which is the rotating part.
A microcontroller cannot easily control a D.C motor it would be driven either through an
arrangement of transistors known as an H-bridge, or using a dedicated motor driver IC.
3.4 H-BRIDGE
The H-bridge is designed to drive the motor clockwise and anticlockwise by switching the
applied voltage. This is achieved putting the input logic of the microcontroller as 01 and 10 to
rotate the motor clockwise and anticlockwise respectively. Thus, depending upon the signals
generated at the transmission end, the two motors can be rotated in desired directions. A Hbridge can be made with switches, relays, transistors or MOSFETs. It can also be used to “brake”
the motor that is making all inputs high or making all inputs to be low so that the motor can run
free to a stop. The H-bridge use is a transistor H-bridge, which is clamped with zener diodes, this
is to prevent the high voltage spikes that could destroy the transistors.
16
Figure 3. 3 H-bridge [10]
17
CHAPTER 4: DESIGN AND IMPLEMENTATION
4.1 DESIGN
The collision warning system designed in this project consists of hardware and software part.
The hardware consists of construction of the project circuit, which will be explained in detail.
The software part deals with the programming part of the project.
The project consists or five circuits that is the power supply, the microcontroller, obstacle sensor,
warning system and the motor driver system. The block diagram below shows the different units
Power supply
Obstacle sensor
Central Control
Module
Warning
system
Figure 4. 1 Block diagram of control system
18
Driver system
4.1.2 CENTRAL CONTROL MODULE
The microcontroller used is Atmega 328P. The interrupt pin one is used to receive the echo pulse
from the sensoring unit and the bit 1 pin of register was used to send the 10µs trigger pulse. The
external interrupt is activated when there is a change in the rising and falling edge. This
microcontroller was chosen because it is cheap and locally available. Below is the pinout of the
Atmega 328P.
Figure 4. 2 Atmega 328P Pinout
4.1.2 DRIVER CIRCUIT
The driver circuit consists of the following



9v battery
H-bridge
DC Motor
The DC Motor is already included in the toy car that was bought it draws a current of 0.08ms.
19
The tip 122 where used to design the h-bridge because they have their own internal diodes. The
maximum collector current allowed for tip122 is 5A. Thus it is sufficient to drive the motor.
The diagram below shows the driver circuit
Figure 4. 3 Driver System
20
4.1.3 OBSTACLE SENSING UNIT
To make a successful obstacle sensoring unit the following methodology was used
Figure 4. 4 Block diagram of ultrasonic sensor
21
4.1.3.1 WORKING PRINCIPLE
The sensor has for pins that is VCC, ground, echo and trigger pulse. VCC and ground are
connected to the respective pins in the microcontroller. The trigger pulse is connected to Pin1 of
PORT D while the echo pin is connected to Pin 3 of PORT D. The operation of the sensing unit
is as follows



Send a short, but long enough 10us pulse on the trigger pin (module automatically sends
eight 40KHz square wave)
Wait for the echo line to go high
Time the length of the pulse it stays high
The length of the pulse is directly proportional to distance. The range is then calculated using the
formula below
µ𝑆
58
= 𝑑𝑖𝑠𝑡𝑎𝑛𝑐𝑒 𝑖𝑛 𝑐𝑒𝑛𝑡𝑖𝑚𝑒𝑡𝑒𝑟𝑠
4.1.4 WARNING SYSTEM
The warning system used consists of a LED and a buzzer. The LED was used as top distance
warning and is derived by connecting an LED to the microcontroller output pin through a series
resistor of 220Ω. The LED consumes 20mA for normal brightness and the voltage drop across
LED is about 2V. But the voltage at the output of the microcontroller is about 5V when the port
is at logic one. As a result a resistor is needed to be connected in series with the LED. Therefore
there is a need to determine a current limiting resistor value. So if the output voltage of the port
is 5V, to have a voltage drop of 2V, we need to drop 3V across the resistor. If we assume the
current through the LED to be 20mA, the resistance value can be calculated as
𝑅=
5𝑉−2𝑉
10𝑚𝐴
= 0.15𝐾 The lowest resistor value is 150Ω
The buzzer was used for the low level distance warning. It is connected directly to the
microcontroller output pin.
4.1. 5 SOFTWARE DESIGN
The software should be able to acquire data from the sensor, analyze the data and send the data
to the peripheral devices. The software should be integrated into the microcontroller. The
22
language used to program the microcontroller was C++. The program was written in AVR
Studio.
4.1.5.1 REQUIREMENTS
 PC
 AVR Studio
 Programmer
4.1.5.2 PROGRAMMING ENVIRONMENT
The programmer of choice was AVRISPmkII. This was because it was the only programmer
available in the lab for the moment. The programmer was easy to use and very effective.
Figure 3.8 shows the AVRISPmkII. This was the programmer that was used to load the program
file to the microcontroller.
Figure 4. 5 AVRISP mkII programmer [11]
23
Below is the pinout of the AVRISPmkII
Figure 4. 6 AVRISPmkII pin out [12]
The AVRISPmkII pins were connected to the corresponding pins in the ATMEGA328P
microcontroller. The pin out of the microcontroller is shown in figure 3.3.
4.1.5.3 SOFTWARE ALGORITHM
The software algorithm is written using C++ and it is shown using the flow chart and a sample
codes taken from the complete program of the project. The flow chart of the complete program is
as below
24
START
INITIALISE INTERRUPTS
SEND TRIGGER PULSE
IS THERE
FEEDBACK
NO
YES
IS DISTANCE<=100
NO
YES
LIGHT LED
B
A
25
B
A
IS
DISTANCE<=50
NO
YES
PUT ON BUZZER
NO
IS DISTANCE<=20
YES
STOP MOTOR AND REVERSE
MOTOR
STOP
Figure 4. 7 Program Flow Chart
4.1.6 FINAL DESIGN
The schematic of the circuit in fig was constructed on a breadboard and tested to meet the design
specifications.
26
/
Figure 4. 8 Schematic of the system
27
Once it was verified as working on the breadboard, a PCB (printed circuit board) layout was
designed using PCB design software called Proteus.
Figure 4. 9 Component view of PCB
28
CHAPTER 5: RESULTS AND ANALYSIS
5.1 SIMULATION OF THE OBSTACLE SENSOR
The ultrasonic sensor was simulated by using a digital oscilloscope and a signal generator as
shown in the fig below. The signal generator simulator simulated the incoming square wave that
the echo pin will receive. The incoming square wave that comes into the microcontroller was
about 5V. The waves entering the trigger pin and echo pin were observed in the oscilloscope. At
the beginning when the frequency was high the motor rotated clockwise as the frequency was
increased slowly the led went on simulating the top distance warning. As the frequency was
continued to be increased the buzzer went on simulating low level distance warning finally the
motor stopped rotating at high frequency simulating the distance that is less than 20 cm. the
simulation is shown in Figure 5.1.
5.2 OBSERVATION
The following are the observations that were made after the circuit mounted on the PCB
Distance
<= 100cm
<=50cm
<=20cm
Table 1
Observation
LED lit
Buzzer went on
Motor stopped and changed direction
29
Figure 5. 1 System schematic diagram
30
CHAPTER 6: CONCLUSIONS AND RECOMMENDATIONS
A rear end anti-collision warning system is designed and mounted on a very simple and easily
understandable model constructed to demonstrate the system and it was found functional. The
sensor was able to read distances that are at shorter range accurately. The system was not real
time because there were incidences were the microcontroller didn’t receive any feedback. This is
due to noise from the enivronment
A distance sensor that detects objects at long distances is required to apply on a real vehicle.
Therefore, if the right materials are collected, it is possible to enhance its features so that it can
be used in vehicles. This model is also a good tool to use for demonstration for anti-collision
warning system research.
6.1 RECOMMENDATIONS
For the anti-collision avoidance system to work better one has to


Put an array of sensors to give high accuracy readings.
Use a prototype in which the sensor is put at a higher level so that it can escape the cone
detection from the ground.
31
REFERENCES
[1] http://www.statistics.gov.hk/wsc/CPS030-P2-S.pdf
[2] http://www.ikalogic.com/infra-red-proximity-sensor-part-1/
[3] http://www.cvel.clemson.edu/auto/sensors/distance-radar.html
[4] http://www.osenon.com/en/view.asp?/7.html
[5] http://www.yuvaengineers.com/ultrasonic-automatic-braking-system-for-forward-collisionavoidance-with-accelerator-pedal-disengagement-mechanism-nishad-vivek-kumbhojkar-chaitanyaavadhutchintan-kuber/
[6] http://v-codes.blogspot.com/2010/09/difference-between-harward-and-von.html
[7] http://letsmakerobots.com/content/hc-sr04-ultrasonic-sensor
[8] http://www.micropik.com/PDF/HCSR04.pdf
[9] http://www.ezdenki.com/ultrasonic.php
[10] https://courses.cit.cornell.edu/ee476/FinalProjects/s2005/jhl33/
[11] http://www.atmel.com/tools/avrispmkii.aspx
[12] http://allaboutee.com/2011/05/11/how-to-program-an-avr-microcontroller/
32
APPENDIX
/*
* COLLISION AVOIDANCE SYSTEM
*
* Created: 2/9/2015 9:29:23 AM
* Author: Vanessa Amondi Otieno
*/
#define F_CPU 8000000UL
#include <avr/io.h>
#include <util/delay.h>// for sei()
#include <avr/interrupt.h>//for _delay_ms()
#define sensorPORT PORTD
#define sensorPIN 1
#define sensorDDR DDRD
char feedback=0;
double counter=0;
int rising=1;
double distance=500;
void sendPulse()
{
sensorPORT &=~(1<<sensorPIN);
_delay_us(5);
33
sensorPORT |=(1<<sensorPIN);
_delay_us(10);
sensorPORT &=~(1<<sensorPIN);
}
void startTimer()
{
TCCR0B |=(1<<CS00);//start timer with no prescaling
TIMSK0 |=(1<<TOIE0);// start timer interrupt enable
TCNT0 = 0;// initialising counter
counter=0;
}
ISR(TIMER0_OVF_vect)
{
counter++;
}
SIGNAL(INT1_vect)
{
if(feedback==0)// enabling interrupt if there is a reponse
{
if(rising==1){//voltage rise start the time measurement
startTimer();
rising=0;
}
else// voltage drop stop the time measurement
34
{
distance = (counter*256+TCNT0)/58;// divide by 58 to get the distance in cm
feedback=1;
rising=1;
}
}
}
int main(void)
{
DDRD &=~ (1<<3);// pin d3 is used as an input
DDRB = 0xff;
EICRA |=(1<<ISC10);// enables interrupt for rising and falling edge
EIMSK |=(1<<INT1);// turns on int 1
sensorDDR |=(1<<sensorPIN);// pin d1 is used as output
sendPulse();
sei();
while(1)
{
if(feedback==1){
sendPulse();
feedback=0;
}
35
if(distance<= 100)
{
if(distance<=50)
{
if (distance<=20)
{
cli();
PORTB &=~ (1<<2);
PORTB &=~ (1<<3);
_delay_ms(2000);
PORTB &= ~(1<<1);
PORTB &= ~(1<<0);
PORTB &=~ (1<<2);
PORTB|=(1<<3);
_delay_ms(2000);
PORTB &=~ (1<<2);
PORTB &=~ (1<<3);
_delay_ms(10000);
EICRA |=(1<<ISC10);// enables interrupt for rising and falling
edge
EIMSK |=(1<<INT1);// turns on int 1
sendPulse();
feedback=0;
sei();
_delay_ms(2000);
}
36
else
{
PORTB|=(1<<1);//turning the buzzer on
}
}
else
{
PORTB|=(1<<0);// turning the led on
}
}
else{
PORTB |= (1<<2);// for moving car forward
PORTB &=~ (1<<3);
}
}
}
37
Figure 6. 1 Side View Of Car
Figure 6. 2 Front View Of Car
38
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertisement