3 ms·
You've seen the scope output for bounces: the signal will often go completely from one extreme to the other, as well as a little bit of noise just after a chang
by codebje 3y ago
You've seen the scope output for bounces: the signal will often go completely from one extreme to the other, as well as a little bit of noise just after a change. A switch might bounce a hundred times, rail to rail, taking 5ms or more to settle. A typical switch probably only bounces 1-10 times over 1-2ms, but unless you plan to test every switch and throw out the worst ones you should plan for the worst.
A capacitor resists change in voltage. Where a switch's change on the oscilloscope usually looks like a steep cliff, adding a capacitor will introduce a curve as the voltage drops. The size of the curve depends on both the capacitance _and_ the resistance between ground and the capacitor: simply adding a capacitor won't give you much of a curve because there'll be very little resistance. You also need to add a resistor to make an RC network.
To handle the worst of switches you want an RC value somewhere around 10ms. What you choose for R and C depends on any other constraints you might have, like power consumption or capacitor size.
Because the RC network slows the transition time a lot you need a Schmitt trigger to convert the slowly curving voltage change into a nice sharp input signal change without allowing noise to ruin everything.
There are other ways to deal with bounces in hardware, too: you can convert the switch's on/off signal into a pulse using a monostable circuit (eg, a 555), you can use a dedicated debounce IC, you can use a flip flop with a SPDT switch, you could blow $50 on a Hall effect switch and use an ADC.
Or you can deal with it in software, which is popular because it's typically easier to find space in a ROM than it is to find space for discrete components on a PCB.