# MMC 子模組選擇 (`mmcBalance`)

> 決定 MMC 橋臂要投入哪些子模組：投入幾個由投入指數 m 決定，投入哪幾個則依電容電壓排序決定。

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

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

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

## 何時使用

MMC 橋臂元件內已含一個。當你自己用 MOSFET 或 IGBT（含損耗）搭建子模組，並需要最近準位或移相調變與電容均壓時，再單獨使用這個方塊。

## 接腳

| 接腳 | 訊號域 | 意義 |
|---|---|---|
| `m` | 訊號 | 投入指數：0 … 1，bipolar 為 1 時為 −1 … 1 |
| `i` | 訊號 | 橋臂電流，為投入電容充電的方向為正 |
| `v1` | 訊號 | 子模組 1 的電容電壓 |
| `v2` | 訊號 | 子模組 2 的電容電壓（n 為 2 以上才讀取） |
| `v3` | 訊號 | 子模組 3 的電容電壓（n 為 3 以上才讀取） |
| `v4` | 訊號 | 子模組 4 的電容電壓（n 為 4 以上才讀取） |
| `v5` | 訊號 | 子模組 5 的電容電壓（n 為 5 以上才讀取） |
| `v6` | 訊號 | 子模組 6 的電容電壓（n 為 6 以上才讀取） |
| `v7` | 訊號 | 子模組 7 的電容電壓（n 為 7 以上才讀取） |
| `v8` | 訊號 | 子模組 8 的電容電壓（n 為 8 才讀取） |
| `g1` | 訊號 | 子模組 1：1 投入、0 旁路、−1 反向投入 |
| `g2` | 訊號 | 子模組 2 |
| `g3` | 訊號 | 子模組 3 |
| `g4` | 訊號 | 子模組 4 |
| `g5` | 訊號 | 子模組 5 |
| `g6` | 訊號 | 子模組 6 |
| `g7` | 訊號 | 子模組 7 |
| `g8` | 訊號 | 子模組 8 |

## 常用參數

- `n`: Submodules selected, 1 to 8: inputs v1 … v<n>, outputs g1 … g<n> (預設值: 4)
- `fc`: Carrier frequency of the phase-shifted PWM (n carriers shifted by 1/n of a period); 0 inserts the nearest level, round(m·n) (預設值: 0)
- `bipolar`: Set to 1 for full-bridge submodules: m from −1 to 1, and a negative m inserts submodules reversed (g = −1) (預設值: 0)

## 參數

| 鍵 | 單位 | 預設值 | 典型範圍 | 說明 |
|---|---|---|---|---|
| `n` | — | 4 |  | Submodules selected, 1 to 8: inputs v1 … v<n>, outputs g1 … g<n> |
| `fc` | Hz | 0 |  | Carrier frequency of the phase-shifted PWM (n carriers shifted by 1/n of a period); 0 inserts the nearest level, round(m·n) |
| `bipolar` | — | 0 |  | Set to 1 for full-bridge submodules: m from −1 to 1, and a negative m inserts submodules reversed (g = −1) |
| `sorting` | — | 1 |  | Set to 0 to switch the sorting balance off: submodules go in by index, lowest first, and leave highest first |

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

## 模型

投入幾個：fc = 0 時為 round(m·n)（最近準位）；fc 大於 0 時用 n 個 0 到 1 的三角載波，第 k 個載波移相 k/n 個週期，投入數為低於 |m| 的載波數，在一個載波週期內平均為 |m|·n。投入哪幾個：s·i 為正時（s 為投入極性）電容充電，所以投入電壓最低的；否則投入電壓最高的。投入數增加時只從旁路中的子模組挑出新增者，減少時只從已投入者中挑出離開者，所以子模組只在準位變化時切換。電壓差在橋臂最高電壓的十億分之一以內視為相同，取編號較小者，因此求解器的捨入誤差不會決定投入哪個子模組。sorting 為 0 時改用固定順序：編號小的先投入、最後退出，因此電容電壓會逐漸分散；可用來看出排序的作用。bipolar 為 1 時，負的投入數代表反向投入，極性改變時重新排序。此方塊會回報載波交越時刻，讓求解器剛好落在交越點。

## 常見錯誤

- 橋臂電流的量測方向必須是為投入電容充電的方向。方向相反時，排序會投入錯誤的子模組，電容電壓會越差越遠。
- 選擇只在準位變化時改變。m 保持不變時，電容電壓會逐漸分散，直到準位再次變化；這是減少切換次數的代價。

## 規格書與來源

沒有規格書。將 n 設為橋臂中的子模組數，fc 設為每個子模組的載波頻率。

## 範例

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

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