Ultrasonic System

(click photo for full-size image)
The ultrasonic system is a composed of four Polaroid ultrasonic
transducers/ranging modules, an 8-bit microcontroller which supports the
I2C serial bus,
a few 7405 open-collector inverters, and lots of LEDs. The original
goal was to distribute the ultrasonic sensing to multiple controller
board so that up to 32 transducers at a time could be added to the system
while not bogging down the robot's main CPU. On each controller board,
a sequence of DIP switches is used to select the
I2C bus address
of each board.
The ultrasonic transducers/ranging module are the standard off-the-shelf
versions available from Polaroid, modified to replace the thin 9-conductor
cable with a longer and more standard 2x5 header cable (only 9 pins
are used; the tenth hole is plugged to make sure the cables can't be
inserted incorrectly). The LEDs give some visual conformation that
the sensors are working, and the 7405s are needed since the logic of
Polaroid ranging module's ECHO output was apparently designed "upside
down" (see the discussion on ECHO logic below).
The controller board drives the ranging module of each board in
a sequential fashion. It does this in three stages. First,
the module is activated by asserting the INIT and BLNK inputs.
This initiates the transmission of a 49KHz pulse by the module.
Second, the BLNK input is deasserted to enable the detection
circuitry on the module. Normally this circuitry is automatically
disabled by the module until 2.38ms after the pulse is transmitted
to avoid false ECHO detection, but this also means that objects
closer that approximately 15 inches cannot be detected. We've
shortened this delay to about 0.75ms, giving us reliable detection
down to around 4 inches. Third, the INIT input is deasserted to
turn off the module. An external interrupt, caused by a ECHO signal
from the active ranging module, is used to determine the time-of-flight
of the returning sound pulse.
The board stores the most recent time-of-flight readings until
the data is requested by the robot. This information is then
transmitted over the
I2C serial bus.
The original ultrasonic controller board
was breadboarded in summer of 1995 for one ultrasonic module at a time.
It was re-breadboarded in fall of 1996 to support four modules at a
time and was used on Brak through the summer of 1997.
These designs used a
Philips Semiconductor
8XC751 microcontroller and an RS-232 serial interface to communicate with Brak
since there were no other
I2C bus
boards built at the time.
The 8XC751 does not have a built-in USART as do most other 8051 derivatives
(the I2C serial bus replaces it)
so serial I/O is done in software by bit-banging, giving a transmission
speed of about 9600 bps. One wirewrapped version of the circuit
was briefly built in the summer of 1997 before I realize it would be
cheaper and faster to have the printed circuit boards manufactured.
These board were built later that summer and one was used to replaced
the breadboarded version.
The version of the board now in use on Brak uses the
I2C serial bus for communications. However,
difficulty in locating 8XC751 microcontrollers for development caused us
to switch to the
Microchip Technology
PIC16C63 microcontroller in summer of 1998. The devices unfortunately
are not pin-compatible with the 8XC751, so some nasty retrofitting has
been done on the
board to accept the new microcontroller. The PIC16C63 has proved to be
easy to work with and rewriting the software to drive the ultrasonics
and handle the
I2C bus communication was pretty easy.
The final board uses surface mount SOP devices, which are
cheaper (the 74HC05 is 20 cents in SOP and 53 cents in DIP). Since 2/3 of
the inverters are used to drive the LEDs you can save a few dollars
by not using the LEDs and eliminate one 74HC05. But people think the
blinking lights are cool, so I'd leave 'em. The SOPs are also loads
of fun to solder (yeah, uh-huh).
The board's only problem, which is somewhat typical of ultrasonic
ranging modules, is the modules require quite a bit of current to drive
them and the board occasionally hangs when the CPU's voltage is pulled low
by the surging current draws of a firing transducer.
This however is really more of a power supply problem than a board problem,
but you may have to deal with it.
Polaroid used to sell evaluation kits for their ultrasonics for $99. It's
been many years since I bought them so I have no idea what the actual price
is now or even if they still sell them. They also would separately
sell the transducers and ranging modules in bulk (packs of 10) for something
like $150 and $250 respectively, so since Brak will eventually use twelve
sensors it's a better deal if you can buy them this way.
ECHO illogic (or perhaps ill logic)
I can't for the life of me understand why the ECHO logic on the
board is designed the way it is. At least I can't understand
why it wasn't designed the way I want to use it. To explain my
frustration, let me first explain some about the internal circuitry of
the ECHO output. It is an open-collector output, so if you know what that
means you can skip the next paragraph.
An open-collector output is an output which can generate a true logic 0
but not a true logic 1. Most logic devices output logic 0 and logic 1
by driving one of two internal transistors, one which gives the logic
0 and the other the logic 1. One of these transistors is always on,
but never both. The logic 1 transistor is removed in an open-collector
output, which means that when device tries to output a logic 1 the
output pin can do nothing. There is no electric circuit without the
logic 1 transistor and with the logic 0 transistor off. This logic
level is sometimes referred to as "logic Z". To complete the circuit, an
external pull-up resistor to +5VDC is needed to give a logic 1. What is
the point of all this, you ask? Well, open-collector outputs can be
used to build a "wire-OR" connection by connecting many open-collector
outputs together with one pull-up resistor to form a single output.
If all devices output a logic Z, the pull-up resistor makes the single
output a true logic 1; if any one device outputs a true logic 0, the
single output is a true logic 0. If you try doing the same thing with
a "normal" output, the combination of logic 0 and logic 1 outputs would
cause a small short-circuit.
Anyway, the problem with the ranging module is that each module
outputs a logic 0 when it is inactive or waiting to detect an
echo; it only outputs a logic Z when it detects an echo.
This means the ECHO outputs from each module cannot be wire-ORed together
to give a single ECHO signal since at least one module is always
inactive. Remember, the wire-OR works when all device are normally
outputting logic Z. The ranging modules are just the opposite.
Hence the 7405 devices, which contains six open-collector inverters.
The ECHO output from each ranging module is inverted to give the
correct behavior for a wire-OR design.
Now, this might cause you to ask two other questions: (1) doesn't each
ECHO output need a pull-up then before going into the 7405?, and (2)
why are you wire-ORing things in the first place? The answer to (1) is
"No", since these logic devices will treat an unconnected input as though
it were a logic 1. So logic 0 in gives logic 1 out, and logic Z in gives
logic 0 out. The answer to (2) could be "Well, the wire-OR seemed like
such a neat idea I just needed to try it", but it really goes back to
the original design for the ultrasonic controller which supported six
ranging modules on a 24-pin Philips 8xC751 microcontroller. The available
I/O pins at that point were very precious and without the wire-OR I would
need six INIT outputs plus six ECHO inputs plus one BLNK output plus
one POWER output, so I was already at 14 I/O pins used. In addition,
the ECHO outputs needed to cause an interrupt on the microcontroller and
the 8xC751 didn't have six interrupt input pins. This alone was the
major motivation for using a wire-OR.
Parts List
| Part number | Description | Qty | Price |
| Polaroid |
| N/A | Polaroid ultrasonic evaluation kit |
2 |
$99.00 |
| Digikey |
| PIC16C63-04/SP-ND | Microcontroller,
I2C interface |
1 |
$7.73 |
| SN74HC05 | Inverter, hex O/C, SOP-14 |
2 |
$0.20 |
| Mouser |
| 163-5008 | DC power jack, 1.3mm |
1 |
$0.73 |
| 154-UL6641 | PCB modular jack, RJ11, 6 position/4 contact |
4 |
$0.87 |
| 73-XT49S400-20 | Crystal, 4MHz, HC-49/US |
1 |
$0.73 |
| 571-23825713 | IC Socket, DIP-28 0.300" thru-hole |
1 |
$0.19 |
| Jameco Electronics |
| 67811 | Header, 5x2 0.100" shrouded |
4 |
$0.29 |
| 101856 | DIP switch, 3 position |
1 |
$0.25 |
| 97851 | Resistor pack, 330, one common, 10 pins |
1 |
$0.27 |
| 24660 | Resistor pack, 4.7K, one common, 10 pins |
1 |
$0.27 |
| 28628 | Transistor, 2N2222 NPN, TO-92 |
2 |
$0.10 |
| 34761 | LED, green diffused |
4 |
$0.09 |
| 34796 | LED, red diffused |
4 |
$0.08 |
Board designs
- V1.x Schematic in Adobe PDF (21Kb)
- V1.x Schematic in PostScript (115Kb)
- OrCAD Schematic files and libraries
- Gerber 274-X format
Software (includes source code, project files, and Intel HEX-format files)
Tools (programs you may need)
|