168а. A real coil and an LCR meter: the equivalent circuit, series and parallel models, D and Q, synchronous detection on an STM32
Section 168 treated a coil as an ideal inductance with wire resistance. A handheld LCR meter shows that it is not: the same coil gives different numbers at 100 Hz and at 100 kHz, and the meter asks you to pick a "series" or a "parallel" circuit. This section explains what exactly it measures, how to choose the circuit, what D and Q mean, where 10 pF with open leads comes from — and how to build such a meter on the microcontroller itself.
Grounds: alg.c (synchronous detection, conversion to equivalent circuits, lead
compensation) was built with gcc 12.2.0 on a computer (stm-sys:1) and run by host.c:
a coil with self-capacitance and core losses, two lossy capacitors and open leads, a
0.3 V signal, a 12-bit ADC, frequencies 100 Hz, 120 Hz, 1 kHz, 10 kHz and 100 kHz — the
same as on handheld meters such as the FNIRSI LC1020E. The same alg.c was built with
arm-none-eabi-gcc 12.2.1 (stm-arm:1) for Cortex-M4F and Cortex-M0.
Terms used in the documentation
Term Meaning LCR meter a meter of inductance, capacitance and resistance with alternating current complex impedance Z = R + jX the resistive and reactive parts together series equivalent circuit (Ls, Cs, Rs) the elements in a row parallel equivalent circuit (Lp, Cp, Rp) the elements side by side dissipation factor D the ratio of losses to the reactive part open compensation (OFFSET) subtracting the admittance of the open leads Hcur, Hpot, Lpot, Lcur current and sense terminals of a four-wire connection synchronous detection multiplying by a reference sine and cosine stray capacitance of the leads the parasitic capacitance of probes and wires In plain words. The meter applies a sine of one frequency to the part and looks at how much the current lags or leads the voltage. That gives two numbers — "what dissipates" and "what stores". How to split them into "a coil and a resistor" — in series or in parallel — is your choice, and the numbers on the screen depend on it.
168а.1 A real coil: the equivalent circuit
Besides the inductance L a coil has the wire resistance Rdc (section 168.6, DCR), a capacitance between turns C∥ and core losses, drawn as a resistor R∥ in parallel with everything. The experiment takes a 100 µH coil: Rdc 0.5 Ω, C∥ 10 pF, R∥ 50 kΩ. The model is simple but explains everything seen on a meter's screen: below resonance L grows, losses grow with frequency, and above resonance the coil becomes a capacitor.
168а.2 What the meter actually measures
At one frequency the meter sees any part as one complex impedance Z = R + jX. R is the resistive part (energy goes into heat), X the reactive part (energy is stored and returned). X > 0 — the part behaves as a coil, X < 0 — as a capacitor. The meter knows nothing else: "L", "C", "D", "ESR" on the screen are these two numbers converted by the chosen circuit and frequency.
168а.3 Series and parallel circuits
The same Z can be represented in two ways:
- in series: Rs and Xs in a row, Xs = ωLs or −1/(ωCs);
- in parallel: Rp and Xp side by side, Rp = (R² + X²)/R, Xp = (R² + X²)/X.
lcr_parallel_t lcr_parallel(lcr_z_t z, float f)
{
float w = 2.0f * 3.14159265f * f;
float m = z.r * z.r + z.x * z.x;
lcr_parallel_t p = {0, 0, m / z.r};
float xp = m / z.x;
Both forms are exact at this frequency — they describe the same point. They differ in which of them does not change with frequency for your part. That is the one to choose.
168а.4 Which to choose: an experiment with two capacitors
A 100 µF electrolytic has its losses as a series resistance, ESR 0.1 Ω. A 100 pF ceramic has its losses as a 100 MΩ leakage in parallel with the capacitance. A measurement at three frequencies, both circuits:
| Part | frequency | Cs | Rs | Cp | Rp |
|---|---|---|---|---|---|
| 100 µF, ESR 0.1 Ω | 100 Hz | 100.01 µF | 0.1016 Ω | 100.01 µF | 2493.56 Ω |
| 100 µF, ESR 0.1 Ω | 1000 Hz | 99.99 µF | 0.0999 Ω | 99.60 µF | 25.46 Ω |
| 100 µF, ESR 0.1 Ω | 100000 Hz | 100.03 µF | 0.1000 Ω | 2.47 µF | 0.10 Ω |
| 100 pF, leakage 100 MΩ | 100 Hz | 102.53 pF | 2471468 Ω | 100.00 pF | 100.0 MΩ |
| 100 pF, leakage 100 MΩ | 1000 Hz | 100.03 pF | 25318 Ω | 100.00 pF | 100.0 MΩ |
| 100 pF, leakage 100 MΩ | 100000 Hz | 100.00 pF | 4 Ω | 100.00 pF | 60.7 MΩ |
For the electrolytic Cs and Rs are constant: at 100 kHz the series circuit gives the same 100 µF and 0.1 Ω, while the "parallel capacitance" collapses to 2.47 µF. For the small capacitance it is the other way round: Cp and Rp stay at 100 pF and 100 MΩ, while Cs at 100 Hz drifts to 102.53 pF. Hence the rule from meter manuals: a low part impedance (large capacitance, small inductance, roughly below 100 Ω) — the series circuit; a high one (small capacitance, large inductance, above 10 kΩ) — the parallel one; in between the choice hardly matters.
The last row is an honest limit: at 100 kHz the 100 pF part has D of about 10⁻⁵, below the resolution of a 12-bit ADC, and Rp came out as 60.7 MΩ instead of 100. A meter does not see small losses at a high frequency — the screen shows noise.
168а.5 D and Q: losses as one number
D = Rs/|Xs| — the ratio of losses to the reactive part in the series circuit, Q = 1/D. For capacitors D (the loss tangent) is customary, for coils Q (the quality factor):
s.d = z.r / fabsf(z.x);
s.q = fabsf(z.x) / z.r;
D does not depend on the choice of circuit: the parallel form gives the same number. The coil of 168а.1 has Q of just 0.13 at 100 Hz — the wire resistance exceeds the reactance; at 100 kHz Q is already 108.88 (the table in 168а.9). There is no Q of a coil "in general" — only at a frequency.
168а.6 The measurement frequency and self-resonance
The inductance with C∥ and Rdc forms a tank with its own frequency 1/(2π√(LC∥)): for 100 µH and 10 pF — 5033 kHz. Below it the meter shows an apparent inductance that grows as it is approached:
| Frequency | apparent L, µH | apparent Rs, Ω |
|---|---|---|
| 1 MHz | 104.09 | 9 |
| 2 MHz | 118.64 | 45 |
| 4 MHz | 266.48 | 918 |
Handheld meters work up to 100 kHz, and for a coil of hundreds of microhenries that is far from resonance. But a choke of tens of millihenries with a self-capacitance of tens of picofarads resonates around a hundred kilohertz — it must be measured at 1 kHz. The rule: the measurement frequency is the one the part works at, but well below its resonance.
168а.7 Leads: four terminals and open compensation
A meter has four terminals: Hcur and Lcur drive the current, Hpot and Lpot take the voltage right at the part's leads — the four-wire connection of 166.4, the drop on the wires does not enter the result. The GUARD terminal carries leakage current along the probe bodies past the measurement.
Open leads are a capacitor themselves. A meter with no part shows about 10 pF and D of about 0.2 at 100 Hz — the capacitance and leakage of the wires themselves. In the experiment the leads are modeled the same way: 10.00 pF, D 0.200. The "open" calibration (the OFFSET button) remembers their admittance and subtracts it from every following measurement:
lcr_z_t lcr_open_comp(lcr_z_t z, lcr_z_t open)
{
float m = z.r * z.r + z.x * z.x, mo = open.r * open.r + open.x * open.x;
float g = z.r / m - open.r / mo, b = -z.x / m + open.x / mo;
A 47 pF capacitor together with the leads gave 57.00 pF, after compensation — 47.004 pF. After calibration open leads show fractions of a picofarad, and D jumps to tens — that is not losses but noise divided by an almost zero reactive part. Small impedances (milliohms of ESR) need a second calibration — "short", which subtracts the resistance and inductance of the shorted leads.
168а.8 🔧 An LCR meter on an STM32: synchronous detection
The circuit: a DAC (or PWM with a filter) gives a sine of 32 points per period, which goes through a reference resistor Rref to the part. Two ADC channels take the voltage on the part and on the resistor — the latter is proportional to the current. Each channel is multiplied by a cosine and a sine of the same frequency and summed over a whole number of periods:
lcr_acc_t lcr_demod(const int16_t *x, uint32_t n)
{
lcr_acc_t a = {0, 0};
for (uint32_t k = 0; k < n; k++) {
uint32_t p = k & (LCR_PTS - 1);
a.re += (int32_t)x[k] * lcr_cos[p];
a.im -= (int32_t)x[k] * lcr_cos[(p + LCR_PTS - 8) & (LCR_PTS - 1)]; /* sin = cos(p - 8) */
}
return a;
}
The sine is taken from the same cosine table shifted by a quarter period. Everything that is not at the signal frequency — the ADC offset, 50 Hz pickup at other frequencies, harmonics — sums to zero over a whole number of periods. The ratio of the two complex numbers multiplied by Rref is the part's Z:
lcr_z_t lcr_impedance(lcr_acc_t vd, lcr_acc_t vr, float gd, float gr, float rref)
{
float ar = (float)vd.re * gd, ai = (float)vd.im * gd;
float br = (float)vr.re * gr, bi = (float)vr.im * gr;
float m = br * br + bi * bi;
Rref is chosen to suit the part (in the experiment 10 Ω, 100 Ω, 10 kΩ or 100 kΩ by |Z|), and the gain of each channel so that the signal takes almost the whole ADC scale: then both channels are measured with the same relative accuracy. Factory meters work the same way — with automatic range selection.
| Function | Cortex-M4F, bytes | Cortex-M0, bytes |
|---|---|---|
lcr_demod |
124 | 212 |
lcr_impedance |
154 | 208 |
lcr_series |
92 | 112 |
lcr_parallel |
88 | 144 |
lcr_open_comp |
82 | 222 |
Cortex-M0 has no hardware floating point — lcr_impedance calls the software
__aeabi_fmul, __aeabi_fdiv and their neighbours 21 times; for one measurement that does not
matter, the main loop — lcr_demod — is integer.
168а.9 Experiment: a coil at five frequencies
The coil of 168а.1, 16 periods of 32 points, a 12-bit ADC:
| Frequency | exact Ls, µH | measured Ls, µH | exact Rs, Ω | measured Rs, Ω | D | Q |
|---|---|---|---|---|---|---|
| 100 Hz | 99.998 | 100.049 | 0.5000 | 0.5000 | 7.953 | 0.13 |
| 120 Hz | 99.998 | 100.060 | 0.5000 | 0.4999 | 6.627 | 0.15 |
| 1000 Hz | 99.998 | 100.012 | 0.5000 | 0.4999 | 0.796 | 1.26 |
| 10000 Hz | 99.998 | 99.984 | 0.5008 | 0.5009 | 0.080 | 12.54 |
| 100000 Hz | 100.037 | 100.055 | 0.5794 | 0.5774 | 0.009 | 108.88 |
The largest Ls error is 616 parts per million (0.06 %), at 120 Hz: there the reactive part is smaller than the resistive one, and ADC quantization affects it more. At 100 kHz Rs grows too — 0.5794 Ω instead of 0.5: that is not the wire but core losses (R∥) and the nearness of resonance converted into the series circuit. That is why a coil's datasheet Q always comes with a frequency.
168а.10 Pitfalls
The wrong circuit — a "drifting" capacitance. A 100 µF electrolytic in the parallel circuit at 100 kHz is 2.47 µF. The part is fine, the model is wrong (168а.4).
No open calibration. The 10 pF of the leads add to any small capacitance: 47 pF reads 57 (168а.7). Calibrate after every change of leads and at the frequency you measure at.
A coil near resonance. The closer the frequency to self-resonance, the larger the "inductance": 266 µH instead of 100 at 4 MHz (168а.6).
D and Q without a frequency. The Q of the coil in the experiment ranges from 0.13 to 108.88 within the meter's span. Parts can be compared only at one frequency.
An incomplete number of periods. If the sum in lcr_demod stops in the middle of a
period, the DC component and the signal itself do not cancel — an error of percents. The
record length is a multiple of 32 points.
An undischarged capacitor. A charged electrolytic on the meter input kills the input; the "discharge capacitor before testing" label on the case is not a formality.
168а.11 Summary
- At one frequency the meter knows only Z = R + jX; L, C, D, ESR are a conversion by the chosen circuit.
- The series and parallel forms are both exact; choose the one whose values do not depend on frequency: a low part impedance — series, a high one — parallel. Experiment: 100 µF in the parallel circuit at 100 kHz — 2.47 µF, 100 pF in the series one at 100 Hz — 102.53 pF.
- D = Rs/|Xs|, Q = 1/D, both only with a frequency: the 100 µH coil goes from 0.13 at 100 Hz to 108.88 at 100 kHz.
- A coil's self-capacitance sets its resonance (5033 kHz in the experiment); nearer to it the apparent L grows.
- Open leads are 10 pF; OFFSET calibration subtracts their admittance: 57.00 → 47.004 pF.
- On an STM32 such a meter is a sine, a reference resistor, two ADC channels and synchronous detection over a whole number of periods: Ls error up to 0.06 % with 12 bits, 124 bytes of main-loop code on Cortex-M4F.
Check yourself
- What does an LCR meter actually measure? - A) Only inductance or only capacitance - B) The complex impedance Z = R + jX at one frequency - C) The DC resistance - D) The part's resonant frequency
- Which equivalent circuit to choose for a 100 µF electrolytic? - A) Parallel - B) Any, it does not affect the result - C) Series: for a low part impedance Cs and Rs are constant - D) None, electrolytics are not measured with an LCR meter
- Why the "open" calibration (OFFSET)? - A) To subtract the admittance of the leads themselves, about 10 pF - B) To discharge a capacitor - C) To choose the measurement frequency - D) To zero the wire resistance
Check yourself: answers - 1 — B. Why: L, C, D and ESR on the screen are R and X converted by the chosen circuit and frequency (168а.2). - 2 — C. Why: In the parallel circuit at 100 kHz the same part gives 2.47 µF (168а.4). - 3 — A. Why: Without it 47 pF read 57, with it — 47.004 (168а.7).
Next: section 169 "Diodes in detail".