Maris [maris@TIAC.NET] says
I have done this using a 68HC11 and some fairly simple circuits. I used a transducer from a boat depth sensor (they can be purchased separately) - this was a 2" diameter piezo-ceramic disc with a resonant frequency of 192KHz.I drove this with a 200KHz square wave from the 68HC11 (easier to generate than 192KHz) -- this drove a mosfet with a step-up transformer connected from the drain to +12 volts. The step-up ratio was 20:1 and it was wound on a ferrite toroid. This produced an output of approximately 500 volts peak-to-peak. This voltage is necessary to produce an adequate output from the ceramic transducer in order to get a strong return echo, especially from a muddy lake bottom.
I had to fiddle with the windings a bit to get the transformer to work right because the ceramic transducer is basically a capacitor and should roughly resonate with the secondary of the transformer. You should look at the drive signal to the transducer with a scope, it should look somewhat like a sine wave. Use some attenuation to your scope in case it might not like a 500 volt input. I tested the transducer at both 192KHz and 200KHz and while the output was greater at 192KHz, it was OK at 200KHz and this was much easier to produce with the 6811.
The transducer should be driven with approximately 25 cycles of the square wave in each burst, maybe more if you need to receive echoes from greater depths.
Now for the receiver: The input for the receiver is taken from the ouptut of the transducer through a 10K resistor so as not to load the transducer when it is being driven. Then this has to be clamped with a pair of fast back-to-back diodes since your amplifier might not like getting the full 500 volts from the transmit pulse going into its input.
For amplification I used a couple of fast opamps. The amount of A/C gain you need will vary with your transmit circuit and transducer, so no figure can be given. Probably something around 500 max gain will be in the ballpark. You will also need a 200KHz bandpass filter, preferrably at the input of your amplifier. A simple LC filter will work well with a Q of around 10. This filters extraneous noise out of the received echo.
The amplifier is followed by a full or half-wave rectifier going into a smoothing filter (just a cap to GND with a parallel resistor). This needs some adjustment also as it affects the speed of response and the noise resistance of the system. This then goes to a comparator which feeds the micro input capture port pin which measures the time between the transmit pulse and the echo.
Since the beam from the sonar pulse spreads as it leaves the transducer, you need to increase the receiver gain with time. The simplest way to do this is with a diode attenuator -- this can attenuate the received signal over a 1000:1 range by changing the current through the diode. The diode forms a voltage divider with a series resisor; as more current is passed through the diode, its resistance decreases, attenuating the signal. The current can be supplied by a DAC controlled by the micro. The rate of gain increase needs some adjustment because of differences in the beam spread of different transducers. I didn't find this to be too critical.
Although this sounds fairly complicated, it's relatively straightforward and the individual sections of the circuit can be set up independently. My system worked well down to approximately 120 feet (I didn't try it beyond that) and had a resolution of approximately 2 inches. The accuracy depends on compensating for the changes in the speed of sound with temperature, the time delays in your system, etc.
Some other things to note:
1. You need to wait approximately 500 microseconds before enabling the input capture after the transmit pulse because the transducer and its housing will "ring" for a while after the transmit pulse ends.
2. The speed of sound is very close to 1500 meters per second. When figuring the distance to the target, you have to figure the round-trip time. The round trip time for 100 feet is approximately 44 miliseconds.
3. If you don't get a return echo after a preset time, you should abort the input capture. Then you should step up the amplifier gain and try again.
Water with floating silt will absorb more sonar energy, air bubbles will absorb a LOT of energy, etc.
Because of possible reflections from floating debris, fish, etc. it's best to send about 16 pulses in succession and pick the 8 most valid echoes (ones that match each other most closely) and average them to get more accuracy and greater resistance to false echoes. You can also check the echoes against the time history of the previous echoes to see if they make sense depending on your application. As an example, if you are looking at a lake bottom 30 feet down and suddenly get an echo from 5 feet, this should be probably be discarded.
Sorry I can't furnish a circuit diagram but this was for a commercial application. However from the above you should be able to brew your own. A PIC should work great for this; I used a 6811 because of other considerations. There are a lot of links on the web which should help you fill in the details.
See also:
Interested:
Questions: