Ranging

I've had the joy of working on a really interesting project with a real 3D
CAD expert. Mostly I helped with some math and spewed out ideas, but the
simplicity and the results are astounding. The project is a laser 3D scanner
built for much less than any commercial unit.

The filter value is a threshold value to screen out noise and to set the
final picture to black and white. As the laser line light is intense in the
middle of the line and then falls off to the edges the filter value also
helps narrow the thickness of the line so as we don't capture too much data
for 1 line

And the
result is a "point cloud" that describes your subject. Additional software
will be added to process the points into lines or faces, smooth and reduce
the complexity of the image.

Now, this process can, and has to some degree, been done with a microcontroller.
Here are the potential problems and how they are avoided:

Memory for two pictures and workspace: By processing the data as it comes
rather than after, and using a much faster hardware setup, most memory
requirements are removed. First, process each scan line separately while
turning the laser on and off. If you scan with a camera, use color and
polarization filters to ensure that the camera only sees the laser. Verify
that the spot you picked up on the first scan is the laser by checking to
see if it is gone in the next scan. If you use mechanical scanning (great
for robots since there is generally a shaft turning somewhere that can have
a mirror added to it) then a PLL or other signal filter can be combined with
a modulated laser to reject noise. On each scan line, record only the position
of the laser. This is the time from a horizontal sync pulse or start of scan
to the detection of the laser light. At this point we are only collecting
one data point per scan line. Now, process that scan line, looking for anything
interesting and discard it if it has no value. For example, you might check
to see if the scan line is showing an object to the left or right and at
what distance.

High precision, floating point trigonometry: By reducing the resolution of
the scan and lowering our expectations of the outcome, we can bring the math
within the capabilities of the microcontroller. And actually, most can do
really extensive
math given
some clever programming.

This simple sonar ranging device eliminates a lot of the usual discrete
components by executing complex functions in the software of the microcontroller.
Several times per second, the it generates a few cycles (about 8) of a 40
kHz square wave on an output that directly drives the transmitter element.
It then begins counting "ticks" (fast program loops) which will accumulate
until it either detects a response from the 567 tone decoder or a maximum
period has expired. Immediately following the 40 kHz burst, the output of
the 567 chip is ignored for a short time. This is because the 567 will detect
the burst, and the transmitter element will continue to ring or resonate
for a short time. The 567 tone decoder chip is a phase locked loop designed
to detect when the input frequency is within a certain pass-band. The passband
or detection range is determined by the values of the discrete components
connected to it. This makes it very easy to use. The 567 has been around
for many years, it's cheap, and very useful. Ultrasonic sound waves emitted
from the transmitter element travel through the air, hit an object and bounce
back to the unit where the receiver element detects them. The output of the
receiver is amplified and sent into the 567 chip. The 567 chip drives its
output low when it detects the reflected 40 kHz signal. It will react to
all reflections so it may produce more than one output pulse, but this version
of the code will only register the first one. Several readings per second
are averaged and a value proportional to the detected distance is sent
out via a serial line. The pictures show this connected to a serial LCD.
Be aware that the value is for demonstration purposes only and not been scaled
to any actual units of length like feet or centimeters. You would have to
add your own code or lookup table to display specific units of measure.

The program is designed to run in different modes. The dip-switches are used
to select the mode of operation, such as "normal pulse o/p", "continuous
tone o/p" with is used for tuning the 567 for best detection, "binary serial
o/p", "ascii serial o/p", etc.

The processor has a "serin" pin which can be used as a control input from
another processor. Through this pin, it could receive instructions but this
block of code is unfinished and should be tailored to your application. If
selected, nothing will happen, however, it would be a simple matter to add
code that would allow the input to act as a "logic enable" or to accept various
serial commands. Alternatively, the serin pin could be programmed as some
sort of o/p.

The "serout"
pin is used to output the range test results. In ascii o/p mode, the results
are sent with the LCD-Backpack's value for the "I" instruction (#254) value
first that instructs a backpack-LCD or serial-LCD to enter "instruction mode".
The next byte sent is the address of line2 (#192) which sets the cursor of
the LCD to the start of line 2. Then three ascii digits are sent, MSD first,
center digit, LSD last. If the result is a BCD number less than 3 digits,
spaces are sent to clear those digits from the display. In binary o/p mode,
the straight binary test result is sent.

The transmitter is a 40kHz transducer from Digikey, part# P9895-ND.

The receiver is a 40kHz transducer from Digikey, part# P9890-ND.

The PCB design uses several surface mount components. It saves a lot of hole
drilling and lead bending and clipping. Also, assemblies end up smaller,
better looking and easier to modify or service. Soldering surface mount
(especially the larger variants) is ease

Mechanical ranging is old news, but it is seldom done really well. Here are
a couple "better" ideas.

Bumpers

Bumpers don't
give enough warning because they are generally simple on/off things that
don't stick out very far. One of the most brilliant things I've ever seen
was the design of a "sane" car that had a huge spring "bumper" that looped
out in front of the car and extended a little out to each side. The attachment
points on either side were hinged and then extended so that they crossed
under the car. At that point, they intersected a "joystick" which ran up
to the driver through a ball joint. I've drawn up a little picture and the
red dot is the joystick. The left and right edges of the spring have rollers
which are designed to follow a special curb at either side of each lane.
When they are "squeezed" the result is that the stick is pushed forward,
increasing the speed of the car. Contact with the front of the spring pulls
the stick back, slowing the vehicle. Any misalignment of left to right pressure
causes the car to steer to a corrective course and thereby follow the "curbs."
Dead simple, hopefully reliable, and... proportional. It was designed
by a little girl for her science fare entry and I've never been able to forget
it. I wish I knew where she ended up.

For smaller applications, the connection points can be pots or other rotary
encoders. The difference between the readings indicates front/back contact.
The addition of the readings is proportional to the amount of left/right
contact.

Particle gun

Huh? The idea here is to throw some small object and see if it bounces back.
Won't that mess up the area? Not if you throw particles of the environment
around you. "Throw" air. Look for the returning breeze. Or water, sand, etc...
This is the same method that gives you that weird sense of solid objects
close by when you are not able to see and the hair on your face or arms pick
up the little currents of air that are bounding off the wall you will walk
into just before you have time to stop. This is heightened the more skin
exposed and can be quite accurate when leaving a pitch dark house out the
back door without ones clothes. Don't ask.

It was first suggested to me by one of the few ladies on the PICList but
the only implementation of this I have ever seen was an entry in a robot
"firefighter" competition by an obviously brilliant engineer. He (sorry girls,
it was a he) started off with the fact that the candle needed to be blown
out. Rather than depend on accurate positioning, he realized that he could
just "spit" air in all directions at the given height of the candle. So he
mounted a whisper fan vertically and found an inverted cone-like baffle
that would direct the air to all sides. After setting that up, he realized
that the air from the top was being circulated back to the bottom faster
when the bot was up near a wall. His bumpers became nothing more than flags
and never contacted anything under normal operation. When he ran the 'bot
we realized that another advantage of the proportional sensing of
wall proximity allowed him to go much faster and round the corners without
slowing down because he had some room between first sensing the wall and
actually hitting it. The 'bot had no brains to speak of, it just turned away
from any flag that dropped down. Sadly, the rules of the competition didn't
allow the 'bot to just blow out the candle and keep going; the judges ruled
that it had to actually sense the flame and this 'bot never had that ability!
He did put out the candle faster than anyone else, just about every run.

Capacitive
field

Also known as a stud sensor. Good for short range sensing. They need to be
re-calibrated constantly so you need some other way of knowing that nothing
is in the area at all. I know of two versions:

By Zircon and available for about $10 from any hardware store: The circuit
sets up one oscillator and two one shot multivibrators. The two one shots
are triggered by the oscillator at a constant rate. One multivibrators is
connected to the copper plate, this is a sensor plate. The other multivibrator
connects to a fixed capacitor. The difference between the discharge rates
of the one shots determines the relative strength of the capacitive field.

By GB Instruments
and available at Home Depot for about $10 again. One 8 pin 555 timer chip
connected to the antenna. The second 8 pin chip is a PIC chip, maybe a 12c508.
The 555 outputs a pulse stream. As an object moves toward the antenna the
width of the pulses lengthened. Looks like the PIC chip simply calibrates
the pulse width on startup, and if the pulse width stretched beyond a threshold
,say 40%, it turns on an LED. Can't get much simpler than that.

IR

In a word, unreliable except under very controlled conditions. They get used
in bathrooms all the time to flush the toilets and turn on the sinks. In
a nice SoCal restaurant, while exporting the byproduct of processing my
pre-dinner drink, I kept hearing a sink turning on and off. On the way out
I saw why: A high window was allowing sunlight to fall just on the inside
of the sink at about the point that the sensor was looking. It would warm
up, the sink would turn on, the water spray was enough to cool the sink and
turn the water off again. Anyone who has used a TV remote from any distance
should realize that IR is NOT a viable technology. If you must, see also:

After you find an appropriate page, you are invited to
your
to this massmind site! (posts will be visible only to you before review)
Just type in the box and press the Post button.
(HTML welcomed, but not the <A tag:
Instead, use the link box to link to another page.
A tutorial is availableMembers can
login
to post directly, become page editors, and be credited for their posts.

Link? Put it here:
if you want a response,
please enter your email address:
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.