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.
Check a chosen capacitor against the bounce time, or solve for the capacitor that gives a safety factor over it on both edges.
Where the Schmitt input flips. The SN74HC14 presets use the datasheet's min/typ/max at 2, 4.5 and 6 V over the full temperature range; the calculator finds the soonest crossing from the limits, not the typical. Custom takes single values for V_T+ and V_T−.
The pull-up supply. The HC14 table is at 4.5 V; a 5 V design uses that column with a little margin in hand.
From the supply to the switch. SN015 uses 1 kΩ "to limit current"; it carries V_CC / R1 the whole time the switch is held.
Between the switch node and the capacitor. Sets the press delay on its own, and with R1 the release delay.
The debounce capacitor.
The contact's bounce time from its datasheet. Würth specifies 10 ms for its tact, push-button and detector switches; TI's note says "hundreds of microseconds" for many switches. Use the datasheet, or measure with a scope.
SN015 §3.3: a diode across R2 charges the capacitor through R1 alone, so the release is fast and only the press is debounced. Useful when release latency matters and the release bounce is handled elsewhere.
- 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
- SN015 eq 1 for the charge path; the press discharges through R2 alone.
- Time for the capacitor, starting at V_CC, to fall to the negative-going threshold.
- Time, starting at 0, to rise to the positive-going threshold.
- SN015 eq 3; 63 % at one time constant.
- The solve: the soonest crossing on either edge at least k times the bounce, using the threshold limits that cross first.
- SCEA094: what the pull-up costs while the switch is closed.
Assumptions
- The capacitor is rested before each edge: at V_CC before a press, at 0 before a release.
- The switch contact has no resistance and the input draws no current; SCEA094's leakage drop is ignored, which holds below about 100 kΩ for an HC14.
- The SN74HC14 presets are the datasheet's full-temperature limits at 2, 4.5 and 6 V. A 5 V design uses the 4.5 V column.
- The margin is judged on the soonest crossing — V_T− at its maximum for a press, V_T+ at its minimum for a release — because that is the unit that glitches.
- The bounce time is taken as given. Würth's 10 ms is its specification for its own switches; other contacts differ by an order of magnitude either way.
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.
| C | Press, typical | Press, latest | Release, typical | Release, latest |
|---|---|---|---|---|
| 10 nF | 114 µs | 171 µs | 76.2 µs | 108 µs |
| 47 nF | 536 µs | 806 µs | 358 µs | 508 µs |
| 100 nF | 1.14 ms | 1.71 ms | 762 µs | 1.08 ms |
| 220 nF | 2.51 ms | 3.77 ms | 1.68 ms | 2.38 ms |
| 470 nF | 5.36 ms | 8.06 ms | 3.58 ms | 5.08 ms |
| 1 µF | 11.4 ms | 17.1 ms | 7.62 ms | 10.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
- The bounce time is the switch's, not a constant.Würth's 10 ms is a specification for its parts; TI's "hundreds of microseconds" is a different class of switch. A relay contact or a worn toggle can bounce for tens of milliseconds. Take the number from the datasheet or a scope, and size for the worst switch the product will ever be fitted with.
- The capacitor starts rested. The delays assume the capacitor was at VCC before the press and at 0 before the release. A press-release-press faster than the delays starts the second press from a half-charged capacitor and arrives sooner. That is also why the latest delay matters: it bounds how fast the switch can be operated at all.
- The thresholds are the input's. The presets are the SN74HC14's over its full temperature range. A microcontroller pin with Schmitt characteristics has its own VT+/VT−, often specified only as fractions of VDD; put them in as custom values. A pin without hysteresis sees the slow ramp as a long stay in the undefined region, which Würth's note warns of and which is the reason for the Schmitt buffer in the first place.
- Noise on the line. The HC14 datasheet gives ΔVT(min) — 0.4 V at 4.5 V — as "the peak-to-peak limit" for noise the input will ignore. A long wire to a panel switch picks up more than that; Würth's answer is a ferrite bead and a TVS ahead of the RC, and the TVS calculatorsizes the second.
- Leakage. At R2 in the megohms, TI's note reminds that the input's leakage current times the resistance is a voltage the capacitor never reaches. For the HC14 that is microamps and irrelevant below 100 kΩ; for a microcontroller pin with a pull-up enabled it is not.
Common debounce mistakes
- Sizing the time constant equal to the bounce time and stopping. One τ is 63 % of the swing (SN015 eq 3), and with a threshold near the middle of the supply the crossing comes before the bounce ends. Two to three time constants, or TI's rule of a delay twice the bounce.
- Feeding the RC into a plain CMOS input. The slow ramp sits in the undefined band between VIL and VIH for milliseconds, and any noise there produces the very edges the RC was meant to remove. A Schmitt buffer or a pin with hysteresis.
- Judging the margin with typical thresholds. The soonest crossing — VT− at its maximum, VT+ at its minimum — is what the worst unit at the worst temperature does, and it is 40 % sooner than typical for the HC14.
- Forgetting that the release has its own delay. R1 is in the charge path and R2 in both; a 1 kΩ R1 with a 10 kΩ R2 makes the release only 10 % slower than the press, but a diode across R2 makes it a hundred times faster and undebounced.
- Leaving R2 out to save a part. With the capacitor straight across the switch, a press discharges it through the contact with no resistance at all — a current spike that erodes the contact — and the press has no debounce delay whatsoever. R2 is the part that makes the press edge work.
Further reading
- The RC filter calculator: the same time constant as a corner frequency, for when the "switch" is a sensor.
- The I²C pull-up calculator: the other place a pull-up resistor, a capacitance and a threshold set a rise time that has to land in a window.
- The TVS clamping calculator, for the protection Würth puts ahead of the debounce on a long wire.