Issue
148 November 2002
Ultrasonic
Homing Device
Start
Reveiver Ear
Mounting The Transmitter
Software Options
Sources and PDF
SOFTWARE
Each synchronize-then-locate
cycle begins by initializing the counters that keep
track of how many times each ear has had a valid detection
out of the total amount allowed for that cycle. The
example we’re currently analyzing has it looking for
four ping detections out of seven tries. After a delay
of about 6 ms, the sync routine waits for detection
by the left ear. When it’s received, it becomes the
reference that the next detection is compared to.
After the sync pulse is
detected, another 6-ms delay is executed (see Figure
1). After the blanking period, the ears become active
and the software loops, waiting for an ear to hear a
ping. However, it loops 256 times, as controlled in
the chktim routine, so it doesn’t get caught in an endless
loop in case the signal is lost. If no ping is heard
and the 256 loops are used up, the program returns to
the beginning of the cycle and resets.
If an ear hears the second
ping, a pause is inserted, and the other ear is also
checked to see if it too heard the ping. The pause allows
the other ear to hear the ping, though not necessarily
at the exact same time, but rather within a period determined
by the pause. That way, if the transmitter is roughly—though
not exactly—in front of the ears, both ears will hear
the ping at approximately the same time. This is evaluated
as equal.
If after the pause the
other ear does not hear the ping, the ear that did hear
it is determined to be closest to the transmitter and
its ping-detected counter decrements down from four.
If the count is not zero, it means that enough pings
haven’t been detected during this cycle. Each loop cycle
causes the loop total counter to decrement before the
program runs another sequence. This repetition occurs
until either four ear ping detections have been made,
in which case the pings detected counter will count
down to zero, or seven attempts were made after which
the loop total counter will count down to zero.
If the loop total count
reaches zero before the ping detection count, then there
were not four successful detections in the allowed seven
tries. The program then resets and recycles. However,
if the ear does have four detections, it will indicate
so by setting its I/O bit high and then returning to
reset and recycle. You may download the software listing
for this project from the Circuit Cellar ftp site.