Encoder Front Page
SRS Home | Front Page | Monthly Issue | Index
Search WWW Search seattlerobotics.org

Cheap Sonar

Keith Payea

[Editors note: The following is a reprint of a 1993 article about Sonar on the Cheap]

I 've always felt that SONAR--range detection the way bats do it--is an important component of a complete robotics sensor system. The basic idea is that you send out a "chirp" of high frequency sound (usually 40 kHz) and measure the time to receive an echo. Unfortunately, it can be expensive. The Polaroid system runs about $75 per kit. Up until recently, I've used the National Semiconductor LM1812 chip. A complete set of parts is about $40, including the transducers and special inductors. A better deal but still not great.

The LM1812 has two major limitations. First, the transmiter oscillator and receiver filter share an LC tank circuit. This means that even if you use separate transducers, you have to wait for the tank to die out before you can get information out of it. This effectively masks the first 6 to 10 inches of range. Second, I was blowing them up left and right. At $10 each, that gets annoying very fast.

At work, I am involved in a project that involves measuring liquid level with SONAR. The frequency involved is much higher (> 1MHz), but the principle is the same. The designer of the circuit had not bothered with tuned circuits or an actual oscillator since the transducer is a piezo crystal, and will sing quite nicely at its natural frequency if you just "ping" it with a short pulse. They just hit it with something near one had of its natural period.

I realized that the same theory might work: for me. I removed the LM1812 (blown, by now) from its socket and replaced it with a header, to which I had soldered a power transistor and a capacitor. The cap gave me a short pulse to drive the base of the TIP122 power darlington. With this simulation r found that, sure enough the transducer would sing very nicely right at 40KHz. This wouldn't work with the Polaroid transducer, because I don't believe it is as resonant as the piezo type.

Armed with that information, I went back to the drawing board. The result is shown in Figure 1. I replaced the $10 LM1812 with a power darlington transistor, a dual opamp, a comparator, and a few resistors and caps. I had to keep the driver transformer, but I got rid of the oscillator/filter inductor, saving a total of about $15. The circuit is also much easier to tune and debug.

Here's how it works: Your other robot hardware generates a signal called "KEY" which fires the transmitter. It then measures the time until "ECHO" goes high, signalling an echo. You probably want to time out after the equivalent of 10 or 20 feet.

I had been keying the LM1812 with a 250uS pulse. I decided to leave this alone; it gives me a good way to blank the receiver while the transmitter is active. The transmitter centers around Q1 and T1. The "KEY" signal goes to the base through R3 and C3. The values shown give me about a 12 uS on-time for the transistor T1 steps this pulse up by about 5 times to give a nice loud chirp (well, bats would think so). T1 has a capacitor across the secondary so that it acts like a tuned circuit, adding to the resonant effect Once you get the circuit working, T1 should be tuned to give the largest voltage applied to the transducer.

(Click on image for bigger picture!)

The receiver is a little more complex. First, since I only had a single supply to work from, I used an LM336-5.0 voltage reference (D1) to generate a synthetic ground. The signal comes from the receive transducer and goes through two stages of gain (Ula, and Ulb). Because the opamp I chose has a gain bandwidth of 3MHz, I had to use two sections with gains of 10 to get an overall gain of 100 at 40KHz. The caps between stages are calculated to roll of the frequency response somewhere below 40KHz. The filtering doesn't need to be any more complex, because the receiver transducer is so frequency selective all by itself.

U2 is an LM311 comparator with a little positive feedback or hysteresis. The amplified return signal is applied to pin 3. The threshold circuit is a little complicated. First, to keep the polarity of the ECHO signal the same as the LM1812's, U2 is set up to detect the negative side (relative to Vref) of the return signal. Second, objects which are closer return a larger and sooner signal. Objects which are far away take longer, and return a smaller signal. All we care about is the time to the returned signal, so the threshold value varies with time to help reject crosstalk and other spurious noise.

Asuming it has been a long time (more than 25 mS) since the last transmit pulse, the threshold is set to about 5 mV by R15 and R19 with some small side effects from R17 and R18. When the transmitter gets keyed, Q2 turns on, pulling the threshold away from the baseline through R18. With the values shown, it requires about a 2 volt signal to trigger the comparator during this time. Once the key signal goes away and Q2 turns off, C11 begins charging through R17 and R18. This lets tbe threshold voltage slowly rise toward its steady state value. Basically, R18 controls how far the threshold moves, and R17 and R18 together determine how fast it recovers. Because of this, you might want to put, say, 50K pots in at both locations. First set the voltage you want with R18 and then tune R17 until you get the decay you want.

You can also affect this part of the circuit by varying the pulse width of the "KEY" signal. Since the transmitter only cares about the rising edge, the pulse provided can be almost as wide as you want it, up to the equivalent of the minimum distance you want. You could also eliminate C11 and R17, and reduce the value of R18 so that the comparator was effectively "blanked" during the transmit pulse. Without tbe capacitor, the threshold would snap right back to its normal Level with no delay as soon as "KEY" went inactive.

I haven't really explored the long range performance of this circuit because I only really care about six inches to four feet inside the maze. I do plan to try this same scheme on my larger general purpose robot, so I'll tell you then how it worked out.

Sources: DigiKey 1-800-344-4539