Switch Debouncing

From Mech
Revision as of 17:44, 29 June 2006 by Hwang (talk | contribs)
Jump to navigationJump to search

When a mechanical switch is flipped/pressed, the metal contacts inside may not open or close cleanly. In the microseconds before the switch achieves a good solid connection, the switch's contacts may "bounce" against each other, turning the switch on and off in rapid succession. The result of closing a pushbutton switch is shown below on an oscilloscope:

Bouncing switch.jpg

Even though the bounce only lasted milliseconds, a microprocessor is fast enough to tell the difference, and it will think that the switch was pressed twice when it was actually only pressed once.

We can remedy this problem by debouncing the switch. There are many ways to do this with both hardware and software, such as using a flip-flop to "latch" the signal, using a capacitor to "absorb" the bounces, or programming the software to ignore the bounces.