Está en la página 1de 75

Ultrasonic Range Meter

Senior Project Submitted to the Department of Computer and Communication Engineering American University College of Science and Technology

In Partial Fulfillment of the Requirements for the Degree of Bachelor of Science In Computer and Communication Engineering

Maroun Daher Rami Freih Gaby Al Jawabira

August 2006

Abstract
The Ultrasonic Range Meter is an efficient way to measure the distance of unreachable obstacles. It is based on sending sound waves through a specific medium and observing the returning echoes to measure the distance from the device to the obstacle. The device is divided into three parts, transmitter, receiver and the microcontroller. The transmitter consists of an electronics circuitry which generates electrical signal .In addition, an electromechanical transducer to convert electrical signal to physical form to drive through the medium, which is air. The receiver also consists of an electronics circuitry which detects the echoes bounced back from the obstacles. The microcontroller is programmed for selectivity sequence and to calculate the time of flight of the signal to find the distance and display it. The system architecture of the Ultrasonic Range Meter was built to be cheaper, requires less power and delivers better performance. It can be reconfigured to adapt to a variety of pulsed Ultrasonic systems.

ii

Table of Contents
Chapter 1 Introduction 1 1.1 History of ultrasonic waves....................................................1 1.2 History of ultrasonic applications...........................................3 1.3 Future development of this technology...................................6 Chapter 2 Problem statement 7

2.1 Introduction.............................................................................7 2.2 Motivation...............................................................................7 2.3 Characteristics.........................................................................7 2.4 Conclusion..............................................................................8 Chapter 3 Constraints 9

3.1 Introduction.............................................................................9 3.2 Minimum target size and ultrasonic medium..........................9 3.3 Target range............................................................................9 3.4 Range measurement accuracy.................................................9 3.5 The battery............................................................................10 3.6 Weight and size.....................................................................10 3.7 Budget...................................................................................10 3.8 Time......................................................................................10 3.9 Number of engineers.............................................................10 3.10 Conclusion..........................................................................10 Chapter 4 Solutions 11

4.1 Introduction...........................................................................11 4.2 Hand-held laser range meter device......................................11 3

4.2.1 Description.........................................................................11 4.2.1.1 Time of flight measurement............11 4.2.1.2 Triangulation...12 4.2.2 The advantages...13 4.2.3 The disadvantages .13 4.3 Hand-held ultrasonic range meter device.............................13 4.3.1 Description.13 4.3.2 The advantages...14 4.3.3 The disadvantages..14 4.4 Comparison...........................................................................14 4.5 Conclusion............................................................................15 Chapter 5 16 System Design 5.1 Introduction...........................................................................16 5.2 The overall system16 5.2.1 Calculation of the distance to an object.................17 5.3 Ultrasonic system..................................................................18 5.3.1 Ultrasonic transmitter.19 5.3.1.1 The 555 timer datasheet..20 5.3.2 Ultrasonic receiver.21 5.3.2.1 Basis of the operational amplifier. .21 5.3.2.2 The difference gain amplification...22 5.3.2.3 Signal amplification circuit.23 5.3.2.4 Datasheet of the TL082 operational amplifier24 5.3.3 Detection circuit.26 5.3.4 The microcontroller...........................................................27 5.3.4.1 The CCP capture mode..................................................28 4

5.4 The program.29 5.4.1The flowchart......................................................................29 5.4.2 Include file bit.h.............................................................30 5.4.3 The main program..............................................................31 5.5 Power supply and battery..38 5.6 Ultrasonic sensors.................................................................38 5.6.1 Electrostatic ultrasonic sensors..40 5.6.2 Piezoelectric ultrasonic sensors.40 5.7 The schematic of the ultrasonic range meter design.42

Chapter 6

System Implementation

46

6.1 Factors affecting the performance of ultrasonic sensors.......46 6.1.1Radiation pattern.46 6.1.2 Frequency, wavelength and attenuation.48 6.2 Environmental factors.. 48 6.2.1Temperature.. .49 6.2.2 Pressure and humidity50 6.2.3 Medium..50 6.2.4 Acoustic interference.51 6.2.5 Radio frequency interference.52 6.3 Target consideration..52 6.3.1 Composition. .52 6.3.2 Size and shape....................52 6.3.3 Position and orientation.53 6.4 Power of the detected signal.................................................55 6.5 Noise.....................................................................................55

6.6 Errors.....................................................................................5 5 6.6.1 Truncation errors56 6.6.2 Cosine error........................57 6.6.3 Reflection error..57 Chapter 7 System Testing 58

7.1 System Testing......................................................................58 7.2 Testing the Transmitter.59 7.3 Testing the Receiver.60 7.4 Testing the Detection Circuit61 7.5 Conclusion61 Chapter 8 Time line, Cost and conclusion 62

8.1 Time line..............................................................................62 8.2 Cost of the ultrasonic range meter design63 8.3 Conclusion...64

List of Figures
Figure 2.1: The hand-held ultrasonic range meter device....7 Figure 2.2: Description of each part of the device...8 Figure 4.1: Hand-held laser range meter device.12 Figure 4.2: Hand-held ultrasonic range meter device.13 Figure 4.3: Beam width comparison of ultrasonic waves and laser beams....15 Figure 5.1: General block diagram.17 Figure 5.2: Theoretical graph of the pulses and its echo-reflection pulse..18 Figure 5.3: The overall design of the ultrasonic system.18 Figure 5.4: The transmitter circuit design...19 Figure 5.5: The 555 block diagram.20 Figure 5.6: The receiver circuit design..21 Figure 5.7: The difference gain amplification22 Figure 5.8: The circuit of the signal amplification.23 Figure 5.9: Pin connections top view of the TL082 operational amplifier24 Figure 5.10: The detection circuit...26 Figure 5.11: The microcontroller top view.27 Figure 5.12: The flowchart of the program.30 Figure 5.13: The power supply circuit38 Figure 5.14: The SQ-40T/R ultrasonic transducer..41 Figure 5.15: The sensitivity of the SQ-40T/R with respect to the frequency.41 Figure 5.16: The overall schematic of the Ultrasonic range meter.43 Figure 5.17: The printed circuit board diagram of the microcontroller..44 Figure 5.18: The printed circuit board of the transmitter and receiver...44 Figure 5.19: The packaging of the device...45 Figure 6.1: Geometric approximation of the ultrasonic beam width..47 Figure 6.2: Beam pattern with respect to amplitude...48 Figure 6.3: Graph of speed with respect to temperature.50 Figure 6.4: Undetected large object due to reflection.53 7

Figure 6.5: Object offset due to ultrasonic beam width..54

Figure 6.6: Range error due to angle between object and sonar.54 Figure 6.7: Error (increasing accuracy VS increasing precision)...56 Figure 7.1: Graph of error with respect to the measured distance..59 Figure 7.2: The transmitter oscilloscope graph...59 Figure 7.3: The receiver oscilloscope graph...60 Figure 7.4: The transmitter and the receiver oscilloscope graph60 Figure 7.5: The detection oscilloscope graph.61 Figure 8.1: Timeline graph.62

List of Tables
Table 4.1: Solutions comparison with respect to its accuracy and precision.15 Table 5.1: The delay times of boundary range...16 Table 5.2: The datasheet of the 555 timer...20 Table 5.3: The datasheet of the TL082 operational amplifier25 Table 5.4: The microcontroller specifications....28 Table 5.5: The Ultrasonic sensor specifications.38 Table 6.1: The speed of sound at each temperature49 Table 6.2: The ultrasonic wave speed through different mediums.51 Table 7.1: Distance measurement with its error.58 Table 8.1: Distribution of work..62 Table 8.2(a, b): Components and prices.63

List of Terms, Symbols and Abbreviations


A CCD cm cMUTs D KHz MHz MUT NDT POD PSD PZT QNDT Rx S SNR T t Tx UT Vi Vo s Average Error Charge Couple Device centi-meter Capacitive micro-machined Ultrasonic Transducer Spot Diameter Kilo-Hertz Mega-Hertz micro-machined Ultrasonic Transducer Non Destructive Testing Probability of detection Position Sensitive Detector Lead-Zirconate Titanate Quantitative Non Destructive Testing Receiver Distance Signal to Noise Ratio Truncation Error time of flight Transmitter Ultrasonic Testing input Voltage output Voltage Wavelength of sound micro second The target response to the ultrasonic wave

10

CHAPTER 1 Introduction

1.1 History of ultrasonic waves


Prior to World War II, sonar, the technique of sending sound waves through water and observing the returning echoes to characterize submerged objects, inspired early ultrasound investigators to explore ways to apply the concept to medical diagnosis. In 1929 and 1935, Sokolov studied the use of ultrasonic waves in detecting metal objects. Mulhauser, in 1931, obtained a patent for using ultrasonic waves, using two transducers to detect flaws in solids. Firestone (1940) and Simons (1945) developed pulsed ultrasonic testing using a pulse-echo technique. Shortly after the close of World War II, researchers in Japan began to explore the medical diagnostic capabilities of ultrasound. The first ultrasonic instruments used an A-mode presentation with blips on an oscilloscope screen. That was followed by a B-mode presentation with a two dimensional, gray scale image. Japan's work in ultrasound was relatively unknown in the United States and Europe until the 1950s. Researchers then presented their findings on the use of ultrasound to detect gallstones, breast masses, and tumors to the international medical community. Japan was also the first country to apply Doppler ultrasound, an application of ultrasound that detects internal moving objects such as blood coursing through the heart for cardiovascular investigation. Ultrasound pioneers working in the United States contributed many innovations and important discoveries to the field during the following decades. Researchers learned to use ultrasound to detect potential cancer and to visualize tumors in living subjects and in excised tissue. Real-time 11

imaging, another significant diagnostic tool for physicians, presented ultrasound images directly on the system's CRT screen at the time of scanning. The introduction of spectral Doppler and later color Doppler depicted blood flow in various colors to indicate the speed and direction of the flow. The United States also produced the earliest hand held "contact" scanner for clinical use, the second generation of B-mode equipment, and the prototype for the first articulated-arm hand held scanner, with 2-D images. The NonDestructive Testing NDT has been practiced for many decades, with initial rapid developments in instrumentation spurred by the technological advances that occurred during World War II and the subsequent defense effort. During the earlier days, the primary purpose was the detection of defects. As a part of "safe life" design, it was intended that a structure should not develop macroscopic defects during its life, with the detection of such defects being a cause for removal of the component from service. In response to this need, increasingly sophisticated techniques using ultrasonic, eddy currents, x-rays, dye penetrants, magnetic particles, and other forms of interrogating energy emerged. In the early 1970's, two events occurred which caused a major change in the NDT field. First, improvements in the technology led to the ability to detect small flaws, which caused more parts to be rejected even though the probability of component failure had not changed. However, the discipline of fracture mechanics emerged, which enabled one to predict whether a crack of a given size will fail under a particular load when a material's fracture toughness properties are known. Other laws were developed to predict the growth rate of cracks under cyclic loading (fatigue). With the advent of these tools, it became possible to accept structures containing defects if the sizes of those defects were known. This formed the basis for the new philosophy of damage tolerant design. Components having known defects could continue in service as long as it could be established that those defects would not grow to a critical, failure producing size. A new challenge was thus presented to the nondestructive testing community. Detection was not enough. One needed to also obtain quantitative information about flaw size to serve as an input to fracture mechanics based predictions of remaining life. The need for quantitative information was particularly strongly in the defense and nuclear power industries and led to the emergence of quantitative nondestructive evaluation (QNDE) as

12

a new engineering/research discipline. A number of research programs around the world were started, such as the Center for Nondestructive Evaluation at Iowa State University (growing out of a major research effort at the Rockwell International Science Center); the Electric Power Research Institute in Charlotte, North Carolina; the Fraunhofer Institute for Nondestructive Testing in Saarbrucken, Germany; and the Nondestructive Testing Centre in Harwell, England.[2]

1.2 History of ultrasonic applications


Ultrasonic sensing techniques have earned a pre-eminent position in a variety of fields including medicine, nondestructive testing and process monitoring, geophysics, and sonar surveillance. Ultrasonic flow sensors have been employed for a number of years for performing intraoperative or extracorporeal blood flow measurements. Intraoperative flow measurements are typically conducted to monitor blood flow in various vessels during vascular, cardiac, transplant, plastic and reconstructive surgery. Transit-time ultrasonic flow sensors detect the acoustic propagation time difference between the upstream and downstream ultrasonic transmissions in a moving fluid and process this information to derive a fluid flow rate. Ultrasonic array transducers rely on wave interference for their beam forming effects, and typically include a plurality of individual transducer elements organized as either a one-dimensional (linear) array or a twodimensional array. Ultrasound is used as a non-invasive technique for obtaining image information about the structure of an object which is hidden from view, and is widely known as a medical diagnostic tool as well as a tool for non-destructive testing and analysis in the technical arts. Ultrasound diagnostic imaging systems are in widespread use for performing ultrasonic imaging and measurements. Ultrasonic imaging sensors act as both transmitters and receivers of ultrasonic energy. The sensor first acts as a transmitter; emitting ultrasonic energy in a train of high frequency pulses, typically in the range of 2 to 10 Mhz. Then the transmitter is turned off and the sensor acts as a receiver, which listens for returned echoes at the transmitted frequency. Ultrasonic sensors are used to make remote distance measurements. One particular use of ultrasonic sensors is within a vehicle occupant protection system within a vehicle. Ultrasonic range finders typically use ultrasonic frequencies which are inaudible to the human ear. These high 13

frequencies have inherently shorter wavelengths, which lead to greater positional accuracy than audible frequencies. Parking aid systems of today usually consist of an electronic control unit and several ultrasonic sensors. Each ultrasonic sensor possesses a separate data line, since, in order to improve evaluation, echo information from several ultrasonic sensors is required at a certain instant. Thus, the evaluation of several ULS on the basis of one transmitted sound wave permits more precise conclusions to be made about the position of and the range of the obstacle. Ultrasonic sensors are equipped in robots and used for detecting objects positioned along a robot travel path. Such ultrasonic sensors are adapted to convert a pulse signal into an ultrasonic wave energy which is, in turn, radiated at a search area. Ultrasonic testing UT has been practiced for many decades. Initial rapid developments in instrumentation spurred by the technological advances from the 1950's continue today. Through the 1980's and continuing through the present, computers have provided technicians with smaller and more rugged instruments with greater capabilities. Thickness gauging is an example application where instruments have been refined make data collection easier and better. Built-in data logging capabilities allow thousands of measurements to be recorded and eliminate the need for a "scribe." Some instruments have the capability to capture waveforms as well as thickness readings. The waveform option allows an operator to view or review the A-scan signal of thickness measurement long after the completion of an inspection. Also, some instruments are capable of modifying the measurement based on the surface conditions of the material. For example, the signal from a pitted or eroded inner surface of a pipe would be treated differently than a smooth surface. This has led to more accurate and repeatable field measurements. Many ultrasonic flaw detectors have a trigonometric function that allows for fast and accurate location determination of flaws when performing shear wave inspections. Cathode ray tubes, for the most part, have been replaced with LED or LCD screens. These screens, in most cases, are extremely easy to view in a wide range of ambient lighting. Bright or low light working conditions encountered by technicians have little

14

effect on the technician's ability to view the screen. Screens can be adjusted for brightness, contrast, and on some instruments even the color of the screen and signal can be selected. Transducers can be programmed with predetermined instrument settings. The operator only has to connect the transducer and the instrument will set variables such as frequency and probe drive. Along with computers, motion control and robotics have contributed to the advancement of ultrasonic inspections. Early on, the advantage of a stationary platform was recognized and used in industry. Computers can be programmed to inspect large, complex shaped components, with one or multiple transducers collecting information. Automated systems typically consisted of an immersion tank, scanning system, and recording system for a printout of the scan. The immersion tank can be replaced with squirter systems, which allows the sound to be transmitted through a water column. The resultant C-scan provides a plan or top view of the component. Scanning of components is considerably faster than contact hand scanning; the coupling is much more consistent. The scan information is collected by a computer for evaluation, transmission to a customer, and archiving. Today, quantitative theories have been developed to describe the interaction of the interrogating fields with flaws. Models incorporating the results have been integrated with solid model descriptions of real-part geometries to simulate practical inspections. Related tools allow the Nondestructive Evaluation NDE to be considered during the design process on an equal footing with other failure-related engineering disciplines. Quantitative descriptions of NDE performance, such as the probability of detection (POD), have become an integral part of statistical risk assessment. Measurement procedures initially developed for metals have been extended to engineered materials such as composites, where anisotropy and inhomogeneity have become important issues. The rapid advances in digitization and computing capabilities have totally changed the faces of many instruments and the type of algorithms that are used in processing the resulting data. High-resolution imaging systems and multiple measurement modalities for characterizing a flaw have emerged. Interest is increasing not only in detecting, characterizing, and sizing defects, but also in characterizing the materials. Goals range from the determination of fundamental microstructural characteristics such as grain size,

15

porosity, and texture (preferred grain orientation), to material properties related to such failure mechanisms as fatigue, creep, and fracture toughness. As technology continues to advance, applications of ultrasound also advance. The high-resolution imaging systems in the laboratory today will be tools of the technician tomorrow.

1.3 Future development of this technology


Looking to the future, those in the field of NDE see an exciting new set of opportunities. The defense and nuclear power industries have played a major role in the emergence of NDE. Increasing global competition has led to dramatic changes in product development and business cycles. At the same time, aging infrastructure, from roads to buildings and aircraft, present a new set of measurement and monitoring challenges for engineers as well as technicians. Among the new applications of NDE spawned by these changes is the increased emphasis on the use of NDE to improve the productivity of manufacturing processes. Quantitative nondestructive evaluation (QNDE) both increases the amount of information about failure modes and the speed with which information can be obtained and facilitates the development of in-line measurements for process control. The phrase, "you cannot inspect in quality, you must build it in," exemplifies the industry's focus on avoiding the formation of flaws. Nevertheless, manufacturing flaws will never be completely eliminated and material damage will continue to occurring in-service so continual development of flaw detection and characterization techniques are necessary. Advanced simulation tools that are designed for inspectability and their integration into quantitative strategies for life management will contribute to increase the number and types of engineering applications of NDE. With growth in engineering applications for NDE, there will be a need to expand the knowledge base of technicians performing the evaluations. Advanced simulation tools used in the design for inspectability may be used to provide technical students with a greater understanding of sound behavior in materials. As globalization continues, companies will seek to develop, with ever increasing frequency, uniform international practices. In the area of NDE, this trend will drive the emphasis on standards, enhanced educational offerings, and simulations that can be

16

communicated electronically. The coming years will be exciting as NDE will continue to emerge as a full-fledged engineering discipline.

CHAPTER 2 Problem statement


2.1 Introduction
The main purpose of this project is to measure the distance to unreachable objects, obstacles or places using a portable device.

Figure 2.1: The hand-held ultrasonic range meter device.

2.2 Motivation
The motivation of using this device is when construction engineers at any sites need to measure distances to unreachable places in a quick and easy way using this device with high efficiency and accuracy.

17

2.3 Characteristics
This device detects the distance to an object and shows the result in centimeters. This device is activated by a trigger mechanism, pressing the trigger for one time will give us the distance to an object if there was no error like poor aiming. The distance to an object is displayed using a digital display with a high intensity in order to be seen in any lighting conditions. It is a simple and portable device similar to a gun as shown in Figure 2.2 that uses a laser pointer to aim at a specific area to get the reflection at the receiver side.

Figure 2.2: Description of each part of the device.

2.4 Conclusion
In order to design and build a portable device, the weight of the device is a primary problem. The technology of using ultrasonic to measure distances is in continuous progress, features have been added to this technology to make it easy to use and more accurate by assigning more challenging constraints. The constraints of our device are discussed in the next chapter.

18

CHAPTER 3 Constraints

3.1 Introduction
Defining the constraints of our device will help to design and then build the hand-held ultrasonic range meter device. By defining these constraints, the problems will be clearer, the suitable solutions will become easier to find and those constraints will help to get the design needed from the engineer.

3.2 Minimum target size and ultrasonic medium


The minimum target size is 40cm*40cm in order to get detection at the receiver side. The ultrasonic medium is air.

3.3 Target range


The target range is the distance range between the person who is using the hand-held ultrasonic range meter device and the targeted object. The target range consists of two boundaries, one is the minimum distance limit and the other is the maximum distance limit. If the operator of the hand-held ultrasonic range meter device exceeds these two boundaries, the hand-held ultrasonic range meter device may not detect the distance or may display a false detection. The target range is between 10 centimeters and 300 centimeters.

3.4 Range measurement accuracy


Each specific distance has an error percentage; the more samples sent the less the error is.

19

The range measurement accuracy is the accuracy of the distances measured between the operator of the hand-held ultrasonic range meter device and the targeted object; it allows knowing how much each distance is close to the real value of the distance. The range measurement accuracy is +/- 3 cm. The less this value is, the more accurate distances would be calculated by the hand-held ultrasonic range meter device.

3.5 The battery


A 9 V battery could be used to activate this device.

3.6 Weight and size


Our device would not exceed the weight 0.5 kilogram. This weight is acceptable for the operator to carry the hand-held ultrasonic range meter device and to fix his arm while aiming at the targeted object. The area of the cover is 15cm x 7 cm, and the height is 8 cm.

3.7 Budget
This hand-held ultrasonic range meter device is between 50 U.S dollars and 75 U.S dollars.

3.8 Time
The time estimated to accomplish the hand-held ultrasonic range meter device is one month due to the changes in the constraints.

3.9 Number of engineers


The number of engineers working on the hand-held ultrasonic range meter device is three engineers.

3.10 Conclusion
After discussing and choosing the constraints, the solutions for these sets of challenging problems are to be discussed and solved physically and mathematically in the next chapter.

20

CHAPTER 4 Solutions

4.1 Introduction
To solve the problem of detecting the distance to an object, many solutions are presented. In this chapter the solutions are discussed, all the advantages and disadvantages are shown. The comparison between these solutions will help to determine which solution has more advantages and satisfies the constraints at the same time.

4.2 Hand-held laser range meter device


4.2.1 Description This device is characterized by its accuracy and portability; it uses a laser beam. The two techniques might be used to measure the distance. There are two techniques that have been used in order to measure distances, the time of flight technique and the triangulation technique. 4.2.1.1 Time of flight measurement Even the fastest photon requires a certain period of time to cover the distance from the sensor to the target and back. This time is directly proportional to the distance traveled, taking into account the velocity of light in the medium involved, which may be easily derived from the velocity of light in a vacuum. The cost and complexity of this method depends upon the precision and resolution required. Data acquisition and analysis electronics must cope with ns and sub-ns time scales: decimeter ranges may be easily resolved by nanosecond pulses but precision in the 21

millimeter and sub-millimeter range requires pulse lengths of a few tens of picoseconds and the associated electronics. Clearly, a poorly resolved pulse will lead to uncertainty in the accuracy of the measurement; the standard deviation in measured distance is proportional to the optical pulse rise time and is inversely proportional to the signal-tonoise ratio. At ranges of a few kilometers and above, a different problem arises; at such distances the amount of reflected photons which reach the detector is very small. Signal intensity can be improved by optimum beam focusing at the source, or by the use of a retro reflector mounted in the target. 4.2.1.2 Triangulation Triangulation is the most commonly used method for distances of 10 meters or less. A laser or LED is used to produce a collimated beam which then impinges on the surface of the target. The target reflects light in many directions, some of the reflected light reaching the detector. The position of the reflected light focused onto the detector depends on the distance between the sensor and target. Detectors such as position sensitive detectors (PSD), diode arrays or CCD arrays enable the reflected light to be detected with high spatial resolution and at high sampling frequencies. The sensor-object distance is calculated trigonometrically and accuracies of better than 0.5% are the norm. Measurement times of less than 10 ms are common, allowing real-time study of moving or vibrating objects. The light source should be compact and should produce an intense, small spot of light with minimal divergence. Amplitude modulation is used in order to eliminate the effects of stray (background) light.

22

Figure 4.1: Hand-held laser range meter device. 4.2.2 The advantages As shown in Figure 4.1, the hand-held laser range meter device is a portable device. It is characterized with its high accuracy and high precision. The laser beam consists of a small beam width which reaches a long target range. 4.2.3 The disadvantages The poor aiming on the targeted object causes a bad reflection of the laser and that would display a false detection of the objects distance that has been targeted. The atmospheric conditions may affect the ranging capabilities of the hand-held laser range meter device. The rain and snow reflect the laser beam and that may display a false detection of the objects distance.

4.3 Hand-held ultrasonic range meter device


4.3.1 Description: This device works on the same concept of the laser gun device but the difference is that it uses a large beam width of ultrasonic waves as shown in Figure 4.2. The time of flight and triangulation techniques might be used to measure the distance using ultrasonic waves.

Figure 4.2: Hand-held ultrasonic range meter device.

23

4.3.2 The advantages The hand-held ultrasonic range meter device is a portable device as shown in Figure 4.2. The hand-held ultrasonic range meter device is characterized with its precision and high accuracy. Atmospheric conditions will not affect the capabilities of the device. 4.3.3 The disadvantages The beam of the hand-held ultrasonic range meter device consists of a large beam width as shown in Figure 4.2 and that may cause a false detection of the objects distance at the receiver side because the beam may hit a group of objects placed near each others and the reflection of the ultrasonic wave is caused by several objects. The object must be flat and not an absorber and it should be normal to the direction of the ultrasonic wave. This device could be jammed and is affected by interference.

4.4 Comparison
After looking at the advantages and the disadvantages, the best solution is to use the gun device using laser beams. The beam width of the hand-held laser range meter device is smaller than the beam width of the hand-held ultrasonic range meter device as shown in Figure 4.5; this enables the operator of the hand-held laser range meter device to hit a specific object and get less reading errors unlike other devices. The comparison has shown that the hand-held ultrasonic range meter devices could be better in some cases because it will not be affected by the atmospheric conditions. As shown in Table 4.1, using a descending order from the best accuracy and precision of the devices to the worst, the most accurate and precise is the hand-held laser range meter device. The second is the hand-held ultrasonic range meter device. Depending on our constraints, our choice was to design an ultrasonic range meter because of the budget and availability of the components.

24

Table 4.1: Solutions comparison with respect to its accuracy and precision. Devices Hand-held laser range meter Accuracy Precision High accuracy High precision Hand-held ultrasonic range meter High accuracy Precise

Figure 4.3: Beam width comparison of ultrasonic waves and laser beams.

4.5 Conclusion
Each solution has its advantages and disadvantages depending on the situation where the device is used; the hand-held laser range meter device is a fast growing technology because of its efficiency and its accuracy as well as the hand-held ultrasonic range meter device as shown in Table 4.1. In the next chapter the design of the hand-held ultrasonic range meter device will be implemented.

25

CHAPTER 5 System Design


5.1 Introduction
All designs are based on specific constraints. The design of the hand-held ultrasonic range meter device is based on measuring the distance using the time of flight technique. The process of this design is more explained in details in the next section.

5.2 The overall system


The calculations are done by the following way. First of all, the device calculates the time that the ultrasonic wave took to reach the targeted object and come back to the receiver. Thus, if we need to calculate the time needed for the ultrasonic wave to reach the object from the device, we divide the previous time we had by two. Second, the device multiplies the time by the speed of sound (340 m/s) to get the distance between the device and the object. The time from transmission of the pulse to reception of the echo is the time taken for the sound energy to travel through the air to the object and back again. Since the speed of sound is constant through air, measuring the echo reflection time lets you calculate the distance to the object using this equation: Distance = (s * t)/2 (in meters) (5.1)

Where: s [m/s] is the speed of sound in air and t [s] is the round trip echo time. Table 5.1: The delay times of boundary range Round trip echo time t = 588 us Distance 10 cm

26

t = 17.6 ms 3m .

Figure 5.1: General block diagram. 5.2.1 Calculation of the distance to an object The hand-held Ultrasonic Range meter device offers precise ranging information from roughly 10cm to 3 meters. The ranger works by transmitting a pulse of sound outside the range of human hearing. This pulse travels at the speed of sound away from the ranger in a cone shape and the sound reflects back to the ranger from any object/target in the path of this sonic wave. The ranger pauses for a brief interval after the sound is transmitted and then awaits the reflected sound in the form of an echo. The controller driving the ranger then requests a ping; the ranger creates the sound pulse, and waits for the return echo. If received, the ranger reports this echo to the controller and the controller can then compute the distance to the object based on the elapsed time. The Pulse Trigger Input line should be held low and then brought high for a minimum of 100sec to initiate the sonic pulse. The pulse is generated on the falling edge of this input trigger. The rangers receiver circuitry is held in a short blanking interval of 600 sec to avoid noise from the initial ping and then it is enabled to listen for the echo. The echo line is low until the receive circuitry is enabled. Once the receive circuitry is enabled, the falling edge of the echo line signals an echo detection or nothing if there is no reflection. The long-range measurement is difficult a little. To measure the correct distance, the following conditions are necessary. The object must be perpendicular to the range meter. The surface of the object must be flat.

27

There is not object which reflects the ultrasonic around.

Figure 5.2: Theoretical graph of the pulses and its echo-reflection pulse.

5.3 Ultrasonic system


It consists of a transmitter and receiver pair on the device and a microcontroller with a digital display. There are two different transducers for transmitter and receiver. The transmitter transmits and the receiver waits for the reflected signals. The Figure 5.3 illustrates this system.

28

Figure 5.3: The overall design of the ultrasonic system. 5.3.1 Ultrasonic Transmitter The transmitter consists of an electronics circuitry and an electromechanical transducer. The electronic circuitry generates the required frequency electrical signal and the electromechanical transducer converts that electrical signal into the physical form and activates the open medium surface. This oscillating physical surface creates the ultrasonic Waves. The oscillating surface creates a pressure variation and ultimately a pressure wave with a frequency equal to that of the surface oscillation. The Figure 5.4 shows the generation of ultrasonic waves.

Figure 5.4: The transmitter circuit design. The transmitter was designed to oscillate at a resonant frequency of about 40 KHz. The 555 timer generates a 40 KHz sinusoidal ultrasonic wave. The frequency is calculated by using the following formula: F = 1.44 / 2 * R1 * C = 1.44 / 2 * 15.6 K * 1nF = 46 kHz. (5.1)

This design of the transmitter was done in way to get the closest value to 40 KHz by adjusting the resistor and the capacitor to the values shown in the Figure 5.4.

29

5.3.1.1 The 555 timer datasheet The 555 monolithic timing circuits is highly stable controller capable of producing accurate time delays, or oscillation .In the delay time of operation, the time is precisely controlled by one external resistor and capacitor .For a stable operation as an oscillator, the free running frequency and the duty cycle are both accurately controlled with two external resistors and one capacitor. As shown in Figure 5.5:

Figure 5.5: The 555 block diagram. The Table 5.2 shows the datasheet of the 555 timer, the parameter rating and the units characterized by each component.

Table 5.2: The datasheet of the 555 timer Symbol VCC Pd TA VTH (Vcc = 5v) VTRIG(Vcc = 5v) VRESET Parameter Supply Voltage Maximum allowable power dissipation Operating ambient temperature range Threshold voltage Trigger Voltage Reset Voltage Rating +16 600 0 to 70 3.33 1.67 0.3 to 1.0 Unit V mW C V V V

30

.5.3.2 Ultrasonic Receiver The receiver also has the same configuration except that it has a receiver electronic circuitry and a transducer, which converts the ultrasonic sound waves into an electrical signal. The sound waves travel into the medium and are reflected by an object in the path of the waves. This reflected wave is then sensed by the receiver, which actually calculates the time of flight of the signal to find the distance. The Figure 5.6 illustrates the receiver circuit.

Figure 5.6: The receiver circuit design. 5.3.2.1 Basis of the operational amplifier The operational amplifier is the amplifier with the very big voltage gain. In case of TL082 to be using this time, at the specification, the voltage gain becomes 150V/mV. It is the 15 V output in 0.1 mV of the input. To say becomes 150,000 times of gain. In case of the operational amplifier, the value of the voltage gain doesn't have the relation too much. Anyway, the fact that the voltage gain is big is important.

5.3.2.2 The Difference Gain amplification 31

There are positive

input and negative

input in the operational amplifier.

The voltage gain can be calculated by the following formula. G = Vo/Vi = -(Rf/Ri) (5.2)

Figure 5.7: The difference gain amplification. Using the voltage divider formula: Vb = V1 * R2/(R1 + R2) (5.3)

The current passing through Ri is the same current passing through Rf because the current entering the negative input is negligible in A (in the ideal operational amplifier, it is considered zero) and this gives the following equation: (Vi Va) / Ri = (Va Vo) / Rf (5.4) (5.5)

Vo = (V1 * R2 * (Rf + Ri) / (R1 + R2) * Ri) Vi * Rf / Ri

5.3.2.3 Signal amplification circuit

32

The signal amplification circuit is illustrated below in the Figure 5.8.

Figure 5.8: The circuit of the signal amplification. The ultrasonic signal which was received with the reception sensor is amplified by 2500 times (68dB) of voltage with the operational amplifier with two stages. The voltage gain G is 100 times at the first stage (40dB) and 25 times (28dB) at the next stage. Generally, the positive and the negative power supply are used for the operational amplifier. The circuit this time works with the single power supply of +5 V. Therefore, for the positive input of the operational amplifiers, the half of the power supply voltage is applied as the bias voltage and it is made 2.5 V in the central voltage of the amplified alternating current signal. When using the operational amplifier with the negative feedback, the voltage of the positive input terminal and the voltage of the negative input terminal become equal approximately. So, by this bias voltage, the side of the positive and the side of the negative of the alternating current signal can be equally amplified. When not using this bias voltage, the distortion causes the alternating current signal. When the alternating current signal is amplified, this way is used when working the operational amplifier for the two power supply with the single power supply. Using the formula in 5.1: Vi is the input voltage at the ultrasonic transducer. Vo1 is the output voltage of the first amplification stage. Vo2 is the output voltage of the second amplification stage. At minimum distance, d = 10 cm,

33

Vi max = 2.50004 V. Vo1 = (5 * 47K * (100k + 1k) / (47k + 47k) * 1K) - 2.50004 * 100k / 1k = 2.496 V. Vo2 = (5 * 47K * (100k + 3.9k) / (47k + 47k) * 3.9K) - 2.496 * 100k / 3.9k = 2.6 V. At maximum distance, d = 3 m, Vi max = 2.4999 V. Vo1 = (5 * 47K * (100k + 1k) / (47k + 47k) * 1K) - 2.4999 * 100k / 1k = 2.46 V. Vo2 = (5 * 47K * (100k + 3.9k) / (47k + 47k) * 3.9K) - 2.46 * 100k / 3.9k = 2.50156 V. Vi = 2.50004 2.4999 = 0.04 mV. A slight change in Vi formed a bigger change in Vo2. Vo2 = Vi * Gain = 0.04 * 2500 = 100 mV. 5.3.2.4 Data of the TL082 operational amplifier As for TL082, the two operational amplifiers are enclosed with the one package.

Figure 5.9: Pin connections top view.

Table 5.3: The datasheet of the TL082 operational amplifier. 34

Symbol Supply Voltage Differential Input Voltage Input Voltage Range Output Short Circuit Duration Power Dissipation (Plastic Package) Operating Ambient Temperature Rage Storage Temperature Range Slew rate Gain bandwidth product

Symbol VCC VEE VID VIDR tSC PD 1/8JA TA Tstg SR GBW

Value +18 -18 30 15 Continuous 680 10 0 - +70 -65 - +150 16 4

Unit V V V

mW mW/C C C V/s MHz

The magnitude of the input voltage must not exceed the magnitude of the supply voltage or 15V, whichever is less. The output may be shorted to ground or either supply. Temperature and/or supply voltages must be limited to ensure that power dissipation ratings are not exceeded. For the 741 operational amplifier, GBW = 1 MHz, SR = 0.5 V/s. For the TL082 operational amplifier, GBW = 4 MHz, SR = 16 V/s. Vi(t) = 0.04 cos ( 40000 * 2 * * t) mV. Vo(t) = 100 cos ( 40000 * 2 * * t) mV. (Vo(t)) = 2 * * 40000 * 0.1 = 0.025 V/s. 0.025 V/s < 0.5 V/s the 741 operational amplifier could be used. 0.025 V/s < 16 V/s the TL082 operational amplifier could be used. The TL082 operational amplifier has a better slew rate. For a 10% error in the frequency, F = 40000 * 0.9 = 36000 Hz. The required gain bandwidth product for a gain = 2500 is, GBW = 36000 * 2500 = 90 MHz > 4 MHz. The signal amplification is split into two stages because of this gain bandwidth product. The maximum gain G max = 4 MHz / 36000 Hz = 111.11. The maximum gain is greater than the gain for the first stage 100 and the second stage 25.

35

5.3.3 Detection circuit The detection is done to detect the received ultrasonic signal. It is the half-wave rectification circuit which used the 1N4148 diodes.

Figure 5.10: The detection circuit.

The DC voltage according to the level of the detection signal is gotten by the capacitor behind the diode. The 1N4148 diode is used because it is a fast switching diode.

5.3.4 The microcontroller

36

Figure 5.11: The microcontroller top view. The microcontroller used in this project is the 40 pin PIC16f877A. This microcontroller was chosen because it consists of two timers, two capture modes CCP, five ports, a good size of memory and its low price compared to other microcontroller with less functionality. By manipulating the program of this project, this microcontroller with its big number of ports could be added to a robot or other applications and also it could control other applications due to the measured distance needed to react for. The clock used for this project is 4 MHz. The port B is an output port used for the digital display of the distance measured. The bit RC4 of the port C is used to enable the transmitter in order to send pulses. The bit RC2/CCP1 of the port C is used for its capture mode by capturing the echo reflected, it is connected to the receiver.

Table 5.4: The microcontroller specifications. Device PIC16f877a

37

Bytes Program # single word instruction memory Data SRAM (Bytes) EEPROM (Bytes) I/O Ports 10 bit A/D (ch) CCP (PWM) SPI Master IC MSSP USART Timers 8/16 bit Comparators

14.3 K 8192 368 256 33 A, B, C, D, E 8 2 yes yes yes 2/1 2

5.3.4.1 The CCP capture mode This project makes use of the CCP module (in its capture mode) to accurately measure the signal reception time at the CCP port pin. When a signal triggers the CCP module the value of timer 1 is stored in a CCP register (or captured). If you store the value of timer 1 and then enable the CCP after transmitting an ultrasound pulse the CCP will trigger when the comparator activates i.e. as soon as an ultrasonic echo is received. Subtracting the stored value from the CCP register value gives the time delay in machine cycles. Since the project uses a 4MHz main clock then the time delay will be measured in micro-seconds.

5.4 The program


This program is written in C code. It is compiled using the program MicroC in order to generate the Hex file. It consists of an include header bit.h, the main program with eight functions.

38

5.4.1 The flowchart It enters a continuous loop calling ulta_gen the routine that generates the ultrasound at 40 kHz. The ultra_gen routine is set up using the simulator to set the timing of the output signal for a period of 25 s (40 kHz). This is then repeated every 40 ms. The required refresh rate of the seven segment display is 20 ms so the display update routine seg_display_int is called twice over the 40 ms period. The display update routine takes 20 ms and calling this twice creates the total 4 0ms delay. The display relies on persistence of vision to make it appear that the display is not flickering; a refresh rate of 50Hz or more does the job (1 / 50 Hz = 20 ms). In theory the maximum distance that you could measure is (20 ms * 340 m) / 2 = 3.4 m, but in practice this is limited by the signal conditioning circuits. If they were changed, more range could be got. If a capture occurs indicated by gCapInt, then the distance calculation is performed and the value of variable val is updated. val is the value displayed by the seven segment display routine seg_display_int, so val is continuously refreshed to the seven segment display. The interrupt routine is only enabled when required and when the capture occurs, only the first capture is stored. So that later reflections are ignored by resetting gCapOn. The first reflection should be the strongest and therefore the closest object. When captured, the variables t_capL, t_capH and t_capO are set to the value of the capture register which will be the value of timer 1 when the capture module triggered.

39

Figure 5.12: The flowchart of the program. 5.4.2 Include file bit.h This macro preserves the current value of the 'PORT' or register. WRITEPORT is the same as writing to a port but preserves the keepmask bits. The macro WRITEPORT(port,newval,keepMask) is used to write only to specific bits of a port. The PORT is read, keepMask bits are preserved when the data value is output to the port.

40

#define WRITEPORT(port,newval,keepMask) \ (port) = ((newval) & (~keepMask)) | ((port) & (keepMask)); #define setBit(var, bitnum) (var)|=(1<<(bitnum)) #define resBit(var, bitnum) (var)&=~(1<<(bitnum)) #define clearBit(var, bitnum) (var)&=~(1<<(bitnum)) #define testBit(var, bitnum) (var)&(1<<(bitnum)) This code is saved as an include header file bit.h. 5.4.3 The main program #include "bit.h" // macro // globals for interrupt. unsigned int T1_O = 0; // timer1 overflow updated in interrupt routine. unsigned short gCapInt = 0; // captured something in interrupt routine. unsigned short gfCapOn = 1; // control capture only capture 1st value. unsigned int t_capL = 0; // timer 1 low. unsigned int t_capH = 0; // timer 1 high. unsigned int t_capO = 0; // timer 1 overflow. unsigned int gCapVal = 0; // captured this.

void init(void) { // set CCP to capture mode every rising edge. CCP1CON = 0x05; ADRESH = 0;

41

// Timer 1 on T1CON = (1<<TMR1ON); } void init_ports(void) { PORTA = 0; TRISA = 0;

PORTB = 0; TRISB = 0; // 0=o/p - sets analogue pins to digital output.

PORTC = 0; TRISC = 0x04; // 0=o/p Receive on RC2. }

void enable_interrupts(void) { // Timer 1 PIR1 &= ~(1<<TMR1IF); // Zero T1 overflow register value. // Capture PIR1 &= ~(1<<CCP1IF); // Zero Capture flag // Interrupt enable PIE1 = (1<<CCP1IE); // Global interrupt enable. INTCON = (1<<GIE) | (1<<PEIE); // enable global & peripheral }

42

void disable_interrupts(void) { INTCON &= ~(1<<GIE); // disable global & peripheral }

int2seg(unsigned short digit) { unsigned short r; unsigned short ret[10] = { 0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F }; if (digit<0 || digit>9) { r = 0x7f; } else { r =( ret[digit] & 0x1f ) | \ ( (ret[digit] & 0x60)<< 1); } return r; }

void seg_display_int(unsigned int val) { char op[7]; IntToStr(val,op); // Display the lower 4 digits. PORTB=int2seg(op[2]-'0'); setBit(PORTA,0); delay_ms(4);

43

resBit(PORTA,0);

PORTB=int2seg(op[3]-'0'); setBit(PORTA,1); delay_ms(4); resBit(PORTA,1); PORTB=int2seg(op[4]-'0'); setBit(PORTA,2); delay_ms(4); resBit(PORTA,2);

PORTB=int2seg(op[5]-'0'); setBit(PORTA,3); delay_ms(4); resBit(PORTA,3); PORTA &= ~0xe4; // turn off all resBit should do this PORTA=0; PORTB=0x00; } // generate 4 pulses of ultrasonic at 32kHz (8 periods of 32kHz). void gen_ultra(void) { setBit(PORTC,4); delay_us(12);

44

resBit(PORTC,4); delay_us(11); setBit(PORTC,4); delay_us(12); resBit(PORTC,4); delay_us(11); setBit(PORTC,4); delay_us(12); resBit(PORTC,4); delay_us(11); setBit(PORTC,4); delay_us(12); resBit(PORTC,4); delay_us(11); }

void main() { unsigned int i,val,s1,s2,tH,tL,tO; char op[12]; unsigned long calc=0; init_ports(); init(); gCapInt=0; // Reset capture indicator. while(1) { gfCapOn = 1; // allow one capture value

45

tO = T1_O; // Get the current timer value. tH = TMR1H; tL = TMR1L; t_capL = 0; t_capH = 0; t_capO = 0; // initialise capture gen_ultra(); enable_interrupts(); seg_display_int(val); disable_interrupts(); // had 20 ish ms of time so stop if (! gCapInt) { // no echo from soft output ? try loud enable_interrupts(); seg_display_int(val); seg_display_int(val); disable_interrupts(); // had 20 ish ms of time so stop } // Did we get any echo from soft or loud? if (gCapInt) { // captured anything ? gCapInt=0; // reset for next time // 4MHz clock so timer 1 returns us // gCapVal * 1,000,000 = seconds. // speed of sound in air at 20degC = 340m/s // (gCapVal*1000000*340)/(2*100) = distance in cm s1=(t_capH-tH); s2=(t_capL-tL);

46

calc = ((s1)<<8)+s2; calc *= 34; calc /= 2000; // output in cm val = (int)calc; } } // while(1) } void interrupt(void) { // Free run Timer 1 get the overflow to extend counter here. if (PIR1 & (1<<TMR1IF) ) { // T1 overflowed ? PIR1 &= ~(1<<TMR1IF); // clear timer1 overflow bit. T1_O++; } // Capture if (PIR1 & (1<<CCP1IF)) { PIR1 &= ~(1<<CCP1IF); // Zero Capture flag. if (gfCapOn) { // allow only 1 capture gfCapOn = 0; t_capL = CCPR1L; t_capH = CCPR1H; t_capO = T1_O; gCapInt = 1; // signal that a capture occured. } } // Interrupts are only enabled at a specific point from program. // They are not re-enabled here // Note GIE set by RETFIE instruction }

47

5.5 Power supply and battery


The Ultrasonic transmitter and receiver require four connections to operate. First there are the power and ground lines. The Ultrasonic transmitter and receiver require a 5V power supply capable of handling roughly 50mA of continuous output. The remaining two wires are the signal wires, one to enable or disable the transmitter and the other to get the returned echo. The microcontroller needs also a 5V to operate. This 5V power supply is got using a regulator. The user can use a 12V DC power supply or a 9V battery to operate this device illustrated in Figure 5.13.

Figure 5.13: The power supply circuit.

5.6 Ultrasonic sensors


A market survey has been done to select the best available ultrasonic proximity sensor available at that time. The following are some of the sensors that have been considered for the development of this system. Table 5.5: The Ultrasonic sensor specifications. Transducer SQ-40T/R SensComp 600 The ultrasonic transducers are optimized for 25 kHz, 32 kHz, 40 kHz or wide bandwidth transducers. This project uses a 40 kHz transducer but it will still work with the others if the appropriate changes to the software are being made. The receiver and generator 48 Range 10 cm - 3 m 15 cm 10.7 m Beam angle 30 15 Measurement speed 20 ms 200 ms Frequency 40 Khz 50 Khz Sensitivity high good

circuits will work as they are. The 40 kHz signal is easily generated by the microcontroller but detection requires a sensitive amplifier and a peak detector. Transducers are devices that convert electrical energy to mechanical energy, or vice versa. The transducer converts received echoes into analog electrical signals that are output from the transducer. Ultrasonic transducers operate to radiate ultrasonic waves through a medium such as air. Transducers generally create ultrasonic vibrations through the use of piezoelectric materials such as certain forms of crystals or ceramic polymers. The overall capacitance of a transducer is dependent upon the area and the thickness of the piezo material. Ultrasonic transducers are available in various technical forms. Ultrasonic transducers are typically formed of either piezoelectric elements or of micro-machined ultrasonic transducer (MUT) elements. For industrial use, solid-state transducers are usually used, because of their robustness. They basically include a piezoceramic device as an element for converting between electric signals and acoustic signals and a resonant adapter layer, with which the transfer of sound to the air is optimized. The piezoelectric elements typically are made of a piezoelectric ceramic such as lead-zirconate-titanate (PZT), with a plurality of elements being arranged to form a transducer. Piezoceramic ultrasonic transducers are the transducers of choice for rugged, industrial applications because they are efficient and environmentally robust. These sensors have been used in industry for numerous applications; however have not been capable of short range object detection until recently. A micro-machined ultrasonic transducer (MUT) is formed using known semiconductor manufacturing techniques resulting in a capacitive ultrasonic transducer cell that comprises a flexible membrane supported around its edges over a silicon substrate. The membrane is supported by the substrate and forms a cavity. The MUT may be electrically energized to produce an appropriate ultrasonic wave. Similarly, when electrically biased, the membrane of the MUT may be used to receive ultrasonic signals by capturing reflected ultrasonic energy and transforming that energy into movement of the electrically biased membrane, which then generates a receive signal. Capacitive micro-machined ultrasonic transducers (cMUTs) are tiny diaphragm-like devices with electrodes that convert the sound vibration of a received ultrasound signal into a

49

modulated capacitance. For transmission the capacitive charge is modulated to vibrate the diaphragm of the device and thereby transmit a sound wave. In general, ultrasonic transducers are constructed by incorporating one or more piezoelectric vibrators which are electrically connected to pulsing-receiving system. [3] 5.6.1 Electrostatic Ultrasonic Sensors Electrostatic ultrasonic sensors operate similar to an electrical capacitor. These sensors usually are composed of a fixed conductive plate and a free metallic surface coated with a layer of insulation that separates the two plates. When an electric potential is placed across the fixed conductive plate, the free metallic surface is pulled against the fixed plate. When an oscillating electrical potential is applied to the fixed plate, the free plate oscillates at a similar frequency thereby creating acoustic pressure waves. When receiving an ultrasonic signal, the Electrostatic ultrasonic sensors produce a varying capacitance created by the pressure waves hitting the free metallic surface. 5.6.2 Piezoelectric Ultrasonic Sensors Piezoelectric ultrasonic Sensors are composed of a Piezo material and an acoustic surface. The Piezo material can either be a crystal or ceramic. The Piezo material is attached to the acoustic surface such that any physical changes in the geometry of the material will affect the acoustic surface. When an electrical potential is placed across the Piezo material, the geometry changes thereby disturbing the acoustic surface. When an oscillating electrical potential is placed across the Piezo material, the acoustic surface generates an acoustic signal. When receiving an ultrasonic signal, the ultrasonic waves strike the acoustic surface thereby compressing the Piezo material. The Piezo material emits electrons when compressed thereby creating an electrical signal. Piezoelectric materials vibrate in response to alternating voltages of certain frequencies applied across the material. Piezoelectric elements are similar to common analog

50

capacitors in that piezo elements generally include two electrodes separated by a piezoelectric material that functions as a dielectric, shown in Figure 5.14 and the sensitivity with respect to frequency is described in Figure5.15.[3]

Figure 5.14: The SQ-40T/R ultrasonic transducer.

Figure 5.15: The sensitivity of the SQ-40T/R with respect to the frequency.

5.7 The schematic of the ultrasonic range meter design:

51

The functionality of this system can be divided into three main parts as shown in Figure 5.27; the transmitter, the receiver, the microcontroller and the digital display. The transmitter, enabled via the microcontroller, is designed to activate a 555 oscillator with a frequency of 40 KHz. The width of the pulse is 0.1 ms, every 40 ms a pulse is transmitted. One of the most important and sophisticated part of the device is the receiver. The receiver consists of a signal amplification stage and peak detection stage. The signal is amplified by a gain of 2500 in order to reduce the noise effect. In order to reduce the cost of the power supply of the device, the +/- Vcc was avoided and 0-5 V power supply was used in the design of the signal amplification stage. The peak detection is used to transform the signal into a pulse. The microcontroller controls all the parts in the device and performs all the arithmetic calculations of the distance and displays it on the 7-segment digital display. This process of distance calculation is continuously repeated as long as the device is turned on. The laser pointer on the device is used to pinpoint the target in order to get less error caused by the malfunction use of the device. The program used in the PCB design is ExpressPCB which is a professional program. The design of the PCB is splitted into two PCB circuits as shown in Figures 5.28, 5.29; one for the transmitter and receiver and the other for the microcontroller with transistors used to enable the 7-segment display.

52

Figure 5.16: The overall schematic of the Ultrasonic range meter.

53

Figure 5.17: The printed circuit board diagram of the microcontroller.

Figure 5.18: The printed circuit board diagram of the transmitter and receiver. 54

Figure 5.19: The packaging of the device.

55

Chapter 6 System Implementation

6.1 Factors affecting the performance of Ultrasonic sensors


Position/distance measurement using ultrasonic sensors is based on the principle of measuring the time of flight of the ultrasonic waves in a particular medium. There are number of factors which affect the accuracy of measurement and therefore should be taken into consideration while designing the ultrasonic sensing system. The following are some of the factors. 6.1.1 Radiation pattern: All ultrasonic sensors have their specific radiation pattern associated with it. This acoustic radiation pattern is a function of spatial angle called beam angle. Beam angle, is defined as the total angle between the points at which the sound power reduces to half its peak value, commonly known as 3 dB points. The spot diameter of the beam can be formulated as. D = 2R tan (0.5 ) Where, D = spot diameter in centimeters. R = target range in centimeters. = beam angle in degrees. At minimum range, R = 10 cm and = 30. D = 2 * 10 * tan (15) = 5.358 cm. At maximum range, R = 300 cm and = 30. D = 2 * 300 * tan (15) = 160.769 cm. (5.6)

56

Radiation pattern consists of a main lobe and side lobes. Radiation power is dominant mainly in the front region of the sensor, so as to say that the main lobe is directly in front of the sensor, followed by side lobes sidewise with null region in between these lobes. Radiation pattern is mainly determined by factors such as the frequency of operation and the size, shape and acoustic phase characteristics of the vibrating surface. The beam pattern of the transducer is independent of its nature as a transmitter or receiver. In most of the application, side lobes are suppressed and narrow beams are used. This suppression is achieved by the processing system and so, the radiation pattern of the transducer may not be same as the radiation pattern of the whole ultrasonic sensing system. The narrowness of the beam pattern is a function of the diameter of the radiating surface to the wavelength of the sound at the operating frequency. As the D/ ratio increases, beam narrows out whereas as D/ ratio decreases, beam broadens. For most of the application narrow beam is desired and therefore D/ ratio should be more. The following Figures 6.1, 6.2 show the radiation pattern, its main lobe and side lobes with the relative attenuation.

Figure 6.1: Geometric approximation of the ultrasonic beam width.

57

Figure 6.2: Beam pattern with respect to amplitude.

6.1.2 Frequency, wavelength and attenuation: The frequency of the ultrasonic sensing system is determined by the resonant frequency of the ultrasonic transducer. The selection of this transducer is made considering number of factors such as transducer size, measurement resolution, measurement range, background noise and attenuation. The wavelength of the ultrasonic wave can be found out with the following formula, = C/f the frequency equal to 40 KHz. C, velocity of sound varies with variation in temperature, pressure, medium type, humidity, air turbulence, conventional currents. So before calculating the wavelength, the speed of sound is required to be calculated. = 340/40 = 8.5 mm. 6.2 Environmental factors: The attenuation of sound power depends on the speed of sound, which depends on many environmental factors like temperature, medium, pressure, humidity, acoustic interference, radio frequency interference. (6.1) Where is the wavelength, C is the velocity of sound equal to 340 m/s at 20 C and f is

58

6.2.1 Temperature The velocity of sound in a medium varies with temperature. So, the time taken by the sound to echo back to the receiver will vary and since this time of flight is proportional to the measured distance. The measured distance will vary with the variation in temperature. Thus the variation in temperature introduces errors in the measurement. The sound wave propagation speed in the air depends on the temperature. So, to measure the distance more correctly, it is necessary to revise according to the temperature. The sound wave propagation speed can be calculated using one of the two formulas. V = 331.5 + 0.6 * T [ m/sec ] T : The temperature (C) (6.2)

Table 6.1: The speed of sound at each temperature. Temperature (C) in air -10 0 10 20 30 40 50 Speed of sound (m/sec) 325.5 331.5 337.5 343.5 349.5 355.5 361.5

59

370 Speed of sound m/s 360 350 340 330 320 310 300 -10 0 10 20 30 40 50 Temperature C

Figure 6.3: Graph of speed with respect to temperature In this project, the speed of sound used in this program is 340 m/s because this speed is relative to the temperature 20 C which is an average value. A temperature sensor could be added to this project with a small manipulation to the program, in order to use the right speed value. In this way, this device would be used in all atmospheric conditions. [4] 6.2.2 Pressure and humidity As the pressure reduces, the density of particle in the medium decreases thus providing less and less resistance to the traveling wave. Although slightly pressure effects the velocity of sound wave, humidity which is defined as the moisture content in the medium basically has a very little effect on the velocity of sound but it actually effect the radiating surface. The acoustic pressure p must satisfy the three-dimensional wave equation.

(6.3) 6.2.3 Medium Velocity of sound depends on the kind of medium the sound travels. Sound speed varies with different medium. The Table 6.2 summarizes some of the medium with the sound velocity in it.

60

Table 6.2: The ultrasonic wave speed through different mediums Medium Air Ammonia Argon Carbon Dioxide Carbon Disulfide Carbon Monoxide Chlorine Ethylene Helium Hydrogen Illuminating Gas Methane Neon Nitric Oxide Nitrogen Nitrous Oxide Oxygen . 6.2.4 Acoustic Interference If the environment contains number of objects that generates background noise and if this background noise falls in the sensitive frequency of the receiver of the ultrasonic sensing system, it will result in erroneous measurement. This error is more pronounced when the amplitude/power of the background noise is more then the echo itself resulting in very low SNR (signal to noise ratio), which is undesirable. Typically, the background noise is less at higher frequency and so narrow beam angles works best in an area where background noise is high. Speed, m/s at 10C 331.5 414.8 301.9 257.8 (low frequency) 184.7 337.1 205.4 313.9 969.8 1269.4 490.4 431.9 434.9 324.9 334.06 261.8 317.2

6.2.5 Radio Frequency Interference Radio frequency signal present in the environment also affects the ultrasonic sensing system. 6.3 Target Consideration

61

The principle of ultrasonic sensing is based on transmission of sound wave followed by the reflection of the echo. These echoes are summed up at the receiver. The return echo is a function of target distance, geometry, surface, size, composition, orientation of object/sensor etc. 6.3.1 Composition Some of the objects are good reflector and some are good absorber. So the amount of echo returned back depends on the kind of material the object is composed of. This finally effects the measurement as it varies from object to object for the same fix distance of the target from the sensor. The object must not be composed of soft surfaces that absorb most of the sound energy. 6.3.2 Size and shape Size and shape affects the amount of echo reflected back to the receiver. For example, for large planner object (object size >> beam size) almost all the ultrasonic wave will be reflected back to the receiver. Whereas in case where the object is very small as compared to the beam size, then part of the ultrasonic sound wave will be reflected to the receiver and the rest will be lost. The shape determines the angle at which the ultrasonic wave will be reflected. Common to all ultrasonic ranging systems is the problem of ultrasonic reflection. With light waves, our eye can see objects because the incident light energy is scattered by most objects, which means that some energy will reach our eye, despite the angle of the object to us or to the light source. This scattering occurs because the roughness of an object's surface is large compared to the wavelength of light 550 nm. Only with very smooth surfaces such as a mirror does the reflectivity become highly directional for light rays. Ultrasonic energy has wavelengths much larger 6.35 mm in comparison. Therefore, ultrasonic waves find almost all large flat surfaces reflective in nature. The amount of energy returned is strongly dependent on the incident angle of the sound energy. Figure 6.4 shows a case where a large object is not detected because the energy is reflected away from the receiver.

62

Figure 6.4: Undetected large object due to reflection.

6.3.3 Position and Orientation If the size of object is small as compared to the beam size, then the measurement depends on the position of the object in the beam region. When object is on the main lobe axis, the reflected echo reaching to the receiver will be very strong and if it is out of axis, the reflected echo will be weak. Although the basic range formula is accurate, there are several factors when considering the accuracy of the result. Since the speed of sound relies on the temperature, a 10N temperature difference may cause the range to be in error by 1%. Geometry also affects range in two major ways. The range equation assumes that the sonar beam width is negligible. An object may be off center, but normal to the transmitted beam. The range computed will be correct, but the X-component may be in error. Using the formula: X = R * sin f off center. Figure 6.5 illustrates this. (6.4) At a range of 9 meters and a beam width of 30N, the X component would be 2.33 meters

63

Figure 6.5: Object offset due to ultrasonic beam width. Another geometric effect is shown in Figure 6.6. When the object is at an angle to the receiver, the range computed will be to the closest point on the object, not the range from the center line of the beam. This is called cosine error.

Figure 6.6: Range error due to angle between object and sonar.

6.4 Power of the detected signal


We need to calculate the power of the detected laser beam in order to detect the reflection at the receiver in a maximum distance range. Power of the detected signal is calculated by the following way:

Pdet = Pult * * * S / (4 * * R)
64

(6.5)

Pult is the power of the emitted ultrasonic wave. S is the object target area that reflected the echo. R is the distance between the device and the target. is the target response to the ultrasonic wave.
is the geometric form-factor for propagation of the ultrasonic wave and the response signal through the ambient media (air, water ).

6.5 Noise
The output of the sensor involves noise, which is primarily introduced because of the uncertainty of the echo which might comes back from the false object/target. Also the attenuation of the sonic burst depends on the position of the object/target in the lobe region.

6.6 Errors
In general it is desired to develop the worst case analysis to permit the design of the hand-held ultrasonic range meter device capable of operation under all conditions with a minimum error (maximum acceptable error is +/- 3 cm). The errors associated with both calculations and measurements can be characterized with regard to their accuracy and precision as shown in Figure 6.7. Accuracy refers to how closely a computed or measured value agrees with the true value. Precision refers to how closely individual computed or measured values agree with each other.

65

Figure 6.7: (a) The samples are inaccurate and imprecise. (b) The samples are accurate and imprecise. (c) The samples are inaccurate and precise. (d) The samples should be accurate and precise in order to get the acceptable error. 6.6.1 Truncation errors The truncation errors are those that result from using an approximation in place of an exact mathematical procedure. For a distance that is being measured, the hand-held ultrasonic range meter device showed a distance R but the real distance was R +/- 3 cm. This means that the error is at its maximum. At a minimum distance range, with the distance equal to 10 cm. T1 is the real time of the real distance for the echo to propagate, get reflected by the targeted object then get back to the receiver. T1 = (0.1 m * 2) / 340 m/s = 588 s. T2 is the time captured by the microcontroller for the echo to propagate, get reflected by the targeted object then get back to the receiver. 66

T2 = (0.12 m * 2)/ 340 m/s = 705 s. Truncation error = ((T2 T1)/T2) * 100 = 16.6 %. At a maximum distance range, with the distance equal to 300 cm. T1 is the real time of the real distance for the echo to propagate, get reflected by the targeted object then get back to the receiver. T1 = (3 m * 2) / 340 m/s = 17.6 ms. T2 is the time captured by the microcontroller for the echo to propagate, get reflected by the targeted object then get back to the receiver. T2 = (3.07 m * 2)/ 340 m/s = 18.05 ms. Truncation error = ((T2 T1)/T2) * 100 = 2.54 %. 6.6.2 Cosine error The effect attributable to cosine error occurs with ultrasonic when the position of this ultrasonic range meter device is not in true alignment with the target. Since the distance to be determined is relative to the position of the object with respect to the position of the device, any deviation from true alignment results in an increase in the distance displayed. 6.6.3 Reflection error Reflection can also give rise to erroneous reading, often due to the size and shape of the targeted object or due to the presence of many objects near to the targeted object. (6.7) (6.6)

67

Chapter 7 Testing and results

7.1 System testing This experiment was done at a 17 C and that increased the error. It consisted of measuring the distance from the device to a flat wall. Eleven measurements were done in this experiment. The average error A = (2 + 2 + 2 + 3 + 3 + 3 + 3 + 3 + 4 + 5 + 7) / 11 = 3.36 cm. Table 7.1: Distance measurement with its error. Real measurements in cm 10 20 30 40 50 75 100 150 200 250 300 Device measurements in cm 12 21 32 43 53 77 103 153 204 255 307 Error in cm +2 +2 +2 +3 +3 +3 +3 +3 +4 +5 +7

The Figure 7.1 shows the variation of error with respect to distance. The error increases as long as the distance increases.

68

8 7 6 error cm 5 4 3 2 1 0 12 21 32 43 53 77 103 153 204 255 307 Device measurements cm

Figure 7.1: Graph of error with respect to the measured distance 7.2 Testing the Transmitter The transmitter was enabled and tested on the oscilloscope shown in Figure 7.2 to get the desired frequency. The voltage/division used on this oscilloscope is 2 V/div and the time/division used is 20 s/div. The period is about 1.1. To get the value, 1.1 * 20 s = 22 s. F = 1 / 22 s = 45.4 KHz.

Figure 7.2: The transmitter oscilloscope graph.

69

7.3 Testing the Receiver The Figure 7.3 shows the receiver oscilloscope graph where the transmitted and received echoes are present on the second stage of the signal amplification. The voltage/division used on this oscilloscope is 2 V/div and the time/division used is 5 ms/div.

Figure 7.3: The receiver oscilloscope graph. The Figure 7.4 shows the transmitter and receiver oscilloscope graph where the transmitted and received echoes are present on the second stage of the signal amplification. The voltage/division used on this oscilloscope is 2 V/div for the signal amplification stage of the receiver, 1 V/div for the transmitter and the time/division used is 2 ms/div.

Figure 7.4: The transmitter and the receiver oscilloscope graph.

70

7.4 Testing the Detection circuit The detection oscilloscope graph is done showing a detection of the reflected echo for a 72 cm distance. The first part is for the signal amplification of the receiver and the second part is for the detection part of the receiver.

Figure 7.5: The detection oscilloscope graph. The voltage/division used on this oscilloscope is 2 V/div for the signal amplification stage of the receiver, 5 V/div for the peak detection and the time/division used is 1 ms/div. The period measured on the oscilloscope is about 4.2. To get the value of it, 4.2 * 1 ms = 4.2 ms, this is 72 cm of distance. Looking at the detection oscilloscope graph from left to right, the first peak is the transmitted pulse but the second is the received pulse as shown in Figure 7.5.

7.5 Conclusion
The solutions of the problems and the design of our device according to our constraints. These solutions are the preliminary solutions of the most important problems and they can be improved at anytime.

71

Chapter 8 Timeline, Cost and conclusion


8.1 Timeline
Time needed to complete each part of this project. Ultrasonic transmitter and receiver (three weeks) Microcontroller with the program (two weeks) Building the circuits (one week)

Figure 8.1: Timeline graph. The time needed to complete the hand-held ultrasonic range meter device is one month and two weeks as shown in Figure 8.1 and Table 8.1 shows how the work was distributed. Table 8.1: Distribution of work. Euclid Team Ultrasonic Transmitter Maroun Daher Rami Freih Gaby Al Jawabira X X Ultrasonic Receiver X X X X X X X X Program Circuits

72

8.2 Cost of the ultrasonic range meter design


The components of this project was selected carefully to get the most efficient ,less error ,cheaper and which can be modified to adapt to a variety of pulsed ultrasonic systems. The Table 8.2, show the cost of the components. Table 8.2(a): Components and prices Quantity 6 2 2 2 1 1 1 1 1 1 1 Resistors 1 k 5.6 k 47 k 100 k 56 3.9 k 10 k Capacitors 15 pF 3.3 nF 470 F 1 nF 1.2 nF 10 nF 120 nF 220 nF 10 F 22 F Price 1200 L.L. 900 L.L. 900 L.L. 900 L.L. 450 L.L. 450 L.L. 450 L.L. 250 L.L. 250 L.L. 250 L.L. 250 L.L.

Table 8.2(b): Components and prices Quantity 1 1 1 1 2 5 4 Transistors C32725 BC548 ICs TL082 NE555 7805 16F877A Diodes 1N4007 1N4148 Others SQ40-T SQ40-R 4 MHz clock 7 segment display Price 9500 L.L. 5500 L.L. 1500 L.L. 7500 L.L. 1000 L.L. 2750 L.L. 2000 L.L.

Adding the cost of the electrical components used in the Tables 8.2(a), (b), it cost 34000 L.L. By adding the cost of the packaging, the PCB and the laser pointer, the overall handheld ultrasonic range meter device cost was 55000 L.L.

73

8.3 Conclusion
During the process of designing and implementing the hand-held ultrasonic range meter device, the personal and professional benefits were extremely important. Teamwork was the most interesting part, dividing the project into several parts related to each other, helped in reducing the time of completing the project. Each individual worked on a specific part and in the end all the work was combined into a whole working device. The importance of the device is based on calculating accurate distances. The device can be used in many different fields and categories like distance calculation in construction field, robots, car sensor to avoid obstacles and many other applications. The building process of the device was based on using as much as possible from the courses taken in the university, like Programming I, II, Circuits I, II, Analog Integrated Circuits, Electronics and Field Theory. The cost of the device was minimized as much as possible in order to benefit more financially and decrease its price in the market.

References
[1] Ultrasonic instruments and devices by Emmanuel P. Papadakis, ElSevier academic press [2]http://www.ndted.org/EducationResources/CommunityCollege/Ultrasonics/Introduction/history.htm

74

[3] http://www.electronics-manufacturers.com/info/sensors-and-detectors/ultrasonic-sensor.html [4] http://www.hobby-elec.org/e_srm1_4.htm Software: Microsoft Word. Microsoft Excel. Microsoft Visio. Microsoft Paint. Express PCB. Circuit Maker.

75

También podría gustarte