Resistors only ever turn electrical energy into heat. Capacitors and inductors are different: they store energy, a capacitor in an electric field and an inductor in a magnetic field, and give it back later. That one difference makes time appear in your circuits. A capacitor takes time to fill, an inductor takes time to build its current, and a pair of simple resistor-and-capacitor circuits can delay a signal, smooth a supply, filter out noise or clean up a bouncing switch. It also explains why a motor or relay coil can destroy the transistor that switches it, which Basic Electronics 5, Basic Electronics 6 and Basic Electronics 9 will solve. This chapter builds on Ohm's law (Basic Electronics 1), series and parallel rules (Basic Electronics 2) and the divider (Basic Electronics 3).
1. Capacitors
What a capacitor is
A capacitor is two conductors (plates) separated by an insulator (the dielectric). No current flows through it, but when a voltage is applied, charge piles up on one plate and an equal charge leaves the other. The more charge it holds per volt, the bigger its capacitance C, measured in farads (F):
Definition: charge stored per volt
Q = C x V (Q in coulombs, C in farads, V in volts)
Practical units (a farad is enormous)
1 mF = 0.001 F 1 uF = 0.000001 F 1 nF = 0.000000001 F 1 pF = 10^-12 F
1 uF = 1000 nF = 1,000,000 pF
Worked example: 100 uF charged to 5 V
Q = 100e-6 x 5 = 500e-6 C = 500 uC = 0.5 mC
Why practical capacitors are built the way they are: parallel plates, C = e x A / d
(e = permittivity of the dielectric, A = plate area, d = gap). With air (e0 = 8.85 pF/m),
plates of 1 cm^2 (1e-4 m^2) and a 1 mm gap:
C = 8.85e-12 x 1e-4 / 1e-3 = 8.85e-13 F = 0.885 pF
To get microfarads, makers roll very large areas of metal foil with micron-thin
dielectric, or use dielectrics with a permittivity thousands of times that of air.
Energy stored
Moving a small extra charge dq onto a capacitor that already holds voltage v = q/C takes energy dE = v × dq. Adding that up from empty (0) to full charge Q:
E = integral from 0 to Q of (q / C) dq = Q^2 / (2C)
and since Q = C x V:
E = 1/2 x C x V^2
Worked example: 100 uF at 5 V
E = 0.5 x 100e-6 x 5^2 = 0.5 x 100e-6 x 25 = 1.25e-3 J = 1.25 mJ
That is tiny: an AA cell holds about 1.5 V x 2.5 Ah x 3600 = 13,500 J, roughly ten
million times more. Capacitors are for fast, small bursts, not for bulk energy.The energy goes as the SQUARE of the voltage: doubling V gives 4 x the energy.
1000 uF at 50 V holds 0.5 x 1e-3 x 2500 = 1.25 J: enough to feel or to blow a thin wire.
Charged capacitors
A large capacitor stays charged after the power is off. At 5 V that is harmless, but never open a mains-powered supply or touch a high-voltage capacitor (tens of volts and up) without discharging it through a resistor first. Never short a charged capacitor with a screwdriver: the spark can weld metal and throw it at you. Use a resistor of 100 Ω or more.
Capacitors in parallel and series
PARALLEL: same voltage V across both, charges add (Q = Q1 + Q2 = C1 V + C2 V)
C_total = C1 + C2 + C3 ... (more plate area, so more capacitance)
10 uF || 22 uF = 32 uF
SERIES: the same charge Q on each, voltages add (V = Q/C1 + Q/C2 = Q (1/C1 + 1/C2))
1 / C_total = 1/C1 + 1/C2 + ... (note: the opposite of resistors)
Two only: C_total = C1 x C2 / (C1 + C2)
10 uF in series with 10 uF = 100 / 20 = 5 uF
10 uF in series with 47 uF = 470 / 57 = 8.246 uF (always smaller than the smallest)Voltage sharing in series: V across C1 = Vtotal x C2 / (C1 + C2)
(the SMALLER capacitor gets the LARGER share, because the same Q gives V = Q/C)
10 uF and 47 uF across 12 V:
V(10 uF) = 12 x 47 / 57 = 9.895 V
V(47 uF) = 12 x 10 / 57 = 2.105 V (sum 12.000 V)
Capacitors combine the opposite way round to resistors: parallel adds, series reduces. Because the voltage shares unevenly, putting capacitors in series to survive a higher voltage is risky unless you add balancing resistors; the sensible fix is one capacitor with a higher voltage rating.
Types you will meet
Type
Typical range
Tolerance
Polarised?
Use
Ceramic C0G / NP0
1 pF to 100 nF
±1 to 5 %
No
Precise, stable: filters, timing, radio
Ceramic X7R / X5R
100 pF to 10 µF and up
±10 to 20 %
No
Decoupling (the 100 nF "104" on every board); capacitance falls with applied DC voltage
Film (polyester, polypropylene)
1 nF to 10 µF
±5 to 10 %
No
Audio, stable timing, mains-rated types; physically large
Aluminium electrolytic
1 µF to 10,000 µF and up
±20 % (often −20 / +80 %)
Yes
Smoothing, bulk decoupling; leaky, ages, has series resistance (ESR)
Tantalum
0.1 µF to 470 µF
±10 to 20 %
Yes
Compact bulk decoupling; can fail short and burn if reversed or over-volted
Supercapacitor
0.1 F to 1000 F
−20 / +80 %
Yes
Memory back-up; about 2.7 V per cell
Reading the value
Small ceramics use the same code as SMD resistors, but the answer is in picofarads
104 = 10 x 10^4 pF = 100,000 pF = 100 nF = 0.1 uF (the standard decoupling cap)
103 = 10 x 10^3 pF = 10 nF
473 = 47 x 10^3 pF = 47 nF
224 = 22 x 10^4 pF = 220 nF
105 = 10 x 10^5 pF = 1 uF
A letter after the digits is the tolerance: J = 5 %, K = 10 %, M = 20 %.Electrolytics have the value, the voltage and the polarity printed on the can:
220 uF 16 V a stripe with minus signs marks the NEGATIVE leg; the new, long leg is POSITIVE
Voltage rating, polarity and tolerance
Voltage rating is the most the capacitor may see continuously. Choose at least 1.5 to 2 × the working voltage for an electrolytic (a 10 V part on a 5 V rail, a 25 V part on 12 V). Ceramics also lose capacitance as the DC voltage across them rises ("DC bias derating"): a 10 µF X5R ceramic rated 6.3 V can deliver well under half of 10 µF at 5 V, depending on the part, so read the datasheet curve for a smoothing capacitor.
Polarity. An electrolytic connected backwards leaks heavily, heats up and can vent or burst with a pop and a puff of electrolyte. Check the stripe before you power up. Ceramic and film capacitors have no polarity.
Tolerance is wide: a 100 µF ±20 % electrolytic is anywhere from 80 to 120 µF, so a timing circuit built with it is only accurate to about that. Use film or C0G where the time or frequency really matters.
2. Charging and discharging through a resistor
Connect a resistor R in series with a capacitor C and a supply Vs through a switch. The moment the switch closes the capacitor is empty, so it looks like a short circuit and the current is Vs/R. As charge builds, the capacitor's voltage rises, the voltage left across the resistor falls, and the current dwindles. It is the same shape as water filling a bucket through a narrow pipe: fast at first, ever slower as it fills.
Vs o---o o---[ R ]---+---o Vc (voltage across C)
switch |
===== C
|
0 V o---------------+
Charging: the switch connects the resistor to Vs. Discharging: it connects it to 0 V.
Derivation
1. The resistor drops what the capacitor does not: Vs - v = i x R
2. The capacitor's current is the rate of change of its charge: i = dQ/dt = C dv/dt
(so a steady v means no current: a capacitor blocks DC once charged)
3. Combine: Vs - v = R C dv/dt so dv / (Vs - v) = dt / (R C)
4. Integrate, with v = 0 at t = 0: -ln(Vs - v) + ln(Vs) = t / (R C)
Charging: v(t) = Vs x (1 - e^(-t / RC))
Current: i(t) = (Vs / R) x e^(-t / RC)
Discharging (C starts at V0 and the resistor goes to 0 V): same method with Vs = 0:
v(t) = V0 x e^(-t / RC)
The product tau = R x C has units of time (ohm x farad = second) and is called the
TIME CONSTANT. Everything is a function of t / tau.
The 63 % and 99 % points
t / tau charging: v / Vs = 1 - e^-(t/tau) discharging: v / V0 = e^-(t/tau)
0.5 39.3 % 60.7 %
1 63.2 % 36.8 %
2 86.5 % 13.5 %
3 95.0 % 5.0 %
4 98.2 % 1.8 %
4.6 99.0 % 1.0 %
5 99.3 % 0.7 %
Memory aid: after ONE time constant a charging capacitor is about 63 % full;
after FIVE it is, for practical purposes, full (99.3 %).Time to reach a chosen fraction f of the supply (rearranging the charging formula):
t = -R C x ln(1 - f)
half way (f = 0.5): t = 0.693 tau 90 % (f = 0.9): t = 2.303 tau
Worked example: 10 kΩ and 220 µF from 5 V
tau = R x C = 10,000 x 220e-6 = 2.2 s
Charging from 0 V:
t = 2.2 s (1 tau): v = 5 x (1 - e^-1) = 5 x 0.632 = 3.16 V
t = 4.4 s (2 tau): v = 5 x (1 - e^-2) = 5 x 0.865 = 4.32 V
t = 6.6 s (3 tau): v = 5 x 0.950 = 4.75 V
t = 10.1 s (4.6 tau): v = 5 x 0.990 = 4.95 V
Time to reach 2.5 V: t = 0.693 x 2.2 = 1.52 s
Current: it starts at Vs / R and decays with the same time constant
i(0) = 5 / 10,000 = 0.500 mA i(2.2 s) = 0.5 x 0.368 = 0.184 mA
Discharging from 5 V through the same resistor:
t = 2.2 s: v = 5 x 0.368 = 1.84 V t = 4.4 s: v = 0.677 V t = 6.6 s: v = 0.249 V
Energy: the capacitor ends up storing 1/2 C V^2 = 0.5 x 220e-6 x 25 = 2.75 mJ.
The supply delivered Q x V = (220e-6 x 5) x 5 = 5.5 mJ. Exactly HALF is lost as heat in R,
whatever the value of R.Tolerance: C +/-20 % and R +/-5 % give tau from 0.8 x 0.95 x 2.2 = 1.7 s to 1.2 x 1.05 x 2.2 = 2.8 s.
The same law everywhere
Any quantity that changes at a rate proportional to how far it is from its target follows this exponential curve: a hot drink cooling, a rising battery-voltage reading through a filter, a motor's speed after a throttle change. The RC circuit is the easiest place to see it and measure it.
3. Capacitors and AC: reactance and RC filters
Capacitive reactance
A capacitor passes a changing voltage but not a steady one. The faster the voltage changes, the more current it passes. Starting from i = C dv/dt with a sine wave v = Vp sin(ωt), where ω = 2πf:
i = C dv/dt = C x Vp x w x cos(w t) so the peak current is Ip = w C Vp
The ratio of peak voltage to peak current acts like a resistance, called REACTANCE:
Xc = Vp / Ip = 1 / (w C) = 1 / (2 x pi x f x C) (in ohms; falls as f or C rises)
Worked examples
100 nF at 1 kHz: Xc = 1 / (2 x pi x 1000 x 100e-9) = 1 / 6.283e-4 = 1,592 ohm
100 nF at 100 kHz: Xc = 15.9 ohm
100 nF at 50 Hz: Xc = 31.8 k ohm
220 uF at 50 Hz: Xc = 1 / (2 x pi x 50 x 220e-6) = 1 / 0.06912 = 14.5 ohm
At DC (f = 0): Xc = infinite (blocks DC)
A capacitor in series with a resistor is a frequency-dependent voltage divider. Because the capacitor's current leads its voltage by a quarter of a cycle (90°), the reactance and the resistance do not add directly; they add at right angles, like the sides of a triangle:
The RC low-pass filter
Vin o----[ R ]----+----o Vout LOW-PASS: lets low frequencies through, cuts high ones
|
===== C
|
0 V o------------+------o 0 V
Impedance of R and C in series: Z = sqrt(R^2 + Xc^2)
Divider (reading across C): |Vout / Vin| = Xc / sqrt(R^2 + Xc^2) = 1 / sqrt(1 + (w R C)^2)
Special frequency: where Xc = R, i.e. w R C = 1:
fc = 1 / (2 x pi x R x C) the cut-off (corner, -3 dB) frequency
At fc: |Vout / Vin| = 1 / sqrt(2) = 0.707 (the output is at 70.7 % of the input
amplitude: the power is HALF, called -3 dB)
phase of the output lags the input by 45 degrees
Well below fc: gain close to 1. Well above fc: gain falls as fc / f (10 x the frequency, 1/10 the output)
Link to the time constant: fc = 1 / (2 x pi x tau)
Worked example: R = 1.6 k (E24 value), C = 100 nF
tau = 1600 x 100e-9 = 160 us
fc = 1 / (2 x pi x 1600 x 100e-9) = 1 / 1.0053e-3 = 994.7 Hz (about 1 kHz)Gain at various frequencies, 1 V peak input: gain = 1 / sqrt(1 + (f/fc)^2)
100 Hz: f/fc = 0.1005 gain = 1 / sqrt(1.0101) = 0.995 out = 0.995 V
995 Hz: f/fc = 1.000 gain = 0.707 out = 0.707 V (phase -45 deg)
1 kHz: w R C = 1.0053 gain = 1 / sqrt(2.0106) = 0.705 out = 0.705 V
10 kHz: f/fc = 10.05 gain = 1 / sqrt(102.0) = 0.099 out = 0.099 V (-20 dB)
Use: a 1 kHz low-pass removes hum and hiss above 1 kHz from a sensor line, or turns a
PWM waveform (Basic Electronics 10) into a steady average voltage.
The RC high-pass filter
Swap the two parts and the capacitor is in the signal path: it passes fast changes and blocks slow ones, including DC. Taking the output across the resistor,
Vin o-----||-----+----o Vout HIGH-PASS: blocks DC and low frequencies
C |
[ R ]
|
0 V o------------+------o 0 V
|Vout / Vin| = w R C / sqrt(1 + (w R C)^2) same fc = 1 / (2 x pi x R x C)
Same R = 1.6 k and C = 100 nF (fc = 995 Hz):
100 Hz: gain 0.100 1 kHz: gain 0.709 (about -3 dB) 10 kHz: gain 0.995
Use: couple an audio or sensor signal into the next stage while blocking its DC level,
or detect a sudden edge on an otherwise steady line.
Filter
Where C goes
Passes
Blocks
Typical robot use
Low-pass
Across the output (to ground)
Slow signals, DC
Fast noise
Smooth a sensor reading before the ADC; average a PWM signal
High-pass
In series with the signal
Fast changes
DC, drift
AC-couple a microphone; detect an edge
4. Decoupling and smoothing
Decoupling: a tiny local reservoir
A microcontroller or motor driver draws current in sudden bursts as its transistors switch, for example 50 mA in 10 ns. The supply wires back to the battery are not perfect: they have inductance (roughly 1 nH per millimetre, so about 100 nH for 10 cm). A rapidly changing current through an inductance produces a voltage, v = L di/dt (section 5):
Without a capacitor: the supply droops while the wire resists the change
v = L x di/dt = 100e-9 x (0.050 / 10e-9) = 100e-9 x 5e6 = 0.5 V
With 100 nF right at the chip, the burst is supplied by the capacitor's own charge:
dV = I x dt / C = 0.050 x 10e-9 / 100e-9 = 5 mV
(from the definition Q = C V: removing charge I dt lowers V by I dt / C)
100 nF ceramic as close as possible to each IC's power pins, with short leads (that is the purpose of the "104" caps on every board).
10 to 100 µF electrolytic (bulk) near a motor driver, regulator or the point where power enters a board: slower, bigger bursts.
A small and a large capacitor in parallel is useful: each covers a different range of speeds.
Smoothing a rectified supply
A rectifier (Basic Electronics 5) turns AC into a series of humps. A big capacitor fills at each peak and feeds the load between peaks. While feeding the load with a steady current I for one gap of T = 1/f seconds, the voltage falls by dV = I × T / C, so:
ripple dV = I / (f x C) (a slight over-estimate, as the capacitor is topped up part of the time)UK mains is 50 Hz; a full-wave rectifier gives humps at 100 Hz. Load 100 mA:
C = 1000 uF: dV = 0.1 / (100 x 1e-3) = 1.0 V
For 0.1 V ripple: C = I / (f x dV) = 0.1 / (100 x 0.1) = 0.01 F = 10,000 uF
Why switching supplies run at 100 kHz or more: same 100 mA, f = 100 kHz, C = 100 uF:
dV = 0.1 / (1e5 x 100e-6) = 0.1 / 10 = 0.01 V
A hundred times smaller capacitor does a hundred times better job.
5. Inductors
An inductor is a coil of wire, often wound on an iron or ferrite core. Current through it makes a magnetic field; if the current changes, the field changes, and a changing field induces a voltage in the coil that opposes the change (Lenz's law). The inductance L is measured in henries (H; practical sizes are µH to mH, up to a few H for relay and motor coils).
Definition: the voltage across an inductor follows how fast its current changes
v = L x di/dt (a steady current = no voltage: at DC an inductor is just a wire,
apart from the resistance of the copper)Energy stored: power = v x i = L i di/dt, so the energy added while the current
rises from 0 to I is the integral of L i di:
E = 1/2 x L x I^2
100 mH carrying 50 mA: E = 0.5 x 0.1 x 0.05^2 = 1.25e-4 J = 125 uJ
Reactance (same method as for the capacitor, i = Ip sin(w t), v = w L Ip cos(w t)):
XL = w L = 2 x pi x f x L (RISES with frequency: the opposite of a capacitor)
10 mH at 50 Hz: XL = 2 x pi x 50 x 0.01 = 3.14 ohm
10 mH at 1 kHz: XL = 62.8 ohm 10 mH at 100 kHz: 6.28 k ohm
Combining (when the coils are far apart, with no magnetic coupling): the OPPOSITE of
capacitors, the SAME as resistors
series: L = L1 + L2 parallel: 1/L = 1/L1 + 1/L2
Capacitor
Inductor
Stores energy in
Electric field
Magnetic field
Cannot change instantly
Voltage (a sudden step needs infinite current)
Current (a sudden stop needs infinite voltage)
Law
i = C dv/dt
v = L di/dt
Energy
½ C V²
½ L I²
At DC (steady state)
Open circuit
Short circuit (a wire)
Reactance
1/(2πfC), falls with f
2πfL, rises with f
Time constant with R
τ = R C
τ = L / R
The RL time constant
Vs o---o o---[ R ]---( L )---o 0 V (a coil always has some wire resistance R)Derivation: Vs = i R + L di/dt --> di / (Vs/R - i) = (R/L) dt. Integrating, as for the RC case:
i(t) = (Vs / R) x (1 - e^(-t R / L)) time constant tau = L / RWorked example: 5 V, R = 100 ohm, L = 100 mH
tau = 0.1 / 100 = 1 ms final current = 5 / 100 = 50 mA
i(1 ms) = 50 x 0.632 = 31.6 mA i(3 ms) = 50 x 0.950 = 47.5 mA (95 % after 3 tau, 99 % after 4.6 tau)
Notice: the inductor makes the current RISE slowly, and a larger R makes it faster
(the opposite behaviour to a capacitor).
Back-EMF and why coils need protection
The law v = L di/dt has a dangerous consequence. When current through a coil is switched off, di/dt is large and negative, so the coil produces a large voltage in the direction that tries to keep the current flowing. This is the back-EMF (or inductive kick). Think of a heavy wheel: you cannot stop it instantly, and the faster you try, the more force you feel.
A 12 V relay coil: R = 240 ohm, L = 240 mH. Running current = 12 / 240 = 50 mA.
A transistor (Basic Electronics 6) cuts the current to zero in 2 us:
v = L x di/dt = 0.24 x (0.050 / 2e-6) = 0.24 x 25,000 = 6,000 V (in theory)In reality something gives way first: the switch contacts spark, or the transistor
junction breaks down at tens of volts and is destroyed. The stored energy
1/2 L I^2 = 0.5 x 0.24 x 0.05^2 = 300 uJ has to go somewhere.THE FIX: a FLYBACK diode across the coil (arrow pointing at the supply side).
Normally reverse-biased, so it does nothing; when the switch opens, the coil's current
can circulate through the diode and fade away harmlessly:
+12 V o-------+-----------+
| |
( L ) coil --- flyback diode: cathode (bar) to the +12 V side
[ R ] /_\ anode to the switched side
| |
+-----------+------o to the switch (transistor) and then 0 V
With the diode: the switched node goes only about 0.7 V ABOVE +12 V (to 12.7 V), and the
current decays with tau = L / R = 1 ms, from 50 mA to 5 mA in about 2 ms.
Always protect inductive loads
Relays, solenoids, motors and any coil switched by a transistor or microcontroller pin need a flyback (freewheel) diode or an equivalent clamp. Without one, the spike can kill the switching transistor in a single operation, or travel back down the supply and reset the microcontroller. The diode itself is introduced in Basic Electronics 5, wired up to a transistor switch in Basic Electronics 6, and used with motors, H-bridges and relays in Basic Electronics 9.
A spinning motor adds a second, related effect: it also generates a voltage proportional to its speed, the motor's own back-EMF, which limits its speed and current. Basic Electronics 9 covers both kinds.
6. A switch debounce circuit
A mechanical switch does not close cleanly. For a millisecond or several, the springy contacts bounce, making and breaking the circuit dozens of times. A microcontroller reads every bounce as a separate press, so one press can count as five. The fix is to make the signal change slowly enough that the bounces are smoothed away. An RC circuit does it with two parts. The pull-up resistor from Basic Electronics 3 charges a capacitor on the input pin.
+3.3 V o------+
|
[ 10 k ] Rp (pull-up)
|
+--------+-----o to the input pin (reads 1 normally, 0 when pressed)
| |
===== C [ 100 ] Rs C = 1 uF, Rs = 100 ohm
| |
| o/ o button
| |
0 V o-------+--------+
(C is from the pin node to 0 V; Rs and the button are a second path from the pin node to 0 V)
Button released: C charges through the pull-up. tau_up = Rp x C = 10,000 x 1e-6 = 10 ms
The pin must reach the logic-high threshold, about 0.7 x Vcc (2.31 V on 3.3 V):
t = -tau x ln(1 - 0.7) = 1.204 x 10 ms = 12.0 ms (a short, harmless delay on release)Button pressed: C discharges through Rs (100 ohm) and the closed contacts. tau_down = 100 x 1e-6 = 0.1 ms
Pin falls to the logic-low threshold, 0.3 x Vcc (0.99 V), in t = 1.204 x 0.1 ms = 0.12 ms.
Peak discharge current = 3.3 / 100 = 33 mA (Rs protects the contacts and the capacitor).
Pressed, steady: pin = 3.3 x 100 / (10,000 + 100) = 0.033 V (a clear 0)How long a bounce gap does it absorb? During a gap (contacts open) C charges for that time
from about 0 V. The pin must stay below 0.3 x Vcc:
t_gap = -tau_up x ln(1 - 0.3) = 0.357 x 10 ms = 3.6 ms
Gaps shorter than 3.6 ms are completely hidden. For longer bounces, increase C:
Rp = 10 k, C = 2.2 uF gives tau = 22 ms and absorbs gaps up to 0.357 x 22 = 7.85 ms.
Even better: a Schmitt-trigger input
A normal input can chatter if the slow RC edge hangs around the threshold. A Schmitt-trigger input (the 74HC14 inverter, and the input of many microcontroller pins) has two thresholds, one for rising and one for falling, so a slow edge produces one clean transition. RC plus Schmitt trigger is the classic hardware debounce. Software debouncing (ignoring changes for about 20 ms after the first one) is the alternative, and Basic Electronics 10 shows both. Basic Electronics 8 covers Schmitt triggers and logic levels properly.
7. Build it: charge, filter, coil
Three stages. Stages A and B use only a multimeter and a stopwatch (a phone is fine) on a breadboard. Stage C, the filters and the inductor, shows things that need an oscilloscope on a real bench (a scope reads signals changing in microseconds and milliseconds; a multimeter cannot follow them), so do those in a simulator. If you own a signal generator and scope, build the filter from the parts list and compare with the table.
Parts list
Part
Value
Used in
R
10 kΩ, 1/4 W (brown-black-orange)
A, B
C1
220 µF electrolytic, 10 V or more
A
C2
100 µF electrolytic, 10 V or more (and 1 µF for the simulator)
B
Rs
100 Ω, 1/4 W (brown-black-brown)
A (discharge), B
Push button
Tactile switch, or two wire ends to touch
B
Filter parts (simulator, or bench with a signal generator)
1.6 kΩ, 100 nF
C
Coil (simulator)
240 mH, 240 Ω, 12 V; a real relay coil with the same figures
C
Supply
5 V (USB adapter, power module or a board's 5 V pin; 3 AA cells gives 4.5 V and every voltage below scales by 0.9)
A, B
Breadboard, jumper wires, multimeter, stopwatch
A, B
Check the polarity
The electrolytic's stripe side is negative and goes to ground (the − rail). Wire it backwards and it will heat and may burst. The positive leg is the longer one.
Stage A: charge and discharge, measured
Hole list (one column per connection):
R: column 5 row a -> column 10 row a (10 k)
C1: + leg (long) in column 10 row b, - leg (stripe) in column 12 row b
J2: column 12 row c -> - rail
J1: column 5 row b -> + rail (the "switch": pull it out and push it in)
Supply + to + rail, supply - to - rail (connect LAST)
Measure: red probe on column 10 row e, black probe on the - rail (meter on volts DC)
Discharge: touch the 100 ohm resistor across the capacitor's legs until the meter reads 0.00 V
With J1 out, discharge C1 with the 100 Ω resistor and confirm the meter reads about 0 V. Check the supply voltage too.
Charge: push J1 into the + rail and start the stopwatch at the same moment. Write down the voltage at 1.5 s, 2.2 s, 4.4 s, 6.6 s and 10 s (a phone video of the meter and stopwatch makes this easy).
Discharge: once at full voltage, move J1 from the + rail to the − rail, restart the stopwatch, and record the voltage at the same times.
Estimate the time constant: it is the time when the charge reading reaches 63 % of the supply (3.16 V on 5 V). Divide by R and you have your capacitor's real value.
Stage B: debounce circuit in slow motion
Build the debounce schematic from section 6 with the 100 µF capacitor, which stretches the 10 ms time constant to 1 s so the meter can follow it. The real-speed version (1 µF) is in the simulator.
Hole list:
J1: + rail -> column 5 row b
Rp: column 5 row a -> column 10 row a (10 k, pull-up)
C2: + leg column 10 row b, - leg column 12 row b; J2: column 12 row c -> - rail
Rs: column 10 row c -> column 15 row a (100 ohm)
Button: one terminal to column 15 row b, the other terminal to the - rail
Measure: red probe on column 10 row e (the pin node), black probe on the - rail
Power up and wait about 5 s: the pin node reads the supply (about 5 V).
Press and hold the button: the reading drops at once to about 0.05 V (5 × 100 / 10,100).
Release and start the stopwatch: the reading climbs back, reaching 63 % (3.16 V) at 1 s and 70 % (3.5 V) at 1.2 s. That 70 % point is where a 5 V logic input would see a "1".
Stage C: simulator only (filters and coil)
Falstad Circuit Simulator (falstad.com/circuit). Use Draw to add parts, double-click a part to edit its value, and right-click a node to send it to the scope.
RC charging (compare with Stage A): a 5 V DC source, a switch, a 10 kΩ resistor and a 220 µF capacitor to ground. Scope the capacitor node and click the switch. The 63 % mark must fall at 2.2 s (you may need to slow or speed the simulation with its speed slider).
Low-pass and high-pass: an AC voltage source (set the amplitude to 1 V, frequency to 100 Hz, 1 kHz, then 10 kHz), a 1.6 kΩ resistor and a 100 nF capacitor. Scope the source and the output together and read the output amplitude. Then swap R and C for the high-pass.
Coil current: a 12 V DC source, a 240 Ω resistor and a 240 mH inductor (set the inductance in its edit box) in series, then a switch to ground. Right-click the resistor and choose the scope to show its current. Close the switch: the current should climb towards 50 mA with a 1 ms time constant.
Flyback: in the same circuit, open the switch and look at the voltage at the node between the coil and the switch. Then add a diode with its anode at ground and its cathode at the +12 V end of the coil (across the coil, as in the section 5 schematic), and repeat. Without the diode the node jumps to a very large voltage; with it, the node rises only to about 12.7 V.
Tinkercad Circuits (tinkercad.com): the breadboard, resistor, electrolytic capacitor (it shows its polarity), push button, power supply and multimeter cover stages A and B with the same hole lists. The function generator and oscilloscope components give the filters (set the generator to a sine wave of 1 V amplitude and use the scope's cursors to read the output). Tinkercad has no ideal inductor in its basic parts, so use Falstad for stage C's coil.
Expected readings
Measurement
Calculated
Real (typical)
Simulator
A: time constant 10 k × 220 µF
2.2 s
1.7 to 2.8 s
2.2 s
A: charging at 2.2 s
3.16 V
2.7 to 3.6 V
3.16 V
A: charging at 4.4 s
4.32 V
4.0 to 4.6 V
4.32 V
A: charging at 10 s
4.95 V
4.8 to 5.0 V (leakage)
4.95 V
A: time to reach 2.5 V
1.52 s
1.2 to 1.9 s
1.52 s
A: discharging at 2.2 s
1.84 V
1.4 to 2.3 V
1.84 V
A: discharging at 6.6 s
0.25 V
0.1 to 0.5 V
0.25 V
B: button pressed (5 V)
0.05 V
0.03 to 0.15 V
0.05 V
B: 1 s after release (tau = 1 s)
3.16 V
2.7 to 3.6 V
3.16 V
B: 1.2 s after release
3.50 V (70 %)
3.0 to 3.9 V
3.50 V
C: low-pass, 100 Hz / 1 kHz / 10 kHz out (1 V in)
0.995 / 0.705 / 0.099 V
Within a few %
0.995 / 0.705 / 0.099 V
C: high-pass, 100 Hz / 1 kHz / 10 kHz out (1 V in)
0.100 / 0.709 / 0.995 V
Within a few %
0.100 / 0.709 / 0.995 V
C: coil current at 1 / 2 / 3 ms (12 V, tau = 1 ms)
31.6 / 43.2 / 47.5 mA
(needs a scope)
31.6 / 43.2 / 47.5 mA
C: coil, final current
50 mA
(measure with the meter, 12 V)
50 mA
C: switched node after opening, with flyback diode
about 12.7 V (0.7 V above the supply)
(needs a scope)
about 12.7 V; without the diode a huge spike
The real readings spread because of tolerance: the capacitor is ±20 % (and electrolytics change with age) and the resistor is ±5 %. The numbers that do not depend on tolerance are the fractions: the reading is always 63 % of the supply after one measured time constant, and 99 % after 4.6.
8. Challenges
Challenge 1: Capacitor sums
(a) A 47 µF capacitor is charged to 12 V: find the charge and the stored energy. (b) A 22 µF and a 47 µF capacitor are connected (i) in parallel and (ii) in series: find each total capacitance. With the series pair across 24 V, find the voltage across each, and say whether the 22 µF part is safe if it is rated at 16 V. (c) A 220 µF capacitor charged to 9 V discharges through 1 kΩ: find the time constant, the starting current, the energy stored, and the time for the voltage to fall to 1 V. Also give its reactance at 50 Hz.
Design a low-pass filter with a cut-off close to 500 Hz using a 47 nF capacitor. (a) Calculate the exact resistance, then choose the nearest E24 value and find the actual cut-off. (b) Find the gain (as a ratio of output to input amplitude) at 50 Hz, 500 Hz and 5 kHz. (c) A 5 V step is applied: find the time constant and the time for the output to reach 90 % of its final value, and check it against rise time = 0.35 / fc. If you can, simulate it in Falstad and compare.
(a) A switch on a 3.3 V input bounces for up to 6 ms. With a 10 kΩ pull-up and the capacitor on the pin as in section 6, choose an E6 capacitor (1, 1.5, 2.2, 3.3, 4.7 µF) so that gaps of 6 ms are hidden (pin stays below 0.3 × Vcc). Give the release delay (to 0.7 × Vcc), and the peak discharge current and time constant with a 100 Ω series resistor. (b) A 12 V relay coil has R = 240 Ω and L = 240 mH. Find the final current, the time constant, the time to reach 90 % of final current, and the stored energy. If the transistor cuts the current in 2 µs, what voltage does v = L di/dt predict? With a flyback diode (ignore its 0.7 V drop), find how long the current takes to fall to 10 %.
Capacitor: Q = C V; E = ½ C V²; parallel C = C1 + C2; series 1/C = 1/C1 + 1/C2 (smaller capacitor takes the larger voltage share)
RC: τ = R C; charging v = Vs (1 − e−t/τ), discharging v = V0 e−t/τ; 63 % at 1 τ, 95 % at 3 τ, 99 % at 4.6 τ; t = −τ ln(1 − f)
Reactance: Xc = 1/(2πfC); XL = 2πfL; capacitors block DC and pass AC, inductors the opposite
RC filter: fc = 1/(2πRC); gain 0.707 (−3 dB) at fc; low-pass has C to ground, high-pass has C in the signal path
Decoupling: 100 nF ceramic at each IC supply pin, 10 to 100 µF bulk near drivers and regulators; ripple dV = I/(fC)
Capacitor care: electrolytic stripe is negative; rating at least 1.5 to 2 × the working voltage; ±20 % tolerance; "104" = 100 nF
Inductor: v = L di/dt; E = ½ L I²; τ = L/R, i = (V/R)(1 − e−t/τ)
Back-EMF: switching off a coil makes a big voltage spike; put a flyback diode across every relay, solenoid or motor coil (cathode to the supply side)
Debounce: 10 k pull-up plus 1 µF to ground plus 100 Ω series resistor to the button; hides gaps up to 0.357 × R C
Next, Basic Electronics 5 introduces diodes and LEDs: one-way current, forward voltage, sizing an LED resistor, the flyback and protection diodes promised above, and rectifier basics.