Once upon a time, around 1983, I found a bunch of Polaroid "Sonar One-Step"[TM] auto-focus cameras on sale at a local discount store. Not only are these cameras a treasure-trove of small mechanical parts (springs, motors, gears, lenses, light-sensors, shutters, mirrors, and switches), but they also contain Polaroid's ultra-cool single-transducer sonar ranging board. Polaroid sells a modified version of this board in kit form, but if you can find one of these cameras at a garage sale or thrift store for a few dollars, the modification shown below will allow you to interface it to a microcontroller (PIC, BASIC Stamp, HandyBoard, etc) or a PC. (The modification came from a magazine article, but I can't find the original source - only one of the boards I used it on. I think it may have been a Steve Ciarcia article, but I'm not sure. If anyone knows where it was originally published, please let me know so I can properly credit the source!)
[Disclaimer: To the best of my knowledge, this information is correct. However, if you destroy your sonar, your health, your life, your house, or your planet during the use of these instructions, I take no responsibility. Caveat aedificator.]
First, make sure your board matches the pictures below:
If your board is of the same design, proceed as follows: Using an X-acto knife or other sharp instrument, carefully cut the three traces circled in red, one on top leading from pin 1 of the connector to a trace which parallels the diagonal edge of the board, and two on the bottom. (On the right-hand cut, only sever the horizontal trace connecting pin 10 of the IC to the long vertical trace; don't cut the vertical trace itself!) Then, using a soldering pencil, add the two jumper wires whose ends are circled in green.
Connect it to your computer in a fashion similar to the circuit shown below (from an article entitled "Using the Polaroid Ultrasonic Ranging System", by Glenn Hoffstatter, published in Robotics Age magazine, September 1984.):
You really don't have to use interrupts if you don't want to; you can always just poll the ports. It works like this: You drive the VSW signal high via a +5V signal to the base of the 2N2907A transistor from a TTL-level output port. (The transistor has to be there due to the high current drain on this signal; you can't drive it right off your I/O port!) Some indeterminate time later (generally a few milliseconds), the "XLOG" output goes low (and is inverted to be active-high by the TI2003 open-collector hex-inverter chip), indicating a pulse has been fired by the sonar (actually, a train of many pulses at a number of different frequencies, to help eliminate false detections of other ultrasonic sounds which may be present in the environment). When an echo is detected by the transducer, the MFLOG signal goes low (again, inverted by the TI2003). If you use interrupts, all you need to do is pulse VSW, then wait for XLOG. Start incrementing a counter, and when MFLOG goes active, stop and store the value. Via some creative scaling of your counter value (which will depend on the speed of your CPU, among other things), you can convert the time interval to feet and inches (or meters and centimeters, or furlongs and fathoms, or whatever suits your fancy).
1) While transmitting, the transducer is driven (via a step-up coil) by a pulse of 300 volts or so. While probably not fatal, it can sting like a son-of-a-gun, and it could be embarrassing (not to mention costly) if, as a result of the reflexive twitch, you ended up throwing the whole thing across the room...
2) The sonar board draws a lot of current from the 5VDC supply when transmitting - on the order of an amp or two if I remember correctly - so be sure your power supply is up to the task. I would strongly recommend using a separate supply from the one that powers your computer; just be sure to connect the grounds (commons) together, or it won't work.