blindspot collision avoid er

66
Jordan University of Science and Technology Electrical Engineering Department Graduation Project EE 592 Car's Blind-Spot Collision Avoidance System using Ultrasonic Sensors and PIC Microcontroller Prepared By: Rami Moh'd Zaghal ID # 20010024035 E-mail: [email protected] January 2007 Supervisor: Bassam El-Asir, Assoc. Prof.

Upload: marcos-bressan

Post on 30-Dec-2015

42 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Blindspot Collision Avoid Er

Jordan University of Science and Technology Electrical Engineering Department

Graduation Project

EE 592

Car's Blind-Spot Collision Avoidance System using Ultrasonic Sensors and

PIC Microcontroller

Prepared By: Rami Moh'd Zaghal

ID # 20010024035

E-mail: [email protected]

January 2007

Supervisor: Bassam El-Asir, Assoc. Prof.

Page 2: Blindspot Collision Avoid Er

To my loving parents

You are all the reasons I am what I am…

To Richard Bandler

You made up NLP… It changed my life!

1

Page 3: Blindspot Collision Avoid Er

Acknowledgments

First, I want to thank Dr. Bassam El-Asir for supervising my graduation project. His continuous support and consultation provided great help during the progress of the project. He has not only been an excellent teacher and a caring father, but also a long-lasting mentor to me… and he will remain…

I also want to thank Jordan University of Science and Technology for completely funding my

project. Without their funding, none of this could have been accomplished.

Finally, my special thanks and gratitude go to all the people on the Internet (EDAboard, MicroChip Forum, and MELabs PICBASIC Forums) who answered my technical questions and provided invaluable information without even knowing me.

2

Page 4: Blindspot Collision Avoid Er

Abstract

The Blind-Spot collision voidance system is an integrated automobile system designed to assist drivers when changing lanes. On busy highways, changing lanes can be very hazardous. There is region called “blind spot” which is a problem for every car driver since it is not covered by the driver’s mirrors. Relying solely on the mirrors while changing lane can lead to a collision with another vehicle.

It is proposed to implement the collision avoidance system to address these problems and provide a cost-effective solution that eases the process of changing lanes. The system employs ultrasonic sensors for the detection of objects in the blind spot. The sensors are mounted to car's left and right bumpers and the distance from the bumper of the automobile to another car is continuously updated to the driver on an LCD display located in the cabin of the automobile. A PIC microcontroller is used to control the sensors and the LCD.

3

Page 5: Blindspot Collision Avoid Er

Contents

Acknowledgments --------------------------------------------------------------------------------------------------------------------- 2 Abstract ------------------------------------------------------------------------------------------------------------------------------------ 3 Contents ----------------------------------------------------------------------------------------------------------------------------------- 4 Chapter 1: Introduction ---------------------------------------------------------------------------------------- 6

1.1 The Modern Car ---------------------------------------------------------------------------------------------------------- 6 1.1.1 Present and Future Car Technologies Overview -----------------------------------------------6 1.1.2 The Parking Space Finder Service-----------------------------------------------------------------7 1.1.3 Parking Assistant Systems --------------------------------------------------------------------------7 1.1.4 No-Hands Parking System--------------------------------------------------------------------------8

1.2 Blind-Spot Detection System----------------------------------------------------------------------------------------- 9 1.3.1 System Overview -------------------------------------------------------------------------------------9 1.3.2 Features and Benefits ------------------------------------------------------------------------------ 11 1.3.3 Technical Specifications--------------------------------------------------------------------------- 11

1.4 Project Objectives Summary --------------------------------------------------------------------------------------- 11 Chapter 2: Ultrasonic Waves and Sensors------------------------------------------------------------------12

2.1 Introduction to Acoustics and Ultrasonics-------------------------------------------------------------------- 12 2.1.1 Sound Propagation --------------------------------------------------------------------------------- 12 2.1.2 Sound Waves properties--------------------------------------------------------------------------- 13

2.1.2.1 Amplitude and Frequency ------------------------------------------------------------------ 13 2.1.2.2 Wavelength and Attenuation--------------------------------------------------------------- 13 2.1.2.3 Speed of Propagation ------------------------------------------------------------------------ 15

2.2 Ultrasonic Sensors------------------------------------------------------------------------------------------------------ 15 2.2.1 Types of Ultrasonic Sensors ---------------------------------------------------------------------- 15

2.2.1.1 Magnetostrictive Ultrasonic Sensors ------------------------------------------------------ 16 2.2.1.2 Piezoelectric Ultrasonic Sensors ----------------------------------------------------------- 16

2.2.2 Pro-Wave 40 kHz Piezoelectric Ultrasonic Sensors------------------------------------------ 16 2.3 Sensor Radiation Pattern--------------------------------------------------------------------------------------------- 18

2.3.1 Transmitter Sensor Excitation -------------------------------------------------------------------- 19 2.4 How Far The Sensor Could Reach? ----------------------------------------------------------------------------- 20 2.5 Sensor Equivalent Circuit ------------------------------------------------------------------------------------------- 21 2.6 Environmental Factors and Sensors ----------------------------------------------------------------------------- 23 2.7 Applications of Ultrasonic Sensors ------------------------------------------------------------------------------ 24

2.7.1 Special Applications--------------------------------------------------------------------------------- 25 Chapter 3: Microcontrollers ----------------------------------------------------------------------------------26

3.1 Introduction -------------------------------------------------------------------------------------------------------------- 26 3.1.1 What is a Microcontroller? ----------------------------------------------------------------------- 26 3.1.2 MicroChip PIC Microcontrollers---------------------------------------------------------------- 28

3.2 The PIC16F877A Microcontroller------------------------------------------------------------------------------- 29 3.2.1 PIC16F87X → PIC16F87XA Migration------------------------------------------------------- 29 3.2.2 PIC16F877A Hardware and Features ---------------------------------------------------------- 29 3.2.3 PIC16F877A Pin-out Description --------------------------------------------------------------- 30

3.3 PIC16F877A Subsystems in Use --------------------------------------------------------------------------------- 32 3.3.1 I/O Ports --------------------------------------------------------------------------------------------- 32 3.3.2 Timer1 ------------------------------------------------------------------------------------------------ 33 3.3.3 Comparator Module ------------------------------------------------------------------------------- 34 3.3.4 Comparator's Voltage Reference Module ------------------------------------------------------ 36

4

Page 6: Blindspot Collision Avoid Er

Chapter 4: Ultrasonic Ranging Systems --------------------------------------------------------------------37 4.1 Overview of Echo Ranging ----------------------------------------------------------------------------------------- 37 4.2 Pro-Wave Sonar Ranging Module ------------------------------------------------------------------------------- 38 4.3 Distance Calculation using the Microcontroller ------------------------------------------------------------ 40

Chapter 5: Design Details and Circuit Explanation ------------------------------------------------------41

5.1 The Overall System ---------------------------------------------------------------------------------------------------- 41 5.1.1 System Block Diagram ---------------------------------------------------------------------------- 41 5.1.2 System Circuit Schematic ------------------------------------------------------------------------- 42 5.1.3 Transmitter-Receiver Separation ---------------------------------------------------------------- 43

5.2 The Transmitter --------------------------------------------------------------------------------------------------------- 43 5.2.1 Design Explanation -------------------------------------------------------------------------------- 43 5.2.2 Simulation Results---------------------------------------------------------------------------------- 45

5.3 The Receiver ------------------------------------------------------------------------------------------------------------- 45 5.3.1 Design Explanation -------------------------------------------------------------------------------- 45 5.3.2 Simulation Results---------------------------------------------------------------------------------- 47

5.4 The Microcontroller --------------------------------------------------------------------------------------------------- 49 5.4.1 Biasing the PIC-------------------------------------------------------------------------------------- 49 5.4.2 Resetting the PIC ----------------------------------------------------------------------------------- 50 5.4.3 PIC Clock Frequency ------------------------------------------------------------------------------ 50 5.4.4 PIC Ports and Pins --------------------------------------------------------------------------------- 50

5.5 The Switches ------------------------------------------------------------------------------------------------------------- 50 5.5.1 The Manual SPDT Switch------------------------------------------------------------------------ 50 5.5.2 IC Electronic Switch ------------------------------------------------------------------------------- 50

5.6 The Alphanumeric LCD Module -------------------------------------------------------------------------------- 51

Chapter 6: PIC Programming and Interfacing -------------------------------------------------------------53 6.1 Programming Language --------------------------------------------------------------------------------------------- 53 6.2 PIC Programmer-------------------------------------------------------------------------------------------------------- 53 6.3 PIC Program Code----------------------------------------------------------------------------------------------------- 54

6.3.1 Code Flow ------------------------------------------------------------------------------------------- 54 6.3.2 Code Analysis --------------------------------------------------------------------------------------- 56

Chapter 7: Conclusions----------------------------------------------------------------------------------------59

7.1 Challenges----------------------------------------------------------------------------------------------------------------- 59 7.2 Future Work-------------------------------------------------------------------------------------------------------------- 59 7.3 Recommendations ----------------------------------------------------------------------------------------------------- 60 7.4 Final Comments -------------------------------------------------------------------------------------------------------- 60

References and Readings --------------------------------------------------------------------------------------61 Web Resources --------------------------------------------------------------------------------------------------62 Appendix A ------------------------------------------------------------------------------------------------------63

List of Components Used in the Project --------------------------------------------------------------------------------- 63 Appendix B ------------------------------------------------------------------------------------------------------64

Sensors and Modules Purchase Order ------------------------------------------------------------------------------------ 64 Appendix C ------------------------------------------------------------------------------------------------------65

Selected Data Sheets------------------------------------------------------------------------------------------------------------- 65

5

Page 7: Blindspot Collision Avoid Er

Chapter 1: Introduction

1.1 The Modern Car 1.1.1 Present and Future Car Technologies Overview

As the technology advances day-after-day, cars manufacturers and developers provide us with

more sophisticated, high technology cars and vehicles. We are living in the smart car era. Figure 1.1 illustrates features available in a typical modern car. This car utilizes an engine control system that optimizes performance and fuel combustion, a system that detects collisions and activate the airbags in the event of a crash, a system that regulates the interior climate based on passenger preferences and exterior climate conditions, a system that controls the braking system for maximum efficiency, a GPS navigation system to aid driver approach his destination in most efficient ways, and much more. In fact, modern car - nowadays - may contain up to a 100 microprocessor and microcontroller systems that together manifest all these features.

According to statistics, vehicle accidents cause 40,000 deaths and 3.5 million injuries annually. In a given two-hour period, 1,600 accidents, 800 injuries, and 10 deaths will occur on U.S. highways. The ultimate goal of cars manufacturers is to come up with safe, driver-friendly add-on systems to ensure the safety of drivers, passengers and pedestrians. This may, in some way or another minimizes car accidents and injuries.

Figure 1.1: Example of features of a modern car.

Safe driving support systems are starting to appear on vehicles including adaptive cruise control

(ACC) systems that maintain safe distance between you and the vehicle ahead, lane keep support (LKS) systems that prevent drivers from departing lane, and pre-crash brake systems that automatically tighten seat belts, activate air-bags and apply brakes if a collision cannot be avoided. Ultrasonic, Millimeter-wave and Infrared Radars and image processing cameras are the environment sensors with the key roles of recognizing and deciding what action to take in these safe driving support systems. These sensors must incorporate intelligent recognition technologies considering various complex external factors they might encounter in the real world: pedestrians darting out into the road, other vehicles cutting-in in front of you, poor visibility due to adverse weather conditions, etc. Symbols and signals in a car must provide the driver with accurate information about the car’s status, and with clear warnings of critical situations. The visual aspect frequently dominates in convenience functions. A graphical icon or symbol, for instance, may clearly demonstrate available options and appropriate actions the driver can take to back into a parking space or to change into

6

Page 8: Blindspot Collision Avoid Er

new lane. In addition, acoustic (audible) signals can denote the start and finish of required steering, backing-up and braking actions. Figure 1.2 illustrates ACC and LKS systems.

Figure 1.2: Examples of safe driving support systems. 1.1.2 The Parking Space Finder Service

This is one of the most promising (hot) schemes in the field. The objective of the PSF service is to use feeds from cameras installed in parking lots in a metropolitan area and allow users to make queries about the availability of parking spots at a particular location. The microcomputers used in this service processes the webcam feed and recognize whether the parking spots are empty or full. Users specify a destination and constraints of their desired spot. The PSF service returns the driving directions (using the Yahoo Maps service) to the empty parking spot that satisfies the constraints and is the nearest to their destination. 1.1.3 Parking Assistant Systems

With increasing traffic density, especially in urban areas, parking can be a tricky maneuver and an error can be costly, in the event of contact with other parked cars or hidden obstacles. Such accident repairs are more and more frequent and expensive. Drivers can prevent such costly, time consuming and stressful situations by selecting an Ultrasonic Park Assist (UPA) system when buying a new vehicle or installing any of the commercially available kits as post-equipment, both of which cost less than the average accident repair.

UPA is available for rear applications using two to six sensors mounted discreetly behind the rear

bumper or a combined front and rear system using eight to twelve sensors. Figure 1.3 shows a typical four-sensor reverse parking aid. Figure 1.4 shows - from three different views - how the system is installed and highlights the range covered by the three sensors. This system provides a visual or acoustic warning, which alerts the driver of the presence of, and distance to any obstacles to the rear or front of the vehicle. Various display and audio options are available.

7

Page 9: Blindspot Collision Avoid Er

Figure 1.3: Rear-bumper sensors (Blue) used to detect the distance from behind cars and walls.

Figure 1.4: Installation diagram and sensing range of a 3-sensor parking assistant. 1.1.4 No-Hands Parking System

Also referred to as “Autonomous Parallel Parking System”. It is very similar to the well-known aircraft's auto-pilot system. It helps drivers park their cars in tight spaces between other cars along the street (parallel parking). This system would be an option (although probably not a cheap one!) that a car buyer could purchase with a new car in the very soon future. Figure 1.5 demonstrates the operation of the No-Hands Parking System.

Although not yet applied to real-life cars, the

same idea is applied in Robot Homing Systems, where a pre-programmed autonomous robot moves in a prescribed path to reach its final destination with an intelligent capability to adjust its route in case some obstacle "popped-up" and encountered its way.

However, my project is concerned only in one of safe driving support systems, namely, the Blind-Spot Collision Avoidance System. The next section will deal in-detail with this system.

Figure 1.5: Autonomous Parallel Parking System.

8

Page 10: Blindspot Collision Avoid Er

1.2 Blind-Spot Detection System 1.3.1 System Overview

It is every driver's nightmare: you change lanes suddenly, glancing in the rearview mirror without looking over your shoulder... and you merge directly into a car hidden in one of your car's blind spots. Yes, that is true. Every car has a blind spot; the area behind the car where cannot be seen from driver seat. According to recent statistics, more than 800,000 vehicles are involved in lane-change blind-spot collisions annually. Furthermore, the U.S. National Highway Traffic Safety Administration says that "lane change situations" are involved in 4 to 10 percent of all car crashes. So, we are talking about a serious problem here!

To solve this problem and maintain car's safety, the driver must make sure that the blind-spots of the vehicle are clear before he attempts to change lanes. My design goal is to implement a system that would detect objects present within the blind-spot, on either side of the vehicle (left/right), and appropriately warn the driver if the turn signal was on. The warning mechanism can be audio warning by a buzzer, or beeper. In addition, we wanted to display the distance measurement of the object present in the blind-spot on an LCD. The system will detect the presence of vehicles within the detection zone, as shown in Figure 1.6 by use of sensors. The detection zone is fixed. The zone extends from one to three and a half meters to the side of the vehicle to allow for traffic in the adjacent lane of traffic. The zone does not extend more than two meters back from the rear of the car. Objects detected will not be limited to cars, as vehicles such as motorcycles will be present in some situations. Sensors employed in design are so sensitive that they ensure the detection of an object the size of a pole or broom's handle!

Figure 1.6: Blind-Spot detection region.

9

Page 11: Blindspot Collision Avoid Er

During initial design stages, various design alternatives were explored. The Blind Spot Detection system can be realized in two ways: Scheme Alternative 1: Always On

The first scheme involves continuous monitoring of the rear blind spots on both sides of the

vehicle. When a vehicle is present in either blind spot, for example, an overtaking vehicle, the driver is alerted to this potential hazard by a visible icon displayed in the door rear view mirror or a warning buzzer goes off when the distance becomes less than certain critical value to warn the driver of a possible collision. Scheme Alternative 2: Instant On

The second scheme is illustrated in figure 1.7. When the driver gives the turn signal for a lane change to either left or right side, vibroactuators mounted on the wheel actuate the related sensor (left or right). The system uses microcontrollers to calculate the distance and indicate whether the car can turn left or right. The driver can be warned by means similar to those in scheme 1. I chosen this scheme over the first one because it saves power (only one sensor is activated) and electronic circuitry (the timer, transmitter and receiver can be shared between the two sensors).

Figure 1.7: Functional Block Diagram of the Blind-spot Detection System (Scheme 2). One sensor or array of sensors

During my initial research to find the best possible sensor for this application, I considered

whether to get one sensor or an array of sensors. I had initially thought that we would require an array of sensors to cover all the detection region of Figure 1.6. Later on, I found one sensor that covered the entire detection region. Hence, at the end, I decided to go for one sensor since it also made controlling it much easier compared to controlling an array of sensors. Details on sensors radiation patterns, beam width and coverage area will be explained later in Section 2.3.

10

Page 12: Blindspot Collision Avoid Er

1.3.2 Features and Benefits

• The device will warn the driver of the presence of an object within the blind spot of the vehicle when the driver gives the turn signal for a lane change (Scheme 2).

• The system will provide measurements of the object’s distance relative to the vehicle to the driver.

• The system will decrease the probability of an accident occurring due to any reason related changing lanes.

• The system will help the driver focus on road by taking care of his blind spot region. • The device will only notify the driver when the turn signal is activated (Scheme 2). • The device should withstand typical weather conditions. • The device will not significantly alter the outward appearance of the vehicle.

1.3.3 Technical Specifications

Operating voltage: 12 V (from car's battery). Operating frequency: 40 kHz. Range: 25 to 225 cm. Resolution: 1 mm. Microcontroller clock (speed): 20 MHz. Wide operating temperature range.

1.4 Project Objectives Summary:

Building a reliable, accurate, robust ultrasonic blind-spot collision warning system.

Having sufficient number of sensors and ranging modules (ICs) available at the beginning of summer course.

Operating and evaluating various types of ultrasonic sensors, for research's sake.

Building a high-speed, fast-response system by minimizing stages delays and optimizing

microcontroller's software code.

Reducing the number of sensors used by replacing transmitter-receiver pair with a single transceiver.

Reducing the power consumption of the overall system to minimum.

Implementing the final system using PCB technology.

Reducing the number of used microcontrollers to minimum.

Designing a compact system with minimum size (area).

Installing and testing the system board and sensors on a miniature remote-controlled car.

Not exceeding the available funding budget (low-cost system).

11

Page 13: Blindspot Collision Avoid Er

Chapter 2: Ultrasonic Waves and Sensors

There are several ways to measure distance without contact. Some products have infrared light emitters and receivers that determine an object’s distance by implementing the optical triangulation method. Other devices have laser-based systems that increase accuracy and precision. For electrically conductive metal objects, the eddy current method is an option, and capacitive sensors that are independent of the metal used in the measured objects can be used. I decided to use ultrasonic sensors. This chapter discusses ultrasonic waves and sensors with details.

2.1 Introduction to Acoustics and Ultrasonics

Ultrasonics is the science of sound waves above the limits of human audibility. The frequency of a sound wave determines its tone or pitch. Low frequencies produce low or bass tones. High frequencies produce high or treble tones. Ultrasound is a sound with a pitch so high that it can not be heard by the human ear. Frequencies above 18 kHz are usually considered to be ultrasonic. The frequencies used for ultrasonic cleaning range from 20,000 cycles per second or kilohertz to over 100,000 kHz. Although ultrasound behaves in a similar manner to audible sound, it has a much shorter wavelength. This means it can be reflected off very small surfaces such as defects inside materials. This very property makes ultrasound useful for nondestructive testing of materials, and hence can be used in distance measurement systems.

The Acoustic Spectrum in Figure 2.1 bre

Figure 2.1: Acoustic Spectrum.

.1.1 Sound Propagation

In order to easily illustrate the generation and propagation of sound waves, I'll make use of the rese

he source of the sound in the model is at the left. The compression generated by the sound sou

rarefaction, the pressure in the medium is negative (as indicated by the meter under the spring).

aks down sound into 3 ranges of

frequencies. The Ultrasonic Range is then broken down further into three subsections. I am interested in the frequency band (20-100 kHz) as the operating frequency is 40 kHz.

2

mblance of sound waves propagation through transmission media and mechanical waves traveling through a spring as depicted in Figure 2.2.

Trce as it moves propagates down the length of the spring as each adjacent coil of the spring pushes

against its neighbor. It is important to note that, although the wave travels from one end of the spring to the other, the individual coils remain in their same relative positions, being displaced first one way and then the other as the sound wave passes. As a result, each coil is first part of a compression as it is pushed toward the next coil and then part of a rarefaction as it recedes from the adjacent coil. In much the same way, any point in a sound conducting medium is alternately subjected to compression and then rarefaction. At a point in the area of a compression, the pressure in the medium is positive (as indicated by the meter under the spring). At a point in the area of a

12

Page 14: Blindspot Collision Avoid Er

Figure 2.2: The Nature of Sound Waves. 2.1.2 Sound Waves prop

y of sound waves. The illustrations below in Figure 2.3 emonstrate amplitude and frequency using the spring model introduced earlier. If “A” is the

refe

Figure 2.3: Illustration of frequency and amplitude

.1.2.2 Wavelength and Attenuation

ction of both speed of sound and frequency, as shown by the well-known expression:

erties 2.1.2.1 Amplitude and Frequency

Amplitude is very important propertd

rence sound wave, “B” with less displacement of the media (less intense compression and rarefaction) as the wave front passes, represents a sound wave of less amplitude or “loudness”. “C” represents a sound wave of higher frequency indicated by more wave fronts passing a given point within a given period of time.

properties of sound waves.

2

The wavelength of sound changes as a fun

13

Page 15: Blindspot Collision Avoid Er

As the sound travels, the amplitude of the sound pressure is reduced due to friction losses in the transmission medium. The attenuation (also known as absorption) of sound in air increases as the frequency increases, and at any given frequency the attenuation varies as a function of humidity. The value of humidity that produces the maximum attenuation is not the same for all frequencies. For example, above 125 kHz the maximum attenuation occurs at 100% relative humidity; however, at 40 kHz the maximum attenuation occurs at 50% relative humidity.

Since an ultrasonic sensor usually is required to operate at all possible humidities, target range calculations should use the largest value of attenuation. A good estimate for the maximum attenuation in air at room temperature over all humidities for frequencies up to 50 kHz is given by:

For frequencies between 50 kHz and 300 kHz, the maximum attenuation over all humidities is:

I will take the first equation into account when calculation maximum detectable distance as the nominal operating frequency is 40 kHz. Substituting 40 in the first equation gives:

α(40) = 0.4 dB/ft = 0.1886 dB/m

This value will be used in Section 2.4 in some important calculations. Figure 2.4 depicts the relation between sound waves absorption and frequency. Calculating the attenuation at 40 kHz using the curve gives the same result as the equation.

Figure 2.4: Sound Waves Absorption (Attenuation) due to distance traveled.

14

Page 16: Blindspot Collision Avoid Er

2.1.2.3 Speed of Propagation

The speed of sound waves propagation depends on many factors including temperature and the nature of the medium itself (gas type). For an ideal gas, the speed of sound is mainly a function of temperature. At 0° C, the speed of sound is 13,044 in /s (332 m/s). At other temperatures, the speed is given by:

C = γ × R × T Where: C = Speed of sound in meters per second γ = Ratio of specific heats. R = Gas constant. T = Absolute temperature (Kelvin), where 0˚C = 273.16 K

or dry air (as in m = 1.4 (non-dimensional) = 286.9 N.m/(kg.K)

herefore, the speed of sound at room temperature (22˚C) is:

F γ

y case):

R T

1.4 × (22 + 273.16) × 286.9 = 344C = .31 meters per second (m/s)

Thi

asonic Sensors

transducer r sensor, by definition, is any device that converts one form of energy to another. n ultrasonic transducer converts electrical energy to mechanical energy, in the form of sound, and

a. When operating as transmitters, ultrasonic transducers transform electrical energy into medium, which is usually air or water. When operating as

e acoustical energy into electrical energy. The main components of e the active element, backing, and wear plate.

The active element can be piezo- or ferro-electric material. The most commonly used materials ch can be cut in a variety of manners to produce different wave modes. uch as piezo polymers and composites are also being employed for

provide benefit to transducer and system performance.

redetermined by mechanical design. It ld be selected after consid s transducer size, measurement

r.

s calculated value will be used in distance measurement formula in later chapter. 2.2 Ultr

A oAvice versacoustic energy that propagates through areceivers, they transform thultrasonic sensors ar

are polarized ceramics, whiRecently, new materials sapplications where they

The operating frequency of an ultrasonic transducer, f, is pshou ering a number of factors such aresolution, background noise and attenuation, and the range to the receiving transduce

2.2.1 Types of Ultrasonic Sensors

The variations of the employed active element material give rise to two general types of ultrasonic transducers in use today: Magnetostrictive and Piezoelectric.

15

Page 17: Blindspot Collision Avoid Er

2.2.1.1 Magnetostrictive Ultrasonic Sensors

Magnetostrictive transducers (also known as Ferroelectric transducers) utilize the principle of ma

d into an alternating magnetic field through the use of a coil of wire. The alternating magnetic field is then used to induce me

plied to the transducer is ½ of the desired output frequency. Magnetostrictive transducers were first to supply a

bust source of ultrasonic vibrations for high power applications such as ultrasonic cleaning.

the physical size of the hardware as well as lec

.2.1.2 Piezoelectric Ultrasonic Sensors

what are called the piezoelectric and reverse piezoelectric effects. The piezoelectric effect causes

e long been known as single-crystal piezoelectric substances. However, these sub

in my project. As a result, all subsequent discussion nd

gnetostriction in which certain materials expand and contract when placed in an alternating magnetic field.

Alternating electrical energy from the ultrasonic generator is first converte

chanical vibrations at the ultrasonic frequency in strips of nickel or other magnetostrictive material which are attached to the surface to be vibrated. Because magnetostrictive materials behave identically to a magnetic field of either polarity, the frequency of the electrical energy ap

ro Because of inherent mechanical constraints on

e trical and magnetic complications, high power magnetostrictive transducers seldom operate at frequencies much above 20 kHz. Piezoelectric transducers, on the other hand, can easily operate well into the megahertz range. 2

Piezoelectric ultrasonic sensors are known for a crystal to produce an electrical potential when

it is subjected to mechanical vibration. In contrast, the reverse piezoelectric effect causes the crystal to produce vibration when it is placed in an electric field. Of piezoelectric materials, Rochelle salt and quartz hav

stances have had a relatively limited application range chiefly because of the poor crystal stability of Rochelle salt and the limited degree of freedom in the characteristics of quartz. Later, barium titanate (BaTiO3), a piezoelectric ceramic, was introduced for applications in ultrasonic transducers, mainly for fish finders. More recently, a lead titanate, lead zirconate system (PbTiO3.PbZrO3) appeared, which has electromechanical transformation efficiency and stability (including temperature characteristics) far superior to existing substances. It has dramatically broadened the application range of piezoelectric ceramics.

Magnetostrictive transducers are generally less efficient than their piezoelectric counterparts are.

This is due primarily to the fact that the magnetostrictive transducer requires a dual energy conversion from electrical to magnetic and then from magnetic to mechanical. Some efficiency is lost in each conversion. Hysteresis effects also detract from the efficiency of the magnetostrictive transducer.

I am willing to use piezoelectric transducersa analysis is concerned only with piezoelectric ceramic ultrasonic transducers. 2.2.2 Pro-Wave 40 kHz Piezoelectric Ultrasonic Sensors

The most important part of this project is to choose and buy necessary sensors. Unfortunately, their availability is limited in the Jordanian market. I spent lot of time searching for suitable sensors that can be shipped with the limited quantity we need. That was a quite difficult task. Here are all the cited manufacturers:

1. Mobicon Electronic Components. 2. MuRata Corp.

16

Page 18: Blindspot Collision Avoid Er

3. PANASONIC. 4. Sanwa. 5. Pro-Wave Electronics Corp.

Pro-Wave Electronics Corp. provides various sensor solutions for all applications (some shown in Fig

ltrasonic piezoelectric ceramic transducers come in different types. They are:

• Open-type Receiver.

ultrasonic transducer design exposes the piezo bender bonded with a metal “enclosed” type transducer design has the piezo bender

underside of the top of the case which is then machined to resonant at the PT and EP” type transducer has more internal damper for minimizing

usually operates as a transceiver, oscillating in a short period and then switching to d in my project and the maximum ringing duration plays an

ining the minimum measurable distance by the sensor and the system.

the enclosed transducer, the open type receiver will develop more electrical ivity) and exhibit less reduction in output as the

perating frequency deviates from normal resonant frequency (greater bandwidth). The open type tran

This include: sing (Silver Color).

Housing.

g.

6. SensComp. 7. Quantelec. 8. KOBITONE. 9. Sencera and Kwang Hwa Elect. Material.

ure 2.5) and they were ready to ship us the quantity we want (refer to Appendix: B for more details) by their middle east distributor, Farnell. U

• Open-type Transmitter.

• Open-type Transceiver. • Enclosed-type Transceiver.

The “open” type

conical cone behind a protective screen. Themounted directly on thedesired frequency. The ““ringing”, whichreceiving mode. The later type is useessential role in determ

When compared to output at a given sound pressure level (high sensito

smitter will produce more output for a specific drive level (more efficient). The enclosed type transducer is designed for very dusty or outdoor applications. The face of the transducer must be kept clean and free of damage to prevent losses. Pro-Wave and other manufacturer provide different Housing Materials as well.

• Natural Aluminum Hou• White Painted Plastic• Black Aluminum Housing. • Black Painted Plastic Housin

Figure 2.5: Various 40 kHz piezoelectric ultrasonic sensors manufactured by Pro-Wave Corp.

17

Page 19: Blindspot Collision Avoid Er

2.3 Sensor Radiation Pattern

The acoustic radiation pattern, or beam pattern, is the relative sensitivity of a transducer as a function of spatial angle. This pattern is determined by factors such as the frequency of operation and

the vibrating surface. The beam patterns of at the beam will be the same whether the transducer is

Transducers can be designed to radiate sound in many different types of patterns, from omnidirectional to very narrow beams. For a transducer with a circular radiating surface vibrating in phase, as is most commonly used in ultrasonic sensor applications, the narrowness of the beam pattern is a function of the ratio of the diameter of the radiating surface to the wavelength of sound at the operating frequency. The larger the diameter of the transducer as compared to a wavelength of sound, the narrower the sound beam.

As can be seen in Figure 2.6, the sensor produces a narrow conical beam and a number of secondary lobes of reduced amplitude separated by nulls. Even though the beam is called onical, it d

The beam angle, alpha (α), is usually defined as the me

symmetrical 2.7 three-dimensional pattern. Figure

beam plots are required to fully the other is along the wide angle.

use the transducers are still sensitive at angles gre ications are specially designed to

nted targets. Narrow beam angle and the systems will also operate

the size, shape and acoustic phase characteristics of transducers are reciprocal, which means thused as a transmitter or as a receiver.

c"c

oes not have straight sides and a flat top as the word onical" may imply.

asurement of the total angle where the sound pressure level of the main beam has been reduced by 3 dB (half its peak value) on both sides of the on-axis peak. However, the transducer still has the sensitivity at greater angles, both in the main beam and in the secondary lobes.

Figure 2.6: Directivity Plot.

When describing the beam patterns of transducers, two-dimensional plots are most commonly used. They show the relative sensitivity of the transducer vs. angle in a single plane cut through the three-dimensional beam pattern. For a conical pattern, such as that shown in Figure

a, a simple single two-dimensional plot will describe the entire 2.7b shows an asymmetric beam pattern. Two perpendicular 2-D describe its directivity. One of which is along the narrow angle and

When using transducers, it is important to be aware that nearby unwanted targets that are beyond the beam angle can inadvertently be detected, beca

ater than the beam angle. Some transducers used in sensing applminimize or eliminate the secondary lobes to avoid detecting unwasystems are also less susceptible to background ultrasonic noise, over a greater range.

18

Page 20: Blindspot Collision Avoid Er

(a) (b)

Figure 2.7: (a) Symmetric Beam Pattern for 400EP18A sensor. (b) Asymmetric Beam Pattern for 400EP14D sensor. 2.3.1 Transmitter Sensor Excitation

1. Continuous Excitation: A sine wave drive should be used to minimize harmonics that may excite the transducer in an

overtone mode (vibrate at a multiple of the resonant frequency). For most models, the maximum amplitude of the drive waveform varies between to 50 - 140 V p-p. The transmitter dissipation must be limited to an effective or average level of 200 mW by reducing the duty cycle when the transmitter is dissipating more than 200 mW. This type of excitation can be used in TX-RX pair system.

2. Pulse Excitation:

The ultrasonic transmitters may also be driven with a pulse waveform. Application of a DC Pulse

of 10 – 20 volts will cause the transducer to “ring” at the selected resonant frequency. The ultrasonic output will be a damped ringing waveform as illustrated in Figure 2.8. This type of excitation can be used in single-sensor (transceiver) system.

(a) (b)

Figure 2.8: (a) Pulse Wave Excitation of Sensor (b) A waveform: Periodic generates a short pulse that drives the

transmitter into conduction. B waveform: A 40 kHz short burst emitted by transducer.

19

Page 21: Blindspot Collision Avoid Er

2.4 How Far The Sensor Could Reach?

transmitter and receiver (transceiver has double distance between reflect target). This SPL must then be converted “Pa” (Pascal) or “μbar” (microbar) units. The sensitivity of the receiver must then be converted from a dB reference to an absolute mV/Pa or μbar level present to obtain the final output.

Assume a 400PT160 transmitter is driven at a level of 8.49 Vrms (12 Vp-p periodic pulses) and a 400PT160 receiver is located 4.5 meters from the transmitter and loaded with a 100KΩ resistor (loaded resistor value varies receiver sensitivity, see Figure 2.9). 4.5 meter separation between TX-RX is equal to 2.25 meters from the target/object in echo ranging.

Figure 2.9: 400PT160 Sensor's Sensitivity Variation vs. Loaded Resistor.

Under the to find the level of

utput voltage from the receiver for maximum detectable distance in my design specification. Worst-case er,

ts 117dB min (0dB corresponding to

0.0002μbar per 10Vrms at 30cm).

onverting S.P.L. to μbar: 91.

One of the most frequently asked questions is “How far the sensor could reach?”. This question

can be answered by a simple calculation that is based on the published specifications in the Ultrasonic Ceramic Transducer Data Sheets. The basic procedure is to first determine the minimum sound pressure level (S.P.L.) developed at the front end of the receiver for a specific transmitter driving voltage and distance between the

above conditions, I am going to perform the worst-case analysis o

analysis includes the minimum values of S.P.L. and sensitivity for transmitter and receivata sheet of 400PT160 (refer to Appendix: C) states the following: respec ively. D

1. Transmitting Sound Pressure Level at 40.0kKHz i

2. Receiving Sensitivity at 40.0kHz is –65dB min (0dB = 1 volt/μbar). Determining S.P.L. at the front end of Receiver S.P.L. Gain for 8.49Vrms (12Vp-p) driving voltage = 20 × log (8.49V / 10V) = –1.422 dB S.P.L. Reduction at 4.5 meters (maximum distance) = 20 × log (30 cm / 450 cm) = –23.522 dB Wave absorption (refer to Figure 2.4) = 0.1886 dB/m × 4.5m = 0.8487 dB The S.P.L. at 4.5 meters becomes = 117 – 1.422 – 23.522 – 0.8487 = 91.207 dB C

207 dB = 20 × log (X / 0.0002 μbar) X = 7.268 μbar Determining Receiver Sensitivity in Volts/μbar Converting Sensitivity to Volt/μbar: -65 dB = 20 × log (X / 1 Volt/μbar) X = 0.56 mV/μbar Voltage generated under 7.268 μbar = 0.56 × 7.268 = 4.07 mV

This calculated voltage developed under the assumed conditions is output voltage from the

ceiver sens ximum m asurable dist nce. Of course, it needs toro

rep

or for ma e a be amplified before cessing. The actual voltage output will be varied depending on the environmental conditions and

absorption or reflection characteristics of target materials.

20

Page 22: Blindspot Collision Avoid Er

The previous two sections (2.3 and 2.4) revealed the comparative characteristics of piezo-electric ultrasonic transducers. They are:

1. Transmitter Sound Pressure Level:

2. Receiving Sensitivity: itivity is better than -85 dB)

ty and wide coverage ide beam). The designer, then, have to judge whether this receiving voltage level is large enough

.5 Sensor Equivalent Circuit

ctric ceramic ultrasonic transducer is similar as the well-known branch of Ls, Cs and Rs and a parallel branch of Cd as shown in

Cd: Clamp

s: Eq 2 2

s resonant frequency

Figure 2.10: Equivalent circuit of a crystal.

iver Equivalent Circuit: A t

The higher, the better. (e.g. 118 dB S.P.L. is better than 100 dB)

The higher, the better. (e.g. -78 dB sens3. Total Beam Angle: Application dependent. The narrower the beam, the more directional the transducer.

A compromise (tradeoff) should be made when desiring high S.P.L, sensitivi(wfor electronic processing.

2

The equivalent circuit of piezoelecrystal, which is composed of a seriesFigure 2.10, where:

ing Capacity, measured at the frequency far away from resonant frequency, which approximates to static capacity. Cs: Equivalent Inductor = 1/(4π2 fs

2 Cs) L uivalent Capacity = Cd × [(fp /fs ) – 1] R : eal part of the impedance at R

The values can be simply obtained from calculation of the impedance data.

400PT160 Open-Type Transceransducer of model 400PT160 has impedance characters shown as below.

Figure 2.11: 400SPT160 Sensor's Impedance/Phase Angle vs. Frequency

fs = 900 Ω

. fs = 39.0 kHz f = 40.6 kHz p

Z

21

Page 23: Blindspot Collision Avoid Er

θfs = -46.5° Zfp = 1200 Ω

= 2400 pFCd (From Data Sheet)

pedance (Z∟θ) at resonant frequency of 39.0 kHz is (900∟-46.5°). ImCs = 2400 × [(40.62/39.02) – 1] = 188.17 pF Ls = 1/[4 × 3.142 × 390002 × (188.17 × 10-12)] = 88.59 mH Rs = 900 × cos (-46.5°) = 619.5 Ω

) 400ST120 Open-Type Transmitter Equivalent Circuit:

A transducer of model 400ST/R120 has impedance characters shown as below. The equivalent circuit parameters of 400ST120 (Transmitter) are calculated below.

These values are used in the simulation of transmitter circuit (refer to Section 5.2 for results

Figure 2.12: 400ST/R120 Sensor's Impedance/Phase Angle vs. Frequency.

fs = 510 Ω

fs = 40.25 kHzfp = 41.50 kHz Z

θfs = -33.0° Zfp = 1330 Ω Cd = 2400 pF (From Data Sheet)

pedance (Z∟θ) at resonant frequency of 40.25 kHz is (510∟-33.0°). Im

Cs = 2400 × [(41.502/40.252) – 1] = 151.38 pF Ls = 1/[4 × 3.14 × 40250 × (151.38 × 10 )] = 103.39 mH2 2 -12

sR = 510 × cos (-33.0°) = 427.7 Ω

From Figures 2.11 and 2.12, one can infer that ultrasonic transmitter impedance characteristics vary with operating frequency and temperature in complex manner that is different for each construction. In general, for frequencies approximately 0.1 octave on either side of the resonant frequency, the transmitter looks like a capacitor. The current through the transmitter will lead the voltage developed across the transmitter by 90 degrees. As the resonant frequency is approached, the voltage drop across the transmitter will decrease to a minimum at the resonant frequency (minimum series impedance) and the current will increase proportionally. The phase lead to this current relative to the voltage will decrease to zero near the resonant frequency and the transmitter will then appear to be a pure resistance. As the frequency is increased above the resonant point, the current may now

22

Page 24: Blindspot Collision Avoid Er

lag the voltage by an increasing amount (maximum of 90 degrees) as the voltage across the transmitter climbs to a peak, which is defined as the anti-resonant frequency. During this transition, the transmitter appears to have an inductive characteristic.

2.6 Environmental Factors and Sensors

Since the sensors will be mounted outside the vehicle, they have to be such that they can withstand the changes in the surrounding environment. Many environmental factors affect the performance of an ultrasonic sensor such as temperature, humidity, atmospheric pressure, acoustic interference, air turbulence and convection currents. Each of these factors is discussed briefly.

emperature

is an important factor since it can negatively affect the performance of an ultrasonic xample, the speed of the sound through air changes 0.18% for every Celsius degree. So

istance of 1 meter, a 25°C change in air temperature throws off the reading by 4.5 cm. ost modern ultrasonic sensors have a built-in temperature compensator to solve this I can use one of these sensors. Figure 2.13 Illustrates an ultrasonic transmitter and

perature range.

T

Temperaturesensor. For eat a target dHowever, mproblem, andreceiver performance for wide tem

Figure 2.13: 400ST/R120 Temperature characteristics: (Left) Sensitivity Variation vs. Temperature (Right) SPL Variation vs. Temperature.

Air Turbulence and Convection Currents

A particular temperature problem is posed by convection currents that contain many bands of varying temperature. If these bands pass between the sensor and the target, they will abruptly change the speed of sound while present. No type of temperature compensation (either temperature measurement or reference target) will provide complete high-resolution correction at all times under

ese circumstances. In some applications it may be desirable to install shielding around the sound the return times from a

t of convection currents. Users addressing pplications requiring high accuracy and resolution should evaluate these suggestions carefully.

Tem

ditions to improve ranging information.

thbeam to reduce or eliminate variations due to convection currents. Averagingnumber of echoes will also help reduce the random effeca

perature variations and wind produce air turbulence that has various effects on the total performance of any ultrasonic sensing system, causing bending and distortion of the sound waves. The narrower the angle of the sound beam and the greater the distance to the target, the greater the turbulence. Additional signal processing may be able to filter data under high turbulence con

23

Page 25: Blindspot Collision Avoid Er

Atm

Humidity does not significantly affect the operation of an ultrasonic measuring system. Changes in humidity do have a slight effect, however, on the absorption of sound. If the humidity produces condensation, sensors designed to operate when wet must be used (enclosed-type). Since the used ultrasonic sensor is required to operate almost at all possible humidity conditions, target range calculations should use the largest value of attenuation.

Acoustic Interference

Special consideration m background noise in the ultrasonic freq r jets used for

th harmonics in the ultrasonic range. When in d at the sensor or not, ultrasonic noise at or around the

sensor's frequency may affect system operation. Typic

cause ultrasonic sensors produce inaccurate measurements due to acoustic drift in the open air. Moreover, The operating range becomes restricted when it is foggy.

he range is approx. 1.5 times the human vision.

asonic Sensors found their way into industry and are used in a wide variety of applications, such as:

• Pre-crash detection. pant position and motion sensing.

• Cruise control and collision avoidance.

Tape measurements. And much more!

ospheric Pressure

Normal changes in atmospheric pressure will have little effect on measurement accuracy. Reliable operation will deteriorates however, in areas of unusually low air pressure, approaching a vacuum.

Humidity

ust be given to environments that contain uency spectrum. For example, air forced through a nozzle, such as ai

cleaning machines, generates a whistling sound wiclose proximity to a sensor, whether directe

ally, the level of background noise is lower at higher frequencies, and narrower beam angles work best in areas with a high ultrasonic background noise level. Often a baffle around the noise source will eliminate the problem. Because each application differs, testing for interference is suggested.

2.7 Applications of Ultrasonic Sensors

Ultrasonic sensors are not ideal and do have drawbacks. The emitted pulse has a nonideal cone shape and it is not possible to discern between small objects, such as a broomstick, and large objects such as a chair or wall for this reason as both will return an echo. Also, The broad ultrasonic beam leads to inaccurate echoes. These drawbacks can be overcome by using multiple or rotating sensors. Other disadvantages are there be

T

Nonetheless, Ultr

• Car parking and reversing. • Blind-spot detection.

• Occu

• Remote control equipments. • Range Finders. • Automatic doors. • Water (liquid) level measurements. • Intrusion alarms. •…

24

Page 26: Blindspot Collision Avoid Er

2.7.

obotics see and find their paths. Ultrasonic Eyes or

s robots and in Robot Homing schemes.

Cra

1 Special Applications Ultrasonic Cleansing

All hermetically sealed and wash-proof components can be cleaned using standard aqueous and solvent based cleaning methods. Units with tuning holes, open covers and other openings should not be soaked or cleaned in an environment where the cleaning solution can penetrate the openings. Exceptions are units that are designed for wash-through and are clearly marked or specified as such. Ultrasonic cleaners use low frequencies (< 20kHz) and typically do not cause damage. R

Ultrasonic Sensors are the eyes by which Robots canUltrasonic Vision is applied widely to various autonomou

ne collision avoidance In crane applications, the distance between traveling cranes running on the same tracks is

estimated by crane-operating staff. Accidents can often occur, particularly where cranes have to be moved in restricted areas. At present, ultrasonic and microwave sensors are used.

25

Page 27: Blindspot Collision Avoid Er

Chapter 3: Microcontrollers

3.1 Introduction

The microcontroller is the intelligent part of the system and its most important component that tegrates the transmitter and receiver together. The microcontroller is a very common component in odern electronics control systems. It consists of a processor, memory, input/output ports, timers, WM and analog to digital converter. This configuration facilitates the widespread of using icrocontrollers in many applications such as:

Engine management systems in automobiles. Keyboard of a PC. Electronic measurement instruments (such as digital multi-meters, frequency synthesizers, and

oscilloscopes). Printers. Mobile phones. Televisions, radios, CD players, tape recording equipment. Hearing aids. Security alarm systems, fire alarm systems, and building services systems.

And much more! As a matter of fact, we are living in the Microcontrollers era!

.1.1 What is a Microcontroller? Basically, a microcontroller is a device, which integrates a number of the components of a icroprocessor system onto a single microchip (System On-Chip, or SoC).

So a microcontroller combines onto the same microchip:

• The CPU core

• Memory (both ROM and RAM)

• Some parallel digital I/O

Most microcontrollers will a

A timer module to al time periods.

A serial I/O port to allow data to flow between the microcontroller and other devices such as a PC or another microcontroller.

ital Converter (ADC) to allow the microcontroller to accept analog input data for processing.

evice and the different sub units integrated onto the microcontroller microchip. Where the heart of the microcontroller is the CPU core.

inmPm

… 3 m

lso combine other devices such as:

low the microcontroller to perform tasks for certain•

• An Analog to Dig

• PWM, or formally pulse width modulation, creates a square wave with duty cycle and frequency depending on user demand.

Figure 3.1 illustrates a typical microcontroller d

26

Page 28: Blindspot Collision Avoid Er

Figure 3.1: A

single chip microcontroller.

CP Core in microcontroller

microprocessor unit. For example,

s. For

microcontroller varies between different

e memory will be divided up into ROM and RAM, ith typically more ROM than RAM. Typically, the amount of ROM type memory will vary

memory can be lassified into three types:

• ROM: memory is manufactured containing program that cannot be erased or programmed so program code must be stable that’s why ROM is least expensive.

• EPROM (Erasable Programmable Read Only Memory): here we have Ceramic package has quartz window. The microcontroller can be erased using an ultraviolet eraser and reprogrammed many times typical erase times range between 5 and 30 minutes. EPROM is the most expensive version of program memory due the high cost of the windowed ceramic package.

• EEPROM (FLASH): Electrically Erasable Programmable Read Only Memory provides the ultimate flexibility because it can be electrically erased by a programmer in just a few seconds and reprogrammed. Devices such as the PIC16F77 and PIC16F877 use FLASH program memory, and are denoted with an “F” in the part number.

The amount of RAM memory is usually somewhat smaller, typically ranging between 25 bytes to 4 Kbytes. RAM is used for data storage and stack management tasks. It is also used for register stacks (as in the microchip PIC range of microcontrollers).

U

In the past this has traditionally been based on an 8-bit Motorola uses a basic 6800 microprocessor core in their 6805/6808 microcontroller devices. In recent years, microcontrollers have been developed around specifically designed CPU coreexample, the 10-Bit Microchip PIC range of microcontrollers.

Memory in a microcontroller

The amount of memory contained within a microcontrollers. Some may not even have any integrated memory. However, most modern microcontrollers will have integrated memory. Thwbetween around 512 bytes and 4096 bytes, although nowadays we can see microcontrollers with more ROM memory. ROM type memory is used to store the program code. ROMc

27

Page 29: Blindspot Collision Avoid Er

3.1.2 MicroChip PIC Microcontrollers

There is a large variety of microcontrollers on the market. Selection the most suitable microcontroller was crucial and time-consuming. The most popular manufacturers are:

1. Micochip's PIC. 2. Atmel's AVR. 3. Intel's 80xx. 4. Motorola's MCxxx. 5. Cypress PSoC.

Most of them support more than one programming language, such as Assembly Language, Pascal, C Language, and Basic Language. I went for Microchip's PIC microcontrollers.

Microchip provides solutions for the entire performance range of 8-bit and 16-bit microcontrollers, with a powerful architecture, flexible memory technologies, comprehensive easy-to-use development tools, complete technical documentation and post design-in support through a global sales and distribution ecting Microchip’s microcontroller solutions are:

duct families.

ent serving 50000+ customers.

p's PIC MCU and dsPIC families. In the early 1980s, the term PIC stood for Peripheral Interface Controller. Microchip's microcontroller solutions come in different IC

network. Benefits realized by sel

Easy migration across pro Low-risk product development and faster time to market. Lower total system cost. Excellent product support and programming services. Certified quality. Microchip is #1 in worldwide 8-bit microcontroller shipm

Figure 3.2 shows Microchi

packaging and pin numbers such as 8-, 14-, 18-, 28-, 40-, 64-, 68-, or 84-Pin IC.

Figure 3.2

Generally speaking, developing a PIC-based project takes only six easy steps: 1. Type in the program. 2. Assemble the program into a binary file.

. Switch on and test.

3. Simulate the program and debug it. 4. Load the binary program into the PIC’s memory. 5. Wire up the circuit. 6

28

Page 30: Blindspot Collision Avoid Er

3.2 The PIC16F877A Microcontroller

vice in the lab. Others factors will be revealed in the following paragraphs. 3. IC16F87XA Migration

lication note released by Microchip. This document is intended to

IC

3.2 PIC16F877A Hardware and Features The

8K Words

ily rewrite the program.

The PIC16F877A microcontroller core features are:

• High performance Reduced Instruction Simplified Computer (RISC) CPU. • Only 35 single word instructions to learn. • Operating speed: 20 MHz clock input. • Up to “8 K X 14” words of FLASH Program memory. • Up to “368 X 8” bytes of Data Memory (RAM). • Up to “256 X 8” bytes of EEPROM Data Memory. • Interrupt capability (up to 14 sources). • Eight level hardware stack. • Direct, indirect and relative addressing modes. • Power-on Reset (POR). • Power-up Timer (PWRT) and Oscillator Timer (OST).

eliable operation.

h speed CMOS FLASH/EEPROM technology. l Programming (ICSP) via two pins.

From all Microchip's PICmicro products, I decided to use PIC16F877A in my project. Many

reasons stand behind that choice, most importantly the availability of its programmer de

2.1 PIC16F87X → P

This is the title of an appdescribe the functional differences and the electrical specification differences present when migrating from one device to the next. Simply put, PIC16F877A is a newer version of PIC16F877, which is

bsolete now. PIC16F877A is designed to be pin-to-pin, and functionally compatible with the oP 16F877 product family. As a result, all information in PIC16F877 applies to PIC16F877A. Many improvements and updates were added by Microchip in the migration from PIC16F877 to PIC16F877A. To me, the most important are the new comparator and comparator voltage reference modules in PIC16F877A.

.2

hardware specification of the PIC16F877A is:

• The program memory is• RAM memory is 368 bytes. • EEPROM is 256 bytes. • Three kinds of timers. • Analog Digital converter. • Hardware PWM. • Flash memory is used for PIC16F877A. So, the PIC programmer can eas

Start-up • Watchdog Timer (WDT) with its own on-chip. • RC oscillator for r• Programmable code protection. • Power saving SLEEP mode. • Selectable oscillator options. • Low power, hig• In-Circuit Seria

29

Page 31: Blindspot Collision Avoid Er

• Single 5V In-Circuit Serial Programming capabil•

ity. In-Circuit Debugging (ICD) via two pins.

• Commercial, Industrial and Extended temperature ranges.

1- < 0.6 mA typical @ 3V, 4 MHz

• Processor read/write access to program memory. • Wide operating voltage range: 2.0V to 5.5V. • High Sink/Source Current: 25mA.

• Low-power consumption:

2- 20 μA typical @ 3V, 32 kHz 3- < 1μA typical standby current.

Figure 3.3 illustrates PIC16F877A's block diagram.

Figure 3.3: PIC16F877A block diagram.

its order on the chip, its type -Schmitt trigger, TTL, CMOS), and brief

with more than one input or output. Its state can be r related to.

3.2.3 escription PIC16F877A Pin-out D

Figure 3.4 illustrates PIC16F877A's pin configuration. While Table 3.1 shows PIC16F877A's pin-out configuration (description). every pin is based depends on: its name,(P-power, I-input, and O-output), Buffer type (STdescription. Every pin may be multiplexedcontrolled by defining the special registe

30

Page 32: Blindspot Collision Avoid Er

Figure 3.4: PIC16F877A pin configuration.

Pin Name DIP

Pin# I/O/P Type

Buffer Type

Description

OSC1/CLKIN 13 I ST/CMOS(4) Oscillator crystal input/external clock source input. OSC2/CLKOUT 14 O — Oscillator crystal output. Connects to crystal or resonator in

crystal oscillator mode. In RC mode, OSC2 pin outputs CLKOUT which has 1/4 the frequency of OSC1, and denotes the instruction

cycle rate. MCLR/VPP 1 I/P ST Master Clear (Reset) input or programming voltage input. This

pin is an active low RESET to the device. PORTA is a bi-directional I/O port.

RA0/AN0 2 I/O TTL RA0 can also be analog input0. RA1/AN1 3 I/O TTL RA1 can also be analog input1.

RA2/AN2/VREF- 4 I/O TTL RA2 can also be analog input2 or negative analog reference voltage.

RA3/AN3/VREF+ 5 I/O TTL RA3 can also be analog input3 or positive analog reference voltage.

RA4/T0CKI 6 I/O ST RA4 can also be the clock input to the Timer0 timer/counter. Output is open drain type.

RA5/SS/AN4

7

I/O

TTL

RA5 can also be analog input4 or the slave select for the synchronous serial port.

PORTB is a bi-directional I/O port. PORTB can be software programmed for internal weak pull-up on all inputs.

RB0/INT 33 I/O TTL/ST(1) RB0 can also be the external interrupt pin. RB1 34 I/O TTL RB2 35 I/O TTL

RB3/PGM 36 I/O TTL RB3 can also be the low voltage programming input. RB4 37 I/O TTL Interrupt/on/change pin. RB5 38 I/O TTL Interrupt/on/change pin.

RB6/PGC 39 I/O TTL/ST(2) Interrupt-on-change pin or In-Circuit Debugger pin. Serial ramming clock. prog

RB7/PGD 40 I/ or In-Circuit Debugger pin. Serial programming data.

O TTL/ST(2) Interrupt-on-change pin

RC0/T1OSO/T1CKI 15 I/O ST RC0 can also be the Timer1 oscillator output or a Timer1 clock input.

RC1/T1OSI/CCP2 16 I/O ST RC1 can also be the Timer1 oscillator input or Capture2 input/Compare2 output/PWM2 output.

RC2/CCP1 17 I/O ST RC2 can also be the Capture1 input/Compare1 output/PWM1 output.

RC3/SCK/SCL 18 I/O ST RC3 can also be the synchronous serial clock input/output for both SPI and I2C modes.

RC4/SDI/SDA 23 I/O ST RC4 can also be the SPI Data In (SPI mode) or data I/O (I2C mode).

RC5/SDO 24 I/O ST RC5 can also be the SPI Data Out (SPI mode).

RC6/TX/CK

25

I/O

ST

RC6 can also be the USART Asynchronous Transmit or Synchronous Clock.

RC7/RX/DT 26 I/O ST RC7 can also be the USART Asynchronous Receive or Synchronous Data.

31

Page 33: Blindspot Collision Avoid Er

Pin Name Dip Pin#

I/O/P Type

Buffer Type

Description

RD0/PSP0 19 I/O ST/TTL(3) RD1/PSP1 20 I/O ST/TTL(3) RD2/PSP2 21 I/O ST/TTL(3) RD3/PSP3 22 I/O ST/TTL(3) RD4/PSP4 27 I/O ST/TTL(3) RD5/PSP5 28 I/O ST/TTL(3) RD6/PSP6 29 I/O ST/TTL(3) RD7/PSP7 30 I/O ST/TTL(3)

PORTD is a bi-directional I/O port or parallel slave port when interfacing to a microprocessor bus.

PORTE is a bi-directional I/O port. RE0/RD/AN5 8 I/O ST/TTL(3) RE0 can also be read control for the parallel slave port, or analog

input5. RE1/WR/AN6 9 I/O ST/TTL(3) RE1 can also be write control for the parallel slave port, or analog

input6. RE2/CS/AN7 10 I/O ST/TTL(3) RE2 can also be select control for the parallel slave port, or analog

input 7.VSS 12,31 P — Ground reference for logic and I/O pins.

VDD 11,32 logic and I/O pins. P — Positive supply for NC — — These pins are not internally connected. These pins should be left

unconnected.

Ta e 3.1 7A

Legend: I = input O = output I/O = i— = N TT TTL t = Sch * Notes:

1- fer is a Schm t Trigger input whe d as an extes a Schm t Trigger input whe d in Se

3- This buffer is a Schmitt Trigger input when configured as general purpose I a TTL input when used in the e Port mode (for o

4- a Schm igger input when nfigured

3.3 P C16F877A Subsystems i Use

PIC16F877A contains several independent subsystems and modules for various applications. For this project, I only used some of these subsystems. The employed modules are described in what follows. 3.3.1 I/O Ports The digital/analog I/O ports are the means by which the PIC microcontroller interfaces to th Usua , I/O ds to b roup an be configured as either input bits or output bits by defining the special register related to the port.

The PIC16F877A microcontroller ports are:

as 6 bit ins. 2.3. Port C: has 8 bits/pins. 4. has 8 bit ins. 5 as 3 bit ins.

bl : PIC16F87 Pin

nput/output P = power

out Configuration.

ot used L = inpu ST mitt Trigger input

This buf it n configure rnal interrupt. 2- This buffer i it n use rial Programming mode.

/O andParallel Slav interfacing to a micropr cessor bus).

de and a This buffer is itt Tr co in RC oscillator mo CMOS input otherwise.

I n

e environment. lly ten e g ed into byte wide ports (8 digital bits) that c

1. Port A: h s/p Port B: has 8 bits/pins.

Port D: s/p. Port E: h s/p

32

Page 34: Blindspot Collision Avoid Er

3.3.2 Timer1

PIC16F877A has three timers Timer0, Timer1 and Timer2. Each one of these timers has its own properties and specificat ns. All hree tim s can be used in the same time in one application or any one can be used depending on the application requirement. After a thorough study of each timer, I decided to use Time1 in my design.

The T odule is a -bit t r/counter having the following features: • it registe TMR and ). • Readable and writable are pro amma pres • Internal or external clock select on over w from FFF • Edge select for external clock • (TMR1H: TMR1L) increments from 000h to FFFF

Timer1 can operate in one of two modes: as a timer, or as a counter. The operating mode is

etermined by the clock select bit, TMR1CS (T1CON<1>). In Timer mode, Timer1 increments every instruction cycle. In Counter mode, it increments on every rising edge of the external clock input. Timer1 can be enable it TMR1ON (T1CON<0>).

3.1 shows the Timer1 control register.

reaches a count of 65535 (216–1). prescaler ratios can also be attached to Timer1 allowing it to increment on every 1, 2, 4, or

This means that each count of Timer1 using 1:1 prescalar ratio and 20 MHz clock equals to 200 × 65535) 13.107 ms. Table 3.2 includes Timer1

aximum timing and the equivalent measured distance for each prescalar ratio (using 20 MHz clo

Timer1

io t er

imer1 m 16 ime Two 8-b rs ( 1H TMR1L

• 8-bit softw gr ble caler

• Interrupt flo F h to 0000h

0 h and rolls over to 0000h

d

d/disabled by setting/clearing control bRegister

Since Timer1 is a 16-bit timer, when the timer overflows, it

Different 8 inst uctir on cycles. If 1:1 prescaler was assigned to it, this means that the Timer1 will increment on every instruction cycle (FOSC/4). If 20 MHz crystal was used as clock: FOSC

ncrement = (5 MHz)-1 = 200 ns /4 = 5 MHz

I

ns. In other words, Timer1 can count up to (200 ns m

ck). Thus, 1:1 prescalar ratio is suitable to my design.

r Ratio Maximum Timing (ms) Equivalent Distance (m) Prescale1:1 13.107 4.5088 1:2 26.214 9.0176 1:4 52.428 18.035 1:8 104.85 36.070

uivalent distance for different prescaler ratios. Table 3.2: Timer1 full time and eq

33

Page 35: Blindspot Collision Avoid Er

Register 3.1: Timer1 control register.

3

.3.3 Comparator Module

The com contains . Th rs are multiplexed ins RA0 outp s RA3 and RA4. The on-chip Voltage Reference (described in the next section) can also be an input to the comparators. The CON register (Regist controls the compar ut and output multiplexors. A blo iagram of the various co r configurations is sho ppendix C.

A single comparator is shown in Figure 3.5, al the analog input levels and the digital output. When the analog input at IN+ VIN-, the

utput f the comparator is a digital low level. When the analog input at VIN+ is greater than the nalog input VIN-, the output of the comparator is a digital high level. The shaded areas of the output f the comparator in Figure 3.5 represent the uncertainty due to input offsets and response time.

parator module with I/O port p

two analog comparatorsthrough RA3, while the

e inputs to the comparatouts are multiplexed to pin

CM er 3.2) ator inpck d mparato wn in A

ong with the relationship between V is less than the analog input

o oao

34

Page 36: Blindspot Collision Avoid Er

Register 3.2: Comparator control register.

Figure 3.5: Comparator Operation.

35

Page 37: Blindspot Collision Avoid Er

3.3.4 Comparator's Voltage Reference Module

The comparator voltage reference generator is a 16-tap resistor ladder network that provides a fixed voltage reference when the comparators are in mode ‘010’. A programmable register controls the function of the reference generator. Register 3.3 lists the bit functions of the CVRCON register.

The comparator reference supply voltage (also referred to as CVRSRC) comes directly from VDD. It should be noted, however, that the voltage at the top of the ladder is (CVRSRC – VSAT) where VSAT is the saturation switch transistor. The output of the reference connected to the RA2/AN2/CVREF/VREF- pin. This can be used as a simple D/A function by high impedance load is used. The primary function is to provide a test reference generator function.

Register 3.3: Voltage reference control register. For example, using the high range of the D/A, i.e.: CVREF = (¼ × CVRSRC) + (VR3:VR0/32 × CVRSRC) And assuming CVRSRC = 4.8 V (this means that VSAT = 0.2 V) gives: For VR3:VR0 = 0110 → CVREF = 2.10 V For VR3:VR0 = 0111 → CVREF = 2.25 V For VR3:VR0 = 1000 → CVREF = 2.40 V

36

Page 38: Blindspot Collision Avoid Er

Chapter 4: Ultrasonic Ranging Systems

The amplitude of the reflected wave is directly

proportional to how much surface is available on the object for coherent reflection. Surface size, shape and orientation (normal or oblique incidence), are major factors contributing to the strength of the reflected signal. Material composition of the object is a decisive factor too. A part of the wave landing on the surface of the material is reflected, while a part of the wave penetrates the material and is eventually reflected of any surface boundaries encountered while traveling within the material (delayed reflection).

Figure 4.1: Reflection of ultrasonic waves is used in distance measurements systems.

Any ranging system should contain a timer to estimate the Time-of-Flight (TOF), that is, the time

required for the ultrasonic wave to hit the target/object, reflect, and reach the receiver back. TOF is equivalent to double the distance between the distance sensor and the target. This should be taken into consideration.

The past few years witnessed an increased use of ultrasonic sensors in ranging and distance measurement applications. This popularity made the manufacturers to extend their products to include a complete ultrasonic system consisting of transmitter, receiver, and sensor. These ranging modules became widely used by designers, since they save the efforts to design the transmitter and receiver electronic circuits, and interface it to the sensor. The whole system is integrated into one board using PCB technology. All what the user have to do is to connect the ranging module to MCU (Microprocessor Control Unit) such as a microcontroller. The user's focus is more concentrated on

e programming of the microcontroller (task becomes more software oriented).

c RangeFinder (SRF04, SRF08, and SRF10), ro-Wave Sonar Ranging Module (SRM400) are

ila ar s Sas a turning point in the progress of my project,

to d

4.1 Overview of Echo Ranging

Ultrasonic ranging systems are used to determine the distance to an object by measuring the time required for an ultrasonic wave to travel to the object and return to the source. This technique is frequently referred to as “echo ranging”. Figure 4.1 illustrates the reflection principle. The transmitter is designed to have low impedance at the resonant frequency to obtain high mechanical efficiency.

e receiver is constructed to maximize the impedance at the specified anti-resonant frequency to Thprovide high electrical efficiency.

th

Commercial modules such as Devantech SoniSensComp 6500 Ranging Module (Polaroid), and Pava ble in the m ket. I chose Pro-Wave' onar Ranging Modules (SRM400) for my project. Unfortunately, they have not arrived yet! This wsince I was forced esign my own transmitter and receiver sensor-compatible circuits.

37

Page 39: Blindspot Collision Avoid Er

4.2 Pro-Wa Pro-Wave's Sonar Ranging Module (SRM400) in Figure 4.2 is being discussed in what follows:

tilizing

h

of

Figure 4.2: Pro-Waves' Sonar Ranging Module.

tran ith d es High Gain Amplifier: varies with time over

32 steps I

tting a pulse and ceiving an echo

A

ve Sonar Ranging Module

The SRM400 is a sonar ranging module uur new developed Sonar Ranging IC, PW-0268, o

w ich can work with all our PT or EP type transducers. SRM400 provides as a shortcut to develop car reversing systems or some other distance measurement systems for design engineers who are not very familiar with analog circuit and/or the operation of ultrasonic transducers. By using this module engineers can focus firstly on the other fields

digital circuit and software designs as well as some other mechanical issues. After first stage then you can either design your own analog circuit based on the module construction or consult with

factory for making your own module for your special needs. Features: Operating Voltage: 6 – 10Vdc single source Operating Frequency: broadband output ranging up to 250KHz Built-in variable RC oscillator matching

sducers w ifferent frequenci

ntegrated Band Pass Filter: reduces external component count, Bi-direction I/O Pin: simplifies the control function for transmire

n adjustable System Clock: enables the control of, the number of pulses transmitted, the slope of the variable gain amplifier, and the pulse repetition rate Board size: 27.9 * 18 mm (L*W)

Table 4.1: SMR400 Specifications. SRM400 includes: 1. Module board 2. 400EP14D enclosed type transducer of asymmetrical beam patterns. 3. Detail electrical schematic

38

Page 40: Blindspot Collision Avoid Er

Figure 4.3: Electronic Circuit Diagram.

Figure 4.4: Waveforms and Operations of SRM400

.

Waveforms at different test points: Figure 3.7 (above) shows how the module works with transducer model 400EP14D against a

hard target of size of 20cmL×20cmW×1cmT at distance of 50cm.

39

Page 41: Blindspot Collision Avoid Er

4.3 Distance Calculation using the Microcontroller

The electrical parameter in this system is time and is proportional to the distance separating the object from the source (car in my case). It is straightforward to trigger a timer (stopwatch) when the ultrasonic burst is transmitted and stop the timer when the transmitted burst is received. The distance traveled is related to time-of-flight and speed by the well-known relation:

Distance = (Time-of-Flight / 2) × Speed Or using mathematical notation:

D = 0.5 × C × (T1 - T0) Where: D = Distance to Object C = Speed of Sound in transmission medium T0 = Time at which ultrasoT1 = Time at which ultrasonic wave is received

PIC16F877A's Timer1 is used as a stopwatch. It was shown in Section 3.3.2 that Timer1 can be

incremented once every 200 nanoseconds. In Section 2.1.2.3, the speed of sound waves in dry air in rooms temperature was found to be 344.31 meters per second. The value stored in the two 8-bit registers of Timer1 represents the time-of-flight. Thus:

D(in mm) = ½ × Timer1 register value × 200 (ns) × 344310 (mm/s)

With some mathematical manipulations, the formula becomes:

D(in mm) = Timer1 register value ÷ 29.04 (mm-1) ≈

nic wave is transmitted

29TimerValue

This is the formula used in PIC16F877A to calculate distance in millimeters.

Instrument's Resolution is the smallest change in the measured value to which the instrument will respond. Using the last formula to evaluate the distance produces a resolution of one millimeter for the designed ranging system.

40

Page 42: Blindspot Collision Avoid Er

Chapter 5: Design Details and Circuit Explanation

The car's blind-spot collision avoidance system was described in Section 1.2 in terms of design equire l overview. This chapter deals with design details

are implementation of the system. The most important advantage e evident. That is, their ease of interface to electronic circuitry

(digital and analog). 5.1.1

Unlike the simplified, functional block diagram of the blind-spot collision avoidance system present s detailed gives a closer look to the system details. ller is the brain of the system that controls and o controlled by the driver's turning signal when he

5.1 The Overall System

ra

ments, technical specifications, and generand circuit schematic, and hardw

of ultrasonic sensors will becom

System Block Diagram

ed in Figure 1.7, the block diagram in Figure 5.1 i As shown in the block diagram, the microcontroordinates between the other parts. The switch is c

decides to change lane. The appropriate sensor is selected (left or right) and connected to the transmitter and receiver. The state of the switch is known to the microcontroller so the correct sensor side is displayed on the LCD.

Figure 5.1: System's Block Diagram.

Throughout my design, I adapted a modular approach towards the development and building of e system. After testing and verifying the operation of each module (subsystem) alone, all modules

re connected and interfaced together to give the complete system.

tha

41

Page 43: Blindspot Collision Avoid Er

5.1.2 S

igure 5.2 shows the complete system schematic drawn using PREOTEUS ISIS Professional, version 6.9 SP3. Figure 5.3 shows a photo of the system realized on solderless breadboard.

ystem Circuit Schematic

F

Figure 5.2: Complete System Schematic.

From Figure 5.2, one can notice that the implemented system consists mainly from these components:

1. Transmitter (has red wires). 2. Receiver (has blue wires).

3. Microcontroller (the largest block). 4. Switches (have green wires).

5. LCD (has purple wires).

Each of these components will be explained in detail in the following sections.

42

Page 44: Blindspot Collision Avoid Er

Figure 5.3: System Implementation on Test Board.

5.1.3 Transmitter-Receiver Separation

The use of a single transceiver sensor instead of using a dedicated transmitter and receiver sensors means that the sensor will be connected directly to the both the transmitter and receiver circuits. Some sort of physical separation between these two circuits is required. This was done by use of diodes (1N4148 small-signal diode). Figure 5.4 illustrates the separating action of the two groups pf parallel-opposite diodes.

On the receiver side: These diodes just limit (clip) any transmitted signal to prevent receiver circuit damage. Any input signal to the receiver's circuit is limited to ± 0.6 V (the threshold "ON" voltage of the diode).

On the transmitter side: Since the received

signal voltage is very small, (aVolts) the diodes' dynamic impedance is very high and they separate

Figure 5.4: Diodes configuration to separate the receiver from the transmitter.

.2 The Transmitter

signal is done by the PIC. An output pin goes high and low continuously. The output pulses have 5V amplitude. We need to transmit as large a signal as possible

back to the receiver.

e supply voltage instead of the 5V.

bout few milli-

the transmitter circuit from the receiver.

5 5.2.1 Design Explanation

The generation of 40 kHz

in order to carry enough energy (large S.P.L.) to have a portion of it reflectedThis can be achieved via a transistor, which switches a larger power supply, jacking up the voltage to th

43

Page 45: Blindspot Collision Avoid Er

The transmitter circuit design shown in Figure 5.2 (with red connections) or in Figure 5.3 was inspired from the well-known TTL to CMOS interface circuit which converts the voltage levels (0-5) to (0-10). The transmitter circuit operation explanation follows:

transistor Q2 is OFF too (EB2 is also reverse biased VEB < VEB ON) and is taken out of the circuit. This means that VC2 is zero.

h (5V): IB1 > IB1(EOS).

s SAT (this results in VC1= VCE1 SAT =0.3 V)

Figure 5.5: Ultrasonic transmitter schematic.

1. When RB2 (or F.G. output) is at logic low (0V): The NPN transistor Q1 is OFF (BE1 junction is reverse biased VBE < VBE ON) and is taken out of the circuit. The PNP

2. When RB2 (or F.G. output) is at logic higThe NPN transistor Q1 will be in SAT mode if Assuming that Q1 i

IC2 SAT = 2

1

C

C

VR

= 2

1

SATCC EC

C

V VR−

= 12 0.3

2.7k−

= 4.3 mA

IB2(EOS) =

2SATCIβ

= 4.3

80m

= 53.75 μA

IB2 = 2 1B CV V− 2 1ACTCC EB ON CV V V

12 0.6 0.3− − = −

= 2.7k1BR 1BR

− = 4.1 mA

Since 2 is SAT.

IB2 > IB2(EOS) → Q

IC1 SAT = 1

1CR+ IB2 =

SATCC CEV V− 12 0.32.7k−

+ 4.1 m = 8.4 mA

= 1SATCI 8.4

IB1(EOS)β

= 75

m= 112.6 μA

IB1 = 15

2.7k –

ACTBE ONV− 1

2.7k =

ACTBE ONV 5 0.6 0.62.7k

– −

2.7k = 2 mA

Since IB1 > IB1(EOS) → Q1 is SAT. My assumption is verified correct! So, VC2 equals 11.7 V

The analysis above has shown that 5V pulses entering the circuit becomes approximately 12V pulses. Transistors data was taken from their data sheets (refer to Appendix: C for more data).

44

Page 46: Blindspot Collision Avoid Er

5.2

nics Workbench MultiSim version 9 Power-Pro. The Agilent function generator simulates the pulses produced by the PIC pin RB2 in Figure 5.2. Agilent two-channel oscilloscope displays the input and the output of the transmitter circuit. These waveforms are shown in Figure 5.6. The waveform in purple color is input signal generated by PIC while the waveform in red color shows the output, which is the input to the transmitting ultrasonic sensor.

.2 Simulation Results

The simulation circuit of Figure 5.5 was drawn using Electro

Figure 5.6: Transmitter operation simulation using EWB MultiSim.

5.3 The Receiver 5.3. ation

The signal picked up from the ultrasonic transducer is extremely small and has a large fluctuation depending on the size, angle, surface shape, moving s ce of the reflector body for the receiv needs quite a significant amount of amplification. In fact, cation gives increment to the detection range (distance) and more sensitivity to smaller bodies.

Unlike other receivers, a typical ultrasonic receiver does not require filtering before the

amp ge, b ause nit is a resonator itself. As a result, it oscillates only at a certain frequency (40 kHz), and it filters out other frequencies. In other words, the receiver sensor is naturally sensitive to signals around 40 kHz only.

U l Any amp ated filte

1 Design Explan

peed, distaner. Therefore, in order to be of any use it

every enhancement in the amplifi

lification sta ec the receiver u

sing a sing e operational amplifier with large voltage gain will be very problematic. fication of more that 50 V/V may introduce noise to the 40 kHz signal, and sophisticli

ring is required. I had to split amplification into two cascaded stages. The overall gain is the

45

Page 47: Blindspot Collision Avoid Er

product of each individual gainn e t

s. The gain value usually depends on the sensor type and detection g hat a designer needs for his application.

ra

Figure 5.7 below shows the ultrasonic receiver schematic. It is very simple, consisting of two main components; amplifier and comparator. The receiver sensor is loaded with a 100kΩ resistor to provide a direct signal path to ground and to increase (improve) the receiver's sensitivity as the curve in Figure 2.9 in Section 2.4 indicates.

Figure 5.7: Ultrasonic receiver schematic.

R2, R3 and R7 10kΩ potentiometer form a voltage divider that supplies the op-amps with about

alf the 5V-regulated s true AC, and the perational amplifier has a single positive power supply (5V-regulated). This commonly named loating ground" eliminates the need for a negative supply by lifting the input signal up. C1 is used

Each of the operational amplifiers along with its negative input terminal series capacitor and r is essentially a "high-pass" filter. The first active high-pass filter has

ut-off frequency (2πR C )-1 Hz and high-frequency gain (R / R ) V/V. The same analogy applies to the

n amplified AC signal with a midpoint DC voltage in the range 1.67V to 3.33 V depending on the potentiometer position. This is were the use of some sort of wave sha

ustrated by Figure 3.5 in Section 3.3.3. Without ny input signal to the two-stage amplifier, the output of U1B will be a steady DC voltage. This is fed

dire

h voltage. The reason for this is that the input signal io"ffor ripple suppression.

resistor, and the feedback resistoc 1 2 6 1

second Op-Amp. The output of U1B is now sufficiently large enough to be useful, but is not suitable for interfacing

directly to the PICmicro microcontroller. The PICmicro expects a clean high or low on its IO pin, but the output of the Op-Amp is a

ping comes in. In order to convert the AC signal into discernable highs and lows, I use PIC16F877A built-in comparator (which is simulated by the LM393 comparator IC in Figure 5.7).

PIC16F877A comparator's operation was illa

ctly to the negative input of the PIC16F877A comparator. The positive input of the comparator is connected to the PIC16F877A voltage reference module (which is simulated by the 2.2V voltage source Figure 5.7).

46

Page 48: Blindspot Collision Avoid Er

Initially, the potentiometer's position will be set to produce about 2.5V DC level "floating ground" to the amplified AC signal. Therefore, when there is no reflected wave (no obstacle/object

ate) the voltage on the negative input is slightly higher than the positive input, and the output of the com

ator, which now goes both higher and lower than before as the C signal is super-imposed on the original 2.5 DC voltage. So, if the received signal on the negative

input should go lower than the voltage on the positive input, the comparator output will go high, and hence, the output from the comparator will be a series of positive going pulses that can be recognized by the PICmicro processor.

By adjusting 10kΩ potentiometer, the voltage difference varies between the positive and negative inputs of the comparator and makes it more or less sensitive. Higher DC voltages set by the potentiometer makes the receiver less sensitive. 5.3.2 Simulation Results

The LM358 IC is a low noise high gain dual operational amplifier that needs a single positive supply to work. Referring to the data sheet, I found its gain bandwidth product (also known as "unity gain") equals to 1 MHz. This means that for 40 kHz signal input, the maximum attainable gain from the amplifier is:

GainMax = (Unity Gain)/(signal frequency) = 1M/40K

= 25 V/V (27.96 dB) In other words, if the ratio of the feedback resi

6

s performed in Section 2.4 where the minimum det

Detection is confirmed by the PIC when the comparator's output becomes high. Being high for about 12.

stparator is low.

When an echo is received, an amplified version of the signal appears on the output of U1B and is

fed to the negative input of the comparA

stor to the negative input terminal resistor, i.e., (R / R1) or (R10/ R4) is more than 25, the actual voltage gain is reduced to 25.

Once again, simulation was done using Electronics Workbench MultiSim version 9 Power-Pro. In the first case shown by Figure 5.7, the SPDT switch is closed enabling a 40 kHz signal from the function generator to enter the circuit (The receiving sensor is modeled by an AC voltage source represented by the F.G.). Worst-case analysis wa

ectable signal has 8 mVp-p amplitude. This signal is generated by the F.G. in Figure 5.7. Tektronix four-channel oscilloscope displays the input AC signal, the output of first amplifier, the output of second amplifier, and the output of comparator as in Figure 5.8. The results were as expected theoretically, the gain of the first stage is 25V/V, while the second stage gives gain of 10V/V.

5 μs is enough to be recognized by the PIC. Notice the 4.7k pull-up resistor at the output of LM393 in Figure 5.7. This is because its output is open collector requiring a pull-up resistor.

The second case when there's no received signal is shown in Figure 5.9. The simulation results for

the four channels are displayed simultaneously on the scope screen in Figure 5.10 and they are expected.

47

Page 49: Blindspot Collision Avoid Er

(a) (b)

(c) (d)

Figure 5.8: Receiver operation simulation using EWB MultiSim (Switch is closed): (a) Input signal (b) Output of first amplifier (c) Output of second amplifier (d) Output of comparator

Receiver's practical experimentation and measurements in the lab gave the following results: G1

/VIN2 = 2.935/370m = 7.93 V/V (17.98 dB)

Gtot = G1×G2 = 18.73 × 7.93 = 148.53 V/V (43.44 dB)

The actual results are close to the computer simulation results.

= VO1/VIN1 = 370m/19.75m = 18.73 V/V (25.45 dB) G2 = VO2

48

Page 50: Blindspot Collision Avoid Er

Figure 5.9: Ultrasonic receiver schematic.

Figure 5.10: Receiver operation simulation using EWB MultiSim (Switch is open).

ing voltage range: 2.0V to 5.5V. However, the available voltage is 12 V from car's battery. Voltage level step-down is performed by the voltage regulator IC LM7805

to 5V output suitable for PIC. These five volts are fed to one of PIC's VDD pins (11 or 32). They are internally connected. Ground (0V) connection is required to any of PIC's VSS pins (12 or 31). The Two capacitors, C4 and C5, suppress high- and low-frequency noise on the 5-V supply line, respectively.

5.4 The Microcontroller 5.4.1 Biasing the PIC

PIC16F877A has wide operat

(U3 in Figure 5.2). The 7805 takes a 12V input and convert it

49

Page 51: Blindspot Collision Avoid Er

5.4.2 Resetting the PIC

PIC16F877A reset can be achieved via its MCLR pin (Master CLear Reset) numbered one. Being active low dictates the use of a 4.7 kΩ pull-up (current-limiting) resistor. Pressing the push-button makes the input "low" and resets the PIC. 5.4.3 PIC Clock Frequency

For maximum processing speed, I used a 20 MHz crystal as a clock by connecting it across pins 13 and 14. This results in 200 ns instruction cycle. 5.4.4 PIC Ports and Pins

PIC16F877A connection in Figure 5.2 uses 9 pins of the 33 available Ports pins. These are:

RA1: Second amplifier output. RA4: Switch state. RB2: Transmitter drive. RD2: LCD Register Selec RD3: LCD Enable line. RD4-RD7: LCD Data lines.

5.5 The Switches 5.5.1 The Manual SPDT Switch

The left and right sensors are selected and switch using a Single-pole Double-through switch (SPDT). For car's application, this switch is controlled by the turning signal. Before changing lane, the driver should give a pre-turn signal, similar to the manual switching action. In Figure 5.2, the collector C3 is connected to the control input of the IC switch connected to the left sensor. While the Base B3 is connected to the control input of the IC switch connected to the right sensor. Thus, the electronic switch cannot be in the same state. One of them is ON (closed), while the other if OFF (open).

When the SPDT SW is in the upper position, Q3 (inverter configuration) is in saturation mode.

The signal fed into pin 13 of the 4066 IC switch is low and Switch A is closed. Switch B, on the other hand, is open and the left sensor is selected (connected to the transmitter-receiver side).

When the SPDT SW is in the lower position, Q3 is off. The signal fed into pin 12 of the 4066 IC

itch is low and Switch B is closed. Switch A, on the other hand, is open and the right sensor is -receiver side).

itch

t line.

swselected (connected to the transmitter 5.5.2 IC Electronic Sw

The CD4066 IC is a quad bilateral switch intended for the transmission or multiplexing of analog or digital signals. Each switch has three pins, input "X", output "Y", control "C". When the control signal is low, the switch is closed, otherwise it's open. This switch has many attractive features that made me consider it in my design. It has wide supply voltage range, extremely low "ON" resistance, high noise immunity, low crosstalk, and high degree linearity

50

Page 52: Blindspot Collision Avoid Er

5.6 The Alphanumeric LCD Module

erial and parallel LCDs. The serial LCD requires uses one erial" line for data transmission. However, it works on voltages of -10V and +10V but the output

erial output port is the standard digital voltages of 0V and +5V. oltage level conversion to standard TTL is required. This can be done by use of MAX232 chip. On

thet they do not need voltage level

onversion made me decide on them. Figure 5.11 Shows the available LCDs. Its connection to e 5.2.

One of the best solutions for devices that require visualizing the data is the Alphanumeric Dot-Matrix Liquid Crystal Display (LCD). I used the 16×2 LCD to display the distance to the driver. There are two main types of these LCDs, s"scoming out of the PIC16F877A sV

other hand, parallel LCD requires 4 to 8 "parallel" data pins to be connected to the PIC. The availability of parallel LCD modules in the lab and the fact thacPIC16F877A is shown in Figur

5.11: Available LCD Modules. Figure

The pin-out for standard parallel LCD is shown in table. Description of each pin's function is presented below.

Pin No. Name Function 1 Vss Ground 2 Vdd Positive Supply 3 V Contrast ee

4 RS Register Select 5 R/W Read/Write 6 E Enable 7 Data bit 0 D0 8 D1 Data bit 1 9 D2 Data bit 2

10 D3 Data bit 3 11 D4 Data bit 4 12 D5 Data bit 5 13 D6 Data bit 6 14 D7 Data bit 7

Table 5.1: Pin-out designation for most standard LCDs.

Pins 1 and 2 are power supply lines, Vss and Vdd. The Vdd pin should be connected to the positive supply, and Vss to the 0V supply or ground.

51

Page 53: Blindspot Collision Avoid Er

Pin 3 is a control pin, Vee, which is used to alter the coconnected to a variable voltage supply. For simplicity, I connected

ntrast of the display. ideally, this pin should be it to the ground for maximum

con

ed to initiate the actual transfer of commands or character data between the module and the data lines. When writing to the display data is transfer only on the high to low transition of this signal.

Pins 7 to 14 are the eight data bus lines (D0–D7).data can be transferred to and from the display, either as single 8-bit or as 4-bit. I decided to use 4-bit mode to save engaged pins in the PIC.

trast.

Pin 4 is the Register Select (RS) line, the first of the three-command control input. When this line is low, data bytes transferred to the display are treated as commands. By setting the RS line high, character data can be transferred to and from the module.

Pin 5 is the Read/Write line. This line is pulled low in order to write commands or character data to the module because communication is one-way (toward LCD).

Pin 6 is the Enable line this input is us

52

Page 54: Blindspot Collision Avoid Er

Chapter 6: PIC Programming and Interfacing

m code explanation.

iting code and accessing the different aspects of

The high-level language I used is a derivative of the BASIC language. It is called PicBasic. (The icBasic and PicBasic Pro compilers used to write PicBasic programs are products and trademarks of icroEngineering Labs, Inc.) PicBasic is similar to the PBasic language used in programming the asic Stamp series. Programming microcontrollers directly using the PicBasic (or PicBasic Pro) ompiler offer two major advantages over the Basic Stamp series of microcontrollers which use xternal serial EEPROM for memory storage, faster program execution speed, and reduced cost.

hen compared to other high-level languages, BASIC is still considered by many PC users to be the asiest programming language to use. It allows faster and much easier development of applications r PIC. I had to learn about 30 different instructions to write my program code.

The compiler I used is "MicroCode Studio", which compiles PicBasicPro (PBP) programming nguage. The program code is written and edited in MicroCode Studio window. Then it saves the ork as PBP file (program.pbp). When compiled, the program.pbp file is converted to Assembly nguage code file (program.asm) and HEX file (program.hex). This file is the one that should be aded to the PIC using its programmer. To accomplish this, an application called "IC-Prog" has to

e used to interface the programmer to MS-Windows. It loads the hexadecimal file to the PIC's emory.

.2 PIC Programmer

Microcontroller Programmer is a circuit (hardware) by which HEX files (program code) are ansferred (loaded) from a computer to the microcontroller's memory. The used programmer was lready available in the lab. Its circuit is very simple and can be homemade (there are lot of ready-to-se programmer schematics on he Internet). Figure 6.1 shows the circuit schematic for the rogrammer. Its photo is shown in Figure 6.2.

Programming PIC microcontrollers is a simple three-step process: Write the code, compile the code, and upload the code into a microcontroller. Following is discussion about the used programming language, compiler, programmer, and progra

6.1 Programming Language

There are a number of compilers on the market that allow users to write programs (codes) in different high-level languages. High-level language frees the programmer from wrestling with and controlling the microcontroller’s registers when wrthe microcontroller’s features and memory. There are various programming languages such as Assembly, BASIC, C, Pascal, …etc.

PmBceWefo

lawlalobm

6

traup

53

Page 55: Blindspot Collision Avoid Er

Figure 6.1: Programmer computer interface diagram and circuit.

Figure 6.2: PIC Programmer.

The PicBasic program code shows the "big picture" of the whole system. The code flow diagram in Figure 6.3 tells the whole story of how distance is measured.

The program starts by introducing the surrounding environment to the PIC microcontroller. The

clock oscillator and the LCD are defined, along with the variables intended to be used later (so their memory locations are stored). Initial settings are set by storing correct values in the controlling registers of Ports A and B (determine input and output pins), comparator module, and voltage

6.3 PIC Program Code 6.3.1 Code Flow

54

Page 56: Blindspot Collision Avoid Er

reference module (D/A). A delay of half second allows the PIC to stabilize its clock and registers. Then, the selected sensor is recognized by the PIC by checking the logic state of Port A's pin 4 (RA4).

Figure 6.3: Cod low Diagram.

outine "Send40k" which transmits ten cycles of 40 kHz ultrasonic ulses. This is immediately followed by resetting and restating Timer1 which works as a stopwatch.

ation) of 1.2 ms is required before staring the detection of any reflected waves ma e sure that Ringing (residual vibrations) is over to avoid false detection. Before starting the

detetection process, otherwise the new

state is saved and the program returns to the transmitting phase. The detection loop aims to check the

e F

The program then calls the subrpAnother delay (No oper

ktoection loop, a check on the selected sensor state is made. If the selected sensor hasn't changed

since its recognition at the beginning, the program starts the d

internal comparator's output repeatedly. When it goes high, detection of reflected wave is confirmed and Timer1 is stopped. The value in Timer1 registers (low and high) is then divided by 29 to evaluate the distance in millimeters. The calculated value is then displayed on the LCD.

55

Page 57: Blindspot Collision Avoid Er

If Timer1 overflows without any detection, an "out of range" message is displayed on the LCD. After displaying either the distance measured by the selected sensor or out of range messages on the LCD, the program returns to the beginning to send another cycles of ultrasonic waves. And so on.

6.3.2 Code Analysis

Now comes the actual PicBasic code. The comments (in blue) clarify each line of the code in detail. I wrote a self-explanatory code so there is no need to say more!

'**************************************************************** '* Name : Documentation.BAS * '* Author : Rami M. Zaghal * '* Notice : Copyright (c) 2006 J.U.S.T. * '* : All Rights Reserved * '* Date : 09-Dec-06 * '* Version : 1.5 * '* Notes : * '* : * '**************************************************************** '' ------------ [ Includes / Defines ] ----------------------- '' define osc 20 'Inform PBP compiler that 20MHz is used as clock DEFINE LCD_DREG PORTD 'Define PIC port used for LCD Data lines DEFINE LCD_DBIT 4 'Define first pin of PORTD connected to LCD DB4 DEFINE LCD_RSREG PORTD 'Define PIC port used for RS line of LCD DEFINE LCD_RSBIT 2 'Define PORTD pin used for RS connection DEFINE LCD_EREG PORTD 'Define PIC port used for E line of LCD DEFINE LCD_EBIT 3 'Define PORTD pin used for E connection DEFINE LCD_BITS 4 'Define the 4 bit communication mode to LCD DEFINE LCD_LINES 2 'Define using a 2 line LCD DEFINE LCD_COMMANDUS 2000 'Define delay between sending LCD commands DEFINE LCD_DATAUS 50 'Define delay time between data sent '' ------------ [ Variables, Aliases and Constants ] --------- '' T1_LowerByte var word 'Variable used to store lower byte value of TIMER1 T1_UpperByte var word 'Variable used to store upper byte value of TIMER1 TOF var word 'Variable used to store the whole word value of TIMER1 Distance var word 'Variable used to store current measured Distance value Sensor_old var byte 'Variable used to store initial value of PORTA4 (Sensor select) Sensor_new var byte 'Variable used to store new value of PORTA4 (Sensor select) oop_cnt var byte 'Variable used to determine the number of 40k ultrasonic cycles

'to be sent

''

pause 500 'Wait for PICmicro to stabilize

L

------------ [ Initialization ] --------------------------- '' TRISA = %11111011 'Set PORTA to all input except RA2 TRISB = %00000000 'Set PORTB to all output CMCON = %00000101 'Set Comparator Module to one independent comparator mode 'with its output not inverted CVRCON = %11000110 'Set Comparator Voltage Reference Module to generate about '2.15V at PORTA.2 (Comparator's positive terminal) '' ------------ [ Main Code ] -------------------------------- '' INTCON = 0 'Make sure that all interrupts are OFF LCDOUT $FE, 1 'Clear display screen

56

Page 58: Blindspot Collision Avoid Er

Mai

arator's positive terminal voltage is less than the negative terminal (NO )

f CMCON.7 = 1 then the Comparator's positive terminal voltage is greater than the negative terminal (De

ow"

PORTA.4 (Initially caler 1:1 0kHz ultrasonic waves ER1 and start TIMER1 ER1 shes

PORTA.4 (Currently

r has changed and return

IMER1

LCDOUT $FE, 1, "Object is out of range from LEFT SENSOR!" 'Clear display screen

'show "out of range"

ble

T1_U ) 'Calculate total time of flight Distance = TOF/29 'Calculate distance in millimeters

'Display decimal value 'of distance in 'millimeters on the 'screen

elay"

n: 'Main program's loop T1CON = %00000000 'Stop TIMER1 PIR1.0 = 0 'Make sure that TIMER1 overflow flag is clear 'If CMCON.7 = 0 then the Comp'detection occurred! No echo!'I' tection occurred! Echo Received!) if CMCON.7 = 1 then PORTA.1 = 1 'Make sure that Echo pin is initially high '"Comp. out is l

'If PORTA.4 = 0 then the Right sensor is activated/chosen 'If PORTA.4 = 1 then the Left sensor is activated/chosen Sensor_old = PORTA.4 'Store initial value of 'selected sensor) T1CON = %00000001 'Enable TIMER1 with PresGosub Send40k 'Start transmission of 4TMR1L = 0 'Clear lower byte of TIMTMR1H = 0 'Clear upper byte of TIMpauseus 1200 'Wait until Ringing fini Sensor_new = PORTA.4 'Store current value of 'selected sensor)

if Sensor_new != Sensor_old then Main 'Check if selected senso 'to "Main" if it has

peat 'Loop until TIMER1 overflows re

if CMCON.7 = 1 then 'If detection occurred: T1CON = %00000000 'Stop TIMER1 goto Calculate_Dist 'Then start distance calculation process endif

"Tuntil PIR1.0 = 1 'Timeout if TIMER1 overflow flag is set 'overflowed" if PORTA.4 = 0 then 'Check which sensor is currently selected LCDOUT $FE, 1, "Object is out of range from RIGHT sensor!" 'Clear display screenand 'show "out of range" 'message se el

and

'message endif pause 1000 'Wait 1 second "LCD Delay" Goto Main 'Start a new program cycle Calculate_Dist: 'Distance calculation process T1_LowerByte = TMR1L 'Store lower byte value of TIMER1 in varia T1_UpperByte = TMR1H 'Store upper byte value of TIMER1 in variable TO = T1 ower te + F _L By ( pperByte * 256

if PORTA.4 = 0 then 'Check which sensor is currently selected LCDout "DISTANCE from RIGHT sensor (in mm) = ", dec Distance

else

'Display decimal value LCDout "DISTANCE from LEFT sensor (in mm) = ", dec Distance 'of distance in

n the 'millimeters o 'screen

endif use 1000 'Wait 1 second "LCD Dpa

Goto Main 'Start a new program cycle

57

Page 59: Blindspot Collision Avoid Er

'' ------------ [ Subroutines ] ------------------------------ ''

that generates 10 cycles of 40kHz

it's 2 n z

S command used lay of 2 μs should be taken into

ack

s

Send40k: 'Function 'ultrasonic pulses at PORTB.2 or Loop_cnt = 10 to 0 step -1 f 'Count from 10 to 0 by 1 PORTB=%00000100 'First half of the cycle pauseus 11 'Create delay of 11 us (ON Time) PORTB=%00000000 'Second half of the cycle pauseus 10 'Create delay of 10 us (OFF Time)

next count next Loop_cnt 'Go back to and doreturn

atOne last point worth mentioning here regards the subroutine "Send40k", you can notice th

simply a loop that is repeated 10 times. The aim of each cycle in "Send40k" is to make PortB's pin. Duty cycle of 50% is very difficult to obtaihigh for the first half cycle, and low for the second half

. That's a 40 kHusing this technique. Instead, PortB.2 can be "high" for 12 μs, and "low" for 13 μswaveform of 48% duty cycle. From my experimentation, I found that the PAUSEU

the “MicroCode Studio” compiler takes 1μs to be executed. This deinaccount. Extra delay is caused by the looping action, i.e., decrementing the loop counter, going bto the start, and checking that it did not reach zero value. This is approximately 2 μs delay. So, for

d 10 μs for the ON and the period to be 25 μs (40 kHz), The no-operation delay should be 11 μs anOFF times, respectively. That is:

s + 11μs + 1μs 1μ + 10μs + 2μs = 25μ

58

Page 60: Blindspot Collision Avoid Er

Chapter 7: Conclusions

7.1 Challenges

During my work on the project, I faced the following challenges:

1. Studying various microcontrollers to choose the most suitable one with no previous background.

point for several other projects in distance measurement using ultrasonic sensors and microco d improvements are suggested

low:

1. The measurement process is based on a typical air temperature of 22°C. This can be limiting when the specific application involves a wide operating temperature range. It would be an improvement to implement an external integrated temperature sensor to measure the air temperature.

2. Serial LCD can be used instead of the parallel one with only one data input to the PIC.

3. LEDs with three or four levels or colors can be used to alert the driver. The LEDs flashes depending on the distance between the car and the obstacle/object in a pre-determined color convention.

4. With slight modifications, the system can be converted into a reverse parking assistant.

5. With slight modifications, the system can be converted into ultrasonic radar by simply mounting the sensor on a stepper motor that rotates to scan the required areas.

6. Improvement the PIC code could be achieved by implementing ISR (Interrupt Service Routine) using the interrupt-on-change-pin supported by PIC to switch (select) sensors.

7. The system can have the ability to increase the volume of the audible warning sound as the object distance decreases when turn signal is activated with the extra option to switch off the sound warning by the user. Moreover, the distance range for sounding the audio warning may be changed or controlled by the user.

8. The system can have the ability to change units of distance being displayed on LCD.

2. Learning PIC programming from scratch. 3. Delay in arrival of ranging modules (SRM400) changed the course of the project significantly.

I didn't see that coming!

7.2 Future Work

This project can be a startingntrollers area. Some modifications an

be

59

Page 61: Blindspot Collision Avoid Er

7.3 Recommendatio

fter completing the project, I realized that the following improvements could be made by the department of Electrical Engineering any future projects including microcontrollers:

ts and boards for students working on uilt-in LCD, ICD (In-Circuit

nts. More

Simulators and IDE (Integrated Development d fully functional versions of the well known

3. Add an introductory course on microcontrollers in new plan for Electrical Engineering

entertaining. It involved precise selection of

ms &

experience is the power of question, or let us nown

ns

A

1. Providing PIC Programmer and development Ki

projects involving PIC microcontrollers. Such kits have bDebugging) feature and much more. The programmer can program PIC chips with different pin numbers, which enhance the experimentation with PIC experience for the studeinformation is available on MicroChip's and mikroelektronika websites.

2. Getting a licensed version of PICmicro

Environment) tools such as PROTEUS. LicenseC and BASIC programming languages compilers, such as mikroBasic, PICBASIC Pro, PICC, CCS PCWH, …etc.

students.

7.4 Final Comments

The work on this project was very challenging and sensors and microcontroller, programming the microcontroller, designing ultrasonic transmitter and receiver circuits, simulating the designed circuits and written code, and finally, implementing the whole system and testing it. To sum up, my project involved all what it takes for a real electronics engineer or designer to build a reliable practical system.

My Internet research skills have improved remarkably. I joined many internet foruommunities related to CAD simulation and microcontrollers. My reading speed even increased! c

Another advantage worth mentioning is the interaction with Dr. Bassam El-Asir (Project supervisor). It was my pleasure to work with him. This was the richest experience I had in my academic life.

One of the most important lessons I learnt from this call it "the power of courtesy". You must ask properly, precisely and in good timing about unk

r unclear things in order to get fulfilling useful answers. As they say, ask gently and you will be ogiven. All in all, I was 95% satisfied with my graduation project.

60

Page 62: Blindspot Collision Avoid Er

References and Readings

. David N. Cheeke, "Fundamentals and Applications of Ultrasonic Waves", CRC Press, 2002.

J. B obile Robot

En cience, University of California, Berkeley, 1993.

ler - Student Guide v2.2 ", Parallax Inc., 2004.

, McGraw-Hill, 2001.

ohn Iovine, "PIC Robotics - A Beginner’s Guide to Robotics Projects Using the PICmicro", McGraw-Hill, 200

Pic

del Sedra and Kenneth Smith, "Microelectronic Circuits", Fifth Edition, Oxford University Press,

illiam Hayt, Jack Kemmerly and Steven Durbin, "Engineering Circuit Analysis", Sixth Edition, cGraw-Hill, 2002.

"Top 10 Tech Cars", IEEE Spectrum Magazine, April 2006, pp.24-33.

J

F. Alton Everest, "The Master Handbook of Acoustics", Fourth Edition, McGraw-Hill, 2001.

R. A. Serway and R. J. Beichner, "Physics for Scientists and Engineers, with Modern Physics", Fifth Edition, Saunders College Publishing, 2000.

renstein, H.R. Everett and L. Feng, "Where Am I?, Sensors And Methods For MoPositioning", The University of Michigan, April 1996.

Donald Massa, "Part 2: Optimizing Sensor Selection", Sensors Magazine, March 1999.

Ming C. Lin, "Efficient Collision Detection for Animation and Robotics", Department of Electrical g neering and Computer Si

"PICmicro Mid-Range MCU Family Reference Manual", Microchip Technology Inc., 1997.

"What’s A Microcontrol

Myke Predko, "PICmicro Microcontroller Pocket Reference"

J4.

John Iovine, "PIC Microcontroller Project Book", McGraw-Hill, 2000.

Fred Stevens, "Getting Started With PIC Microcontrollers", 1997.

" Basic Pro Compiler", microEngineering Labs, Inc., 2004.

Chuck Hellebuyck, "Programming PIC Microcontrollers with PicBasic", Newnes, Elsevier Science, 2003.

Les Johnson, "Experimenting with the PICBasic Pro Compiler", CROWNHILL Associates Ltd, 2000.

A2004.

K. "Gopal" Gopalan, "Introduction to Digital Microelectronic Circuits", Prentice-Hall.

WM

61

Page 63: Blindspot Collision Avoid Er

Web Resources

Pro-Wave Electronics Corp. application notes:

http://www.prowave.com

MuRata Corp. application notes:

http://www.murata.com

MicroChip Technology Inc. application notes:

http://www.microchip.com

MicroChip Forum:

http://forum.microchip.com/

MELabs PICBASIC Forums:

http://www.picbasic.co.uk/forum/

Basic Micro Forums:

http://forums.basicmicro.net/Default.aspx

Proton PICBASIC Development Forums:

http://www.picbasic.org/forum/

mikroElektronika Forum:

http://www.mikroe.com/forum/search.php?mode=results

EDABoard:

http://www.edaboard.com

Farnell Distributor:

http://www.farnell.com

62

Page 64: Blindspot Collision Avoid Er

Appendix A

♦ Resistors:

2. 2.7 kΩ (× 5).

.

2. 1 μ F radial electrolytic (× 1) trolytic (× 1)

1. Manual SPDT-SW (× 1). l switch (× 1).

nductor Components: 1. 1N4148 small-signal diode (× 4).

r transistor (× 1). 3. 2N2907 PNP bipolar transistor (× 1). 4. 2N3904 NPN bipolar transistor (× 1).

Integrated Circuits: 1. PIC16F877A Microcontroller (× 1). 2. LM358N dual operational amplifier (× 1). 3. LM7805 voltage regulator (× 1). Miscellaneous: 1. 20 MHz crystal (× 1). 2. 16×2 standard parallel alphanumeric LCD (× 1). 3. NEWSTAR voltage adapter [12V voltage source] (× 1). 4. Solderless breadboard (× 3). 5. Connection cords.

List of Components Used in the Project

1. 100 Ω (× 1).

3. 4.7 kΩ (× 3). 4. 10 kΩ (× 4). 5. 100 kΩ (× 2). 6. 1 MΩ (× 1). 7. 10 kΩ potentiometer (× 1)

♦ Capacitors:

1. 0.1 μ F radial electrolytic (× 1).

3. 100 μ F radial elec4. 10 nF ceramic disc (× 2). 5. 10 pF ceramic disc (× 2).

♦ Switches:

2. CD4066 quad bilatera3. Mini push-button (× 1).

♦ Sensors: 1. 400PT160 open-type transceiver ultrasonic sensor (× 2).

♦ Discrete Semico

2. 2N2222 NPN bipola

63

Page 65: Blindspot Collision Avoid Er

Appendix B

Sensors and Modules Purchase Order

rer and Supplier Info:

Electronics Corp. http://www.prowave.com

Manufactu Manufacturer: Pro-Wave

r: Farnell. http://www.farnell.comDistributo ler): Madhoun Electronics and Trade.

Agent (Dea

Order Details:

Part Part Order Unit Qty Total Status

Number Description Code Price Cost

(JD) (JD) SRM400

PROWAVESonar Modu

Ranging le (Includes

One 400EP14D)

1007370 39.76 4 159.04

Has not arrived yet!

PW0268

Sonar Ranging 1007371 5.70 2 11.40 Arrived PROWAVE SMT IC 400EP18A

Ultrasonic Txr, 1007355 11.4 3 34.20 Arrived PROWAVE Enc, 40kHz 400PT160

PROWAVE Ultrasonic Txr, Open, 40kHz

7.15 3 21.45 Arrived 1007353

400PT120 Ultrasonic Txr, 100PROWAVE Open, 40kHz

7354 7.40 3 22.20 Has not arrived yet!

400ST120 Ultrasonic Tx, 100PROWAVE Open, 40kHz

7339 6.90 4 27.60 Arrived

400SR120 UltPROWAVE Open, 40kHz

rasonic Rx, 1007340 6.90 4 27.60 Arrived

303.49 Sub Total

48.56 16% Sales Tax

352.05 Total

64

Page 66: Blindspot Collision Avoid Er

Appendix C

Selected Data Sheets

eets for the following components:

ic Sensor or

4. 400EP14D Ultrasonic Sensor 5. PIC16F877A Comparator Configuration 6. LM358N Dual Operational Amplifier 7. CD4066 Quad Bilateral Switch

8. 2N2222 NPN Bipolar Transistor 907 P lar ist

8 gn e

This appendix contains data sh

1. 400PT160 Ultrasonic Sensor 2. 400ST/R120 Ultrason3. 400EP18A Ultrasonic Sens

9. 2N210. 1N

NP BipoSmall-Si

Transal Diod

or 414

65