Hi:
I have BEI encoders which make waveforms which look like:
N-1 N 0 1 2 3 4 5 ... ______ ______ ______ ______ B: ______ ______ ______ ______ ___ ______ ______ ______ ___ A: ______ ______ ______ ______ ______ Z: __________________ ________________________
Now the thing is, that because the signals are generated by an opto-mechanical interruptor, one cannot be certain that the edges which appear to line up between the Z pulse and the B pulse train, really are occurring before or after each other.
So a proper logic design to decode the signals into a count that is accurate on a 1/4-cycle basis and can recalibrate itself to an absolute zero position using the Z pulse when running either forward or backward would involve a state machine that resets to zero at some defined condition such as having both A and B high when the Z is high. Then it won't matter if the direction is forward or backward, the count will always become zero within the correct 1/4 cycle, and it also won't matter if the edges of B vs. Z lead or lag each other slightly.
Well I would have thought this is how things would work with the F2812 QEP circuit, because that's what it says it can do. But it doesn't work. It only resets the count to zero (when the EXTCONx.QEPIQUAL bit is set) when the Z pulse happens clearly *within* the 1/4 cycle in which A and B are both high. Ie, the rising edge of Z must occur after A = B = 1. It is edge sensitive to Z rather than condition sensitive of A=B=Z.
That means, the only way Z resets is if my pulses look like this:
____ _____ ____ ____ A: ____ ____ ____ ____ __ ____ _____ ____ __ B: ____ ____ ____ ____ _ Z: _______________ ________________
But as far as I know (only having experience with BEI encoders) is that most encoders produce Z pulses that are a full half-cycle wide, and look like my first diagram above (with the mentioned edge timing uncertainty).
Thus, the TI QEP circuit is bungled because if I did somehow have an encoder that produced pulses like this, I would get an extra count in the forward direction:
Let's say I have a 12 position encoder. My counts should be in the set {0, 1, 2,..., 11}. But I'd get a brief forward count of 12 with this situation, but reverse would be OK (after an initial forward pass):
FWD: 5 6 7 8 9 10 11 12 0 1 2 3 4 REV: 5 6 7 8 9 10 11 0 1 2 3 4 ________ ___________ ________ B: ________ __________ ________ ____ _________ __________ ____ A: ________ __________ ________ __ Z: __________________________________ _________________
I'd say this is not good!
There is another mode if the EXTCONx.QEPIQUAL bit is not set in which the counter resets to zero whenever there's a rising Z edge, regardless of the state of the phases. In this case, I'd get a 1/4 cycle error between the two directions (with a real BEI encoder waveform):
FWD: 6 7 8 9 10 11 0 1 2 3 4 5 REV: 5 6 7 8 9 10 11 0 1 2 3 4 ________ ___________ ________ B: ________ __________ ________ ____ _________ __________ ____ A: ________ __________ ________ ___________ Z: __________________________ _________________
Oh, but actually things could be much worse because if the Z edges lag B, then I get extra glitch counts again!
Ugh!
How could TI do it this way?
Has anybody found this to actually work correctly?
I'll be sending them an inquiry about this tomorrow.
Good night!