Charging through a resistor
A capacitor on its own has no speed — it charges as fast as the wire allows. Put a resistor in front of it and it gets one, and that number is the only piece of capacitor arithmetic you will use again.
Every capacitor on a real board has resistance in front of it whether you fitted it or not: the resistance of the track, of the supply, of the pin driving it. Add a deliberate resistor and the pair has a characteristic time.
τ = R × C. Ohms times farads gives seconds, and that product is called the time constant. One time constant gets the capacitor 63% of the way to wherever it is heading. Five gets it to within a percent, which is where everyone stops counting.
The shape never changes. Not the numbers — the shape. 10 kΩ with 100 nF and 1 MΩ with 1 nF both have a 1 ms time constant and both draw exactly the curve above.
Why it bends
At the instant you connect it, the capacitor is at 0 V and the whole supply is across the resistor, so the current is as big as it gets. As charge arrives the capacitor's voltage rises, which leaves less across the resistor, which means less current, which means charge arrives more slowly. The approach slows down because it is succeeding.
Which is also why it never quite arrives. There is no moment when a capacitor is "full"; there is only a moment when you stop caring, and five time constants is the convention for that.
Discharging is the same curve upside down. Through the same resistor, it takes the same time — 37% left after one τ. If the discharge path is a different resistor, and it usually is, use that one.
Where it turns up
A button that bounces. A switch contact chatters as the metal settles — well under a millisecond on a small tactile switch, several on a bigger one — and a pin sampling every microsecond reads each bounce as a press. 10 kΩ and 100 nF is a 1 ms τ, which swallows the short ones and is still a thousandth of the time a finger takes, so nobody notices the delay. A noisier switch wants a bigger capacitor, or debouncing in software, or both. This is the RC that appears on half the schematics you will ever open.
A pull-up with a long wire on it. The wire has capacitance whether you like it or not — tens of picofarads per metre — and an I²C line is a pull-up resistor with exactly that hanging off it. 10 kΩ against 100 pF is a 1 µs rising edge; fast-mode I²C allows 300 ns. That is why a long bus stops working at 400 kHz and why the fix is a smaller pull-up, not a slower loop.
A reset that has to arrive late. A resistor to the rail and a capacitor to ground holds a chip's reset pin low for a few τ after power comes up, giving the supply time to settle. Many chips do this internally now; boards that do not have an R and a C next to the reset pin doing exactly this.
Next: the capacitor that is on your board a dozen times over, and the two milliseconds it exists for.
Edit this page — content/fundamentals/electricity/charging-through-a-resistor.mdx
Discuss this article
Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.