Resistors Light Dark
1 165/47K 0.12V 4.1V
2 330/47K 0.13V 4.1V
3 470/47K 0.16V 4.4V
4 1K/47K 0.21V 4.8V
5 470/100K 0.13V 3.7V
6 330/100K 0.12V 3.0V
7 1K/100K 0.16V 4.5V
Table 1. Resistors vs. readings.
power, so I would pick either
number 3 or number 4 for my
line sensors. While we’re on
the topic of IR sensors, let’s
talk about wheel encoders. I
have not traditionally used
them since I usually like my
robots to blunder about until
they reach their objective, but
recently I’ve been getting
into the Trinity Fire Fighting
competition fun and have
found that I want a bit tighter
control over where my robot is.
But how to make those nifty wheel encoders? If you don’t
want to buy a set and want to DIY (Do It Yourself) like me,
you go looking. A friend sent me a postscript file that he
had to generate pairs of encoder graphics and I went out
looking and found the original author of the code before
(as the author put it) it had escaped into the wild. Here is
the URL for the original encoder wheel generator: http://
— given with kind permission from the author, I. J.
Stefanov-Wagner of Eaton-Peabody Laboratory.
Figure 6 shows the output of the postscript file. If you
are using a Windows PC, then you’ll want to have both
Ghostscript and Ghostview to create the output, then send
it to your local printer. If you are using a Macintosh with
OSX, then you can look at the file by just using Preview and
print out the PDF file it generates.
The link given explains how to modify the postscript file
to change the various characteristics of the encoder disk
output. It is simplicity itself and will allow any kind of
encoder wheel that you could find useful. I have a
derivative encoderdisk.ps that prints out two encoder
wheels of the same dimensions. While you can’t make as
big of an encoder wheel with this file, it makes an identical
pair which can be useful. It is used in the same way but
has another option to print out a center hub of variable
diameter, as well. Rather than print it in the magazine
(which would make a tedious and error prone job of
re-typing it), you can get this file from the SERVO website
at www.servomagazine.com — it is called encoderdisk.ps.
If you are going to do basic odometry using ticks from your
drive wheel encoders, then the single bar disks will do —
you already know which direction the wheels are turning!
If you wish to implement a PID loop, then you will need the
second kind of disk, which is called a quadrature encoding.
If you use two sensors and detect the timing of the
detection for the inner vs. the outer bars, you can tell
which direction the wheel is turning. When using
quadrature encoding, make sure that your two sensors
are in a direct line with each other along a line through the
center of the hub. Figure 7 shows wheels I made with an
encoder disk created from this nifty program.
You can use the QRB-1134 reflection sensor to read
this disk or try for something smaller. I have a handful of
Omron EE-SY124 reflection sensors that are very tiny, about
Figure 6. Encoderdisk.ps output example.
for our IR reflection sensors. But do they work? Did we
read the tables right? The best way to find out is to go to
the lab bench and hook up some meters to our circuit and
check it out. Table 1 shows the results of my tests of this
sensor with our chosen values. My sensor was about 0.15”
above the surface and I used a 5V source.
The first entry in the table is our calculated and
estimated values we got from reading the graphs and
charts. We see that we do get what we expect and it will
work great. CMOS inputs (our microcontrollers) want to see
a logic zero be less than about 1.3V and a logic one to be
more than about 3.7V. Our values fit that bill just fine. But,
I like to experiment since the charts and tables really only
give worst case values or values under very controlled
circumstances. So, I tried a few different values for both
resistors. You can see that the first four value pairs would
all work just fine; the optimal ones are the 470/47K and
the 1K/47K since their logic high values are quite high.
Numbers 5 and 6 do not reliably meet CMOS logic high
levels so they should be avoided. Number 7 would seem to
be a good choice too. What we are seeing here is that if
we have too much current (numbers 1 and 2), then too
much IR is seen by the sensor on the black surface and we
don’t shut off quite enough and our logic high suffers. On
the other hand too, if we limit the current too much in the
IR sensor then it’s affected more by the reflected IR beam
and we can’t pull up as far when we are over the dark
areas. So, to make ourselves less susceptible to ambient
light (all those lamps and camera lights), we want a
reasonable current through the sensor. I like to save battery
Figure 7. Wheels with encoder disks attached.
16 SERVO 06.2008