|The one and only problem you have to account for is that the resting |position of the decoder is VERY close the the leading edge of one of the |pulses.. ie if you bump the decoder slightly or it begins to wear, it would |be all too possible to generate direction-indication pulses in one direction |without even touching the knob.. What about regarding the four states of the encoder as (in CW order), 1X, X0, 0X, and X1? Or, to put it another way... State 0: Wait for first input lo. If second input lo, inc count and goto state 1. Else dec and state 3. State 1: Wait for second input hi. If first input lo, inc count and goto state 2. Else dec and state 0. State 2: Wait for first input hi. If second input hi, inc count and goto state 3. Else dec and state 1. State 3: Wait for second input lo. If first input hi, inc count and goto state 0. Else dec and state 2. Note that since this algorithm will always be waiting for an edge on the input which *DIDN'T* change last, it won't have jitter problems the way the more "normal" algorithm doesn. Further, if the chip being used has suitably-programmable interrupts, the decoding can be interrupt-driven without excessive numbers of interrupts.