Switch Debounce Calculator
t = -RC ln(1 - VT+/VCC). 10 kΩ × 100 nF to 0.7 VCC is 1.204 ms.
Calculator
Formula
Charge to VT+
t = -R C ln(1 - VT+/VCC) Discharge to VT−
td = -Rd C ln(VT-/VCC) (Rd = 0 → instant) Schmitt hysteresis
ΔVT = VT+ - VT- Variables
| Symbol | Meaning | Unit | Typical range | Precision | Default |
|---|---|---|---|---|---|
| VCC | Supply | V | ≥ 0 V | 4 sig | 3.3 V |
| R | Pull-up | Ω | ≥ 0 mΩ | 4 sig | 10 kΩ |
| C | Capacitor | F | ≥ 0 pF | 4 sig | 100 nF |
| Rd | Discharge resistance (0 = ideal short) | Ω | ≥ 0 mΩ | 4 sig | 0 mΩ |
| VT+ | Rising threshold | V | ≥ 0 V | 4 sig | 2.31 V |
| VT- | Falling threshold | V | ≥ 0 V | 4 sig | 0.99 V |
| SW0 | Initial switch closed | — | — | 1 sig | 0 |
| Ts | Firmware sample period | s | ≥ 0 ns | 4 sig | 1 ms |
| φ | Firmware sample phase | s | ≥ 0 ns | 4 sig | 0 ns |
| N | Consecutive samples to accept | — | ≥ 1 | 1 sig | 2 |
| t | Charge time 0 → VT+ | s | — | 4 sig | — |
| td | Discharge time VCC → VT− | s | — | 4 sig | — |
| ΔVT | Hysteresis VT+ − VT− | V | — | 4 sig | — |
| τc | Charge time constant | s | — | 4 sig | — |
Worked example
10 kΩ × 100 nF to 0.7 VCC
| Input | Value |
|---|---|
| VCC · Supply | 3.3 V |
| R · Pull-up | 10 kΩ |
| C · Capacitor | 100 nF |
| Rd · Discharge resistance (0 = ideal short) | 0 mΩ |
| VT+ · Rising threshold | 2.31 V |
| VT- · Falling threshold | 0.99 V |
| SW0 · Initial switch closed | no |
| Ts · Firmware sample period | 1 ms |
| φ · Firmware sample phase | 0 ns |
| N · Consecutive samples to accept | 2 |
| Output | Value |
|---|---|
| t · Charge time 0 → VT+ | 1.204 ms |
| τc · Charge time constant | 1 ms |
| ΔVT · Hysteresis VT+ − VT− | 1.32 V |
39 kΩ × 100 nF to 0.7 VCC
| Input | Value |
|---|---|
| VCC · Supply | 3.3 V |
| R · Pull-up | 39 kΩ |
| C · Capacitor | 100 nF |
| Rd · Discharge resistance (0 = ideal short) | 0 mΩ |
| VT+ · Rising threshold | 2.31 V |
| VT- · Falling threshold | 0.99 V |
| SW0 · Initial switch closed | no |
| Ts · Firmware sample period | 1 ms |
| φ · Firmware sample phase | 0 ns |
| N · Consecutive samples to accept | 2 |
| Output | Value |
|---|---|
| t · Charge time 0 → VT+ | 4.695 ms |
| τc · Charge time constant | 3.9 ms |
How it works
Mechanical switches bounce. An active-low SPST to ground with a pull-up and a capacitor is a first-order RC: release charges through R toward VCC, press discharges through Rd (or an ideal short). A Schmitt input remembers the last state between VT− and VT+; a raw midpoint comparator does not. Firmware that polls that Schmitt bit still needs N consecutive samples.
This page runs all four methods on one synthetic bounce timeline you can edit. Thresholds are yours. They are not a CD74HC14 test limit and not a scope capture.
Pitfalls
- A 1τ heuristic is not the VT+ crossing. t = −RC ln(1 − VT+/VCC).
- Charge (release through R) and discharge (press through Rd) are not symmetric. Rd = 0 is an ideal short, not a fake matching RC.
- VT+/VT− are the numbers you typed. They are not CD74HC14 min/max and do not certify a slow edge on a non-Schmitt GPIO (SLLA364A / SCEA046B).
- The bounce table is synthetic and editable. It is not a captured waveform, and this page does not cover encoders or double-click.
FAQ
Why not wait one time constant?
1τ is ~63 % of VCC. VT+ = 0.7 VCC is −ln(0.3) τ ≈ 1.204 τ. The calculator prints that exponential, not a 1τ rule of thumb.
What does Rd = 0 mean?
An ideal switch short to ground. Press voltage drops immediately. Real switches have milliohms plus inductance; type a series Rd if you want a finite discharge.
Is a slow RC edge safe on any GPIO?
No. SLLA364A and SCEA046B discuss slow edges and Schmitt inputs. This page does not certify a non-Schmitt pin.
Does firmware sample the analog voltage?
No. It samples the Schmitt lane at phase + k × period and accepts after N consecutive equal samples.
Related
Sources
- NXP UM10204 I2C-bus specification and user manual, Rev. 7.0 — §7.1 exponential V(t) = VDD (1 − e^{−t/RC}) (UM10204 Rev. 7.0) · retrieved
- TI SCEA046B Understanding Schmitt Triggers (SCEA046B) · retrieved
- TI SLLA364A Solving CMOS Transition Rate Issues Using Schmitt Trigger Solution (SLLA364A) · retrieved
- TI CD74HC14 Hex Schmitt-Trigger Inverters, Rev. G — labelled VT+/VT− example only, not auto-selected (CD74HC14 Rev. G) · retrieved