-
Notifications
You must be signed in to change notification settings - Fork 115
Open
Description
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 !
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels