# Harmonic Meter (`harmonic`)

> The amplitude and phase of one harmonic of a signal, while the circuit runs.

![harmonic](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/harmonic.svg)

[Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/harmonic/)

**Group:** Control · **Kind:** `{"block":"harmonic","kind":"control"}`

## When to use it

Use it to act on one harmonic during the run, such as a selective harmonic compensator, or to check a filter against a limit on one order.

## Pins

| Pin | Domain | Meaning |
|---|---|---|
| `in` | signal | Signal to measure |
| `freq` | signal | Optional fundamental frequency in hertz, such as a PLL output |
| `amp` | signal | Peak amplitude of the harmonic |
| `phase` | signal | Phase in degrees, as the phase of a Sine Source |

## 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)
- `order`: Harmonic order measured: 1 is the fundamental, 3 the third harmonic (Default: 1)
- `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) |
| `order` | — | 1 |  | Harmonic order measured: 1 is the fundamental, 3 the third harmonic |
| `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

The harmonic of order n is amp*sin(n*theta + phase), where theta is the fundamental angle 2*pi*f*t, or the integral of 2*pi*freq while freq is wired. Over the sliding window a = 2*mean(in*sin(n*theta)) and b = 2*mean(in*cos(n*theta)); amp = sqrt(a^2 + b^2) and phase = atan2(b, a) in degrees. A Sine Source with phase 30 reads phase 30 at order 1.

## Common mistakes

- The phase is measured against the fundamental angle from t = 0, not against the signal's own zero crossing. Compare two Harmonic Meters with the same f to get the phase between two signals.
- An order above half the samples per period of a coarse step is not resolved. Keep at least 20 steps in one period of the harmonic.

Problems rules: `pin.unconnected`

## Datasheet and sources

Harmonic limits, such as IEC 61000-3-2 for equipment up to 16 A, are given per order in amperes RMS; the RMS of the harmonic is amp divided by sqrt(2).

## Example

Open the example with the command `file.openExample` and the name `demo:harmonic`.

---
Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand.
