Author Topic: Debounce for buttons - what's your favorite technique?  (Read 7576 times)

0 Members and 1 Guest are viewing this topic.

Offline Rufus

  • Super Contributor
  • ***
  • Posts: 2095
Re: Debounce for buttons - what's your favorite technique?
« Reply #25 on: October 17, 2013, 11:52:46 am »
My favorite is posted in this http://www.microchip.com/forums/tm.aspx?m=426510 thread.
 

Offline madires

  • Super Contributor
  • ***
  • Posts: 8183
  • Country: de
  • A qualified hobbyist ;)
Re: Debounce for buttons - what's your favorite technique?
« Reply #26 on: October 17, 2013, 12:58:47 pm »
Before designing any debounce hardware/software check the bouncing characteritics of the push button. Checking the button every 1ms as someone suggested is total overkill. Most buttons work well with 20 to 30ms, i.e. the bouncing happens within that timeframe, but there are also some buttons which require a longer delay. Waiting 500ms might prevent pressed-by-mistake situations but gives a bad feedback to the user ("I'm pressing that damn button for ages but nothing happens."). Since most buttons don't give a tactile response the UI has to provide the feedback, typically a change of the display and a beep optionally (could be annoying).
 

Offline AG6QR

  • Frequent Contributor
  • **
  • Posts: 865
  • Country: us
    • AG6QR Blog
Re: Debounce for buttons - what's your favorite technique?
« Reply #27 on: October 17, 2013, 08:04:16 pm »
Before designing any debounce hardware/software check the bouncing characteritics of the push button. Checking the button every 1ms as someone suggested is total overkill. Most buttons work well with 20 to 30ms, i.e. the bouncing happens within that timeframe, but there are also some buttons which require a longer delay. Waiting 500ms might prevent pressed-by-mistake situations but gives a bad feedback to the user .

I agree with all of that, especially the part about making your debounce technique fit the button.

But the idea of waiting to process a button got my attention.

Usually, with a typical normally open push button, if it has been "open" for a long time, and then you register a "closed" condition, even for a microsecond, you can be absolutely sure the button was pressed.  There's no need to wait at all to start processing the button.  However, you want to wait some time period for things to settle down before you start interpreting subsequent openings and closings as genuine. 

But the reverse isn't true.  If the button has been closed for a while, a detected opening should probably remain open for some time before you interpret it as a real opening, and not just a glitch in the contacts.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf