---
title: Active filters
heading: Biquads in active-RC and gm-C form, tuning and dynamic range
eyebrow: S2 · Lesson 38 · Active filters
xp: 50
---

::: hook
Before a signal is sampled it must be filtered, and on a chip there are no inductors worth using at audio or baseband frequencies. Active filters make second-order sections, **biquads**, from resistors, capacitors and amplifiers, or from transconductors and capacitors (gm-C), and cascade them into Butterworth or Chebyshev responses. Their design questions are analog ones: what sets the pole frequency and Q, how much they drift with process, and how big the capacitors must be for the filter's own noise to stay below the signal.
:::

::: play
- The curve is a second-order low-pass's magnitude against frequency normalized to $f_0$, on log axes, for the Q set by the slider.
- At Q = 0.707 (Butterworth) the response is maximally flat; higher Q makes a peak near $f_0$, and lower Q a slow, droopy corner.
- The readout is the peak's height, $Q/\sqrt{1 - 1/4Q^2}$, for Q above 0.707.
:::

```sim plot
view: graph
x: x = 0.01..100 log
y: H = 0.0001..10 log
slider: Q = 0.3..10 = 0.707 log
plot: 1/sqrt((1 - x^2)^2 + (x/Q)^2) | label: gain
readout: peak gain (Q above 0.707) = Q/sqrt(abs(1 - 1/(4*Q^2))) | digits: 3
```

::: predict
## A gm-C biquad's pole frequency is $g_m/C$. If the process makes $g_m$ 20% high and C 10% low, where does $f_0$ land?

- [ ] 10% high
- [x] About 33% high
- [ ] 20% high
- [ ] Unchanged

::: reveal
$f_0 \propto g_m/C$: $1.2/0.9 = 1.33$. On-chip resistors, capacitors and transconductances vary 10 to 30% independently, so filters that need accurate corners include an automatic tuning loop: a master copy locked to a reference clock, whose control voltage also sets the filter's transconductors.
:::
:::

::: nameit
## The biquad

$$H(s) = \frac{\omega_0^2}{s^2 + (\omega_0/Q)s + \omega_0^2}$$
peaks at $Q/\sqrt{1 - 1/4Q^2}$ for Q > 0.707; Butterworth sections have Q = 0.707.

## Sallen–Key (unity gain)

Two resistors and two capacitors around a follower: $\omega_0 = 1/\sqrt{R_1R_2C_1C_2}$ and $Q = \sqrt{R_1R_2C_1C_2}/((R_1 + R_2)C_2)$, with $C_1$ the feedback capacitor and $C_2$ the one to ground. With equal resistors, $Q = \frac12\sqrt{C_1/C_2}$.

## Two-integrator loops

Two integrators in a loop (Tow–Thomas, or a gm-C biquad) set $\omega_0$ by the integrators' unity-gain frequencies ($1/RC$, or $g_m/C$) and Q by a separate damping element, so the two can be adjusted independently.

## Dynamic range

Each integrator's capacitor holds kT/C of noise. For a signal of $V_\text{rms}$ and a target SNR, $C \gtrsim kT\cdot\text{SNR}/V_\text{rms}^2$: 80 dB at 1 V rms needs about 0.4 pF per pole, and each 6 dB of SNR quadruples the capacitance and the power needed to drive it.
:::

::: example
## A unity-gain Sallen–Key low-pass uses R = 10 kΩ for both resistors, $C_1$ = 20 nF and $C_2$ = 10 nF. What are its $f_0$ and Q?

::: solution
1. **Natural frequency.**
   $$\begin{aligned} f_0 &= \frac{1}{2\pi R\sqrt{C_1C_2}} \\ &= \frac{1}{2\pi \times 10^4 \times \sqrt{2 \times 10^{-16}}} \\ &= 1.13\ \text{kHz} \end{aligned}$$
2. **Q.**
   $$\begin{aligned} Q &= \tfrac12\sqrt{20/10} \\ &= 0.707 \end{aligned}$$
   a Butterworth section.
3. **What sets Q.** The capacitor ratio alone sets Q, so it holds as well as the capacitors match.

**Answer:** $f_0$ = 1.13 kHz and Q = 0.707.
:::
:::

::: example
## A gm-C integrator has $g_m$ = 100 µS and C = 1 pF. What unity-gain frequency does it have, and what is a biquad built from two of them tuned to?

::: solution
1. **Unity-gain frequency.**
   $$\begin{aligned} \omega_u &= \frac{g_m}{C} \\ &= 10^8\ \text{rad/s} \end{aligned}$$
   or 15.9 MHz.
2. **The biquad.** A biquad built from two of them has the same $f_0$.
3. **Where gm-C fits.** gm-C filters reach tens to hundreds of megahertz, where active-RC filters run out of op-amp bandwidth.

**Answer:** the integrator's unity-gain frequency is 15.9 MHz, and the biquad is tuned to the same 15.9 MHz.
:::
:::

::: example
## A filter must keep 80 dB of SNR at 1 V rms. How big must each integrating capacitor be?

::: solution
1. **Capacitor at 80 dB.** An SNR of 80 dB is a power ratio of $10^8$:
   $$\begin{aligned} C &= kT \times 10^8/1^2 \\ &= 4.14 \times 10^{-21} \times 10^8 \\ &= 0.41\ \text{pF} \end{aligned}$$
2. **At 100 dB.** It would be 41 pF, and the transconductors driving it a hundred times stronger.
3. **What sets the power.** So most filters' power is set by their dynamic range more than by their bandwidth.

**Answer:** each integrating capacitor must be 0.41 pF.
:::
:::

::: check
kind: parts
given: R = 1 | 10 | 47; C = 1 | 10 | 100; r = 2 | 4

## A unity-gain Sallen–Key low-pass has both resistors {R} kΩ, $C_2$ = {C} nF and $C_1$ = {r} × $C_2$.

::: part
answer: 1/(2*pi*R*1000*sqrt(r)*C*1e-9)
unit: Hz
tolerance: 0.5%

### What is its pole frequency?

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

::: part
answer: sqrt(r)/2
tolerance: 0.5%

### What is its Q?

::: misses
- [any] $\frac12\sqrt{C_1/C_2}$.
:::
:::
:::

::: check
kind: parts
given: Q = 0.8 | 1.3 | 5

## A biquad low-pass has Q = {Q}.

::: part
answer: Q/sqrt(1 - 1/(4*Q^2))
tolerance: 0.5%

### What is its peak gain?

::: misses
- [Q] The peak sits slightly above $f_0$ and slightly above Q.
- [any] $Q/\sqrt{1 - 1/4Q^2}$.
:::
:::

::: part
answer: 20*log(Q)
unit: dB
tolerance: 0.5%

### What is its gain at exactly $f_0$, in dB?

::: misses
- [any] |H| = Q at $f_0$.
:::
:::
:::

::: check
kind: parts
given: g = 10 | 100 | 1000; C = 0.5 | 1 | 5

## A gm-C integrator has $g_m$ = {g} µS and C = {C} pF.

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

### What is its unity-gain frequency?

::: misses
- [any] $g_m/(2\pi C)$.
:::
:::

::: part
answer: g*1e-6*1.2/(C*1e-12*0.9)/(2*pi)/1e6
unit: MHz
tolerance: 0.5%

### Where does it land if $g_m$ comes out 20% high and C 10% low?

::: misses
- [any] × 1.2/0.9.
:::
:::
:::

::: check
kind: parts
given: S = 60 | 80 | 100; V = 0.3 | 1; T = 300 | 350

## A filter must keep {S} dB of SNR with {V} V rms of signal at {T} K.

::: part
answer: 1.380649e-23*T*10^(S/10)/V^2*1e12
unit: pF
tolerance: 0.5%

### How big must each integrating capacitor be?

::: misses
- [any] $kT\cdot\text{SNR}/V^2$.
:::
:::

::: part
answer: 4
tolerance: 0.5%

### By what factor must the capacitors grow for 6.02 dB more SNR?

::: misses
- [any] SNR power ratio of 4.
:::
:::
:::

::: check
kind: parts
given: R = 10 | 20; q = 1 | 5 | 10; C = 1 | 10

## A Tow–Thomas biquad has integrators of R = {R} kΩ and C = {C} nF, and a damping resistor {q} times R.

::: part
answer: 1/(2*pi*R*1000*C*1e-9)
unit: Hz
tolerance: 0.5%

### What is its pole frequency?

::: misses
- [any] $1/(2\pi RC)$.
:::
:::

::: part
answer: q
tolerance: 0.5%

### What is its Q?

::: misses
- [any] The damping resistor's ratio to R.
:::
:::
:::

::: check
kind: choice

## Why do gm-C filters on a chip usually need an automatic tuning loop, while an active-RC filter built from matched on-chip resistors and capacitors may only need a trim?

- [ ] gm-C filters are slower
- [x] Both drift with absolute R, C or $g_m$, but gm-C transconductances also vary with temperature and supply, so a continuously running master–slave loop tracks them; an RC product can be trimmed once
- [ ] Active-RC filters don't depend on component values
- [ ] Tuning loops reduce noise

::: misses
- [1] gm-C filters are usually the faster kind.
- [3] Their corner is set by an RC product, which varies with process.
- [4] Tuning sets frequency, not noise.
:::
:::

::: check
kind: derivation
vars: a = 1e3..1e5, b = 1e3..1e5, c = 1e-10..1e-7, d = 1e-10..1e-7

## A unity-gain Sallen–Key low-pass has resistors a and b, feedback capacitor c and grounded capacitor d.

::: step
answer: 1/sqrt(a*b*c*d)

### What is $\omega_0$?
:::

::: step
answer: sqrt(a*b*c*d)/((a + b)*d)

### What is Q?
:::

::: step
answer: sqrt(c/d)/2

### What is Q when a = b?
:::

::: right
Right. With equal resistors Q depends only on the capacitor ratio, which on a chip is set by matching.
:::
:::

::: check
kind: python

## Write `biquad_mag(f, f0, Q)`: the magnitude of the low-pass biquad, and `butter_q(n)`: the Q values of the second-order sections of an n-th order Butterworth filter (n even), $Q_k = 1/(2\sin((2k - 1)\pi/2n))$ for k = 1..n/2, sorted ascending.

```python starter
import math

def biquad_mag(f, f0, Q):
    return 1.0

def butter_q(n):
    return []
```

```python solution
import math

def biquad_mag(f, f0, Q):
    x = f / f0
    return 1 / math.sqrt((1 - x * x) ** 2 + (x / Q) ** 2)

def butter_q(n):
    return sorted(1 / (2 * math.sin((2 * k - 1) * math.pi / (2 * n))) for k in range(1, n // 2 + 1))
```

```python tests
assert abs(biquad_mag(1000, 1000, 0.707) - 0.707) < 1e-9, "At f0 the gain equals Q."
q4 = butter_q(4)
assert abs(q4[0] - 0.5412) < 1e-4 and abs(q4[1] - 1.3066) < 1e-4, "4th-order Butterworth: Q = 0.541 and 1.307."
g = biquad_mag(2000, 1000, q4[0]) * biquad_mag(2000, 1000, q4[1])
assert abs(20 * math.log10(g) + 24.1) < 0.1, "One octave above the corner: −24 dB, 4th order."
```

::: right
Right. A Butterworth response comes from cascading sections with exactly those Qs at the same $f_0$.
:::
:::

::: explain
## Why does a filter's dynamic range, rather than its frequency, usually set how much power it burns?

::: model
Every integrator's capacitor carries thermal noise of kT/C, independent of the resistance or transconductance around it, so reaching a given signal-to-noise ratio for a given signal swing demands a minimum capacitance. Placing the poles at a given frequency then fixes the transconductance or conductance needed to drive that capacitance, $g_m = \omega_0C$, and transconductance costs bias current. Each extra 6 dB of SNR quadruples the capacitance and therefore the current, while the frequency only scales it linearly, so high-resolution filters spend most of their power fighting their own noise.
:::
:::

::: practice
::: check
given: R = 5 | 22; C = 2 | 15
answer: 1/(2*pi*R*1000*sqrt(2)*C*1e-9)
unit: Hz
tolerance: 0.5%

## $f_0$ of a Butterworth Sallen–Key with R = {R} kΩ, $C_2$ = {C} nF, $C_1 = 2C_2$?

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

::: check
given: g = 50 | 500; C = 2 | 4
answer: g*1e-6/(C*1e-12)/(2*pi)/1e6
unit: MHz
tolerance: 0.5%

## gm-C unity-gain frequency, {g} µS and {C} pF?

::: misses
- [any] $g_m/2\pi C$.
:::
:::

::: check
given: S = 60 | 70 | 80 | 90 | 96 | 100
answer: 1.380649e-23*300*10^(S/10)*1e12
unit: pF
tolerance: 0.5%

## Capacitor for {S} dB SNR at 1 V rms?

::: misses
- [any] $kT\cdot\text{SNR}/V^2$.
:::
:::
:::
