Switch Bounce in mechanical switch and Debounce Circuit

Sometime, you may find yourself building a fast response circuit with a tactile or mechanical switch and wonder why the circuit is not working properly. This may be due to contact bouncing (also known as chattering) from your switch.

Switch Contact Principle
It seems intuitive to think that the switch making connection is fast, direct and firm. But the real situation looks a little different.

image
Figure 1: Ideal situation of switching signal

image
Figure 2: Real situation of switching signal

In reality, the switch contact between electrically conductive points is established or separated by means of movable mechanical elements. The typical switch makes multiple transitions during the tens of milliseconds required to open or close a connection, due to effects that include age, operating inertia, mechanical design, and the microscopic condition of the switch-contact surfaces. Commonly called “switch bounce,” this behavior is an inescapable fact of life.

Mechanical switches sometimes show their bounce time information in the datasheet, such as the WS-TASV series J-Bend SMT Tact Switch 4.7x3.5 mm from Würth Elektronik.

Debounce Circuit
We would like to share a simple debounce circuit using some common discrete components to create a low pass filter to eliminate this unwanted signal.

1.Adding a filter
A simple RC filter is one of the cheapest and simplest way to make a low pass filter. When the switch is open, the capacitor charges through R1+R2 which causes the voltage rise more slowly. When the switch is closed, the capacitor is discharge through R2 at a controlled rate.
image
When the components for the filter are selected properly and carefully, the switch bouncing is absorbed during the charging and discharging period during a smooth transition.
To calculate the value of capacitor and resistors, you can use the following time constant formula applicable for above circuit:

τ = (R1 + R2) ⋅ C1

ꞇ : time constant in s
R : resistor value in Ω
C : capacitance value in F

The time constant is a balance between the needs to debounce the switch and the required response time of the circuit. During one time constant the voltage will rise to 63% of its final value or fall to 37% of its final value. In both cases, 99% is reached after five time constants.

For example:
Bounce time: specifications give 10 ms
R1 is chosen to limit current, we may take the classical value of 1 kΩ.
R2: we choose two standard values for debouncing: 10 kΩ and 47 kΩ.
Supply Voltage is 5 VDC

Therefore, calculation gives two capacitance values:

C1= τ / (R1+R2 )

Then it proposes two value ranges for this circuit:

  • Solution 1 : R1 = 1 kΩ, R2 = 10 kΩ, C1 = 1 µF
  • Solution 2 : R1 = 1 kΩ, R2 = 47 kΩ, C1 = 220 nF

2.Adding a diode
By adding a D1 diode at both ends of R2, the charging time and discharging time can be controlled separately. This allows the use of R1 and D1 to provide a faster transition time for capacitor charging, while using only R2 to provide a different discharge time for the capacitor, because the diode is in a blocking state in this case.
image

3.Adding a buffer
If the application cannot support undefined values (such as 0.8V and 2.5V), a schmitt trigger buffer with hysteresis may be required. Below figure shows a circuit with different turn-on and turn-off times and additional hysteresis. The response time of the circuit may have to be coordinated with the sampling time of the microcontroller.
image

4.Transient protection
If the switch is located far away or at the end of a long line, protection against overvoltage, ESD, or other transients may be required. This can be as simple as a ferrite bead and TVS diode at the front end of the input circuit.
image

3 Likes

For further information I highly recommend this two part article.
http://www.ganssle.com/debouncing.htm