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

A5 · Lesson 55 · Project: characterizing a capacitor discharge

From a noisy record to a time constant, an energy and a deadline

A capacitor of unknown value discharges through a known 1 kΩ resistor, and a logger records its voltage every half millisecond, with 1% noise on each reading. From that record alone you'll find the time constant and the starting voltage, the energy the resistor absorbed, the moment the voltage fell below 1 V, and the current partway through. Every part of the course comes in: logarithms and a straight-line fit, integrals of data, an exponential's tail, and a derivative of noisy samples.

  • The plot shows ln⁡v against time for a discharge from 9 V. A pure exponential turns into a straight line, of slope −1/τ and intercept ln⁡V0.
  • Change the time constant (in ms) and watch the slope change. The readout gives the slope.
  • Noise in the readings scatters points about this line; a straight-line fit through all of them recovers the slope and intercept.

Predict

The fit gives ln⁡v=2.197−100.0t, with t in seconds. What are the time constant and the starting voltage?

Name it

The plan

  1. Fit. Take yk=ln⁡vk and fit a straight line y=c+st by least squares:
s=∑(tk−t¯)(yk−y¯)∑(tk−t¯)2,c=y¯−st¯

Then τ=−1/s, V0=ec and C=τ/R.

  1. Energy. The resistor absorbs ∫v2/Rdt. Integrate the record by Simpson's rule, add the tail past the end of the record from the fit, V02τ2Re−2T/τ, and compare with the energy the capacitor started with, 12CV02.
  2. Deadline. The fit says v falls to 1 V at τln⁡(V0/1). The data say it at the first sample below 1 V, interpolated with the one before.
  3. Current. At 10 ms, compare −Cvk+1−vk−12Δt from the data with V0Re−t/τ from the fit.

Why fit in logs

Fitting a line to ln⁡v turns a curve fit into the straight-line formulas above. The price is that 1% noise on v becomes about 0.01 of noise on ln⁡v at every sample, so late samples, where v is small, count as much as early ones. With multiplicative noise like this, that's fair; with a fixed noise floor it would give the tail too much weight.

Worked example

A fit returns s=−102.0 per second and c=2.20. What are τ, V0 and C with R = 1 kΩ, and when does the voltage reach 1 V?

Show the solution
  1. Time constant. τ=1/102.0=9.80ms
  2. Starting voltage. V0=e2.20=9.03V
  3. Capacitance. C=τ/R=9.80μF
  4. Time to reach 1 V. t=τln⁡(9.03)=9.80×2.200=21.6ms

Answer τ=9.80 ms, V0=9.03 V and C=9.80 µF, and the voltage reaches 1 V at 21.6 ms.

Worked example

The record is 50 ms long, five time constants of 10 ms. How much energy does it leave out?

Show the solution
  1. Energy in the tail. The tail past T = 50 ms holds E=V02τ2Re−2T/τ=81×0.012000e−10=1.8×10−8J
  2. Compare with the total. Against a total of 0.405 mJ, that's 0.005%.
  3. Why so little. Five time constants capture all but e−10 of the energy, since the energy decays twice as fast as the voltage.

Answer the record leaves out 1.8×10−8 J, 0.005% of the 0.405 mJ total.

Check

A straight-line fit to ln⁡v against t (in seconds) has slope −100 and intercept 1.6. What is the time constant?

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

Check

With the same fit (slope −100, intercept 1.6), when does the voltage fall to 1 V?

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

Check

The starter makes the logged record t, v. Fit a line to ln⁡v by least squares (write the formulas yourself) and set tau, V0 and C (with R = 1000 Ω).

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

Check

Using the record and your fit (copied into the starter), set E_data to ∫v2/Rdt over the record by Simpson's rule, E_tail to the fit's tail past the end, V02τ2Re−2T/τ, and E_cap to 12CV02.

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

Check

With the same record and fit, set t_fit to the time the fit says the voltage reaches 1 V, and t_data to the first crossing below 1 V in the data, interpolated linearly between that sample and the one before.

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

Check

At t = 10 ms (sample 20), set i_data to the current from a central difference of the data, −Cv21−v192Δt, and i_fit to V0Re−t/τ from the fit. Then set true to the noise-free value, 91000e−1, and better to "fit" or "data", whichever is closer.

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

Check

How noisy were the readings? Using the fit from the starter, set res to the residuals ln⁡vk−(c+stk), and noise to their standard deviation (the n−2 formula, since the fit used two parameters). For 1% noise on v, it should come out near 0.01.

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

Explain why

The project found the current at 10 ms two ways, and the fit won by a wide margin. When would you trust the central difference instead?

Practice

Keep practicing

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