Reading Rotary Encoder

Hi guys,
This has probably been tackled before but I haven’t found anything yet and I’m unfortunately in a bit of a rush.
I have a rotary encoder but unfortunately it’s not the kind I’ve come across before which cycles through the standard 00, 01, 11, 10 in quarters (notches on 00, notches on 01 etc).
Instead it has thin spiderleg conductors which pulse the A and B “switches” slightly out of sync. So it notches on 00 then sweeps across 01, 11, 10 and back to 00 for the next notch.

Now, I’m just looking to write a brief function to give me CW or CCW depending on which order it fires in.
I figured I could write (in basic pseudo):
If A or B high
If A high
Dir = CW
Else
Dir = CCW
else Dir = None

If that makes sense? Doesn’t work though. I thought it’d pick up the riding edge (00→01 or 10) but no luck.
Any tips or pointers?
Many thanks :slight_smile:

Your pseudo code has the problem in that it is detecting "when" something is high, rather than "when it goes high".

Paul

SJMaybury:
Hi guys,
This has probably been tackled before but I haven’t found anything yet and I’m unfortunately in a bit of a rush.
I have a rotary encoder but unfortunately it’s not the kind I’ve come across before which cycles through the standard 00, 01, 11, 10 in quarters (notches on 00, notches on 01 etc).
Instead it has thin spiderleg conductors which pulse the A and B “switches” slightly out of sync. So it notches on 00 then sweeps across 01, 11, 10 and back to 00 for the next notch.

They are the same thing, just the detents are different.
Use standard incremental encoder code and divide the output count by 4 ?

check this - RotaryEncoder/RotaryEncoder.cpp at master · enjoyneering/RotaryEncoder · GitHub