-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
#3875 proposed fix for dead spot when reversing #3967
Conversation
I have not accounted for the possibility that some encoders might be wired with closed circuit (pins a and b connected to common) when at rest (the detent resting spot). My encoder is open circuit (both a and b pins are OFF - disconnected from the common) in the detent position. I have simulated what an encoder with closed circuit (a and b pins ON - connected to common) at rest. In this case, this PR does not fixed this dead spot, although it continues to function as before. If what I am calling a closed circuit encoder exists and needs this fix, an added configuration parameter will be needed, since this is my first PR I am keeping it simple and not adding this parameter, unless it is required. |
Is your encoder the same as https://www.adafruit.com/product/377 ? If not, could you point to its datasheet? |
that is the one! |
@dhalbert I have only (board) tested the nrf common-hal side of things (ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c is untested) |
} else if (self->quarter <= -4) { | ||
self->position--; | ||
self->quarter = 0; | ||
if (new_state == 2 && self->quarter != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if a different encoder (with detent logic levels of pin_a=0 and pin_b=0) needs to be supported, this line of code would effectively need to check new_state == detent_decimal_gray_code
where detent_decimal_gray_code = 0. not a hard coded '2'
for now this PR is not accommodating configuration of a detent_decimal_gray_code 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe this is the correct fix. The code shouldn't depend on last state.
re: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c line 164 The property @tannewt Admittedly, the PR's use of property ideas for possible remedies:
thanks, tell me what you are thinking. |
I am going to look at this in more detail but am preoccupied with getting bugs out of the current upcoming release. I can look at this but maybe not for a few days, sorry. |
still on my list, but I need to do a more thorough look at the algorithm. |
@dhalbert thanks for waking up this thread. From my standpoint, I am happy with my local build that fixes the skip. Code in this PR works well in my application, as it solves the skip when fine tuning a setting, up and down. I would address the 'request for change', but it is non-specific on what acceptance criteria could be. Maybe only the name of the variable I have thought on (but not implemented) that other technique that only interrupts on one pin. It is kind of cool, minimal, creative. It could be best for slower or taxed processors. I need to find time to combine that with the concept of settling the state to Let's give ourselves some credit and acknowledge that there will always be noise coming from these (physical contacts, non-optical) encoders and let's face it, they are "relative" not absolute encoders, so what we think of as impossible transitions may well |
I defer to core team members to choose: this PR or go for a different tack. I'll try to help if you give me some direction. |
afterthought: the state machine that we are trying to wrangle here, is required to debounce those physical contacts. That combined with the possibility of missed interrupts, necessitates a really hardened, all possibilities handled, solution. |
I'm going to close this now without prejudice., since this is still under discussion and the approach may change. We can come back to this. |
Slight change in logic for updating the position. fixes the dead spot #3875 when reversing direction of the encoder knob.
Fixes #3875 [edit to link issue]