5-20
|
ni.com
Chapter 5
Counters
Figure 5-18.
X2 Encoding
•
X4 Encoding
—Similarly, the counter increments or decrements on each edge of
channels A and B for X4 encoding. Whether the counter increments or decrements depends
on which channel leads the other. Each cycle results in four increments or decrements, as
shown in Figure 5-19.
Figure 5-19.
X4 Encoding
Channel Z Behavior
Some quadrature encoders have a third channel, channel Z, which is also referred to as the index
channel. A high level on channel Z causes the counter to be reloaded with a specified value in a
specified phase of the quadrature cycle. You can program this reload to occur in any one of the
four phases in a quadrature cycle.
Channel Z behavior—when it goes high and how long it stays high—differs with quadrature
encoder designs. You must refer to the documentation for your quadrature encoder to obtain
timing of channel Z with respect to channels A and B. You must then ensure that channel Z is
high during at least a portion of the phase you specify for reload. For instance, in Figure 5-20,
channel Z is never high when channel A is high and channel B is low. Thus, the reload must
occur in some other phase.
In Figure 5-20, the reload phase is when both channel A and channel B are low. The reload
occurs when this phase is true and channel Z is high. Incrementing and decrementing takes
priority over reloading. Thus, when the channel B goes low to enter the reload phase, the
increment occurs first. The reload occurs within one maximum timebase period after the reload
phase becomes true. After the reload occurs, the counter continues to count as before. The figure
illustrates channel Z reload with X4 decoding.
Ch A
Ch B
Co
u
nter V
a
l
u
e 5
6
8
9
7
5
6
8
9
7
Ch A
Ch B
Co
u
nter V
a
l
u
e
5
6
8
9
10
10
11
11
12
12
1
3
1
3
7
5
6
8
7
9