By John Blankenship and Samuel Mishal
Many HMs communicate using a serial protocol (SPI,
I2C, etc.) allowing a microcontroller (µC) to do a
lot more work than would be possible with the
limited number of I/O pins it has. Another major advantage
provided by HMs is concurrent processing. To control
multiple servomotors, for example, a µC would have to
constantly generate pulses to keep each motor correctly
positioned against a load. A µC that has interrupt timers
can achieve this, but the necessary programming is more
complicated. Remember too, that the more tasks the µC
has to perform, the less time it has to dedicate to each
process. HMs provide a solution for the above. Once
they are told what to do, they do it in the background
concurrently, freeing the µC to be able to manage multiple
tasks that it may not be able to achieve (simultaneously) by
itself. The HMs themselves are often a µC wired together
with some additional circuitry in a small package.
In a recent project, we built a scale model of a space
station to experiment with attitude control (using digital PID
methodology). An accurate measurement of the heading of
the model station was needed. To do this, we needed to
measure the amount a disc (modeling the station) rotated
(clockwise or counter-clockwise). A very accurate method
for achieving this is quadrature encoding. There are
numerous websites that sell ready-made quadrature
encoders for industrial and other purposes. Unfortunately,
besides being very expensive, many of these devices are
bulky and are not suitable for most hobby projects. We are
going to show a way to create a cost-effective, practical,
and versatile Quadrature Encoder helper module.
receiving infrared light from an infrared LED, thus creating
a data pair of [00]. If the wheel turns counter-clockwise
(CCW), the right sensor will be uncovered (on=1) while the
FIGURE 1. Moving CCW generates these sensor states.
Principles Of Quadrature Encoding
The image in Figure 1 represents a wheel
composed of equal sized spokes and openings.
The two dots on the vertical spoke represent
two infrared sensors. In the current position,
both sensors are blocked (off=0) from
TABLE 1. Quadrature state transition sequence.
Moving CCW (left) Moving CW (Right)
Both blocked (00 = 0) Both blocked (00 = 0)
Left blocked, Right clear (01 = 1) Left clear, Right blocked ( 10 = 2)
Both clear ( 11 = 3) Both clear ( 11 = 3)
Left clear, Right blocked ( 10 = 2). Left blocked, Right clear (01 = 1).
Then repeats Then repeats
SERVO 02.2009
59