100nF

Switch debounce calculator

An RC debounce works when the capacitor cannot reach the Schmitt input's threshold before the contact has stopped bouncing. A press discharges the capacitor through R2 and crosses VT− at R2·C·ln(VCC/VT−); a release charges it through R1 + R2 and crosses VT+ at (R1+R2)·C·ln(VCC/(VCC−VT+)). With Würth's 1 kΩ, 10 kΩ and 1 µF on 5 V into an SN74HC14, the soonest crossings are 7.1 ms and 4.1 ms — both inside the 10 ms bounce Würth specifies for its switches; 5.6 µF covers twice the bounce on both edges. Enter the resistors, the capacitor or the safety factor, the bounce time and the input's thresholds to see the delays and the margin.

press: C discharges through R2bounce 10.0 msV_T− 0.9–2.45 V5.00 V07.13 ms soonest22.3 msrelease: C charges through R1 + R2bounce 10.0 msV_T+ 1.55–3.13 V5.00 V04.08 ms soonest14.1 ms
Fig 1 — Capacitor voltage after a press and after a release, with the 10.0 ms bounce window shaded and the Schmitt threshold band. The soonest crossing lands inside the bounce window on at least one edge, so a bounce can flip the output.
Time constants: press (R2·C) · release
10.0 ms · 11.0 ms
Press delay: soonest · typical · latest
7.13 ms · 11.4 ms · 17.1 ms
Release delay: soonest · typical · latest
4.08 ms · 7.62 ms · 10.8 ms
Margin over 10 ms bounce: press · release
0.71× · 0.41×
While held: current · power in R1
5.00 mA · 25.0 mW

A press can reach V_T− at 7.13 ms, inside the 10 ms bounce: a later bounce can recharge the capacitor and, if it climbs past V_T+, flip the output back. Raise R2 or C.

A release can reach V_T+ at 4.08 ms, inside the bounce. The release path is R1 + R2, so raising R2 helps both edges; raising R1 helps only this one.

How this is calculated

Standard: Würth SN015; TI SN74HC14 datasheet; TI SCEA094

τpress=R2C,τrelease=(R1+R2) C\tau_{press} = R_2 C, \qquad \tau_{release} = (R_1 + R_2)\, C
SN015 eq 1 for the charge path; the press discharges through R2 alone.
tpress=R2Cln⁡VCCVT−t_{press} = R_2 C \ln \frac{V_{CC}}{V_{T-}}
Time for the capacitor, starting at V_CC, to fall to the negative-going threshold.
trelease=(R1+R2) Cln⁡VCCVCC−VT+t_{release} = (R_1 + R_2)\, C \ln \frac{V_{CC}}{V_{CC} - V_{T+}}
Time, starting at 0, to rise to the positive-going threshold.
Vout(t)=Vin(1−e−t/τ)V_{out}(t) = V_{in}\left(1 - e^{-t/\tau}\right)
SN015 eq 3; 63 % at one time constant.
C=max⁡(k tbounceR2ln⁡(VCC/VT−,max),  k tbounce(R1+R2)ln⁡(VCC/(VCC−VT+,min)))C = \max\left( \frac{k\, t_{bounce}}{R_2 \ln(V_{CC}/V_{T-,max})}, \; \frac{k\, t_{bounce}}{(R_1 + R_2) \ln(V_{CC}/(V_{CC} - V_{T+,min}))} \right)
The solve: the soonest crossing on either edge at least k times the bounce, using the threshold limits that cross first.
Iheld=VCCR1,P=VCC2R1I_{held} = \frac{V_{CC}}{R_1}, \qquad P = \frac{V_{CC}^2}{R_1}
SCEA094: what the pull-up costs while the switch is closed.

Assumptions

What sets the debounce delay

A mechanical contact does not close once. Würth's support note on the subject describes the spring inside a tact switch reaching its position, experiencing "a reverse acceleration due to the principles of elastic shock", and repeating "several times in succession until the movement is completely damped". Würth specifies the bounce time — "the time between when the product is mechanically switched and when it is fully electrically switched" — as 10 ms for its tact, push-button and detector switches. TI's note says "hundreds of microseconds" for many switches and points out that logic "responds in just a few nanoseconds", which is why every bounce is a separate edge to a microcontroller pin.

The RC circuit turns those edges into one slow ramp. In the circuit the calculator models — Würth's figure 7 — the switch pulls its node to ground through nothing, the capacitor sits behind R2, and a pull-up R1 feeds both. A press discharges the capacitor through R2 with time constant R2·C; a release charges it through R1 + R2. The capacitor cannot follow a bounce that is shorter than a good fraction of the time constant, so its voltage crosses the input threshold once, after the contact has settled. A Schmitt input then turns that one slow crossing into one clean edge and, with its hysteresis, ignores the small recharge a late bounce can produce.

Because the two edges use different resistances they have different delays, and because the Schmitt thresholds have wide limits, each delay has a range. For the SN74HC14 at 4.5 V, VT− can be anywhere from 0.9 to 2.45 V over temperature and VT+ from 1.55 to 3.13 V; the datasheet states that an input "must cross Vt−(min) to be considered a logic LOW, and Vt+(max) to be considered a logic HIGH". The debounce, though, fails at the other limit: the highest VT− is the one a falling capacitor reaches soonest, and if it reaches it inside the bounce time the circuit can still glitch. The calculator reports the soonest, typical and latest crossing for each edge and judges the margin on the soonest.

Switch debounce chart: RC values and the delay they give

Würth's circuit with the capacitors a drawer holds, computed by the calculator above into an SN74HC14 at 5 V. The press delay runs through R2 alone and the release through R1 + R2, so release is always the slower edge; and each has a typical and a latest figure, because the Schmitt thresholds are specified as a range. Design to the latest column, and check it lands after the switch has stopped bouncing.

CPress, typicalPress, latestRelease, typicalRelease, latest
10 nF114 µs171 µs76.2 µs108 µs
47 nF536 µs806 µs358 µs508 µs
100 nF1.14 ms1.71 ms762 µs1.08 ms
220 nF2.51 ms3.77 ms1.68 ms2.38 ms
470 nF5.36 ms8.06 ms3.58 ms5.08 ms
1 µF11.4 ms17.1 ms7.62 ms10.8 ms

Worked example: Würth's 1 kΩ, 10 kΩ, 1 µF on 5 V

Würth's calculation example takes a 10 ms bounce, R1 = 1 kΩ "to limit current", R2 = 10 kΩ, and sizes the capacitor for a 10 ms time constant through R1 + R2 (eq 2): 10 ms / 11 kΩ = 0.91 µF, rounded to 1 µF. Its second solution, R2 = 47 kΩ, gives 208 nF → 220 nF. Into an SN74HC14 on 5 V, using the datasheet's 4.5 V column:

τ_press   = R2 · C          = 10 kΩ × 1 µF        = 10 ms
τ_release = (R1 + R2) · C   = 11 kΩ × 1 µF        = 11 ms

press:   t = τ_press · ln(V_CC / V_T−)
         V_T− = 1.6 V typ     10 ms × ln(5/1.6)    = 11.4 ms
         V_T− = 2.45 V max    10 ms × ln(5/2.45)   = 7.1 ms   ← soonest, 0.71 × the bounce
         V_T− = 0.9 V min     10 ms × ln(5/0.9)    = 17.1 ms

release: t = τ_release · ln(V_CC / (V_CC − V_T+))
         V_T+ = 2.5 V typ     11 ms × ln(5/2.5)    = 7.6 ms
         V_T+ = 1.55 V min    11 ms × ln(5/3.45)   = 4.1 ms   ← soonest, 0.41 × the bounce
         V_T+ = 3.13 V max    11 ms × ln(5/1.87)   = 10.8 ms

for 2 × 10 ms on both edges:  C = 20 ms / (11 kΩ × ln(5/3.45)) = 4.9 µF → 5.6 µF (E12, rounding up)

Würth's values are right for what Würth says they are — a time constant equal to the bounce time, which is also what its eq 3 and 63 % figure describe. Against a 10 ms bounce and the HC14's worst-case thresholds the release edge has 4.1 ms of delay, and a bounce late in the window can push the capacitor past VT+. TI's note frames the same thing from the other end: "time constant should be approximately half of the desired debounce time", so a 10 ms bounce wants a 20 ms delay, and a 10 ms delay "is commonly selected … to give maximum debounce time while preventing humans from noticing the delay". Both rules land on the calculator's solve mode: 5.6 µF for twice the bounce on both edges with these resistors, or a larger R2 and a smaller capacitor for the same times.

Where the debounce model stops being valid

Common debounce mistakes

Further reading