Quadrature Shaft Encoders Determine the net rotation
State Diagram 00 CW CCW 01 10 11
I. Count up for CCW – Down for CW If (analog(2) > 80 && state == 01) cnt++ ; state=11; If (analog(2) > 80 && state == 00) cnt-- ; state=10; If (analog(2) < 80 && state ==10) cnt++ ; state=00 If (analog(2) < 80 && state == 11) cnt-- ; state=01;
II. Count up for CCW – Down for CW If (analog(3) > 80 && state == 00) cnt++ ; state=01; If (analog(3) > 80 && state == 10) cnt-- ; state=11; If (analog(3) < 80 && state ==11) cnt++ ; state=10 If (analog(3) < 80 && state == 01) cnt-- ; state=00;