Ultrasonic Range Finder

Here's a simple yet useful circuit from EDN Magazine. The figures will require an Adobe viewer.

Ultrasonic range finder uses few components

Daniel R Herrington, National Semiconductor, Arlington, TX

An ultrasonic, or sonar, range finder is a common sensor in robotic systems and industrial environments. Even home and automotive uses are possible. A novel sensor design consists of a µC, a few peripheral components, and a pair of ultrasonic transducers (Figure 1). The range-finder module consists of a µC, a transmitter, a receiver, a direct-receive inhibit circuit, and an RS-485 interface. The module's usable range is approximately 4 in. to 16 ft with an accuracy of approximately ±2 in. This performance is sufficient for many industrial, automotive, and robotic uses.

Measuring distance with ultrasonic signals requires a transmitting ultrasonic transducer; a medium, such as air or water; a reflecting surface or object; a receiving ultrasonic transducer; and a time-of-flight measurement circuit. The speed of sound in air at 20°C is approximately 343m/sec, which translates to about 1 in. per 74 µsec. Doubling the time gives you the round-trip speed, which is 1 in. per 148 µsec. Four aspects of the system limit the maximum measurable distance: the amplitude of the sound wave, the texture of the reflecting surface, the angle of the surface with respect to the incident sound wave, and the sensitivity of the receiving transducer. The receiving transducer's direct reception of the sonar pulse—and not the echo—usually dictates the minimum measurable distance. Although you can use a discrete timer circuit to measure the time of flight, a µC can simplify the hardware design. Using a µC makes it easy to store and serialize the data and then transmit it to a PC or other master controller. The COP8SGR µC from National Semiconductor (www.national.com) includes peripheral blocks, such as timers, analog comparators, and a hardware UART. These peripherals reduce the amount of external hardware or internal software necessary to process the sensory data.

In Figure 1, the µC, IC2 , waits for an "address" from a host controller over the RS-485 interface. When it receives the correct slave address, IC2 begins a 250-µsec pulse of 40 kHz to the ultrasonic transmitter circuit. The µC outputs a high INIT signal to charge C1 . During the transmit pulse, IC1 drives audio transformer T1 in a push-pull manner to generate about 40 to 50V p-p across the transducer. In Figure 1, the transmit and receive transducers are the matching MA40B8S and MA40B8R (MuRata, www.murata.com), respectively. At the end of the transmit pulse, the µC brings the INIT line low again and C1 discharges through R1 to the level that voltage divider R1 /(R1 +R2 ) dictates. D3 keeps the current from flowing back into IC2 's PORTC2 (INIT) pin.

The circuit uses the decaying voltage on the REF signal as a reference for the incoming echo (Reference 1). Op amp IC4 amplifies the echo from the receive transducer. After amplification, D1 and D2 rectify the signal to a positive voltage. C2 smoothes the resulting signal, and the circuit sends this preprocessed echo signal to IC2 's onboard analog comparator.

The CMPOUT signal feeds back into IC2 's T1A pin to perform an input-capture operation on the result of the comparison. A positive edge on the T1A pin causes IC2 's Timer 1 to latch the current countdown value in microseconds. Subsequent scaling reduces the 16-bit measurement in microseconds to an 8-bit value that represents distance in inches. The circuit transmits this 8-bit value back over the RS-485 interface, IC3 , to the host controller.

An assembly-code program performs all of the software processing necessary for ultrasonic distance measurement.

Figure 2 shows an example of the three waveforms: REF, ECHO, and CMPOUT. The comparison of the ECHO and REF signals effectively inhibits the large-amplitude signal received directly from the transmitter at time t=0.2 msec. This method allows the minimum measurable distance to be as low as approximately 4 in. This method also eliminates the need for an ADC, as well as the problems associated with defining a threshold value based on some moving average of echo samples.

You can improve the module by adding multiple-echo-detection capability, which allows a single transmitted ultrasonic pulse to recognize two or more objects at different distances (Figure 2). You can also incorporate this capability by having the program store the capture value for the first echo, at time t=5 msec, for example, and then re-enable the input-capture countdown and wait for the second capture at time t=9.4 msec, and so on. Another possible improvement is to add servo control to the circuit using one of the internal timers in mode. You can control hobby servos that you commonly find in radio-controlled toys with a 1- to 2-msec-wide positive pulse every 20 msec. In PWM mode, the µC's timers require the loading of only a high width value and a low width value to generate this type of output signal. If you add servo control, you can use the sonar module to measure distance in a given direction. (DI #2371)


REFERENCE

  1. Ultrasonic Sensor Application Manual, MuRata Electronics North America Inc, Smyrna, GA, www.murata.com.

Disclaimer
How to save and view schematics

 

  --- HOME  ---  Copyright © 2001 WallyWare, Inc. All rights reserved.  --- HOME ---