Volume 03 Beginner 5 sub-modules ~20 min read

Capacitors, Inductors and RC Timing

Resistors react instantly; capacitors and inductors take time. This volume shows how a capacitor stores charge and why it fills along a curve set by R × C, how that curve makes a filter that smooths fast signals away, why a coil fights every change in its current, and how an RC filter turns a bouncing push button into one clean press.

You will learn
  • What a capacitor is, how much charge and energy it stores, and how capacitors combine
  • Why a capacitor charges along a curve, and what the time constant R × C tells you
  • How an RC low-pass or high-pass filter works, and how to find its cut-off frequency
  • What an inductor does, and why switching one off makes a dangerous voltage spike
  • How an RC filter and a Schmitt trigger debounce a push button
You need
  • Volume 02: Ohm's law and series and parallel resistors.

3.1 Capacitors store charge

A capacitor is two metal plates with an insulator between them. Push charge onto it and it stores the charge; the more charge it holds, the higher its voltage. Its capacitance says how much charge each volt stores.

Two plates and a gap

Picture two metal plates facing each other, very close but not touching. Connect them to a battery. Electrons pile onto the plate joined to -, and leave the plate joined to +. No charge crosses the gap, because the gap is an insulator. But the plates now hold separated charge, and a voltage between them.

Disconnect the battery and the charge stays put. The capacitor holds its voltage, like a tiny rechargeable battery. Real capacitors roll up long, thin plates to fit a lot of area into a small part.

The symbol is just that: two short parallel lines, for the two plates.

Charge and capacitance

The charge a capacitor stores is its capacitance times its voltage:


Q = C x V

Capacitance is measured in farads (F). A farad is enormous, so real parts are microfarads (µF, millionths), nanofarads (nF, billionths) or picofarads (pF, a thousandth of a nanofarad):


100 µF at 5 V holds 500 µC
1 nF at 5 V holds 5 nC

A charged capacitor also stores energy, which it can give back quickly - the flash in a camera works this way:


energy = C x V x V / 2: 100 µF at 5 V stores 1.25 mJ

Kinds of capacitor

Kind Typical values Notes
Ceramic 1 pF to 10 µF Small and cheap; either way round
Electrolytic 1 µF to thousands of µF Large values; has a + and a - lead
Film 1 nF to 10 µF Accurate and steady, for timing and audio

An electrolytic capacitor must go the right way round. Reversed, it can overheat and burst. Every capacitor also has a voltage rating, and must never be used above it.

Combining capacitors

Capacitors combine the opposite way to resistors. In parallel, the plate areas add up, so the capacitances add. In series, they combine like resistors in parallel:


100 nF and 100 nF in parallel: 200 nF
100 nF and 100 nF in series: 50 nF
Remember

Once a capacitor is charged, no more current flows into it. In a circuit that has settled, a capacitor is a gap: no current flows through it.

Quick check

A 10 µF capacitor is charged to 3 V. How much charge does it hold?

Show the answer

Answer: B. Q = C × V = 10 µF × 3 V = 30 µC.

3.2 Charging and discharging: the RC time constant

Through a resistor, a capacitor charges quickly at first and then more and more slowly. The time constant, R × C, sets the pace: after one time constant it is 63% charged, and after five it is as good as full.

Charging through a resistor

A 5 V battery charging a 100 microfarad capacitor through a 10 kilohm resistor + B1 5 V S1 R1 10 kΩ C1 100 µF Vc
Figure 3.1 - The switch has just closed. Current flows through R1 into the capacitor, and the capacitor's voltage Vc starts to rise.

At the moment the switch closes, the capacitor is empty and has no voltage across it. So the whole 5 V is across R1, and the capacitor behaves like a plain wire. Much later, the capacitor is full at 5 V and nothing flows:


circuit rc-charge: at the first instant the capacitor acts like a wire: 500 µA flows
after a long time: the capacitor holds 5 V and 0 A flows

In between, the current falls away smoothly. As the capacitor fills, its voltage rises, so less of the 5 V is left across R1 to push current through it. Less current means slower filling. So the capacitor charges fast at first, and ever more slowly after that.

The time constant

The resistance times the capacitance gives a time, in seconds, that sets the pace:


time constant = R x C = 10 kΩ x 100 µF = 1 s
After Capacitor voltage Share of 5 V
1 time constant 3.16 V 63.2%
2 time constants 4.32 V 86.5%
3 time constants 4.75 V 95.0%
4 time constants 4.91 V 98.2%
5 time constants 4.97 V 99.3%

The shares are the same for any R and C. After one time constant, any RC circuit is 63% of the way there; after five, it is within 1% and counts as finished.

Discharging

Take the battery away and join the full capacitor's leads through the same resistor, and it empties along the mirror-image curve. After one time constant, 37% of the voltage is left.

A 100 microfarad capacitor charging and discharging through 10 kilohms 0 1 2 3 4 5 0 1 2 3 4 5 time (s) capacitor voltage (V) charging discharging
Figure 3.2 - Charging from 0 V towards 5 V, and discharging from 5 V towards 0 V. Both curves change fast at first and slowly later. The time constant is 1 second.
Common mistake

Thinking a capacitor is full after one time constant. It is only 63% charged then. Allow five time constants for it to finish.

The formula behind the curve

The charging curve follows an exponential, where e is a fixed number, about 2.718:


Vc = Vs x (1 - e^(-t / RC))

The table above came from this formula. As a separate check, the charge was also worked out in tiny steps. In each step, the current is found from the voltage left across R1, and the capacitor's voltage rises by that current times the step's length, divided by C:


a step-by-step charge in 200000 small steps agrees with the formula to within 0.001 V
Quick check

A 1 kΩ resistor charges a 1 µF capacitor. Roughly how long until it counts as fully charged?

Show the answer

Answer: D. The time constant is 1 kΩ × 1 µF = 1 ms. Five time constants, 5 ms, brings it within 1% of full.

3.3 RC filters

Because a capacitor takes time to charge, an RC circuit smooths fast changes away and lets slow ones through. That is a low-pass filter, and its cut-off frequency is 1 / (2π × R × C).

Frequency

Many signals go up and down over and over again. The number of times a signal repeats each second is its frequency, measured in hertz (Hz). A signal that repeats a thousand times a second is 1 kHz. Sound you can hear runs from about 20 Hz to 20 kHz.

The low-pass filter

Put a resistor in series with a signal, and a capacitor from its far end to ground:

An RC low-pass filter V1 R1 1 kΩ C1 100 nF Vin Vout
Figure 3.3 - The input signal Vin drives R1, and the output Vout is taken across the capacitor C1. Slow changes reach the output; fast ones are smoothed away.

The circle with a wave in it is a signal source: a voltage that keeps changing. When the input changes slowly, the capacitor has plenty of time to follow, and the output matches the input. When it changes fast, the capacitor cannot keep up. It only half-charges before the input turns round, so the output swings much less.

The cut-off frequency marks the change-over:


fc = 1 / (2 x pi x R x C)
circuit lowpass: R1 = 1 kΩ and C1 = 100 nF, so fc = 1.59 kHz

Here pi is the number π, about 3.14. For this filter, the output compares with the input like this:

Frequency Output / input
100 Hz 0.998
1 kHz 0.847
1.59 kHz 0.707
10 kHz 0.157
100 kHz 0.0159

Well below the cut-off, almost all of the signal gets through. At the cut-off, 0.707 of it does. Ten times above, only about a tenth does, and each further tenfold rise cuts it by ten again.

The high-pass filter

Swap the resistor and the capacitor, and the filter works the other way round. That is a high-pass filter. A steady voltage is blocked completely, because a charged capacitor passes no current. Fast changes pass straight through. It has the same cut-off formula.

Think of it like this

A low-pass filter is like a heavy door on a spring. Push it slowly and it follows your hand. Shake it back and forth fast, and it hardly moves at all.

Quick check

An RC low-pass filter has a cut-off frequency of 1 kHz. Which signal gets through best?

Show the answer

Answer: A. A low-pass filter passes signals well below its cut-off frequency. 50 Hz is far below 1 kHz, so almost all of it gets through.

3.4 Inductors

An inductor is a coil of wire. It stores energy in a magnetic field and fights any change in its current. In a settled circuit it is just a wire - but switch its current off suddenly, and it makes a very large voltage.

A coil of wire

Current through a wire makes a magnetic field around it. Wind the wire into a coil, and the fields of all the turns add up to a strong one. Building that field takes energy, and the field gives the energy back when the current falls. The result is a part that resists any change in its current.

Inductance is measured in henries (H). Real inductors are usually millihenries (mH) or microhenries (µH). The symbol is a row of loops, like a coil.

Steady current: just a wire

Once the current has stopped changing, an inductor is only a coil of copper, with almost no resistance:

A 5 V battery driving a 10 millihenry inductor through a 100 ohm resistor + B1 5 V S1 R1 100 Ω L1 10 mH
Figure 3.4 - Once the current has settled, the inductor is just a coil of wire, and only R1 limits the current.

circuit inductor: once settled, the current is 50 mA - the inductor is just a wire

When the switch first closes, though, the current cannot jump straight to 50 mA. The inductor holds it back, and it grows with a time constant of L / R:


time constant = L / R = 10 mH / 100 Ω = 100 µs
after one time constant the current has reached 31.6 mA

That is the capacitor's story turned round. A capacitor's voltage cannot change instantly; an inductor's current cannot either.

Switching an inductor off

The voltage across an inductor depends on how fast its current changes:


V = L x change in current / time

Open the switch, and the current tries to fall to zero at once. The inductor fights it by making whatever voltage it takes to keep the current going:


stopping 50 mA in 1 µs: V = 10 mH x 50 mA / 1 µs = 500 V

Five hundred volts, from a 5 V battery. The spike jumps across the opening switch contacts as a spark, and it can destroy a transistor. Motors, relays and loudspeakers are all coils, so they all do this. Volume 05 shows the simple diode that makes them safe.

Common mistake

Treating a coil like a resistor when it is switched off. Its stored energy has to go somewhere, and it comes out as a high-voltage spike. Every coil switched by a transistor needs a path for that current.

Quick check

A steady 20 mA flows through an inductor. What does the inductor do to that steady current?

Show the answer

Answer: C. An inductor only fights changes in current. Once the current is steady, it is just a piece of wire with very little resistance.

3.5 Debouncing a switch with RC

A switch's contacts bounce for a few milliseconds when pressed, making a burst of on-off pulses. An RC filter smooths the burst into one slow rise, which a chip reads as a single press.

Switch bounce

A push button is two springy metal contacts. When they meet, they bounce apart and together a few times before they settle. That switch bounce lasts a few milliseconds. People never notice, but a chip does: it can read every bounce as a new press.

Here is a button feeding a chip's input, with an RC filter in between:

A push button with an RC filter before a chip's input + B1 5 V S1 R1 10 kΩ C1 1 µF R2 100 kΩ to the chip
Figure 3.5 - Pressing S1 charges C1 through R1. R2 empties C1 again slowly after the button is released, so the input rests at 0 V.

circuit debounce: button held down: the input settles at 4.55 V; released: 0 V
R1 x C1 = 10 kΩ x 1 µF = 10 ms

One press, with and without the filter

In this press, the contacts touch three times in the first 3.5 ms before they settle. The chip treats anything above 2.5 V as a 1:

One bouncing press, with and without the RC filter 0 5 10 15 20 25 30 0 1 2 3 4 5 time (ms) voltage (V) the chip's 2.5 V switching point switch alone with the RC filter
Figure 3.6 - Without the capacitor, the input leaps up and down with every bounce and crosses 2.5 V four times. With it, the capacitor barely moves during the bounces, then rises smoothly and crosses 2.5 V once.

switch alone: the input rises through 2.5 V 4 times, so the chip sees 4 presses
with the RC filter: it rises through 2.5 V once, 10.8 ms after the first touch

The filter costs a delay of about 11 ms, which nobody can feel. A time constant of 5 ms to 20 ms suits most buttons.

Finishing the job

A slowly rising voltage has one more problem. While it creeps through the switching point, a little electrical noise can tip an ordinary input back and forth. A Schmitt trigger input fixes this. It switches to 1 at a higher voltage than it switches back to 0, so a slow edge crosses cleanly, once. Many chips offer one on their input pins.

Debouncing can also be done by the chip itself: a program, or a small digital circuit, ignores the input until it has been steady for a few milliseconds. State Machines, Volume 07 builds that digital debouncer.

Quick check

Why does an RC filter stop a chip counting one press as several?

Show the answer

Answer: B. The switch still bounces. But each bounce is far shorter than the time constant, so the capacitor's voltage hardly changes during it. The input rises through the switching point only once.

What you learned

Key words from this volume

Every word below has a plain-English entry in the glossary.

Practice

Practice 1

A slower RC

A 47 kΩ resistor charges a 10 µF capacitor. What is the time constant, and roughly when is it full?

Show the solution

47 kΩ x 10 µF = 470 ms; about full after 5 time constants: 2.35 s
Practice 2

Charge and energy

A 10 µF capacitor is charged to 12 V. How much charge and energy does it hold?

Show the solution

10 µF at 12 V holds 120 µC and stores 720 µJ
Practice 3

A filter's cut-off

A low-pass filter uses 10 kΩ and 10 nF. What is its cut-off frequency?

Show the solution

10 kΩ and 10 nF: fc = 1.59 kHz

The same as the lesson's filter: ten times the resistance and a tenth of the capacitance give the same R × C.

Practice 4

Two capacitors

What do 10 µF and 22 µF make in parallel, and in series?

Show the solution

10 µF and 22 µF: 32 µF in parallel, 6.88 µF in series
Practice 5

A relay coil

A relay coil of 20 mH carries 100 mA. A transistor switches it off in 2 µs. How big is the spike?

Show the solution

20 mH, 100 mA stopped in 2 µs: V = 1 kV

A thousand volts would destroy the transistor at once. Volume 05 adds the flyback diode that prevents it.

Interview corner

Interview question 1

What cannot change instantly

"What can't change instantly in a capacitor, and in an inductor? What happens at the moment you switch each one on?"

Show the solution

"A capacitor's voltage can't change instantly, because that would need an infinite current. So at switch-on an empty capacitor still has 0 V across it, and acts like a short circuit for that first instant. An inductor's current can't change instantly, because that would need an infinite voltage. So at switch-on it still carries no current, and acts like an open circuit. Both then settle with a time constant: R × C for the capacitor and L / R for the inductor. Once settled, the capacitor is an open circuit and the inductor is a wire."

Volume 04 meets the diode, which lets current flow one way only, and the LED, a diode that gives out light.