range finder solution using a single transducer - · pdf filewhitepaper on range finder...
TRANSCRIPT
Whitepaper on Range Finder Solution Using a Single Transducer
Page 1
Range Finder Solution Using a Single Transducer
by
Jagadeesh Gowda
Senior Software Engineer
KTwo Technology Solutions Pvt .Ltd.
©2008-09 KTwo Technology Solutions Pvt. Ltd.
Whitepaper on Range Finder Solution Using a Single Transducer
Page 2
Contents
1. Introduction
2. Theory
2.1 Background
2.2 Speed of Sound
3. Software implementation
4. Software Design
4.1 Algorithm
4.2 Flowchart
5. Hardware Block diagram
6. Sensor details
7. Results
8. References
Whitepaper on Range Finder Solution Using a Single Transducer
Page 3
1. Introduction
This whitepaper describes a method of range finding using a single ultrasonic transducer. The
common traditional approach is to use two transducers, one for transmitting a pulse of 40 KHz
and another for receiving it. Range finding solutions are typically used in automobiles for
parking assistance systems. But using a single transducer in place of the common approach of
using two transducers helps bring down the cost of the solution. The detectable range of this
solution is from 20 cm to 250 cm.
2. Theory
2.1 Background
Ultrasonic signals are like sound waves, except the frequencies are much higher. Ultrasonic
transducers have piezoelectric crystals which resonate to a desired frequency and convert electric
energy into acoustic energy and vice versa. Figure 1 shows how sound waves transmitted in the
shape of a cone are reflected from a target.
Figure 1: Operation of Ultrasonic Transducer
These sensors have some limitations. They do not detect objects which are above the maximum
range of the sensor and if any object lies within the minimum range, the sensor gives the
minimum range itself as the distance of the object from the sensor. Depending on the sensor we
choose, we will have variations in terms of minimum and maximum range, and cone angle.
Figure 2 shows (a b) is the minimum range and (b c) is the maximum range of the sensor.
Figure 2: Transducers Limitations
Whitepaper on Range Finder Solution Using a Single Transducer
Page 4
2.2. Speed of Sound
The speed which sound travels depends on the medium which it passes through. In general, the
speed of sound is proportional (the square root of the ratio) to the stiffness of the medium and its
density. This is a fundamental property of the medium. Physical properties and the speed of
sound change with the conditions in the environment. The speed of sound in the air depends on
the temperature. In the air, speed is approximately 345 m/s, in water 1500 m/s and in a bar of
steel 5000 m/s.
A common use of ultrasound is for range finding. This use is also called sonar. Sonar works in a
manner that is similar to radar. An ultrasonic pulse is generated in a particular direction. If there
is an object in the way of this pulse, the pulse is reflected back to the sender as an echo and is
detected. By measuring the difference in time between the pulse transmitted and the echo
received, it is possible to determine the distance of the object from the source of the pulse.
3. Software implementation
The software can be implemented in ‘C’ on any 8-bit microcontroller platform that supports
ADCs.
The working principle of the application is as shown in figure 3. A series of 10 ultrasonic pulses
are transmitted using a transducer that changes voltage into sound waves. These pulses are
generated by the 8 bit microcontroller at a frequency of 40MHz. The transmitted pulse is
reflected off an object, and the reflected wave is then received by the same transducer that
converts sound waves into voltage and is amplified by the amplifier. The amplified signal is
given to the ADC of the 8-bit microcontroller to convert the incoming signal into a digital value
at every 31.25us which can be further processed to give distance information. The
microcontroller measures the time elapsed between transmission of pulses and reception of the
echo using 450 samples of data. By several experiments we have concluded that sampling each
of the 450 samples at every 31.25us gives better results.
Whitepaper on Range Finder Solution Using a Single Transducer
Page 5
Fig 3: working principle of ultrasonic range finder
4. Software Design:
The development of the application using ultrasonic sensors requires good understanding of its
operating principles and its interaction with the environment. They rely on the principle of
propagation of sound waves in the air. The system measures the echo reflection of the sound
from the object.
Ultrasonic Transmitter:
The transmitter consists of an electronics circuit and a transducer. The electronic circuitry
generates electrical signals of the required frequency and the transducer converts those electrical
signals into the physical form and activates the open medium surface. This oscillating physical
surface creates ultrasonic waves. Figure 4 below shows the generation of ultrasonic waves.
Fig 4: Ultrasonic transmitter circuitry
Whitepaper on Range Finder Solution Using a Single Transducer
Page 6
In order to generate the pulse of 40 KHz, the software requires two pins of general purpose I/O
port.
After transmission, the two pins are put into the receiving state by putting one to low and another
to tri state. This is done so that the microcontroller won’t have any control over port and the
received signal from the transducer directly goes to the receiver circuit.
There are two timers used:
1. General Timer
It is used to for generating the 40 KHz samples.
2. ADC Timer
It is used for sampling the data.
Ultrasonic receiver:
The receiver also has the same configuration except that it has a receiver circuit and a transducer
which converts ultrasonic sound waves into electrical signals. The sound waves travel through
the medium and are reflected by an object in the path of the waves. These reflected waves are
then sensed by the receiver, which actually calculates the time taken between the transmission
and reception of the signal to find the distance of the object. Figure 5 illustrates the reception of
the ultrasonic sound waves
Fig 5: Receiver circuitry
After setting the pins of I/O port to the receive state, ADC interrupts are generated every 31.25us
and 450 samples are stored for object detection. After the completion of conversion and object
detection, the pulses are re-transmitted.
Whitepaper on Range Finder Solution Using a Single Transducer
Page 7
The following setting is required for the ADC timer in order to receive the signal through a 10-
bit ADC channel.
• Set the ADC timer value, so that it generates an interrupt every 31.25 us
Once an interrupt is received:
• Stop ADC conversion
• Reset the ADC timer after 450 samples are stored
Transceiver:
It consists of a single transducer, which acts as a transmitter as well as receiver. Figure 6
illustrates the transmitter/receiver.
Fig 6: Transceiver circuitry
The receiver circuit amplifies the signal and the amplified output is given to a 10-bit ADC
channel. The output of the ADC is read by the microcontroller and the distance of the object is
calculated as follows:
Object_time (time at which object is detected) = i * 31.25 + 250, where i is index at which object
is detected
Speed = Distance/ Time
Speed (at 20 degree Celsius) = 340m/s or 34000cm/s
Distance in cms.= Speed * Object_time
Distance in cms.= 34000 * ( i * 31.25 + 250)u
Whitepaper on Range Finder Solution Using a Single Transducer
Page 8
4.1. Algorithm
The algorithm used for this implementation of the range finder solution is as follows:
1. Generate ultrasound burst
2. Turn on the receiver by tri-stating the pin connected to the receiver circuit
3. Count the general timer from end the of the 40 KHz burst to the received echo
4. Start and store the ADC samples every 31.25 us
5. Check if an object is present from the stored ADC samples
6. Calculate the distance by using D= S X T (Distance, Speed, Time).
Note: Actual distance=D/2 because D stands for to-and fro distance from object and
speed of sound depends on temperature.
Whitepaper on Range Finder Solution Using a Single Transducer
Page 9
4.2. Flow chart for the range finder solution
N
Y
Set I/O pin connected to rx ckt
to tri-state and other pin to low
Stop General timer
Set General Timer value for generating 10
pulse 40 KHz frequency
Initialize ADC, General
Timers
Initialize UART
Initialize ADC
Start
Tx of 10
pulses over?
A
B
Whitepaper on Range Finder Solution Using a Single Transducer
Page
10
N
Y
N
Calculate distance
Stop ADC timer
Set ADC timer value to 31.25
micro seconds
Is 450
samples
processed?
A
B
Detect the object from
ADC samples
Whitepaper on Range Finder Solution Using a Single Transducer
Page
11
5. Hardware Block diagram
The figure 7 shows the design circuitry consisting of active components such as the LM324, a
diode array and microcontroller, together with the passive components. The 40 KHz signal is
easily generated by the microcontroller but detection requires a sensitive receiver. The signal
from the transducer is amplified by a bandpass-filter/amplifier with the gain of 22, followed by
another bandpass filter/log-amplifier with a gain of 38 and followed by an integrator. The output
of integrator is given to ADC of the microcontroller for detecting the object.
Fig 7: Transceiver circuit.
Whitepaper on Range Finder Solution Using a Single Transducer
Page
12
Operation
Figure 8 shows the complete hardware setup of the range finder solution. Power supply (5V) to
the receiver circuit is provided by the microcontroller. Pin 1 and Pin 2 of an I/O Port are used for
generating the pulses. The output of the receiver circuit is fed into the 10-bit ADC channel of the
microcontroller (uC). Later samples are stored and processed for object detection.
Fig 8: range finder solution setup
Whitepaper on Range Finder Solution Using a Single Transducer
Page
13
6. Sensor details
Specifications of the Maxbotics sensor, used in the implementation of this solution, are as
follows:
• Sound Pressure Level (SPL): 117dB (0dB=0.2n bar)
• Sensitivity (SEN):–60dB (0dB 1V/u bar)
• Impedance:1K Ohm
• Ringing: less than 1mS
• Capacitance: 2400 pF (+/- 20%)
• Operating Frequency: 38KHz to 42KHz
• Drive Voltage: 20V RMS maximum(60V peak to peak maximum @10% duty)
Temperature Range: -40C to +65C (-40F to +150F)
Whitepaper on Range Finder Solution Using a Single Transducer
Page
14
7. Results
Whitepaper on Range Finder Solution Using a Single Transducer
Page
15
Object at 120 cm.
Distance in cms. = 34000 * (i * 31.25 + 250) u ; u = 10^-6
Object at 60 cm
Distance in cms. = 34000 * (i * 31.25 + 250) u ; u = 10^-6
0
100
200
300
400
500
600
700
0 100 200 300 400 500
120 cm
ADC Vtg
(V)
i
ADC Samples
0
100
200
300
400
500
600
700
0 100 200 300 400 500
60 cm
i
ADC Samples
Whitepaper on Range Finder Solution Using a Single Transducer
Page
16
Object at 30 cm
Distance in cms. = 34000 * (i * 31.25 + 250) u ; u = 10^-6
0
100
200
300
400
500
600
700
0 200 400 600 800 1000
30 cm
ADC Vtg(V)
i
ADC Samples
Whitepaper on Range Finder Solution Using a Single Transducer
Page
17
8. References
1. www.freescale.com
2. http://www.maxbotix.com/
3. http://en.wikipedia.org/wiki/Ultrasonic_sensors