Capacitor charge and discharge time calculator
The RC time constant and the exponential it governs: the voltage on a capacitor at any moment while it charges or discharges through a resistor, the time it takes to reach a threshold, and the current and energy the resistor sees on the way, from any starting voltage.
Charging pulls the capacitor from its starting voltage up to the supply through the resistor; discharging pulls it from its starting voltage down to zero, or to whatever the far end of the resistor sits at.
The resistance in the charging or discharging path: the series resistor, plus the source's own output resistance if it is not negligible. With the capacitance it sets τ.
The capacitance at the operating voltage. A class II ceramic can lose a large fraction of its marked value to DC bias, which shortens τ by the same fraction.
The voltage the capacitor is heading for: the supply when charging, 0 V when discharging into ground. It is never quite reached; SN015 puts 99 % at five time constants.
The voltage on the capacitor when the clock starts: 0 for a first charge, the supply for a discharge, or wherever a previous cycle left it.
A moment to read the voltage at. The debounce and power-on-reset cases both come down to what the voltage is when something else happens.
A voltage to find the time to: a logic threshold, a reset level, a comparator trip point. It has to lie between the start and the final voltage.
- Time constant τ = R·C
- 10.0 ms · 99 % of the way at 5τ = 50.0 ms
- Voltage at 10.0 ms
- 3.16 V · 63.2 % of the way
- Time to reach 3.30 V
- 10.8 ms · 1.08 τ
- After 1τ · 2τ · 3τ · 4τ · 5τ
- 3.16 V · 4.32 V · 4.75 V · 4.91 V · 4.97 V
- Current at t = 0 · power in the resistor then
- 500 µA · 2.50 mW
- Energy stored at the end · lost in the resistor
- 12.5 µJ · 12.5 µJ
Charging from zero, the resistor dissipates exactly as much energy as the capacitor ends up storing, whatever its value: a small resistor only makes the same loss happen faster and at a higher peak current.
How this is calculated
Standard: Würth Elektronik SN015 — Contact debounce circuit for switches
- SN015 Eq 1. "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."
- SN015 Eq 3, U_out = U_in(1 − e^(−t/τ)), generalised to any starting voltage: the same law charges from a partly-charged capacitor and discharges from a charged one.
- The same equation solved for time: what a threshold asks. Two thirds of the swing takes 1.1τ, half takes 0.69τ, 90 % takes 2.3τ.
- The current at the first instant, and the energy the resistor dissipates over the whole charge, which from zero equals the ½CV² the capacitor stores whatever the resistor is.
Assumptions
- An ideal source, an ideal resistor and an ideal capacitor. The source's output resistance belongs in R; the capacitor's leakage and dielectric absorption are not modelled.
- Capacitance at the operating voltage. Class II ceramics lose capacitance to DC bias; enter the derated value.
- A step: the final voltage is present from t = 0. A rail that ramps up gives a different curve.
- No diode or switch in the path. A diode's forward drop and a MOSFET's changing on-resistance are outside the law, as SN015's diode variant shows.
What sets a capacitor's charge and discharge time
A capacitor charged through a resistor never fills at a steady rate, because the current that fills it is set by the voltage still to go: I = (Vsupply − VC)/R, largest at the first instant and falling as the capacitor catches up. The result is the exponential that SN015 writes as Uout = Uin(1 − e−t/τ), with one number governing everything: the time constant τ = R·C. The note states what τ means in the two directions at once: "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."
The 63 % is 1 − 1/e and the 37 % is 1/e, and neither depends on the voltage, the resistor or the capacitor separately, only on their product. That is what makes τ the useful number: a 10 kΩ resistor with a 1 µF capacitor and a 1 kΩ resistor with 10 µF behave identically in time, and differ only in the current the first one draws, which is ten times smaller. The calculator takes any starting voltage, not just zero, because the case that matters on a board is usually a second cycle: a debounce capacitor that had not finished discharging, a reset capacitor after a brown-out, a sample capacitor holding the last value.
Run backwards, the same law gives the time to reach a voltage, which is the question a threshold asks: t = −τ·ln((Vfinal − Vtarget)/(Vfinal − Vstart)). A logic input that switches at two thirds of the supply is crossed at 1.1τ; one that switches at half is crossed at 0.69τ; a comparator set at 90 % waits 2.3τ. The calculator solves this directly and draws where on the curve it lands.
Two quantities that surprise. The current at t = 0 is the full supply over the resistor, so a 12 V rail into 100 µF through 10 Ω starts at 1.2 A and 14.4 W, however briefly. And charging from zero, the resistor dissipates exactly as much energy as the capacitor ends up holding, ½CV², whatever the resistor's value: a smaller resistor does not save that energy, it spends it faster.
RC time constant chart
τ = R·C for the values in a drawer, computed by the calculator above. Multiply the row and column and the table is the same; its use is that the answer is already in the unit a debounce, a reset or a filter is thought about in.
| R \ C | 100 pF | 1 nF | 10 nF | 100 nF | 1 µF | 10 µF | 100 µF |
|---|---|---|---|---|---|---|---|
| 100 Ω | 10.0 ns | 100 ns | 1.00 µs | 10.0 µs | 100 µs | 1.00 ms | 10.0 ms |
| 1 kΩ | 100 ns | 1.00 µs | 10.0 µs | 100 µs | 1.00 ms | 10.0 ms | 100 ms |
| 10 kΩ | 1.00 µs | 10.0 µs | 100 µs | 1.00 ms | 10.0 ms | 100 ms | 1.00 s |
| 100 kΩ | 10.0 µs | 100 µs | 1.00 ms | 10.0 ms | 100 ms | 1.00 s | 10.0 s |
| 1 MΩ | 100 µs | 1.00 ms | 10.0 ms | 100 ms | 1.00 s | 10.0 s | 100 s |
How far the charge has got after each time constant
The fraction of the swing completed, and the fraction still to go, at the points people quote. SN015's two figures are the 1τ and 5τ rows; the rest are the same exponential evaluated by the calculator.
| Time | Charged, % of the way | Still to go | Discharging: remaining, % of start |
|---|---|---|---|
| 0.5τ | 39.3 % | 60.7 % | 60.7 % |
| 0.7τ | 50.3 % | 49.7 % | 49.7 % |
| 1τ | 63.2 % | 36.8 % | 36.8 % |
| 2τ | 86.5 % | 13.5 % | 13.5 % |
| 3τ | 95.0 % | 5.0 % | 5.0 % |
| 4τ | 98.17 % | 1.83 % | 1.83 % |
| 5τ | 99.33 % | 0.67 % | 0.67 % |
| 7τ | 99.91 % | 0.09 % | 0.09 % |
The last column is why a discharge "to zero" is a matter of definition. After 5τ a 5 V capacitor still holds 34 mV; a comparator with a 10 mV threshold needs 6.2τ, and a leakage path of its own decides what happens after that.
Worked example: SN015's debounce capacitor, 10 kΩ and 1 µF on 5 V
The defaults are the note's calculation example: a 10 ms time constant on a 5 V rail, with the voltage read at 10 ms and the time found to a 3.3 V threshold.
τ = 10 kΩ × 1 µF = 10 ms
V at 10 ms = 5 × (1 − e^−1) = 3.16 V (SN015: "63 % (3.15 V)")
t to 3.3 V = −10 ms × ln((5 − 3.3) / 5) = 10.8 ms (1.08 τ)
V at 5τ = 5 × (1 − e^−5) = 4.97 V (99.3 %)
I at t = 0 = 5 / 10 kΩ = 500 µA; 2.5 mW in the resistor
energy = ½ × 1 µF × 5² = 12.5 µJ stored, 12.5 µJ lost in RDischarged through the same resistor from 5 V, the capacitor is at 1.84 V after one τ and at 34 mV after five, and reaches a 0.8 V logic low threshold at 1.83τ, 18.3 ms. The two directions are mirror images of one another, which is what the note's "rise to 63 % or fall to 37 %" says in one sentence.
Where the RC law stops being valid
The source has resistance. The R in τ is everything in the path: the series resistor, the output impedance of the pin or regulator driving it, and any trace worth counting. A microcontroller pin driving a large capacitor directly has tens of ohms of its own, and the current at t = 0 is limited by that and by the pin's rating, not by the wire.
The capacitance is not the marked value. A class II ceramic at its rated voltage can have lost half its capacitance to DC bias, and τ with it; an electrolytic runs ±20 % from the reel. The law is exact; the C put into it rarely is.
Leakage and dielectric absorption. A real capacitor has a parallel resistance, so a discharge never quite reaches zero and a charged capacitor left open slowly loses its voltage. Dielectric absorption goes the other way: a capacitor discharged to zero and released recovers some tenths of a per cent of its previous voltage on its own, which matters for sample-and-hold and for nothing much else.
Large signals through a diode or a switch. A diode in the path drops a forward voltage that the exponential does not include, which is how SN015's own diode variant gets different charge and discharge times from the same capacitor; a MOSFET switch adds its on-resistance, which changes with gate drive during the first microseconds.
Very fast edges. Below a few nanoseconds the lead and trace inductance forms an LC with the capacitor and the current does not start at V/R; it rings. Thedecoupling calculator is where that regime lives.
Common capacitor charge time mistakes
- Reading τ as "the charge time". At one time constant the capacitor is two thirds of the way; a threshold at 90 % takes 2.3τ, and anything that needs "fully charged" needs to say what fraction it means. SN015's five time constants is the usual convention for 99 %.
- Sizing a power-on reset from the supply's nominal rise. The reset capacitor charges from whatever the rail is doing, and a rail that comes up in 5 ms gives a different curve from a step. The starting voltage field is for the case where the capacitor was not empty.
- Forgetting the peak current. A large capacitor behind a small resistor draws a current pulse at switch-on that the resistor, the switch and the upstream supply all see; theinrush calculator is the same law with a fuse rating on the other side.
- Expecting a smaller resistor to charge more efficiently. The energy lost in the resistor from zero is ½CV² regardless; only a switching converter or a resonant path charges a capacitor with less than that.
- Using the marked capacitance of a ceramic on a high rail. Derate for DC bias first; τ shrinks with it, and a debounce that was sized for 10 ms is suddenly 6.
Further reading
- Würth Elektronik SN015, Contact debounce circuit for switches — τ = R·C, the 63 % and 37 % points, 99 % at five time constants, and the charging law Uout = Uin(1 − e−t/τ) with a worked 10 ms example.
- Switch debounce calculator — the same exponential against a Schmitt trigger's real threshold limits, with separate charge and discharge paths.
- RC filter calculator — the frequency view of the same R and C: the corner at 1/(2πτ), and the 10 % to 90 % rise time of 2.2τ.
- Inrush current limiter calculator — the first instant of charging a bulk capacitor, when V/R is more than the fuse allows.