# Controlled Source (`controlledSource`)

> Makes a voltage or current equal to a signal times a gain.

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

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

**Group:** Sources · **Kind:** `{"kind":"controlledSource"}`

## When to use it

Use it to bring a control signal into the power circuit, such as an averaged model or a disturbance. A real switching stage needs a switch with a gate.

## Pins

| Pin | Domain | Meaning |
|---|---|---|
| `p` | electrical | Positive end of the output |
| `n` | electrical | Negative end of the output |
| `ctrl` | signal | Signal that sets the output; draws no current |

## Common parameters

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

## Parameters

| Key | Unit | Default | Typical range | Description |
|---|---|---|---|---|
| `gain` | — | 1 |  | Output size per unit of control signal |
| `mode` | — | voltage |  | Whether the output is voltage or current: `voltage` or `current` |

_Parameter descriptions are in English in both languages._

**Use for:** Averaged models · Signals into the power stage · Disturbance injection

**Not for:** Real switching stages → [`mosfet`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/mosfet/) · Op-amp circuits → [`opAmp`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/opAmp/)

## Formulas

| Formula | Equation | Source |
|---|---|---|
| Voltage mode output | v(p) − v(n) = gain·ctrl | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), Ch. 2 |
| Current mode output | i = gain·ctrl | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), Ch. 2 |
| Load current, voltage mode | I = vout/rl | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), Ch. 2 |

## Quick check

Inputs:

- `gain`: Gain = 1 —, `gain`
- `ctrl`: Control signal = 500m —
- `rl`: Load resistance = 10 Ω

Outputs:

- `vout`: Output voltage, voltage mode = `gain*ctrl` V
- `iload`: Load current, voltage mode = `vout/rl` A
- `pload`: Load power, voltage mode = `vout^2/rl` W

## Model logic

- Mode voltage stamps an ideal voltage branch v(p) - v(n) = gain·ctrl; mode current puts the current gain·ctrl from p to n; any other mode text is an error.
- When ctrl comes only through meters, gain and sum blocks, the measured quantities go into the matrix, so it acts in the same step like a SPICE E, F, G or H.
- Through any other block (filter, limiter, C block) it uses the control value of the previous step, a one-step delay that can make a high-gain loop diverge.
- An unconnected ctrl reads 0; output limits, bandwidth and internal resistance are not modelled.

## Model

In voltage mode, the part forces v(p) - v(n) = gain * ctrl. In current mode, it forces a current gain * ctrl from p to n through the source. mode must be exactly voltage or current, and an unconnected ctrl reads 0.

## Common mistakes

- The ctrl pin belongs on a signal net, and joining it to a power net is flagged. An unconnected ctrl makes the output zero.
- A voltage-mode controlled source counts as an ideal voltage source. Two of them across the same nodes form a loop.

Problems rules: `pin.domain_mismatch`, `pin.unconnected`, `loop.voltage_sources`

## Datasheet and sources

There is no datasheet. gain is the conversion factor you design, in volts or amperes per unit of the signal.

## Example

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

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