THD Meter (thd)
The total harmonic distortion of a signal and its fundamental, while the circuit runs.
Group: Control · Kind: {"block":"thd","kind":"control"}
When to use it
Use it to watch or act on the distortion of an inverter output or a rectifier input current during the run. Use Harmonic Meter for one harmonic and scope.measure for the spectrum after the run.
Pins
| Pin | Domain | Meaning |
|---|---|---|
in |
signal | Signal to measure |
freq |
signal | Optional fundamental frequency in hertz, such as a PLL output |
thd |
signal | Total harmonic distortion as a ratio, 0.05 is 5 percent |
amp |
signal | Peak amplitude of the fundamental |
Common parameters
f: Fundamental frequency: the window is cycles/f seconds; a wired freq input replaces it (50 Hz mains, IEC 60038:2009 Table 1) (Default: 50)cycles: Window length in periods of the fundamental; the harmonic window of IEC 61000-4-7:2002+A1:2008 is 10 at 50 Hz and 12 at 60 Hz (Default: 1)
Parameters
| Key | Unit | Default | Typical range | Description |
|---|---|---|---|---|
f |
Hz | 50 | Fundamental frequency: the window is cycles/f seconds; a wired freq input replaces it (50 Hz mains, IEC 60038:2009 Table 1) | |
cycles |
— | 1 | Window length in periods of the fundamental; the harmonic window of IEC 61000-4-7:2002+A1:2008 is 10 at 50 Hz and 12 at 60 Hz |
Parameter descriptions are in English in both languages.
Model
Over the same sliding window as RMS Meter the block integrates in, in squared, and in times the sine and cosine of the fundamental angle. The fundamental amplitude is A1 = 2sqrt(mean(insin)^2 + mean(in*cos)^2). THD = sqrt(mean(in^2) - mean(in)^2 - A1^2/2) / (A1/sqrt(2)), everything in the RMS that is neither DC nor fundamental over the RMS of the fundamental. It counts every harmonic the step resolves, so a square wave gives the analytic 48.3 percent. The output is 0 while the fundamental is zero.
Common mistakes
- scope.measure sums harmonics up to order 50 by default, as IEEE Std 519-2014 defines THD, and this block counts all of them. For a square wave the two differ by a few tenths of a percent; for a switched waveform with a large ripple at the switching frequency the block reads higher.
- The window must be whole periods of the fundamental. With f wrong by even a percent, part of the fundamental counts as distortion.
Problems rules: pin.unconnected
Datasheet and sources
A power-quality analyser reports THD over a window of 10 cycles at 50 Hz or 12 at 60 Hz (IEC 61000-4-7:2002+A1:2008) and usually up to order 40 or 50; check which orders it sums before comparing.
Example
Open the example with the command file.openExample and the name demo:thd.
Generated by cargo xtask reference from the usage texts and parameter specs. Do not edit by hand.