Let’s call our inputs SensorA and SensorB. SensorB is 90 degrees away from SensorA.

Rotating in one direction, SensorA pulses first, followed by SensorB 90 degrees later, then followed by SensorA again 270 degrees after that.

Rotating in the other direction, SensorA pulses, followed by SensorB 270 degrees later, then followed by SensorA again 90 degrees after that.

You will see from this that there are two distinct Timing periods, a short 90 degree period, and a long 270 degree period. Let’s call this TimeShort and TimeLong.

If SensorB pulse is followed by TimeLong, the we are rotating in one direction. If SensorB pulse is followed by TimeShort you are rotating in the other direction (you can just as easily use SensorA rather than SensorB here).

Simply start a Timer on one Pulse, save the value on the next pulse, restarting the count. After two Timed counts you can then determine the direction of rotation (and as a bonus, the timed counts themselves will give you the rotational speed). It is probably best to junk the first Pulse from start-up/power-on since you don't know where your shaft is at rest.

Melanie