Book Analog Interfacing to Embedded Microprocessors
Figure 3.30
Switch bounce.
If the switch is used as a safety interlock on a door, then the bounce may
not be a problem. The software may simply check the state of the switch when
the user tries to start the instrument, and if the switch happens to be open,
you don’t let any motor start. If the operator has to close the door before
being able to reach the start button, then the switch will have stopped bounc-
ing when the software checks.
On the other hand, the switch might be used in an application where you
need to detect each time the switch is pressed. In this case, the contact bounce
will look like multiple switch presses to the software, and they must be filtered
out. The algorithm usually looks like this:`
Detect switch closure.
Wait 10–30 ms.
If switch still closed, then it was a valid closure. Otherwise, ignore it.