brianlow / Rotary

Rotary encoder library for Arduino
233 stars 73 forks source link

Quarter step #4

Open jaimelaborda opened 6 years ago

jaimelaborda commented 6 years ago

Hi all,

Do this library support quarter encoder step?

Will be really handly to support this, as the library is really compact and lightweight.

Thakns for supporting!

voneiden commented 6 years ago

Why do you need quarter steps? The state machine works as intended as long as there's one sub step between the emitted steps. The sub step acts as a debouncer and therefore without a sub step, your output will be noisy.

chris-elfpen commented 6 years ago

I have this optical rotary encoder: https://www.alliedelec.com/grayhill-61c11-01-08-02/70217116/ It has clicks, and gives me one count for every two clicks when turning slowly.

chris-elfpen commented 6 years ago

This worked for me:

ifdef ONE_STEP

// one-to-one state transition - ignore disallowed transitions const unsigned char ttable[4][4] = { // 00 01 10 11 {0x00, 0x01 | DIR_CCW, 0x02 | DIR_CW, 0x00 }, {0x00 | DIR_CW, 0x01, 0x01, 0x03 | DIR_CCW }, {0x00 | DIR_CCW, 0x02, 0x02, 0x03 | DIR_CW }, {0x03, 0x01 | DIR_CW, 0x02 | DIR_CCW, 0x03 } };

elif HALF_STEP

(edited: had my CWs and CCWs swapped)