---
title: Frequency compensation
heading: Slowing an amplifier on purpose so its feedback loop stays stable
eyebrow: C6 · Lesson 39 · Frequency compensation
xp: 40
---

::: hook
Lesson 38 showed that a feedback loop rings or oscillates when its loop gain still exceeds one at the frequency where its phase lag reaches 180°. A two-stage op amp has at least two poles, each worth 90° of lag, plus more from every transistor, so with enough gain it will oscillate in a follower. The fix is to **compensate** it: deliberately add a low-frequency pole that makes the gain fall below one before the other poles pile up their phase. One small capacitor across the second stage does it, and in doing so it also sets the op amp's gain-bandwidth and slew rate.
:::

::: play
- The loop gain of a two-stage op amp in a follower: DC gain 10⁴, a second pole at $f_2$, and a compensation capacitor $C_c$ setting the gain-bandwidth $\text{GBW} = g_{m1}/2\pi C_c$, with $g_{m1}$ = 0.5 mS.
- With $C_c$ = 2 pF the gain crosses 0 dB at about 36 MHz with a phase margin near 66°: well damped.
- Shrink $C_c$: the bandwidth rises, but the crossover approaches $f_2$ and the phase margin collapses: the follower would ring and then oscillate.
:::
:::

```sim plot
view: bode
x: f = 1k..1G Hz log
slider: Cc = 0.1..10 = 2 pF log
slider: f2 = 10..500 = 80 MHz log
H: 1e4/((1 + j*f/(0.5e-3/(2*pi*Cc*1e-12)/1e4))*(1 + j*f/(f2*1e6)))
readout: GBW, MHz = 0.5e-3/(2*pi*Cc*1e-12)/1e6 | digits: 4
readout: phase margin, ° = 90 - atan(sqrt((sqrt(1 + 4*(0.5e-3/(2*pi*Cc*1e-12)/(f2*1e6))^2) - 1)/2))*180/pi | digits: 3
```

::: predict
## A two-stage op amp's gain-bandwidth equals its second pole's frequency. Used as a follower, what is its phase margin?

- [ ] 90°
- [ ] 65°
- [x] About 52°
- [ ] 0°: it oscillates

::: reveal
About 52°. With GBW = $f_2$, the loop gain reaches 1 a little below $f_2$, at 0.79 $f_2$, where the second pole adds 38° of lag on top of the dominant pole's 90°. The rule of thumb that GBW = $f_2$ gives "45°" uses the crossover at GBW itself; for 60° the second pole needs to sit at about 1.7 times GBW.
:::
:::

::: nameit
## Two poles and a phase margin

With a dominant pole well below crossover and a second pole $f_2$, a follower's loop gain crosses 1 at $f_c$, and

$$\text{PM} = 90° - \arctan\frac{f_c}{f_2} \qquad f_c = f_2\sqrt{\frac{\sqrt{1 + 4(\text{GBW}/f_2)^2} - 1}{2}}$$

The quick estimate takes $f_c \approx$ GBW: PM ≈ 90° − arctan(GBW/$f_2$), so 60° needs $f_2 \approx 1.73$ GBW. More margin means less overshoot (lesson 38).

## Miller compensation and pole splitting

In a two-stage op amp, $C_c$ connects the second (gain) stage's input and output. Its Miller multiplication makes a large capacitance at the first stage's output, creating the **dominant pole**; at the same time it lowers the second stage's output impedance at high frequencies, pushing the other pole up. The poles **split**:

$$f_1 \approx \frac{1}{2\pi g_{m2}R_2R_1C_c} \qquad f_2 \approx \frac{g_{m2}}{2\pi C_L}$$

and the gain-bandwidth and slew rate become

$$\text{GBW} = \frac{g_{m1}}{2\pi C_c} \qquad \text{SR} = \frac{I_\text{tail}}{C_c}$$

**The zero.** $C_c$ also feeds the signal forward, making a right-half-plane zero at $\frac{g_{m2}}{2\pi C_c}$ that adds phase lag. A resistor $R_z = 1/g_{m2}$ in series with $C_c$ moves it to infinity.

**Choosing $C_c$:** for a phase margin PM, set $\text{GBW} = f_2\tan(90° - \text{PM})$, so $C_c = \frac{g_{m1}}{2\pi f_2\tan(90° - \text{PM})}$, then check the slew rate.
:::

::: example
## A two-stage op amp has $g_{m1}$ = 0.5 mS, $g_{m2}$ = 5 mS, a 50 µA tail, $C_L$ = 10 pF and $C_c$ = 2 pF. Find its GBW, slew rate, second pole and phase margin.

::: solution
1. **Gain-bandwidth.**
   $$\begin{aligned} \text{GBW} &= \frac{0.5\ \text{mS}}{2\pi \times 2\ \text{pF}} \\ &= 39.8\ \text{MHz} \end{aligned}$$
2. **Slew rate.**
   $$\begin{aligned} \text{SR} &= \frac{50\ \mu\text{A}}{2\ \text{pF}} \\ &= 25\ \text{V}/\mu\text{s} \end{aligned}$$
3. **Second pole.**
   $$\begin{aligned} f_2 &= \frac{5\ \text{mS}}{2\pi \times 10\ \text{pF}} \\ &= 79.6\ \text{MHz} \end{aligned}$$
4. **Phase margin.** The estimate gives
   $$90° - \arctan(0.5) = 63°$$
   The zero at $\frac{5\ \text{mS}}{2\pi \times 2\ \text{pF}}$ = 398 MHz takes another 6°, to 58°, unless $R_z$ = 200 Ω cancels it.

**Answer:** GBW = 39.8 MHz, SR = 25 V/µs, $f_2$ = 79.6 MHz, and the phase margin is 63° (58° with the zero).
:::
:::

::: example
## With $g_{m1}$ = 1 mS, $g_{m2}$ = 10 mS and $C_L$ = 5 pF, what $C_c$ gives 60° of phase margin (zero nulled)?

::: solution
1. **Second pole.**
   $$\begin{aligned} f_2 &= \frac{10\ \text{mS}}{2\pi \times 5\ \text{pF}} \\ &= 318\ \text{MHz} \end{aligned}$$
2. **GBW for 60°.**
   $$\begin{aligned} \text{GBW} &= 318 \times \tan 30° \\ &= 184\ \text{MHz} \end{aligned}$$
3. **Compensation capacitor.**
   $$\begin{aligned} C_c &= \frac{1\ \text{mS}}{2\pi \times 184\ \text{MHz}} \\ &= 0.87\ \text{pF} \end{aligned}$$

**Answer:** $C_c$ = 0.87 pF gives 60° of phase margin.
:::
:::

::: example
## In the first example's op amp ($g_{m2}$ = 5 mS, $C_c$ = 2 pF, $C_L$ = 10 pF), where is the right-half-plane zero, and what nulling resistor in series with $C_c$ removes it or uses it?

::: solution
1. **Where the zero comes from.** $C_c$ carries signal forward from the second stage's input to its output, making a zero at
   $$\frac{g_{m2}}{2\pi C_c} = 398\ \text{MHz}$$
   in the right half-plane: it adds lag like a pole while raising the gain, which erodes phase margin.
2. **With a nulling resistor.** $R_z$ in series with $C_c$ moves the zero to
   $$f_z = \frac{1}{2\pi C_c(1/g_{m2} - R_z)}$$
3. **Removing it.** At $R_z = \frac{1}{g_{m2}}$ = 200 Ω it goes to infinity.
4. **Using it.** At $R_z = \frac{1 + C_L/C_c}{g_{m2}}$ = 1.2 kΩ it lands in the left half-plane on top of the second pole and cancels it, buying phase margin for free.

**Answer:** the zero is at 398 MHz; 200 Ω removes it, and 1.2 kΩ moves it onto the second pole.
:::
:::

::: check
given: gm1 = 0.1 | 1 | 5; Cc = 0.5 | 5
answer: gm1*1e-3/(2*pi*Cc*1e-12)/1e6
unit: MHz
tolerance: 0.5%

## A Miller-compensated op amp has $g_{m1}$ = {gm1} mS and $C_c$ = {Cc} pF. What is its gain-bandwidth?

::: right
Right. $\frac{g_{m1}}{2\pi C_c}$ = {answer}.
:::

::: misses
- [gm1*1e-3/(Cc*1e-12)/1e6] Divide by $2\pi$ for hertz.
- [any] Not yet. GBW = $g_{m1}/(2\pi C_c)$.
:::
:::

::: check
given: I = 10 | 100 | 1000; Cc = 0.5 | 5 | 30
answer: I/Cc
unit: V/µs
tolerance: 0.5%

## A Miller-compensated op amp has a {I} µA tail and $C_c$ = {Cc} pF. What is its slew rate?

::: right
Right. $I/C_c$ = {answer}.
:::

::: misses
- [any] Not yet. The tail current charges $C_c$.
:::
:::

::: check
given: GBW = 1 | 50; f2 = 2 | 100
answer: 90 - atan(GBW/f2)*180/pi
unit: °
tolerance: 0.5%

## Estimate the phase margin of an op amp follower with GBW = {GBW} MHz and a second pole at {f2} MHz (crossover taken at GBW).

::: right
Right. $90° - \arctan(\text{GBW}/f_2)$ = {answer}.
:::

::: misses
- [atan(GBW/f2)*180/pi] That's the second pole's lag; the margin is what's left of 90°.
- [any] Not yet. The dominant pole gives 90°; the second pole adds $\arctan(f_c/f_2)$.
:::
:::

::: check
given: gm2 = 1 | 10; CL = 1 | 20
answer: gm2*1e-3/(2*pi*CL*1e-12)/1e6
unit: MHz
tolerance: 0.5%

## A Miller-compensated op amp's second stage has $g_{m2}$ = {gm2} mS and drives {CL} pF. Where is its non-dominant pole?

::: right
Right. $\frac{g_{m2}}{2\pi C_L}$ = {answer}.
:::

::: misses
- [any] Not yet. Pole splitting puts it at $g_{m2}/(2\pi C_L)$.
:::
:::

::: check
given: gm2 = 1 | 10; Cc = 0.5 | 5
answer: 1/gm2*1000
unit: Ω
tolerance: 0.5%

## What nulling resistor in series with $C_c$ cancels the right-half-plane zero of a second stage with $g_{m2}$ = {gm2} mS?

::: right
Right. $1/g_{m2}$ = {answer}.
:::

::: misses
- [any] Not yet. $R_z = 1/g_{m2}$.
:::
:::

::: check
given: gm1 = 0.2 | 2; f2 = 50 | 400; PM = 55 | 60 | 70
answer: gm1*1e-3/(2*pi*f2*1e6*tan((90 - PM)*pi/180))*1e12
unit: pF
tolerance: 0.5%

## For a phase margin of {PM}° with $g_{m1}$ = {gm1} mS and a second pole at {f2} MHz, what compensation capacitor is needed?

::: right
Right. $C_c = \frac{g_{m1}}{2\pi f_2\tan(90° - \text{PM})}$ = {answer}.
:::

::: misses
- [gm1*1e-3/(2*pi*f2*1e6)*1e12] That gives GBW = $f_2$; a margin of {PM}° needs GBW = $f_2\tan(90° - \text{PM})$.
- [any] Not yet. Find the GBW the margin allows, then $C_c$.
:::
:::

::: check
given: GBW = 1 | 10; A0 = 1e4 | 1e6
answer: GBW*1e6/A0
unit: Hz
tolerance: 0.5%

## An op amp with DC gain {A0} has GBW = {GBW} MHz. Where is its dominant pole?

::: right
Right. GBW/$A_0$ = {answer}.
:::

::: misses
- [any] Not yet. Gain times bandwidth is constant above the dominant pole.
:::
:::

::: check
kind: parts
given: g = 2 | 5 | 10; Cc = 1 | 2 | 4; CL = 5 | 20

## A two-stage op amp has $g_{m2}$ = {g} mS, $C_c$ = {Cc} pF and $C_L$ = {CL} pF.

::: part
answer: g*1e-3/(2*pi*Cc*1e-12)/1e6
unit: MHz
tolerance: 0.5%

### Where's its right-half-plane zero?

::: misses
- [g*1e-3/(2*pi*CL*1e-12)/1e6] That's the second pole; the zero uses $C_c$.
- [any] $\frac{g_{m2}}{2\pi C_c}$.
:::
:::

::: part
answer: (1 + CL/Cc)/g*1000
unit: Ω
tolerance: 0.5%

### What nulling resistor puts the zero on the second pole?

::: misses
- [1000/g] That moves the zero to infinity; cancelling the pole needs more.
- [any] $R_z = \frac{1 + C_L/C_c}{g_{m2}}$.
:::
:::
:::

::: check
kind: derivation
vars: a = 0.00001..0.01, b = 0.0001..0.1, c = 0.0000000000001..0.00000000001, L = 0.000000000001..0.0000000001, I = 0.000001..0.001

## A two-stage op amp has $g_{m1}$ = a, $g_{m2}$ = b, $C_c$ = c, $C_L$ = L and tail I.

::: step
answer: a/(2*pi*c)

### What's its GBW?
:::

::: step
answer: I/c

### What's its slew rate?
:::

::: step
answer: b/(2*pi*L)

### Where's its second pole?
:::

::: step
answer: b/(2*pi*c)

### Where's its right-half-plane zero?
:::

::: right
Right. The zero sits $C_L/C_c$ times above the second pole.
:::
:::

::: explain
## Why does adding a capacitor, which slows the op amp down, make it stable?

::: model
An op amp oscillates in a feedback loop if its loop gain is still above one at the frequency where its poles have accumulated 180° of phase lag. Each pole contributes up to 90°, so with two or more poles at similar frequencies, the gain is still large when the phase reaches −180°. The compensation capacitor creates one dominant pole at a low frequency, so the gain starts falling early, at 20 dB per decade, and reaches one while only that pole's 90° and a little of the next pole's lag have built up. The amplifier is slower, but at the frequency where the loop could misbehave, there's no longer enough gain for it to.
:::
:::

::: practice

::: check
given: PM = 45 | 60 | 76
answer: tan((90 - PM)*pi/180)
tolerance: 0.5%

## For a phase margin of {PM}°, what must GBW/$f_2$ be (crossover at GBW)?

::: misses
- [any] $\tan(90° - \text{PM})$.
:::
:::

::: check
given: GBW = 1 | 10 | 100; G = 1 | 10
answer: GBW/G
unit: MHz
tolerance: 0.5%

## An op amp with GBW = {GBW} MHz runs at a noise gain of {G}. What is the closed-loop bandwidth?

::: misses
- [any] GBW over the noise gain.
:::
:::

::: check
given: gm2 = 2 | 20; Cc = 1 | 4
answer: gm2*1e-3/(2*pi*Cc*1e-12)/1e6
unit: MHz
tolerance: 0.5%

## Where is the right-half-plane zero for $g_{m2}$ = {gm2} mS and $C_c$ = {Cc} pF?

::: misses
- [any] $g_{m2}/(2\pi C_c)$.
:::
:::
:::
