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);
}
}
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);
}
}