# 受控源 (`controlledSource`)

> 輸出的電壓或電流，等於訊號乘以增益。

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

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

**分類:** 電源 · **種類:** `{"kind":"controlledSource"}`

## 何時使用

用於把控制訊號帶進功率電路，例如平均模型或擾動。真正的開關級請用有閘極的開關。

## 接腳

| 接腳 | 訊號域 | 意義 |
|---|---|---|
| `p` | 電氣 | 輸出的正端 |
| `n` | 電氣 | 輸出的負端 |
| `ctrl` | 訊號 | 設定輸出大小的訊號；不取電流 |

## 常用參數

- `gain`: Output size per unit of control signal (預設值: 1)
- `mode`: Whether the output is voltage or current: `voltage` or `current` (預設值: voltage)

## 參數

| 鍵 | 單位 | 預設值 | 典型範圍 | 說明 |
|---|---|---|---|---|
| `gain` | — | 1 |  | Output size per unit of control signal |
| `mode` | — | voltage |  | Whether the output is voltage or current: `voltage` or `current` |

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

**適用於:** 平均模型 · 訊號帶入功率級 · 擾動注入

**不適用於:** 實際開關級 → [`mosfet`](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/switches/mosfet/) · 運算放大器電路 → [`opAmp`](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/opAmp/)

## 公式

| 公式 | 方程式 | 出處 |
|---|---|---|
| 電壓模式輸出 | v(p) − v(n) = gain·ctrl | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), Ch. 2 |
| 電流模式輸出 | i = gain·ctrl | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), Ch. 2 |
| 負載電流（電壓模式） | I = vout/rl | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), Ch. 2 |

## 快速驗算

輸入:

- `gain`: 增益 = 1 —, `gain`
- `ctrl`: 控制訊號 = 500m —
- `rl`: 負載電阻 = 10 Ω

輸出:

- `vout`: 輸出電壓（電壓模式） = `gain*ctrl` V
- `iload`: 負載電流（電壓模式） = `vout/rl` A
- `pload`: 負載功率（電壓模式） = `vout^2/rl` W

## 模型邏輯

- voltage 模式寫入理想電壓支路 v(p) - v(n) = gain·ctrl；current 模式注入由 p 流向 n 的電流 gain·ctrl；其他 mode 文字會報錯。
- ctrl 只經過電表、增益與加法方塊時，量測量直接寫入矩陣，所以電源在同一步生效，如同 SPICE 的 E、F、G、H 元件。
- 經過其他方塊（濾波器、限幅器、C 方塊）時，電源使用上一步的控制值，這一步延遲可能使高增益迴路發散。
- ctrl 未接時讀到 0；輸出限制、頻寬與內阻都沒有建模。

## 模型

電壓模式下，元件強制 v(p) - v(n) = gain * ctrl。電流模式下，則強制電流 gain * ctrl 由 p 經電源流向 n。mode 必須剛好是 voltage 或 current，ctrl 未接時讀到 0。

## 常見錯誤

- ctrl 腳應接到訊號節點，接到功率節點會被提醒。ctrl 未接時輸出為零。
- 電壓模式的受控源視同理想電壓源。兩個接在相同節點之間會形成迴路。

Problems 規則: `pin.domain_mismatch`, `pin.unconnected`, `loop.voltage_sources`

## 規格書與來源

沒有規格書。gain 是你設計的轉換係數，單位是每單位訊號對應的伏特或安培。

## 範例

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

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