I'll be up-front: this is a project that received more of my time and effort than the results may have justified. Maybe if I put it down in writing, I'll be able to get it out of my system for good. My objective was to see if an array of Ping)))
ultrasonic rangers could be used to determine not just distance, but an (X,Y) position of any object that lay before it -- most importantly -- without any mechanical scanning. I was only moderately successful. Here's what I did.
I first made a holder for three Ping)))s, oriented vertically, with a horizontal spacing of 1.05 inches. With this spacing, I was also able to accommodate a piggy-backed Propeller Backpack and a Proto-DB board, the latter outfitted with some three-pin headers and series resistors to interface the Ping))) to the Propeller chip. Here's a photo of the unit mounted to a BOE-Bot in my experimental setup, along with an inset showing the artwork for the holder:
The idea was to stimulate the three Ping)))s simultaneously, then analyze the timing of the three echoes to determine not only the distance of a subject before it, but its horizontal position as well. One of the first things I discovered is that, since the Ping)))'s SX chip is not crystal-controlled, the actual sonar burst can occur at varying times after the stimulus pulse. For this reason, among others, I decided to block the transmitting transducer in the two outside Ping)))s with foam, in order to read echoes from just the center transducer. You will notice the foam discs adhered with double-stick tape to the transducers in the photo above. The way it works is this:
1. Stimulate all three Ping)))s simultaneously.
2. The two outside Ping)))s don't actually transmit any ultrasound, due to the foam blocking their transducers.
3. Time the response of each Ping))), beginning with the rising edge output of the center one to the falling edge of each.
4. The timed responses give the round-trip distance from the center transmit transducer to each receive transducer.
By analyzing the three times, it should be possible to determine, by triangulation, both the X and Y position of the subject. Here's a diagram that shows the basic geometry:
The equations that govern the X and Y coordinates are as follows:
DL2 = (X + SX)2 + Y2
DM2 = X2 + Y2
DR2 = (X - SX)2 + Y2
DM = aTM / 2
DL = aTL - DM
DR = aTR - DM
and the T
's are round-trip echo times, with a
being a constant of proportionality relating time to distance. After these are computed, each can be corrected for the SZ offset:
D := √(D2 - SZ2)
By subtracting pairs of the corrected equations for the D
's, the Y
terms cancel, and we can solve each difference for X
XLM = (DL2 - DM2 - SX2) / (2 * SX)
XMR = (DM2 - DR2 + SX2 / (2 * SX)
XLR = DL2 - DR2) / (4 * SX)
Obviously, with three Ping)))s, X
is over-specified. So, hopefully, given a set of D
's by experimentation, each equation will yield the same value for X
. Unfortunately, that was not the case, a fact which had me stumped for quite awhile.
You may have noticed the scope leads attached to my setup in the above photo. Each monitored one of the Ping))) signal pins. What it told me was that each timing output included two forms of jitter: a microsecond or two of random noise, plus an increment or decrement of 25 µsec from the dominant falling edge. Twenty-five microseconds just happens to be one period of 40 KHz, the frequency of the ultrasonic transducers. This means that a round-trip distance measurement can bobble by one wavelength, or 0.34" (0.17" one-way). So instead of three over-specified arcs that intersect at a single point, we have three rather broad brush-stroked arcs, whose thickness spans a full ultrasonic wavelength (i.e. ± two half wavelengths) and whose intersection, hopefully, defines a rather small area. By locating the point in this intersecting polygon that satisfies all three equations for X
, we can find the One True X
In the attached Spin program, the search for X
is done by brute force. IOW, X
's are computed for each of several different combinations of values about the three D
's, seeking to minimize their overall difference. The group of X
's that is most tightly clustered wins, and their values are averaged. From that average, Y
can then be computed:
Y = √(DM2 - X2)
From there, a running average of the X
values can be maintained and plotted on a PST screen:
One Spin note: all three Ping)))s are timed simultaneously, beginning at the rising edge of the output from the middle one. This is done with counters for the left and right sensors, and by software alone for the center one, using cnt
I got pretty good, but not perfect, results -- usually within an inch or less of the target's true physical position. As the angle of the target widened away from the normal acceptance cone of the farthest transducer, results got pretty sketchy. But I guess that's to be expected. Nonetheless, the accuracy is probably good enough for, say, following a leader robot at a fixed distance. In any event, I don't plan to pursue this any further. I've gotten what satisfaction I can from this project and need to move on to other things.
As always, questions and comments are invited.