PaulStoffregen / Encoder

Quadrature Encoder Library for Arduino
http://www.pjrc.com/teensy/td_libs_Encoder.html
561 stars 243 forks source link

4 steps in one #26

Closed aster94 closed 6 years ago

aster94 commented 6 years ago

hello Paul,

i m trying your library both on arduino uno and attiny167 for some reason i get 4 steps for every movements of the rotary encoder the encoder is one of the cheap everyone use from aliexpress and i am not using any pull up/down/caps

to have your lib working i am using myEnc.read()/4 do you know why is this happening?

cheers

PaulStoffregen commented 6 years ago

This is normal.

bradanlane commented 5 years ago

Given this is normal, and multiple users have encountered this issue, it may help to make this part of the reader, examples, Etc.

PaulStoffregen commented 5 years ago

It's only normal for certain types of encoders, with detents or "clicky" feel. Definitely not a generalization to all encoders, especially not ones used for sensing motor shaft or linear movement of machines.

bradanlane commented 5 years ago

Gotcha. My installation is using admittedly budget rotary encoders for a user interface.

Mesihas commented 3 years ago

I am having the same issue but the encoder works fine when using the regular Encoder library with 32u4. I am wondering which kind of encoders can work for ESP32Encoder lib. regarding that 98% are from china.

1HighDuke commented 3 years ago

I am having the same issue but the encoder works fine when using the regular Encoder library with 32u4. I am wondering which kind of encoders can work for ESP32Encoder lib. regarding that 98% are from china.

Can confirm that on an Arduino Pro Micro (32u4) it counts multiples of 1 but on a Arduino Nano 168P it counts multiples of 4.

drf5n commented 3 years ago

I am having the same issue but the encoder works fine when using the regular Encoder library with 32u4. I am wondering which kind of encoders can work for ESP32Encoder lib. regarding that 98% are from china.

Can confirm that on an Arduino Pro Micro (32u4) it counts multiples of 1 but on a Arduino Nano 168P it counts multiples of 4.

It is likely the detents interacting with the interrupts -- If the encoder library can use interrupts (32u4?), it will, and will trigger on the rising and falling edges of the A and B signals. If it cannot interrupt on the changes in the signal (168P?), it resorts to polling (probably at the detents) and treats the A and B signals as "Clock" and "Data" and doesn't trigger at the pulse edges.

There's 1 detent per cycle, but 4 pulse-edges per cycle.