---
title: Oscillators
heading: LC, ring and crystal oscillators, startup and phase noise
eyebrow: S2 · Lesson 46 · Oscillators
xp: 50
---

::: hook
Every PLL needs a voltage-controlled oscillator, and every system clock starts from a crystal. An oscillator is an amplifier whose loss is cancelled exactly: a negative resistance across a tuned tank, or an odd ring of inverting stages chasing each other. Getting it to start is a gain calculation; getting it clean is a question of how much power it runs at and how sharp its resonance is, which Leeson's model turns into a phase-noise number in dBc/Hz.
:::

::: play
- The curve is an oscillator's phase noise against offset from the carrier by Leeson's model: a flat floor set by power and noise figure, rising 20 dB per decade inside the resonator's half-bandwidth $f_0/2Q$.
- Raise the tank's Q and the corner moves in: the noise close to the carrier falls 20 dB for every tenfold increase in Q.
- The readout is the noise at a 1 MHz offset from a 2.5 GHz carrier.
:::

```sim plot
view: graph
x: d = 0.001..100 MHz log
y: L = -180..-40 dBc/Hz
slider: Q = 3..1000 = 10 log
slider: P = 0.1..10 = 1 mW log
plot: 10*log(2*1.380649e-23*300*2/(P*1e-3)*(1 + (2500/(2*Q*d))^2)) | label: phase noise
readout: at 1 MHz (dBc per Hz) = 10*log(2*1.380649e-23*300*2/(P*1e-3)*(1 + (2500/(2*Q))^2)) | digits: 4
```

::: predict
## An LC tank of 2 nH and 2 pF has an inductor Q of 10. What transconductance must each transistor of a cross-coupled pair supply for oscillation to start?

- [ ] About 0.6 mS
- [x] About 6 mS
- [ ] About 60 mS
- [ ] Any: an LC tank oscillates on its own

::: reveal
At 2.52 GHz the tank's parallel resistance is $Q\omega L = 316$ Ω. The cross-coupled pair presents $-2/g_m$ across the tank, so it cancels the loss when $g_m \ge 2/R_p = 6.3$ mS; designs use two or three times that to start reliably.
:::
:::

::: nameit
## LC oscillators

A tank of L and C resonates at $f_0 = 1/(2\pi\sqrt{LC})$ with parallel loss resistance $R_p = Q\omega_0L$. A cross-coupled differential pair looks like $-2/g_m$ across it, so it starts when $g_m R_p \ge 2$. Its amplitude then grows until the transistors' nonlinearity (or a tail current limit) holds the loop gain at exactly 1.

## Ring oscillators

N inverting stages (N odd) in a loop oscillate at $f = 1/(2Nt_d)$ for a stage delay $t_d$. They're small, tune over wide ranges and need no inductor, but with no resonator their phase noise is much worse.

## Crystals

A quartz crystal is an electromechanical resonator with Q of $10^4$ to $10^6$: its frequency is set to parts per million and barely moves with temperature or voltage. A Pierce oscillator drives it with a single inverting stage.

## Phase noise

Leeson's model gives the single-sideband noise at offset Δf from a carrier $f_0$:
$$\mathcal L(\Delta f) = 10\log_{10}\left[\frac{2kTF}{P_s}\left(1 + \left(\frac{f_0}{2Q\Delta f}\right)^2\right)\right]$$
More signal power and a higher Q both lower it.
:::

::: example
## What frequency and parallel resistance does a 2 nH, 2 pF tank with an inductor Q of 10 have, and what $g_m$ starts it?

::: solution
1. **Frequency.**
   $$\begin{aligned} f_0 &= \frac{1}{2\pi\sqrt{LC}} \\ &= \frac{1}{2\pi\sqrt{4 \times 10^{-21}}} \\ &= 2.52\ \text{GHz} \end{aligned}$$
2. **Parallel resistance.** With the unrounded $f_0$ = 2.516 GHz:
   $$\begin{aligned} R_p &= Q\omega_0L \\ &= 10 \times 2\pi \times 2.516\ \text{GHz} \\ &\quad \times 2\ \text{nH} \\ &= 316\ \Omega \end{aligned}$$
3. **Starting transconductance.** Per side:
   $$\begin{aligned} g_m &\ge \frac{2}{316\ \Omega} \\ &= 6.3\ \text{mS} \end{aligned}$$
4. **Higher Q.** Raising the inductor's Q lowers the current needed in proportion.

**Answer:** the tank resonates at 2.52 GHz with $R_p$ = 316 Ω, and it takes $g_m$ ≥ 6.3 mS per side to start.
:::
:::

::: example
## A ring oscillator's stages each take 20 ps. What do 5 stages and 101 stages make?

::: solution
1. **5 stages.**
   $$\begin{aligned} f &= \frac{1}{2 \times 5 \times 20\ \text{ps}} \\ &= 5\ \text{GHz} \end{aligned}$$
2. **101 stages.**
   $$\begin{aligned} f &= \frac{1}{2 \times 101 \times 20\ \text{ps}} \\ &= 248\ \text{MHz} \end{aligned}$$
3. **What long rings are for.** Long rings make slow clocks without a big capacitor, and each stage's delay can be tuned by its current.

**Answer:** 5 GHz with 5 stages and 248 MHz with 101.
:::
:::

::: example
## A 2.5 GHz LC oscillator runs at 1 mW with a 3 dB noise figure and a loaded Q of 10. What phase noise does Leeson's model predict 1 MHz off the carrier?

::: solution
1. **Noise floor.**
   $$\begin{aligned} L_\text{floor} &= 10\log_{10}(2kTF/P_s) \\ &= 10\log_{10}(1.66 \times 10^{-17}) \\ &= -167.8\ \text{dBc/Hz} \end{aligned}$$
2. **Resonator term.** This is +41.9 dB:
   $$\left(\frac{2.5\ \text{GHz}}{2 \times 10 \times 1\ \text{MHz}}\right)^2 = 125^2$$
3. **Total.**
   $$-167.8 + 41.9 = -125.9\ \text{dBc/Hz}$$
   a typical cellular-grade VCO.

**Answer:** about −125.9 dBc/Hz at 1 MHz off the carrier.
:::
:::

::: check
kind: parts
given: L = 1 | 2 | 5; C = 0.5 | 2 | 5; Q = 5 | 10 | 20

## An LC tank has L = {L} nH, C = {C} pF and an inductor Q of {Q}.

::: part
answer: 1/(2*pi*sqrt(L*1e-9*C*1e-12))/1e9
unit: GHz
tolerance: 0.5%

### What is its resonant frequency?

::: misses
- [any] $1/(2\pi\sqrt{LC})$.
:::
:::

::: part
answer: 2/(Q*sqrt(L*1e-9/(C*1e-12)))*1000
unit: mS
tolerance: 0.5%

### What $g_m$ must each side of a cross-coupled pair supply to start it ($R_p = Q\omega_0L = Q\sqrt{L/C}$)?

::: misses
- [1/(Q*sqrt(L*1e-9/(C*1e-12)))*1000] The cross-coupled pair presents $-2/g_m$.
- [any] $g_m = 2/R_p$.
:::
:::
:::

::: check
kind: parts
given: N = 3 | 5 | 11; t = 10 | 20 | 50

## A ring oscillator has {N} stages of {t} ps delay.

::: part
answer: 1/(2*N*t*1e-12)/1e9
unit: GHz
tolerance: 0.5%

### What frequency does it make?

::: misses
- [1/(N*t*1e-12)/1e9] A full period needs two trips around the ring.
- [any] $1/(2Nt_d)$.
:::
:::

::: part
answer: 1/(2*(N + 2)*t*1e-12)/1e9
unit: GHz
tolerance: 0.5%

### And with two more stages?

::: misses
- [any] Use N + 2.
:::
:::
:::

::: check
kind: parts
given: P = 0.1 | 1 | 10; F = 2 | 4; Q = 5 | 10 | 50; d = 0.1 | 1

## A 2.5 GHz oscillator runs at {P} mW with noise factor {F} and loaded Q {Q}.

::: part
answer: 10*log(2*1.380649e-23*300*F/(P*1e-3)*(1 + (2500/(2*Q*d))^2))
unit: dBc/Hz
tolerance: 0.5%

### What phase noise does Leeson's model give at {d} MHz offset?

::: misses
- [any] $10\log_{10}[(2kTF/P_s)(1 + (f_0/2Q\Delta f)^2)]$.
:::
:::

::: part
answer: 2500/(2*Q)
unit: MHz
tolerance: 0.5%

### Where is the corner below which the noise rises 20 dB per decade?

::: misses
- [any] $f_0/2Q$.
:::
:::
:::

::: check
kind: parts
given: f = 1 | 2.4 | 5.8; c = 10 | 30 | 100

## A VCO runs at {f} GHz on a 1 pF tank capacitance, and its varactor lowers that capacitance by {c} fF.

::: part
answer: f*1000*(1/sqrt(1 - c/1000) - 1)
unit: MHz
tolerance: 0.5%

### How far up does the frequency move if the capacitance falls by {c} fF?

::: misses
- [any] $f \propto 1/\sqrt C$.
:::
:::

::: part
answer: f*1000*0.5*c/1000
unit: MHz
tolerance: 1%

### What does the small-change approximation $\Delta f/f \approx \tfrac12\Delta C/C$ give?

::: misses
- [any] Half the fractional capacitance change.
:::
:::
:::

::: check
kind: choice

## Why does a crystal oscillator have far lower close-in phase noise than an on-chip LC oscillator at the same power?

- [ ] Quartz has no thermal noise
- [x] Its resonator's Q is thousands of times higher, which moves Leeson's corner $f_0/2Q$ thousands of times closer to the carrier
- [ ] It runs at a lower frequency, and phase noise doesn't depend on frequency
- [ ] Its amplifier is quieter

::: misses
- [1] Every resistance makes thermal noise.
- [3] The model's resonator term grows with $f_0/Q$; Q is what changes most.
- [4] The amplifier's noise figure matters far less than Q.
:::
:::

::: check
kind: derivation
vars: L = 1e-10..1e-7, C = 1e-13..1e-10, Q = 2..100

## An LC tank has inductance L, capacitance C and inductor quality factor Q.

::: step
answer: 1/sqrt(L*C)

### What is its resonant frequency (rad/s)?
:::

::: step
answer: Q*sqrt(L/C)

### What is its parallel resistance at resonance?
:::

::: step
answer: 2/(Q*sqrt(L/C))

### What $g_m$ does a cross-coupled pair need per side?
:::

::: right
Right. A higher-impedance tank (larger L/C) or a better inductor lowers the transconductance, and so the current, needed to sustain oscillation.
:::
:::

::: check
kind: python

## Write `leeson(df, f0, Q, P_mw, F, T=300)`: Leeson's phase noise in dBc/Hz at offset df (Hz), and `offset_for(level, f0, Q, P_mw, F)`: the offset at which it reaches `level` dBc/Hz, by bisection in log df between 1 Hz and $f_0$.

```python starter
import math

def leeson(df, f0, Q, P_mw, F, T=300):
    return -100.0

def offset_for(level, f0, Q, P_mw, F):
    return 1e6
```

```python solution
import math

def leeson(df, f0, Q, P_mw, F, T=300):
    k = 1.380649e-23
    return 10 * math.log10(2 * k * T * F / (P_mw * 1e-3) * (1 + (f0 / (2 * Q * df)) ** 2))

def offset_for(level, f0, Q, P_mw, F):
    lo, hi = 0.0, math.log10(f0)
    for _ in range(200):
        mid = (lo + hi) / 2
        if leeson(10 ** mid, f0, Q, P_mw, F) > level:
            lo = mid
        else:
            hi = mid
    return 10 ** mid
```

```python tests
assert abs(leeson(1e6, 2.5e9, 10, 1, 2) + 125.87) < 0.01, "The worked example: −125.9 dBc/Hz."
assert abs(leeson(1e5, 2.5e9, 100, 1, 2) - leeson(1e5, 2.5e9, 10, 1, 2) + 20) < 0.01, "Ten times the Q: 20 dB better close in."
d = offset_for(-120, 2.5e9, 10, 1, 2)
assert abs(leeson(d, 2.5e9, 10, 1, 2) + 120) < 1e-6, "Bisection hits the level."
```

::: right
Right. Leeson's model is only a guide, but it shows where the power and the resonator's Q go in a phase-noise budget.
:::
:::

::: explain
## What sets an LC oscillator's frequency and what sets its amplitude?

::: model
The frequency is set by the tank: the inductor and capacitor exchange energy at $1/2\pi\sqrt{LC}$, and the active circuit only replaces the energy the tank's resistance loses each cycle. The amplitude is set by nonlinearity. At startup the negative resistance exceeds what the tank needs, so the oscillation grows; as it grows the transistors begin to limit, switching fully or running out of tail current, and their average negative resistance falls until it exactly cancels the tank's loss. The amplitude settles where the loop gain is one, which for a current-limited pair is about the tail current times the tank's parallel resistance.
:::
:::

::: practice
::: check
given: L = 1 | 4; C = 1 | 3
answer: 1/(2*pi*sqrt(L*1e-9*C*1e-12))/1e9
unit: GHz
tolerance: 0.5%

## Resonance of {L} nH and {C} pF?

::: misses
- [any] $1/(2\pi\sqrt{LC})$.
:::
:::

::: check
given: N = 7 | 21; t = 15 | 40
answer: 1/(2*N*t*1e-12)/1e6
unit: MHz
tolerance: 0.5%

## Ring of {N} stages at {t} ps?

::: misses
- [any] $1/(2Nt_d)$.
:::
:::

::: check
given: Q = 8 | 25; P = 0.5 | 5
answer: 10*log(2*1.380649e-23*300*2/(P*1e-3)*(1 + (2500/(2*Q*1))^2))
unit: dBc/Hz
tolerance: 0.5%

## Leeson at 1 MHz from 2.5 GHz, Q = {Q}, {P} mW, F = 2?

::: misses
- [any] Leeson's formula.
:::
:::
:::
