C213 of 30
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

C2 · Lesson 13 · Measurements lab

Fitting time constants, the energy lost in charge sharing, impedance sweeps, PWM ripple and an inductor's saturation, in Python

Lessons 1 to 11 gave capacitors and inductors simple laws and then complicated them: real parts have ESR and ESL, energy goes missing when capacitors share charge, a PWM filter never quite settles, and inductors saturate. On the bench these show up as data: a decaying trace, an impedance curve, a current ramp that steepens. In this lab you'll turn such data into numbers, and check the formulas from the lessons against simulations that don't assume them.

  • The curve is a real capacitor's impedance against frequency: its capacitance dominates at low frequency, its ESR at the bottom of the dip, and its ESL above.
  • The dip, at 12πLC, is the self-resonant frequency, and its depth is the ESR.
  • Change the ESL, as a different package or longer leads would, and watch the useful range shrink. Step 3 finds the dip by a sweep.

Predict

A 10 µF capacitor at 10 V is connected to an empty 10 µF capacitor through a resistor. Does the energy lost depend on the resistor?

Name it

Fitting an exponential

A decay v=V0e−t/τ becomes a straight line in ln⁡v: slope −1/τ. Fitting a line to ln⁡v against t uses every sample, not just two, so noise averages down. Points near zero, where noise dominates the logarithm, should be left out.

Charge sharing

When a capacitor at V charges another through R, the current is VRe−t/τ with τ=RC1C2C1+C2, and the energy dissipated is ∫i2Rdt=C1C2V22(C1+C2), independent of R.

Impedance of a real capacitor

A capacitor with ESR R and ESL L has |Z|=R2+(ωL−1ωC)2. A logarithmic sweep finds the minimum at 12πLC, with |Z| = R there.

PWM ripple exactly

A PWM wave of amplitude V, duty D and period T through an RC settles into a sawtooth whose exact peak-to-peak value is

Δv=V(1−e−DT/τ)(1−e−(1−D)T/τ)1−e−T/τ,

which tends to VD(1−D)Tτ when τ ≫ T.

Inductance from a current ramp

With a known voltage across an inductor, its current ramps at didt=VL(i). Differencing a measured ramp gives L at each current, and where the slope steepens, the core is saturating.

Worked example

A capacitor discharges through a resistor; samples of its voltage, with noise, fall from 5 V. How do you get τ from them?

Show the solution
  1. Keep the clean samples. Use the samples above about 10% of the start, where noise is small compared with the signal.
  2. Fit a line to their logarithms. Take the logarithm of each sample and fit a straight line against time: ln⁡v=ln⁡V0−tτ The slope is −1τ and the intercept ln⁡V0.
  3. How close it gets. With 100 samples over two time constants and 10 mV of noise, the fit lands within about 1% of the true τ.
  4. Compare with one point. Reading τ from a single point, the time to fall to 37%, uses one noisy sample and an eyeballed crossing.
  5. Where it's used. The fit is how an automated tester measures a capacitor's value through a known resistor.

Answer fit a straight line to the logarithm of the samples above about 10% of the start; its slope is −1τ, which gives τ within about 1% here.

Worked example

Integrate the loss when 10 µF at 10 V charges an empty 10 µF through 10 Ω, and through 1 kΩ.

Show the solution
  1. With 10 Ω. τ = 50 µs and the current starts at 1 A.
  2. With 1 kΩ. τ = 5 ms and the current starts at 10 mA.
  3. Integrate the loss. Integrating i2R numerically over ten time constants gives 250 µJ in both cases, matching E=C1C2V22(C1+C2)=10×10×1002×20μJ=250μJ
  4. Compare with the stored energy. That's half of the 500 µJ stored at the start.
  5. How to avoid it. Only adding an inductor, as switched-mode converters do, avoids the loss, by moving charge without a large voltage across a resistance.

Answer 250 µJ is lost with either resistor, half of the 500 µJ stored at the start.

Worked example

How exact is the ripple estimate VD(1−D)Tτ for a 5 V, 25% PWM wave with τ = 100T, 10T and 3T?

Show the solution
  1. Exact ripple. The exact formula gives 9.375 mV, 93.7 mV and 312 mV.
  2. Estimated ripple. The estimate gives 9.375, 93.75 and 312.5 mV.
  3. Compare. Even at τ = 3T the estimate is only 0.2% high.
  4. Why it works. The estimate assumes the capacitor's voltage barely changes during a period, so its current stays nearly constant through each phase.
  5. Why it works so well. The errors in the on and off phases nearly cancel, so the approximation holds surprisingly well and is good enough for design work.

Answer very close: the estimate is at most 0.2% high, even at τ = 3T.

Check

Step 1. Write fit_tau(t, v, floor) returning τ from a least-squares line through ln⁡v against t, using only samples with v > floor.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

Step 2. Write share_loss(C1, C2, V, R) returning the energy dissipated in R when C1 at V charges an empty C2, by integrating i2R numerically (trapezoid rule, 100 000 points over ten time constants).

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

Step 3. Write impedance(f, C, L, R) returning |Z| of a capacitor with ESL L and ESR R, and srf(C, L, R) returning the frequency of minimum |Z| from a sweep of 20 001 log-spaced points between 1 kHz and 10 GHz.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

Step 4. Write pwm_ripple(V, D, T, tau) returning the exact steady-state peak-to-peak ripple of an RC-filtered PWM wave, by iterating the on and off exponentials for many periods until it settles.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

Step 5. Write inductance_curve(t, i, V) returning (i_mid, L): the inductance at each step of a measured current ramp, from L=VΔtΔi, at the midpoint currents.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

A capacitor's voltage falls from 3 V to 1 V in 2 ms.

(a)

What's its time constant?

Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.

(b)

How long from the start until it reaches 50 mV?

Check

A 1 µF capacitor at 12 V charges an empty 1 µF one through a resistor. How much energy does the resistor dissipate?

Write units the way you normally would: 1.5 µJ, 1500 nJ and 0.0015 mJ are the same answer.

Check

A 3.3 V PWM wave at 0.2 duty passes through an RC with τ = 5 periods. What's its exact peak-to-peak ripple?

Write units the way you normally would: 1.5 mV, 1500 µV and 0.0015 V are the same answer.

Check

A 22 µH inductor has 5 V across it. How long does its current take to rise by 0.2 A?

Write units the way you normally would: 1.5 µs, 1500 ns and 0.0015 ms are the same answer.

Explain why

Why does fitting a straight line to the logarithm of a decay give τ more reliably than timing when the voltage reaches 37%?

Practice

Keep practicing

6 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.