# 諧波量測 (`harmonic`)

> 在電路執行中，計算訊號某一次諧波的振幅與相位。

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

[元件參考](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/) · [English](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/harmonic/)

**分類:** 控制 · **種類:** `{"block":"harmonic","kind":"control"}`

## 何時使用

需要在模擬中依某一次諧波動作時使用，例如選擇性諧波補償，或檢查濾波器是否符合某一次諧波的限值。

## 接腳

| 接腳 | 訊號域 | 意義 |
|---|---|---|
| `in` | 訊號 | 要量測的訊號 |
| `freq` | 訊號 | 選用的基本波頻率輸入，單位赫茲，例如鎖相迴路的輸出 |
| `amp` | 訊號 | 該次諧波的峰值 |
| `phase` | 訊號 | 相位，單位度，和正弦訊號源的相位定義相同 |

## 常用參數

- `f`: Fundamental frequency: the window is cycles/f seconds; a wired freq input replaces it (50 Hz mains, IEC 60038:2009 Table 1) (預設值: 50)
- `order`: Harmonic order measured: 1 is the fundamental, 3 the third harmonic (預設值: 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 (預設值: 1)

## 參數

| 鍵 | 單位 | 預設值 | 典型範圍 | 說明 |
|---|---|---|---|---|
| `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 |

_參數說明在兩種語言中都是英文。_

## 模型

n 次諧波表示為 amp*sin(n*theta + phase)，其中 theta 是基本波角度 2*pi*f*t，freq 有接線時則是 2*pi*freq 的積分。在滑動視窗內，a = 2*mean(in*sin(n*theta))，b = 2*mean(in*cos(n*theta))；amp = sqrt(a^2 + b^2)，phase = atan2(b, a)，單位度。相位為 30 的正弦訊號源，在 1 次讀到的相位就是 30。

## 常見錯誤

- 相位是相對於從 t = 0 起算的基本波角度，不是相對於訊號本身的零交越點。要得到兩個訊號之間的相位差，請用兩個 f 相同的諧波量測相減。
- 步長太粗時，高於每週期取樣數一半的次數無法解析。該次諧波的一個週期內至少要有 20 步。

Problems 規則: `pin.unconnected`

## 規格書與來源

諧波限值，例如 16 A 以下設備的 IEC 61000-3-2，是以每一次諧波的均方根安培值給出；該次諧波的均方根值為 amp 除以 sqrt(2)。

## 範例

以指令 `file.openExample` 開啟範例，名稱為 `demo:harmonic`.

---
由 `cargo xtask reference` 依使用說明文字與參數規格產生，請勿手動編輯。
