What is Switch Bouncing?
When we press a pushbutton or toggle switch or a micro switch, two metal parts come into contact to short the supply. But they don’t connect instantly but the metal parts connect and disconnect several times before the actual stable connection is made. The same thing happens while releasing the button. This results the false triggering or multiple triggering like the button is pressed multiple times. Its like falling a bouncing ball from a height and it keeps bouncing on the surface, until it comes at rest.
Simply, we can say that the switch bouncing is the non-ideal behavior of any switch which generates multiple transitions of a single input. Switch bouncing is not a major problem when we deal with the power circuits, but it cause problems while we are dealing with the logic or digital circuits. Hence, to remove the bouncing from the circuit Switch Debouncing Circuit is used.
What is Software Debouncing?
Debouncing occurs in software also, while programming programmers add delays to get rid of software debouncing. Adding a delay force the controller to stop for a particular time period, but adding delays is not a good option into the program, as it pause the program and increase the processing time. The best way is to use interrupts in the code for software bouncing. Arduino have code to prevent the software bouncing.
Switch Debouncing Methods
First, we will demonstrate the circuit without the switch debounce.
You can also see the waveform in oscilloscope while push button in bouncing. It shows that how much bouncing has occurred during the switching of the pushbutton.
There are three commonly used methods to prevent the circuit from switch bouncing.
- Hardware Debouncing
- RC Debouncing
- Switch Debouncing IC
1. Hardware Debouncing
In the hardware debouncing technique we use an S-R flip flop to prevent the circuit from switch bounces. This is the best debouncing method among all.
Components Required
- Nand Gate IC 74HC00
- Toggle Switch
- Resistor (10k -2nos.)
- Capacitor (0.1uf)
- LED
- Breadboard
Circuit Diagram
Working of the Hardware Debounce Circuit
The circuit is consists of two Nand gates (74HC00 IC) forming a SR flip flop. As you can see in the circuit diagram whenever the toggle switches to the A side the output logic gets ‘HIGH’. Here, we have used an oscilloscope to detect the bouncing. And, as you can see in the waveform given below, the logic is shifting with a slight curve rather than bouncing. The resistors used in the circuit are pull-up resistors.
Whenever, the switch is moving between the contacts to create the bounce, the flip flop maintains the output because the ‘0’ is fed back from the output of the Nand gates.
2. R-C Debouncing
The R-C is defined by its name only, the circuit used a RC network for the protection from switch bounce. The capacitor in the circuit filter the instant changes in the switching signal. When the switch is in open state the voltage across the capacitor remain zero. Initially, when the switch is open the capacitor charge through the R1 and R2 resistor.
When the switch is closed the capacitor starts discharging to zero hence the voltage at input terminal of the inverting Schmitt trigger is zero, so the output becomes HIGH.
In the bouncing condition, the capacitor stops the voltage at Vin until it reaches to Vcc or Ground.
To increase the speed of RC debouncing we can connect a diode as shown in the below image. Thus, it reduces the charging time of the capacitor.
3. Switch Debouncing IC
There are ICs available in market for switch debouncing. Some of the debouncing ICs are MAX6816, MC14490, and LS118.
Below is the circuit diagram for switch debouncing using MAX6818.
So here we learned how push buttons create Switch Bouncing effect and how it can be prevented by using Switch Debouncing circuits.