Input push buttons - how long do you debounce for?

Input push buttons - are there some guidelines for 'good' debounce times?
For a momentary button what vales do you use?
For a 'push and hold' button (like say on the radio memory button on a car stereo) what sort of debounce times and delay times do you use.
Not a biggie, just wondering if the collective intelligence of the group could save me some frigging about time....
Thanks
For a momentary button what vales do you use?
For a 'push and hold' button (like say on the radio memory button on a car stereo) what sort of debounce times and delay times do you use.
Not a biggie, just wondering if the collective intelligence of the group could save me some frigging about time....
Thanks
Comments
The time the button is pressed is saved in a variable (btn1) and checked accordingly.
I use the constants Short, Medium and Held to describe how long they are pressed.
if btn1 > Short
xxdoSomething
if btn1 > Medium
xxdoSomethingElse
if btn1 > Held
xxReturnToMenu
Not sure what the actual times are for each, it doesn't take long to adjust the constants to your liking.
Rich H
20ms seems to work well for me with the small tact switches. Don't forget you may want to debounce on key-up as well as key-down, depending on how you design your human interface mechanization.
I have one device which requires a key press AND release before it will do anything - so you can hold the button as long as you want, but it won't do anything until you let go. This requires a debounce on both sides. I run 20ms of 'down' debounce and 20ms of 'up' debounce and it works great.
If I find a switch that needs more than 100ms of debounce, I look for a different switch. Debounce too long, and your device may appear laggy or unresponsive. The brain begins to perceive delays longer than this - remember 100 ms is 1/10 of a second. Think of how long you depress a button on a keyboard while typing: it's usually a very short interval: you strike the key then quickly let go.
Also, you can debounce your inputs with hardware; there are many ways to do it. Although very effective, hardware debounce obviously adds to your cost, weight, and power requirements.
Can you explain more about what problems you run into if you don't debounce on release? I can't see why it would be necessary.
Rich H
Here is a good article about switch debouncing, for anyone who might not already have seen it.
http://www.ganssle.com/debouncing.htm
The 50ms number is a solid one to me. That's a minimum, as a rapid human input would rarely drop below this number. Typing, is one exception I can think of however.
I like the longer times, because I like systems that limit input, because that cuts down on error cases. Where possible, I like to latch things too, so that input is simply ignored, until needed again.
I also think it's good to avoid states on input where possible too. Modal things can get confusing, simply because people don't always remember the state of things, particularly where the input may be complex. Those are like push once for this, twice for that, three times to reset...
The best cases are where the input is repeatable, discoverable, intuitive, consistent. Not always possible, of course, but if possible, preferable.
Another way to look at things is whether or not the response time, or allowable input time, actually adds value. If there isn't any value add, there is a solid case for just insuring that nothing new happens, or that's where "the problem" will be with the input process, means and methods.
Have never had a problem with false switch readings while using this method.
PS - I have also used a spin loop to read a switch until it was high (or low) for 10 consecutive iterations. Also works well.
Example: