# Peak-Current-Mode PWM Controller (`pwmController`)

> Controls a converter switch by comparing its current with a set level.

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

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

**Group:** ICs · **Kind:** `{"definition":"pwmController","kind":"subsystem"}`

## When to use it

Use it when your converter uses a fixed-frequency peak-current-mode chip, with its compensation network on COMP. To try your own control law, use PI Controller and PWM Generator instead.

## Pins

| Pin | Domain | Meaning |
|---|---|---|
| `VFB` | electrical | Feedback input, wire the output divider here |
| `COMP` | electrical | Error amplifier output, wire the compensation here |
| `CS` | electrical | Current sense input, from the sense resistor |
| `OUT` | electrical | Gate drive output |
| `VCC` | electrical | Supply, output stays off below the UVLO level |
| `GND` | electrical | Ground reference of every pin |

## Common parameters

- `rt`: Timing resistor RT (the datasheet: never below 5 kOhm, Table 5-1 Pin Functions, RT/CT, p.4) (Default: 10000)
- `ct`: Timing capacitor CT (the datasheet recommends at least about 1000 pF) (Default: 0.0000000033)
- `dmax`: Maximum duty cycle of the output (Default: 0.97)
- `vRef`: Error amplifier reference at the non-inverting input (Default: 2.5)
- `acs`: Current-sense gain: COMP volts per volt of CS threshold (Default: 3)

## Parameters

| Key | Unit | Default | Typical range | Description | Datasheet source |
|---|---|---|---|---|---|
| `rt` | Ω | 10000 | 5k – 10meg Ω | Timing resistor RT (the datasheet: never below 5 kOhm, Table 5-1 Pin Functions, RT/CT, p.4) | Section 6.5 test condition RRT = 10 kOhm, p.7 |
| `ct` | F | 0.0000000033 | 100p – 1u F | Timing capacitor CT (the datasheet recommends at least about 1000 pF) | Section 6.5 test condition CCT = 3.3 nF, p.7 |
| `dmax` | — | 0.97 | 50m – 990m | Maximum duty cycle of the output | Section 6.5 DMAX typ (UCx842/3), p.8 |
| `oscDiv` | — | 1 | 1 – 2 | Oscillator periods per output period: 1, or 2 for a toggle flip-flop (UCx844/5), which switches at half the oscillator frequency | Section 6.5 note (5): fSW = fOSC for the UCx842/3, fOSC / 2 for the UCx844/5, p.8 |
| `vRef` | V | 2.5 | 500m – 10 V | Error amplifier reference at the non-inverting input | Section 6.5 VVFB typ, p.7 |
| `a0` | V/V | 31623 | 10 – 1g V/V | Error amplifier DC gain (90 dB) | Section 6.5 AVOL typ 90 dB, p.7 |
| `gbw` | Hz | 1000000 | 1k – 1g Hz | Error amplifier unity-gain bandwidth | Section 6.5 unity gain bandwidth typ, p.7 |
| `vCompLo` | V | 0.7 | 0 – 10 V | Lowest COMP voltage | Section 6.5 VCOMP low-level typ, p.7 |
| `vCompHi` | V | 5 | 1 – 20 V | Highest COMP voltage (the datasheet guarantees at least 5 V) | Section 6.5 VCOMP high-level min, p.7 |
| `rCompOut` | Ω | 1250 | 0 – 1meg Ω | COMP output resistance (0 = ideal) | assumption: 6 V at no load falling to 5 V at the 0.8 mA source current, p.7 |
| `iSource` | A | 0 | 0 – 10m A | Error amplifier output source current limit: COMP is fed by this current and clamped to the amplifier's voltage through rCompOut (0 = not modelled: the amplifier drives COMP through rCompOut alone) | Section 6.5 error amplifier output source current typ 0.8 mA, p.7 |
| `acs` | V/V | 3 | 500m – 20 V/V | Current-sense gain: COMP volts per volt of CS threshold | Section 6.5 ACS typ, p.8 |
| `vcsMax` | V | 1 | 50m – 10 V | Maximum current-sense threshold (the COMP clamp) | Section 6.5 VISENSE maximum input signal typ, p.8 |
| `vCompOff` | V | 1.4 | 0 – 5 V | COMP voltage at which the current-sense threshold is zero | Section 7.3.8 p.18: COMP below two diode drops above ground stops the output (0.7 V a drop is an assumption; Figure 6-2 gives the threshold graphically) |
| `vccOn` | V | 8.4 | 1 – 40 V | VCC UVLO enable threshold | Section 6.5 VCCON typ (UCx843/5), p.8 |
| `vccOff` | V | 7.6 | 500m – 40 V | VCC UVLO off threshold | Section 6.5 VCCOFF typ (UCx843/5), p.8 |
| `tSoft` | s | 0 | 0 – 1 s | Soft-start time: the current-sense threshold ramps from 0 to vcsMax after the UVLO releases (0 = none) | assumption: the UCx84x has no internal soft start; usually done with a capacitor on COMP |
| `rOutHi` | Ω | 75 | 100m – 10k Ω | Output resistance to VCC (high level) | Section 6.5 VOUT high 13.5 V at 20 mA from VCC = 15 V, p.8 |
| `rOutLo` | Ω | 5 | 100m – 10k Ω | Output resistance to GND (low level) | Section 6.5 VOUT low 0.1 V at 20 mA, p.8 |
| `rOff` | Ω | 1000000 | 1k – 1t Ω | Off-state resistance of the output switches | assumption: the solver's default switch off resistance |

_Parameter descriptions are in English in both languages._

## Model

The oscillator runs at fosc = 1.72 / (rt * ct), and the output switches at fsw = fosc / oscDiv (oscDiv 2 is the toggle flip-flop of the UCx844/5). A sawtooth gates the output on for the first dmax of every period, which is also the clock that turns the switch on. The error amplifier is a single pole (a0, gbw) driven by err = vRef - VFB, limited to vCompLo ... vCompHi, and it drives COMP through rCompOut. With iSource above zero the amplifier only clamps COMP from above through rCompOut and a current source of iSource feeds the pin, as the real output stage in current limit does when an optocoupler pulls COMP down with VFB grounded. The current threshold is (V(COMP) - vCompOff) / acs, limited to 0 ... vcsMax (and to a ramp over tSoft if that is above zero). When V(CS) exceeds it, the output turns off until the next clock, once per cycle. Below the VCC UVLO (vccOn, vccOff) the output is held low. There is no slope compensation, so duty cycles above 50 percent are subharmonically unstable unless a ramp is added to CS externally.

## Common mistakes

- The frequency comes from rt and ct, and there is no separate frequency parameter. With the defaults it is about 52 kHz, and entering 3.3 instead of 3.3n for ct is off by nine orders of magnitude.
- The error amplifier makes the loop stiff, so use a step of 50 ns or less and a few hundred steps per switching period. A larger step makes the current trip overshoot or leaves the COMP node unsettled.
- Do not leave VFB or CS open. An open VFB pushes COMP to its upper limit, and the converter then runs at full current.

Problems rules: `step.too_large`, `param.out_of_range`, `pin.unconnected`

## Datasheet and sources

rt and ct are your own timing parts, and the datasheet gives f = 1.72 / (RT*CT). oscDiv is 1 for the UCx842/3 and 2 for the UCx844/5 (electrical characteristics note 5). dmax, vRef, a0, gbw, vCompLo, vCompHi, acs and vcsMax come from the PWM, error amplifier and current-sense rows of the electrical characteristics. vccOn, vccOff, rOutHi and rOutLo come from the UVLO and output rows. iSource is the error amplifier's output source current. vCompOff, tSoft and rCompOut are assumptions.

## Example

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

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