the time. I had a drawer full of PIC16F630 microcontrollers.
This is a small, 14-pin PIC with no special hardware
features, but a few timers and an external interrupt pin.
It has 1K of Flash program memory and 64 bytes of RAM.
It also has 128 bytes of EEPROM which will come in handy
in the future when I expand things to modify the individual
device address; my current code hard-codes the address
when I program the part. Figure 2 shows what my sonar
board schematic looks like. It is pretty simple.
I use every I/O line there is. I like to include a
Microchip ICD2 type connector on my prototype boards to
make it easy to program the part while it is in the board.
You can see it to the right in Figure 3 which is a photo of
my prototype board. There isn’t much here — a regulator,
10 MHz resonator, and a reset circuit — everything else is
just connectors. Looking at Figure 2, you’ll see a header
(J4) that has Rx and Tx on it. Even though the 16F630
doesn’t have a hardware UART, you can still use CCS’s
software UART on any two I/O lines. This helps
debugging a part like this where you can’t use the
typical Microchip debugger solution – there aren’t enough
pins! I used a Scott Edward’s BPI-216 2x16 LCD display
for debugging and to directly display range measurements
The left side of the schematic has the connector J5
that is used to control a sonar board that was hacked
from an old Polaroid camera. I have a bunch of these
because they have greater range than the smaller units
that are sold. (If you’d like to get a sonar unit for about
$6 off of eBay, check out my now rather ancient website
that details how to do this with three different Polaroid
instant cameras: www.techtoystoday.com/sonar/
dlcsonar.html). Figure 4 shows what one looks like.
Finally, there is J3 which is the actual I/O lines used in my
SCI (Synchronous Communications Interface) bus. This
bus can be daisy-chained between boards by making sure
that every sensor board has two sets of connectors to
THE SOFTWARE: The code
that goes on the slave and
the master controller.
The master and slave are the two parts to the software
that gets the sonar sensor boards to talk to the master
controller. Let’s talk about the slave first. I chose the
PIC16F630 for three reasons: low pin count ( 14 pins);
they’re cheap (under $1.50 each); and I had about a dozen
of them in a drawer. This part had exactly the number of
pins to make a good sensor board. The pinout matches
other 14-pin PICs that have ADC and PWM hardware
modules as well, so many kinds of sensors can be built on
the same board with similar code.
This sensor board needs to only do two things:
1) Communicate with the master over the SCI interface.
Figure 3. Sonar sensor board.
2) Control a sonar unit, store its readings, and convert
I wanted to tell the sensor board when to ping the
sonar so that I could run several of them in sequence
and not have them interfere with each other, so there is
Figure 4. Sonar from a SUN 660 camera.