Teensy 4.1 Encoder library no interrupts incrementing by 4 w/ Bourn rotary encoders

  • Thread starter Deleted member 70062
  • Start date
D

Deleted member 70062

Guest
Hello, I am using some Bourns PEC11L-4120FN0020 rotary encoders as per the recommended schematic in the data sheet connected to a Teensy 4.1 using the PJRC encoder library with no interrupts.
The problem I am facing is that the encoders will increment by 4 instead of 1 each time they are incremented or decremented. I believe this is a software issue I am overlooking because I have played around with capacitor and resistor values in the debouncing circuitry with no change.


[moderator edit: source code removed]



PEC11L_excerpt.png
 
Last edited by a moderator:
I believe this is a software issue

It's a well know hardware feature, or "issue" depending on your point of view.

The hardware has "click" detents on every full cycle of the quadrature waveform. Since they're quadrature (quad = four) you get 4 changes counted, because the signals really do change every 90 degrees of the waveform or 4 times as it rotates between each detent.

Solution is simple, just divide by 4 if you only wanted to count the clicks rather than the actual quadrature waveform changes.
 
If you buy the version without detents so it turns smoothly, you'll see the software really is working as it should and you'll get 60 or 80 counts (depending on which resolution you buy) per 360 degree turn. 4 counts per pulse is the correct software behavior for quadrature signals.

1747626469193.png
 
Back
Top