Capacitors + RC Time Constant
Charging, Filtering, Timing
Why it matters
Capacitors store energy, filter noise, and create time delays. The RC time constant (τ = R × C) tells you how fast they charge/discharge.
The idea
What Is a Capacitor?
A capacitor stores electrical energy in an electric field. Think of it as a tiny rechargeable battery that charges/discharges very quickly.
flowchart LR
V["Voltage"] -->|Charges| C["Capacitor"]
C -->|Discharges| R["Resistor"]
R -->|Time Constant| Tau["τ"]
Time constant: τ = R × C
RC Time Constant
When charging through a resistor: τ = R × C
- After 1τ: capacitor charges to ~63% of final voltage
- After 5τ: capacitor is essentially fully charged (~99%)
- Larger R or C → slower charging
Why It Matters
Capacitors are used for:
- Power supply filtering — smooth out voltage ripples
- Debouncing — hardware debounce for buttons
- Timing circuits — create delays
- Coupling — block DC, pass AC signals
Demo
Adjust Resistance and Capacitance to see how the charging curve changes.
Watch for:
- Time constant (τ) — how long until 63% charge
- Charging curve — exponential rise
- Effect of R and C — larger values = slower charging
Key takeaways
- Capacitors store energy in an electric field
- RC time constant: τ = R × C
- After 1τ: ~63% charged, after 5τ: ~99% charged
- Capacitors filter noise, create delays, and smooth power supplies
Going deeper
Capacitors have ESR (Equivalent Series Resistance) and leakage current. For power supply filtering, use ceramic capacitors (low ESR, good for high frequencies) and electrolytic capacitors (high capacitance, good for low frequencies). For timing, use film or ceramic capacitors (stable, low leakage).
Math details
RC charging equation:
V(t) = V_final × (1 - e^(-t/τ))
Where:
τ = R × C (time constant in seconds)
t = time
V_final = final voltage
At t = τ:
V(τ) = V_final × (1 - e^(-1)) ≈ V_final × 0.632
At t = 5τ:
V(5τ) = V_final × (1 - e^(-5)) ≈ V_final × 0.993
Example:
R = 10kΩ = 10,000Ω
C = 100µF = 0.0001F
τ = 10,000 × 0.0001 = 1 second
After 1 second: ~63% charged
After 5 seconds: ~99% charged
Implementation
LLM Prompt: RC Charging Simulator
Write a Rust function that simulates RC charging given R, C, V_final, and time.
Return voltage at that time using V(t) = V_final × (1 - e^(-t/τ)).
Include helper function to calculate time constant τ = R × C.
Lab Exercise: Hardware Debounce
- Build RC circuit: Button → 10kΩ resistor → 100nF capacitor → GND
- Connect capacitor to GPIO input (with pull-up enabled)
- Press button rapidly — observe smooth transition (no bounce)
- Measure time constant: τ = 10kΩ × 100nF = 1ms
- Compare to software debouncing (which is easier but uses CPU)