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

C11 · Lesson 20 · Instrument lab

What a scope, a counter, a meter and a power analyzer compute, in Python

Modern instruments are computers that sample and calculate. The scope's rise-time readout interpolates between samples, the counter divides counts by times, the cheap meter scales an average and calls it RMS, the power analyzer averages a product, and a frequency standard's data sheet quotes an Allan deviation. In this lab you'll write each of those calculations and test them on signals whose answers are known.

  • The curve is the reading of an average-responding meter, which scales the average of |v| by the sine's form factor, π/(22)=1.1107, divided by the true RMS, for a train of pulses that are on a fraction D of the time.
  • For such pulses the average of |v| is D and the RMS is D, so the ratio is 1.1107D: 11% high for steady DC, and only 35% of the truth at a 10% duty cycle.
  • A sine gives exactly 1, which is the only waveform such a meter is right for. That's the difference between a meter labeled "true RMS" and one that isn't.

Predict

A load draws a 5 A rms current from 230 V, lagging by 30°, plus a third harmonic. What does the harmonic add to the real power?

Name it

What each instrument computes

  • Rise time: find the signal's low and high levels, then the times where it crosses 10% and 90% of the way between them, interpolating linearly between samples. For a first-order step it's τln⁡9=2.197τ.
  • Reciprocal frequency: take the rising-edge times inside a gate; the frequency is the number of whole periods between the first and last edge, divided by the time between them.
  • Average-responding meters: compute π22|v|¯, which equals the RMS only for a sine.
  • Real power and power factor: P=vi¯, and PF=P/(VrmsIrms).
  • Allan deviation: average the fractional-frequency samples in blocks of m, then σy=12(y¯k+1−y¯k)2¯. It measures how much the frequency wanders between successive averages of that length.

Worked example

A first-order system has τ = 1 ms. What rise time should the scope report?

Show the solution
  1. 10% crossing. v=1−e−t/τ crosses 10% at t10=τln⁡(1/0.9)=0.105ms
  2. 90% crossing. t90=τln⁡10=2.303ms
  3. Rise time. tr=t90−t10=τln⁡9=2.197ms
  4. Measuring it. Sampling every microsecond and interpolating recovers it to better than 0.1%.

Answer the scope should report a rise time of 2.197 ms.

Worked example

What does an average-responding meter read for a triangle wave of 1 V peak, and what is its true RMS?

Show the solution
  1. Mean absolute value. A triangle's mean absolute value is half its peak, 0.5 V.
  2. What the meter reads. 1.1107×0.5V=0.555V
  3. True RMS. 1V3=0.577V
  4. The error. The meter is 3.8% low, and it's worse on pulses and noise.

Answer the meter reads 0.555 V, and the true RMS is 0.577 V.

Check

What is the 10–90% rise time of a first-order step with τ = 1 µs?

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

Check

Write rise_time(t, v): the 10–90% rise time of a rising step, sampled at times t, interpolating linearly between samples.

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

Check

Write reciprocal_frequency(edges, gate): given rising-edge times, use the edges from the first one up to gate seconds later, and return the number of whole periods between the first and last used edge divided by the time between them.

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

Check

Write average_responding(v): what an average-responding meter, calibrated for sines, reads for the samples v.

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

Check

Write power(v, i): return (P, PF), the real power and the power factor of sampled voltage and current covering whole cycles.

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

Check

Write allan(y, m): the non-overlapping Allan deviation of fractional-frequency samples y for an averaging factor m.

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

Explain why

Why do stability specifications use the Allan deviation instead of the ordinary standard deviation of frequency readings?

Practice

Keep practicing

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