You are right in the case when the counter is to be reset
in the presence of a reference mark.
However the problem is to generate output pulses every N-th
increment of for example a X4 encoder. Let N be 6. The
counter counts 6, 5, 4, 3, 2, 1, 0. Then an output pulse
is generated which is fed back to the Z channel. Let us assume
that the Z index reload phase has been chosen correctly. Then
the counter is reset to 6. It continues counting
5, 4, 3, 2, 1, 0 and again an output pulse is generated.
But now the channels A and B of the encoder (which were for example
low at the time of the first output pulse) are in the inverted
state (i.e. in the example high) and the Z index reload phase
does no longer match. Therefore the counter is not reset and
continues counting 4294967295, 4294967294, 4294967293, ...,
which is the U32 form of -1, -2, -3, .... After that no more output
pulses are generated since TC (=0) is no more reached.
The problem is obvious. Only in the case of values N with N mod 4 = 0
this approach can be successful. But then X4 evaluation of the encoder
signals does not make sense, because a X1 evaluation does the same.
In practice the situation is even worse. As theoretically expected
the signal generation for X4 encoders never works when N mod 4 is
unequal 0. If N mod 4 is 0 it only works sometimes. "Sometimes" means
here randomly every fourth time, when the start phase of the encoder
signals (which is determined randomly by the starting time of the
software) matches the preselected Z index reload phase. Here it does
not matter which Z index reload phase is preselected.
Therefore the example program definitely cannot be used in combination
with X4 or X2 encoders.
There are a series of further arguments why we are not really satisfied by
the approach proposed by the example vi to use the Z index channel in order to reset
the counter. One is that we have encoders with real reference marks, which have
to use the Z index channel themselves to reset the counter. Another is that we
think that it is a rather complicated approach to reset a counter when TC (i.e. zero)
is reached by checking the feedback fed Z index channel from time to time in intervals
given by the internal clock of the 6602 and then reloading the counter value
if certain conditions for the encoder channels are fulfilled.
Therefore (and of course above all in order to deal with X4 and X2 encoders) it
should be possible to reset a counter directly by hardware when TC (zero) is
reached. We suppose the given 6602 hardware is supporting this, particularly
because it is already able to react on TC (by generating output pulses) and because
we think that something like that is already done in continous delayed pulse generation
(and is only hidden in some code that is not accessible for LabVIEW users.)