Teensyduino encoder library "provides 4X counting mode" ?

mikemontauk

Active member
Hi, I am using an encoder and the values returned are skipping by 4 (each detent increments the value by 4). I understand this is because the encoder has quadrature output, however, the Teensyduino encoder library "provides 4X counting mode" correct? How do I engage the 4x counting mode?

My circuit is on a pcb with the bourns recomended circuit so I am confident this is a software question. I could divide by 4, but I want to use the library functionality if it it is available.


Bourns Encoder Cat. No. PEC12R-2225F-N0024
Teensy LC

Code:

#include <Encoder.h>
Encoder knobLeft(12, 22);
void setup() {
Serial.begin(9600);
Serial.println("Encoder Test:");
}
long positionLeft = -999;
void loop() {
long newLeft;
newLeft = knobLeft.read();
if (newLeft != positionLeft) {
Serial.print("Left = ");
Serial.print(newLeft);
Serial.println();
positionLeft = newLeft; }
if (Serial.available()) {
Serial.read();
Serial.println("Reset both knobs to zero");
knobLeft.write(0);
}
}
 
Thank you MatrixRat. I will try implementing the EncoderTool library from luni64.

I added my schematic - maybe I executed the example from Bourns incorrectly.

261542606_627250068692379_4892696950666499573_n.png
 
How do I engage the 4x counting mode?
The encoder library is, by design, operating in 4x counting mode: "The library updates its count at each change, which is often called 4X counting". It's not a mode you can select.
I just divide by 4 to count the detents.

Paul
 
Back
Top