Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incompatible encoders #12

Open
ruchuf opened this issue Mar 17, 2024 · 0 comments
Open

incompatible encoders #12

ruchuf opened this issue Mar 17, 2024 · 0 comments

Comments

@ruchuf
Copy link

ruchuf commented Mar 17, 2024

Hello,

I had a problem getting three different encoders working with your library. It's the kind of encoder, which contains pullups and capacitors for immediate use. Checked the encoder with oscilloscope, all three are working fine, without any chatter/bouncing, perfect squares. I tested them with an esp8266, a bluepill and a nano, but no success.

Then I dived into your source, and found out, that all this encoders are not compatible with the current encoder logic.
The encoders keep in idle state both pins high, and produce the following states, when turning one step clockwise:

11
10  
00  <- this change triggers interrupt
01 
11  <- this change triggers interrupt

and when turning counterclockwise, it will look like this:

11
01  <- this change triggers interrupt
00
10  <- this change triggers interrupt
11

this leads to the consequence, that the current switch-statements in the readAB() method do not trigger.
When I changed it to:

  case 0b1100:  // case 0b0011: 
     _counter++;
    break;
  case 0110:  // case 0b1101: 
    _counter--;
    break;

it triggers.

Currently I struggle however with the two respective four cases statements in your code, as for me one statement is enough, to get 1 count per step/click. With two statements i receive two counts on all tested platforms.
From the core logic four statements make no sense at all, as the irq-handler is tied to pin A, so there are not more than two possibilities, as changes on pinB are meaningless.

I would like to create an pull-request for a more general solution, but I would like to understand before, if I am on the right way, or if I miss some aspects of other hardware.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant