I recently bought a few Bourns PEC16 2215F-S0024 rotary encoders on eBay since I'm toying with the idea for a project where I could use some rotary knob as input. Anyway, according to the data sheet, they should have a "2-bit gray code" output. Which would mean that turning the knob left or right should cycle through patterns which differ only by one bit:
I.e. for the one direction
A 0 1 1 0
B 0 0 1 1 ...
There's also a little figure in the datasheet which looks exactly as you would expect.
However, when I test the encoders, I can observe a behavior that is quite a bit different:
A 0 1 1
B 0 1 0 ...
And for the other direction:
A 0 1 1
B 0 0 1 ...
It looks like at the detents, both outputs are open and when turning left/right there are high pulses created on both outputs, where in the one direction, the rising edges are synchronous (but not the falling edges), while in the other direction the falling edges are synchronous (but not he rising edges).
So this should make it possible to detect the direction, but this is clearly no gray code and not nearly the behavior shown in the figure. My guess is that the figure in the datasheet is only valid for the version without detents, but there is no remark and the datasheet is for both versions.