Hardware Reference
In-Depth Information
By far the most common type of encoder is known as the incremental type, which gives an
indication of the fact that the control has been moved and in what direction it has been
moved. Encoders are often classiied by how many steps there are in one rotation. For
switched encoders this is normally between 8 and 16 clicks per rotation. Some encoders also
incorporate a central switch into the rotary control that is activated by pushing down.
Applications for these types of controls include menu selection, volume control and switch-
ing through a large set of values. he point is that the controls themselves provide very little
feedback on the exact angle they are at, leaving it to the application hardware and software to
provide it in an appropriate manner.
The Encoder Output
In order to use an encoder in any project you have to make sense of the signal it produces.
here are two signal lines from each encoder and a common line. he signals are either con-
nected to the common line or not by the internal switch, and normally the common line is
connected to ground. he signals therefore are simply on and of, but they are phase shifted
by 90 degrees from each other; the technical term for the signals is a quadrature output. Take
a closer look at these in Figure 15-1. he two signals are normally called Ø0 and Ø1 although
they are sometimes called A and B. his sort of diagram is called a timing diagram, time from
left to right, logic level up and down. his shows what happens when you rotate the shaft
clockwise. Looking at the two signals you will see there are four diferent combinations of
high and low from the switch; each stable region between the transitions is marked with a
letter on the diagram. One very important thing to notice is that only one of the outputs
changes at any time; this sort of sequence is known as a Gray code after its inventor Frank
Gray, and is used so there is never any confusion over what is being indicated, or if there is it
is only between adjacent regions. Underneath the timing diagram is a list of each stable state
of the output switches for clockwise and anticlockwise rotation. So you will see that you can't
tell very much from just looking at the outputs of the switch; you need to know a bit about
the history - that is, what state they were in before.
his is all well and good but you have to take another thing into consideration, and that is
contact bounce. When any mechanical contact makes or breaks it does not do it cleanly; that
is, the transition from on to of is not a nice simple signal as is drawn on timing diagrams.
Imagine dropping a table tennis ball onto a hard table; the ball doesn't just hit the table and
stop, but it bounces in a sequence of ever shorter bounces. he same thing happens to
switches, and if the computer were to look at the switch often enough it would see a series of
rapid on/of changes; this is known as contact bounce and afects all mechanical switches to a
greater or lesser extent. he duration of the bounces might be 20 to 200 mS or even longer in
some cases. Most of the time this is not a problem because the rest of the code ensures that
the switch is not looked at so frequently, but in some cases it is important, especially ones
where the code is doing little between looking at a switch.
Search WWH ::




Custom Search