Jump to content
43oh

Generic Button Debouncer


Recommended Posts

I implemented Jack Ganssle's State Button Debouncer Algorithm as C/C++ platform independent libraries. This is a fairly robust algorithm that can play nicely with interrupts (if the library is set up to be used that way) and can also work with setups where the button pins are polled on a regular interval instead.

 

The library can debounce buttons on an 8 bit port in parallel and is efficient in that it only requires 14 bytes of RAM per instantiation, is malleable in that the amount of RAM consumed by each instantiation can be reduced if desired, and uses no computationally expensive operations such as multiplication and division to perform the debouncing.  If you would like a detailed explanation of the theory behind the algorithm, feel free to follow the link provided below: 

 

http://www.ganssle.com/debouncing.htm

 

The rest of the documentation can be found inside of the header files within the zipped file below. 

 

EDIT:

 

Updated the button debouncer to revision 1.1.

 

Now instead of specifying pullups or pulldowns are being used for an entire port, you can pick and choose which button pins will have pullups or pulldowns respectively.

 

Also, there is no additional performance or extra RAM penalty for this approach. So, enjoy the extra functionality.

Button Debouncer Rev 1.1.zip

Link to post
Share on other sites

I implemented Jack Ganssle's State Button Debouncer Algorithm as C/C++ platform independent libraries. This is a fairly robust algorithm that can play nicely with interrupts (if the library is set up to be used that way) and can also work with setups where the button pins are polled on a regular interval instead.

 

The library can debounce buttons on an 8 bit port in parallel and is efficient in that it only requires 14 bytes of RAM per instantiation, is malleable in that the amount of RAM consumed by each instantiation can be reduced if desired, and uses no computationally expensive operations such as multiplication and division to perform the debouncing.  If you would like a detailed explanation of the theory behind the algorithm, feel free to follow the link provided below: 

 

http://www.ganssle.com/debouncing.htm

 

The rest of the documentation can be found inside of the header files within the zipped file below. 

Thanks @@Foghorn!

And welcome to 43oh.

Link to post
Share on other sites
  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...