Switch Debounce in Digital Circuits
We all know how a switch or a push button works, you simply press it to toggle its state. In electronics, switches are used to drive or represent many things, and these are mainly in the form of different voltage level, thus making the system binary, i.e either ON or OFF and in voltage levels High or Low. Thus, these voltage levels (e.g. 5 Volts = High = ON = closed circuit and 0 Volts = Low = OFF = open circuit) helps us to represent the binary logic of 0s (zeros) and 1s (ones).
But a lot is happening under the simple push buttons on our keyboards and various other devices. A simple button is basically two metal contacts that touch under the user’s input, i.e. pressing action on the button. These metal contacts then make the underlying circuit complete and informs the sensing element (in most cases a micro-controller) that the button is pressed.
This action of touching metal contacts physically works in a different manner, i.e. the metal contacts bounce upon each other making the switch on and off for a time after impact from pressing action by user. Thus, if the sensing element is sensitive enough, it registers multiple button press from a single action. This can introduce errors in the system you are using and can hinder a lot of processes.
Thus, to avoid this miss-interpretation of button press, the concept of switch debounce is needed. This helps in registering the switch’s action correctly. Switch debounce can be achieved through software programming as well as hardware circuits’ use. Let’s look into these methods in brief.
Software Switch Debouncing:
In this method, the switch’s bouncing state effect is eliminated using various algorithms and filters. The programmer can design an algorithm with use of shift register and counters such that it will register the switch’s state after a delay. Another method is to use filter algorithms on the sampled input from the switch and determine the state of switch based on the output of such digital filter. All this can make the software slightly inefficient, adding to delay in performance if not implemented correctly.
Hardware Switch Debouncing:
In this category, there are various implementations of circuits which can be used for eliminating the effect of switch debouncing right at the hardware level. The different types of circuits used are:
Use of S-R Flip Flop Latch circuit. The circuit when introduced in the output part of the switch, it will retain the voltage level of the input as the output state. Thus, latching to the input, when change in state is introduced. This method is useful, but adds to the bulkiness of the simple circuit.
Use of R-C circuit. This circuit involves the combination of a resistor and a capacitor circuit to act as a filter to smooth out the output glitch for the switch.
Use of dedicated ICs. There are various Integrated Circuits available in market specifically designed to eliminate the switch bouncing action. These implement the use of combination circuits to eliminate the fluctuating output of the switch.