Debouncing Inputs

WadeHatler

New member
Your otherwise excellent manuals seem to lack any information on debouncing of mechanical switches. I'd like to see a real discussion of that, as well as code to implement debouncing in the git repository. Everyone who starts using it has to first figure out if it's even a problem that needs solving, and the solution should just be handed to them.
For example, I'm using the 8-HV-INPUTS for RASPBERRY PI board. It says: Transition of any input is causing pin 29 of the GPIO expander to go low. If you do not want to poll all the inputs, you need to write an interrupt handler to detect the change, but doesn't mention if that's already debounced, or if you have to debounce it in your code, and if so, how you would go about it.

If polling, one can assume you have to debounce, but no mention is made of the necessity or how to do it.

I also looked at the schematic, and it doesn't show any evidence of hardware debouncing.
In an ideal world, you would make a Python library that has a function like lib8inputs.subscribe(board, input, func) , which would just call func() when the input changes after debouncing that's handled by the library
 

alexburcea

Moderator
Staff member
Hi

Is a valid topic but for the 8-HV inputs we have a filter at the output side of the optocoupler that acts as a debouncing circuit. That filter is done so you can feed AC voltage into the card inputs. Software debouncing is also an option but we let the user decide his implementation, but our drivers are open-source so anyone can improve them.

Thank you for the suggestions we will consider them.
 

WadeHatler

New member
So it sounds like I don't have to worry about debouncing at all, and I can just handle the interrupt from pin 29 on GPIO and assume it's already debounced.

Is that correct?

Thanks.
 

TonyD

Member
Giday Wade
if you look in this post at the end you will find a Python interrupt handler that can have as a option to debounce the Interrupt.
However in my testing using this routine & having the RPi5 running flat out i found that debouncing the interrupt pin actually slowed the whole process down & i was missing Interrupts cause i could not lower the debounce interval low enough not to miss interrupts & therefore removed the debouncing on the interrupt pin & never missed an interrupt. Give it a try it could be a good starting point for you if you are using Python for an interrupt handler. If you use the code all i ask is you put a note in your code give me a little credit.
Give it a go
Regards Tony Doust
 
Top