You’ve Always Wanted, that started with the January 2015
issue of SERVO) could be enhanced by adding a ranging
laser to his turret. For a variety of reasons, I chose the SF02.
Figure 8 shows it mounted on Arlo’s turret which also
supports an IR sensor, an ultrasonic sensor, a beacon
detector, and a webcam. My goal was to replace the IR
sensor with the SF02.
Arlo’s original IR sensor produced an analog output, so
I was pleased that the SF02 also had an analog option.
Arlo’s original software obtained the distance data with a
10-bit ADC, but the number was scaled to eight bits. I was
worried that eight bits would not be enough for the laser’s
greater range and accuracy, but the SF02’s ability to be
customized made it easy to solve the problem.
Parallax provides a program called the Lightware
Terminal that lets you configure the SF02 in a variety of
ways as detailed by Figure 9. The configuration options
available on the SF02 proved to be exactly what I needed.
The SF02 outputs a voltage between 0 and 3. 3 volts
(with 10 bits of precision) to indicate the distance
measured. You can configure this output so that a full
reading of 3. 3 volts indicates any valid distance. If the
analog output is read with a 10-bit ADC, the resolution can
be exceptional, but obviously it won’t fit in the eight bits
needed to maintain compatibility with my original
I determined that a resolution of one inch was
acceptable for my needs, which means that an eight-bit
byte could hold distance measurements up to 255 inches.
This distance (more than 21 feet) was also deemed
acceptable for an indoor robot such as Arlo. Therefore, I set
the laser’s maximum distance to 6. 22 meters (see Figure 9)
which is 255 inches.
Most ADCs assume their input voltage has a range of
0V-5V. Remember, though, that the output from the laser is
only 0V- 3.3V. Since 3.3/5 is essentially 2/3, we can
effectively make the voltage a full range reading if we
multiply it by 3/2. The reading will still be 10 bits, though,
so we can shift it right twice (or divide by 4) to create the
desired eight-bit number.
Both of these operations together simply multiple the
acquired reading by 3 and divide that
total by 8. This action proved to
produce an extremely stable reading
with reasonable distance and
accuracy. It also shows the
advantage of being able to configure
the maximum range of the laser.
If your robot needs more
accuracy or to be able to measure
greater distances, there are easy
modifications. Making the maximum
range 12. 44 meters will let the laser
measure more than 40 feet, but each
unit in the eight-bit answer
represents two inches.
Reducing the range to 3. 11
meters will improve
the accuracy to 1/2
inch, but you will
only be able to
measure out about
10 feet. All things
considered, the 6. 22
meter range and
one inch accuracy
seems to be a good
Of course, if you want to use a two-byte value for the
laser reading, you can get both longer distances and
The ability to configure Parallax’s laser sensors should
not be taken lightly. As Figure 9 shows, you have many
options. You can specify an offset to ensure, for example,
that a zero distance is reported at your robot’s perimeter.
You can even tell the sensor to smooth any jitter by
providing you with an average of multiple readings. My
experience with the SF02 showed no need for the
averaging, but it is a nice feature when extreme stability is
It is worth mentioning that the light emitted from a
ranging laser can damage your eyesight if you look directly
into the beam. For that reason, you should carefully
evaluate the safety needs of any project that utilizes a laser.
The higher cost of adding a laser to your robot does
not make sense for every application, but it is a viable
option when your situation requires longer distances and
Knowing the advantages and limitations of various
perimeter sensing options can help you improve the
functionality of your next robot. SV
SERVO 11.2015 63