-
Notifications
You must be signed in to change notification settings - Fork 48
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
How to do software de-bounce? #13
Comments
On that note, if I have noise on my input (I touched the input with my finger) I get a lot of interrupts and they all had the same direction. I find that odd, I'd assume the interrupt would only trigger when there is a change compared to the previous interrupt. Also I'm not convinced the pull-up is working, is there a good way to verify that? |
Interrupts are difficult to handle when sitting so high up the software stack. When an interrupt occurs, subsequent 'interrupts' in the MCP23S17 are ignored until we clear the interrupt flag. This can only be done after the first interrupt reaches our Python process, which is at the mercy Linux's scheduling. Very fast interrupt handling simply isn't possible unless we're programming on the hardware. While we may not be able to get all of the interrupts, we can still often pick up more than we bargained for. In the latest version of pifacecommon we can pass the
Does that solve your issue? |
My problem occurs if the final "off" trigger happens during the settle time. See if this helps explain it:
Preferable I'd want a check in the interrupt routine (PiFace code) after settle time to see if the input is different than what it triggered on and issue another python-interrupt with that new value. In my application I'm dependent on both the high and low state (plus de-bounce) so my application gets stuck in high state. |
I have a similar issue using a relay. I miss some interrupt even if they are slow, it may be a debounce issue, I don't know. I will try the new setting and let you know. |
What's a good way to do a software de-bounce when using interrupts on the PiFace? I've tried with just a sleep in the interrupt routine, hoping it would just pause that thread/process and then do another evaluation after the sleep. It didn't work that well though, sometimes it misses interrupts because of this (like if the return to 0 is within my 100ms sleep then I won't get another interrupt to indicate that the pin is now 0, even if the previous interrupt was 1.
The text was updated successfully, but these errors were encountered: