My sonar is working on my bench. It's good up to about 2 feet, which is all I'll need for my robot. I suspect I'll be able to improve the range after I experiment some. I'm using a PIC16F84 (10 Mhz), an L293D "push pull 4 channel driver", an LM339 "quad comparator", 2 ultrasonic transducers "251-1603" and a bunch of resistors. I suspect I'll need to tweak things a bit before it'll work reliably on my robot. The transducers were $6.20 each from Ciruit Specialists. They came with copy of the first page of the Mouser Electronics data sheet. The L293D came from Ben Wirz, www.wirz.com. The PIC came from DigiKey. The LM339 came from Radio Shack. Except for the transducers, the parts were ones that I had on hand. The PIC generates a pulse of 16 cycles at 40.3 Khz. More cycles should improve the range. The PIC didn't have enough oomph for the transducers, so I use half of an L293D motor driver chip (err, transducer driver chip). It uses a crude 20 volt power supply (2 somewhat used 9 volt batteries and 2 D cells (they were handy)). There are 3 wires from the PIC to the L293D, enable, +pulse and -pulse. The -pulse is just the +pulse inverted. All the logic circuits are running at 5 volts. The input transducer is connected to one of the comparators in the 339. I use the resistors to bias the circuit so that the 339 is off with no signal. One side of the transducer/comparator has a voltage divider made out of two 2.5Kohm resistors. So that pin is at 2.5 volts. There is a 470Kohm resistor across the transducer and a 10Mohm resistor to ground. So with no signal, the other transducer is about 2.4 volts. All these resistor values were based on what resistors were handy. They probably aren't close to optimal, they're just the ones that worked first. I'm open to better ways of doing the input side. I suspect a little tuning will dramatically improve the range. The PIC only enables the driver chip while sending the pulse. When not enabled, the driver chip is "high" impedance. If it is high enough, I'll be able to use the same chip to recieve the echo. The transducer rings for a bit after sending the pulse, so the minimum range that way would be 6 inches, unless I can dampen the ringing. On the bench, I've been cheating. My PIC code doesn't do anything with the comparator output yet. I've been looking at the output with an oscilliscope. You'll note that a complete circuit only needs 6 PIC I/O pins. So this could run on an 8 pin PIC. The I/O pins are: +pulse to driver -pulse to driver enable to driver from comparator serial in serial out That is assuming asynch serial I/O. Since -pulse is an inverted +pulse, it could be generated with an inverter instead. This would save a PIC I/O pin. There are unused comparators in the 339 that could be used as inverters. So a 12C508 could use one of the 3 wire serial protocols, if needed. Life's been hectic recently, so I may not spend more time on this project for a few more weeks. So don't be surprised if I'm slow responding to email. There is more to do to make it work, but the basic concept certainly works. -- paulh@hamjudo.com http://www.hamjudo.com The April 97 WebSight magazine describes me as "(presumably) normal".