Tuesday 25 November 2014

Debounce

When we interface a switch with a microcontroller, one end of the switch is connected to ground, while the other end is connected to the pin and to Vcc through a resistor.

So when the switch is open, we get a constant logic level (HIGH). Now as soon as we press the switch, there is a fluctuation in the voltage at the input pin. This is known as bounce.
This can be explained with the following figure.




The figure shows a constant logic level HIGH initially. Now as soon as the switch is pressed, there is a fluctuation as the levels change quickly between LOW and HIGH for a small duration of time before giving a constant value again.

Now this posses a problem, as these changing levels can be interpreted as multiple switch presses by the microcontroller.

Therefore, to overcome this problem, we run another switch press-checking loop within the first checking loop after a small delay (about 40 ms). If the switch continues to be pressed after this small delay, only then is the switch press registered. Else, the fluctuation is discarded. This is known as Debounce.

A practical usage of debounce can be found here:
http://avrlogic.blogspot.in/search/label/5.%20Switch%20Interfacing

No comments:

Post a Comment