You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I cant understand how you read encoder inputs.
There is some array then some weird calcs. There is A and B channels. Generally when A comes you count pulse. Then inside A interrupt you may compare to B state to determine direction. Can you direct me to explanation of this code please
It is a state machine, where +1 or -1 corresponds to valid encoder count updates and 2 represents invalid transitions in the finite automaton that should never happen.
I cant understand how you read encoder inputs.
There is some array then some weird calcs. There is A and B channels. Generally when A comes you count pulse. Then inside A interrupt you may compare to B state to determine direction. Can you direct me to explanation of this code please
const int QEM [16] = {0,-1,1,2,1,0,2,-1,-1,2,0,1,2,1,-1,0}; // Quadrature Encoder Matrix
static unsigned char New, Old;
void encoderInt() { // handle pin change interrupt for D2
Old = New;
//New = PIND & 3; //(PINB & 1 )+ ((PIND & 4) >> 1); // Mauro Manco
New = digitalRead(encoder0PinA)*2 + digitalRead(encoder0PinB);
encoder0Pos+= QEM [Old * 4 + New];
}
Thanks !
The text was updated successfully, but these errors were encountered: