Manually operated encoders typically generate a
quadrature output consisting of two rectangular
signals which are phase shifted by 90°
.
Each edge of the two phases can be used to generate a count pulse.
⤷ 4 Counts / Period
The direction of the rotation defines what phase is leading.
The graph shows that at each transition:
Type | Observation |
---|---|
Digital | Only one signal changes its state |
Mechanical | Only one switch is operated |
Counting algorithms take advantage of this fact and can
thus provide absolutely bounce free encoder position, if
implemented correctly.
Libraries like the standard Encoder library do exactly this.
Basically this works as one switch will always bounce
at the transition while the other has a stable state.
Because of this, the counter automatically interprets
the bouncing as rapid up / down counts but after the
bouncing stops it will end up at the correct position.
At first glance it may look like it would be necessary to
catch every bounce pulse to determine the correct result.
Despite some libraries using pin change interrupts
to catch them, this is in fact not actually necessary.
Missing a bounce transition is the same as
erasing the transition in the above graph.
Thus if you were to sum up the new ±1
sequence
you'd still end up with the same result as before.