The encoder I'm using is a PEC09 series (panel mount) but I'm noticing a problem with it using the AdaEncoder library.
Using a PEC11 series (PCB mount) is fine though.
Can anyone tell what changes need to be done on the AdaEncoder library to work with the PEC09 series?
The "output table" is shown below.
Basically, the detent position is different for both.
Here's the required changes on the AdaEncoder.cpp library for those interested.
Look for this line (#302)
if (stateA && stateB ) { // the detent. If we're turning, mark it.
if (tmpencoder->turning) {
tmpencoder->clicks+=tmpencoder->direction;
}
change to:
if (stateA == 0 && stateB == 0) { // The 1/2way point. Flag that we've reached it.
if (tmpencoder->turning) {
tmpencoder->clicks+=tmpencoder->direction;
}
AND change from
if (stateA == 0 && stateB == 0) { // The 1/2way point. Flag that we've reached it.
tmpencoder->turning=1;
to
if (stateA && stateB ) { // the detent. If we're turning, mark it.
tmpencoder->turning=1;
A side effect of this change is PinA which used to be CW is now CCW, and PinB which used to be CCW is now CW.
Just swap your pins in your variable setup/definition.