I got an application where the button press needs to be highly reliable, and rather than depending on debouncing in my own code, I wonder if there are off the shelf devices that'll enable the button function without the need for user debouncing code.
You can use 2 two input NAND gates and a toggling switch. That produces a glitch free, none bouncing signal.
Really? Do you have a schematic? NAND gates are pretty fast so I would expect the bouncing to pass-through. In most applications you don't have to debounce a toggle switch.
Sometimes (most of the time?) a capacitor will work. But, I think the sure-fire way to do it in hardware is with a capacitor and Schmitt trigger.
In some applications debouncing isn't necessary. For example, if you press a button to start a sequence/process that takes some time (say, you press a button to start your car) then a little bounce doesn't hurt anything. Or if the button-press halts a process or breaks-out of a loop, you don't need to debounce.
Connect one of the inputs of the NAND to the output of the other NAND. Add pullups to the 2 not connected inputs. Add the switch to the 2 pulled up inputs. Bounce free!
@Delta_G
A good site should be intuitive and make it easy to find such a so often used function. Jumping into Google to use Forum... I think it is a bad mark for Forum. Google is often like a library just after an eartquake, a big mess.
paulwece:
I got an application where the button press needs to be highly reliable, and rather than depending on debouncing in my own code, I wonder if there are off the shelf devices that'll enable the button function without the need for user debouncing code.
Why would debouncing in software be less reliable than in hardware?
There are a few debounce chips -sorry forgot the numbers - most if not all seem to be surface mount - I researched it last year and have misplaced my notes - needing to write special coded for each button really annoys me - the industrial stuff I worked on had the debounce in hardware and it was very nice and easy
Need to establish something important. Someone already mentioned this earlier in the thread, but may have been missed. Many beginners seem to believe "if I have a button, I need to debounce it, or the circuit will not be reliable". In many situations, debouncing is not needed at all and serves no purpose at all. Beginners are often unable to distinguish this. Is this one of those situations? We need more detail from the OP.
Really true. If an action lasting longer then some 50mS is to be started the bounces, retriggers, will not cause any harm. The first trigger starts it all and ought to be reliable.
I would characterise it like this: does pressing the button always result in the circuit being in the same state "X" afterwards? Or could the button press result in the state being "X" or "Y" or a wider choice of states? If the state after the press is always the same, debouncing is not required.
For example, a circuit where a button marked "on/off" turns on or off a particular function within the circuit. Here, debouncing is required. Pressing the button does not always result in the same state.
But if there are two buttons, one marked "on" and the other marked "off", then no debouncing is required. The "on" button always results in the "on" state, so it does not need debouncing. Same for the "off" button.
Scanning switches every 50ms is more than likely all that’s necessary.
No need to debounce each switch, just wait 50ms.
However, with an input connected to a switch you might want to validate a minimum time.
In environments where there might be pickup from nearby components our input might see a short noise spike.
This can usually be handled by looking for the switch needing to be held for a minimum time period that makes sense, example ~20ms.
It would be a good guess that this situation will never be experienced in a hobby environment.
You would of course need to be careful when safety is concerned such as, starting a 100Hp motor, operating an elevator or turning on an electric fence, ouch ??? .