Pages: [1]   Go Down
Author Topic: AdaEncoder library - for use with Bourns pot PEC09 series  (Read 401 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Sr. Member
****
Karma: 9
Posts: 296
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Thanks.


* bourns.gif (27.47 KB, 700x600 - viewed 26 times.)
Logged

Offline Offline
Sr. Member
****
Karma: 9
Posts: 296
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Never mind... figured it out.

Here's the required changes on the AdaEncoder.cpp library for those interested.

Look for this line (#302)
Code:
if (stateA && stateB ) { // the detent. If we're turning, mark it.
if (tmpencoder->turning) {
tmpencoder->clicks+=tmpencoder->direction;
}

change to:
Code:
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
Code:
if (stateA == 0 && stateB == 0) { // The 1/2way point.  Flag that we've reached it.
tmpencoder->turning=1;

to
Code:
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.
Logged

Pages: [1]   Go Up
Jump to: