---
title: Analog switches and sample-and-hold circuits
heading: Freezing a voltage on a capacitor, and the errors that come with it
eyebrow: C6 · Lesson 29 · Analog switches and sample-and-hold circuits
xp: 40
---

::: hook
A converter needs its input to hold still while it measures. A sample-and-hold does that with the simplest possible circuit: a switch and a capacitor. Closed, the capacitor follows the input; open, it remembers. Every detail of that sentence hides an error: the switch's resistance slows the following, its channel charge kicks the capacitor when it opens, the capacitor leaks, thermal noise is frozen in, and the moment of opening wanders. Each sets a limit on the converter behind it.

::: play
- The smooth curve is a sine input; the steps are a sample-and-hold's output, which grabs the input at each sampling instant and holds it until the next.
- Raise the input frequency toward half the sampling rate. The held steps still lie on the input at the sampling instants, but they no longer look like it.
- Add droop: the held value sags between samples as the capacitor leaks.
:::
:::

```sim plot
view: graph
x: t = 0..2m s
y: v = -1.5..1.5 V
slider: f = 100..5k = 500 Hz log
slider: fs = 1k..50k = 10k Hz log
slider: d = 0..500 step 10 = 0 V/s
plot: sin(2*pi*f*t) | label: input | samples: 500
plot: sin(2*pi*f*floor(t*fs)/fs) - d*(t - floor(t*fs)/fs) | color: ch2 | label: held output | samples: 2000
readout: samples per input cycle = fs/f | digits: 3
```

::: predict
## A sample-and-hold's switch has 100 Ω of on-resistance and its capacitor is 10 pF. How long must it track before the capacitor is within half an LSB of a 12-bit converter?

- [ ] 1 ns
- [x] About 9 ns
- [ ] About 100 ns
- [ ] 12 ns exactly

::: reveal
About 9 ns. The capacitor settles exponentially with τ = $R_\text{on}C_H$ = 1 ns, and reaching $\frac{1}{2^{13}}$ of a full-scale step takes $\tau\ln2^{13}$ = 9.0τ. Each extra bit costs another 0.69τ, which is why fast, high-resolution converters need low-resistance switches and small hold capacitors, and why small capacitors bring their own problems.
:::
:::

::: nameit
## Analog switches

An NMOS switch in triode has $R_\text{on} = \frac{1}{K(V_{DD} - v_\text{in} - V_t)}$: low for inputs near ground, infinite as the input nears $V_{DD} - V_t$. A PMOS switch is the mirror image. A **transmission gate** puts both in parallel, so one conducts where the other fails, and the resistance stays bounded across the whole range.

## Tracking

Closed, the switch and the hold capacitor $C_H$ form an RC with $\tau = R_\text{on}C_H$. Settling a full-scale step to within half an LSB of an N-bit converter takes

$$t_\text{acq} = \tau\ln2^{N + 1}.$$

## The errors of holding

- **Charge injection:** the switch's channel holds a charge $Q_\text{ch} = WLC_{ox}(V_{GS} - V_t)$, and when it turns off, roughly half lands on $C_H$: a step of $\frac{Q_\text{ch}}{2C_H}$. **Clock feedthrough** through the gate's overlap capacitance adds to it. Dummy switches and differential sampling cancel most of both.
- **kT/C noise:** the switch's thermal noise is frozen on the capacitor when it opens, with RMS value $\sqrt{\frac{kT}{C_H}}$, independent of the resistance: 20 µV for 10 pF at 300 K, 64 µV for 1 pF.
- **Droop:** leakage current I discharges the capacitor at $\frac{I}{C_H}$.
- **Aperture jitter:** a timing error σ on a sine of frequency f gives an error whose signal-to-noise ratio is $-20\log(2\pi f\sigma)$ dB.

A small $C_H$ tracks fast but suffers more from injection, kT/C noise and droop: every sample-and-hold design is that trade.
:::

::: example
## An NMOS switch with K = 1 mA/V² and $V_t$ = 0.5 V on 3.3 V passes signals from 0 to 3.3 V. Find its on-resistance at 0 V and at 1.65 V, and a transmission gate's at 1.65 V (PMOS with the same K and threshold).

::: solution
1. **NMOS at 0 V.**
   $$\frac{1}{1\ \text{mA/V}^2 \times 2.8\ \text{V}} = 357\ \Omega$$
2. **NMOS at 1.65 V.** The overdrive is 1.15 V, so the resistance is $\frac{1}{1.15}$ kΩ = 870 Ω. Above 2.8 V the NMOS doesn't conduct at all.
3. **Transmission gate at 1.65 V.** The PMOS has the same 1.15 V of overdrive, so it's also 870 Ω, and the pair in parallel is 435 Ω.
4. **Across the range.** At 3.3 V the PMOS alone gives 357 Ω, so the transmission gate's resistance stays between 357 and 435 Ω across the range, worst in the middle.

**Answer:** the NMOS switch is 357 Ω at 0 V and 870 Ω at 1.65 V; the transmission gate is 435 Ω at 1.65 V.
:::
:::

::: example
## A switch releases 20 fC of channel charge when it opens, half of it onto a 10 pF hold capacitor. How big is the error for a 12-bit converter with a 2 V range, and how does it compare with kT/C noise at 300 K?

::: solution
1. **Injection step.**
   $$\frac{10\ \text{fC}}{10\ \text{pF}} = 1.0\ \text{mV}$$
2. **In LSBs.** One LSB is
   $$\frac{2\ \text{V}}{4096} = 0.49\ \text{mV}$$
   so the injection is 2.0 LSB: an error the design has to cancel, usually by sampling differentially so both sides get the same kick.
3. **kT/C noise.** The frozen thermal noise is
   $$\sqrt{\frac{kT}{10\ \text{pF}}} = 20\ \mu\text{V RMS}$$
   a twenty-fourth of an LSB.
4. **A smaller capacitor.** Shrinking it to 1 pF would make the noise 64 µV and the injection 10 mV.

**Answer:** the error is 1.0 mV, or 2.0 LSB, while the kT/C noise is only 20 µV RMS, a twenty-fourth of an LSB.
:::
:::

::: example
## A converter samples a 10 MHz sine with 1 ps of aperture jitter. What signal-to-noise ratio does the jitter allow? And at 100 MHz?

::: solution
1. **SNR at 10 MHz.**
   $$\begin{aligned} \text{SNR} &= -20\log(2\pi \times 10^7 \times 10^{-12}) \\ &= 84.0\ \text{dB} \end{aligned}$$
   enough for about 13.7 bits.
2. **At 100 MHz.** The slope is ten times steeper and the SNR falls 20 dB, to 64.0 dB, about 10.3 bits whatever the converter's resolution.
3. **What sets the bits.** At high input frequencies the clock's jitter limits the effective number of bits more than the converter does.

**Answer:** the jitter allows 84.0 dB (about 13.7 bits) at 10 MHz, and 64.0 dB (about 10.3 bits) at 100 MHz.
:::
:::

::: check
kind: parts
given: K = 0.5 | 2 | 5; V = 1.8 | 3.3 | 5; Vt = 0.4 | 0.7; vin = 0.2 | 0.9

## An NMOS switch (K = {K} mA/V², $V_t$ = {Vt} V) is driven from {V} V and passes {vin} V.

::: part
answer: 1/(K*1e-3*(V - vin - Vt))
unit: Ω
tolerance: 0.5%

### What's its on-resistance?

::: misses
- [1/(K*1e-3*(V - Vt))] The source sits at the signal, so the overdrive is $V_{DD} - v_\text{in} - V_t$.
- [any] $\frac{1}{K(V_{DD} - v_\text{in} - V_t)}$.
:::
:::

::: part
answer: V - Vt
unit: V
tolerance: 0.5%

### Above what input does it stop conducting?

::: misses
- [any] $V_{DD} - V_t$.
:::
:::
:::

::: check
given: R = 20 | 100 | 500; C = 1 | 10; N = 8 | 12 | 16
answer: R*C*1e-12*ln(2^(N + 1))*1e9
unit: ns
tolerance: 0.5%

## A switch of {R} Ω charges a {C} pF hold capacitor. How long must it track to settle a full-scale step to half an LSB of an {N}-bit converter?

::: right
Right. $R_\text{on}C_H\ln2^{N + 1}$ = {answer}.
:::

::: misses
- [R*C*1e-12*ln(2^N)*1e9] Half an LSB is $2^{-(N + 1)}$ of full scale.
- [R*C*1e-12*log(2^(N + 1))*1e9] Exponential settling needs the natural logarithm.
- [any] $\tau\ln2^{N + 1}$.
:::
:::

::: check
kind: parts
given: Q = 5 | 20 | 50; C = 1 | 10 | 50; V = 1 | 2; N = 10 | 12

## A switch dumps {Q} fC of channel charge, half onto a {C} pF hold capacitor, in front of an {N}-bit converter with a {V} V range.

::: part
answer: Q/2/C
unit: mV
tolerance: 0.5%

### How large is the step?

::: misses
- [Q/C] About half the channel charge reaches the capacitor.
- [any] $\frac{Q_\text{ch}}{2C_H}$.
:::
:::

::: part
answer: Q/2/C/1000/(V/2^N)
tolerance: 0.5%

### How many LSBs is that?

::: misses
- [any] Divide by $\frac{V_\text{range}}{2^N}$.
:::
:::
:::

::: check
given: C = 0.1 | 1 | 10 | 100; T = 300 | 350
answer: sqrt(1.380649e-23*T/(C*1e-12))*1e6
unit: µV
tolerance: 0.5%

## What RMS noise is frozen on a {C} pF sampling capacitor at {T} K?

::: right
Right. $\sqrt{kT/C}$ = {answer}, whatever the switch's resistance.
:::

::: misses
- [sqrt(4*1.380649e-23*T/(C*1e-12))*1e6] kT/C has no factor of 4: the resistance's noise and its bandwidth cancel.
- [any] $\sqrt{\frac{kT}{C}}$.
:::
:::

::: check
kind: parts
given: f = 1 | 10 | 100; s = 0.1 | 1 | 5

## A converter samples a {f} MHz sine with {s} ps of aperture jitter.

::: part
answer: -20*log(2*pi*f*1e6*s*1e-12)
unit: dB
tolerance: 0.5%

### What SNR does the jitter allow?

::: misses
- [-10*log(2*pi*f*1e6*s*1e-12)] This is an amplitude ratio: use $20\log$.
- [any] $-20\log(2\pi f\sigma)$.
:::
:::

::: part
answer: (-20*log(2*pi*f*1e6*s*1e-12) - 1.76)/6.02
tolerance: 0.5%

### How many effective bits is that?

::: misses
- [any] $\frac{\text{SNR} - 1.76}{6.02}$.
:::
:::
:::

::: check
given: I = 0.1 | 1 | 10; C = 1 | 10 | 100; t = 1 | 10
answer: I*1e-9/(C*1e-12)*t*1e-6*1000
unit: mV
tolerance: 0.5%

## A hold capacitor of {C} pF leaks {I} nA. How far does it droop in a {t} µs hold?

::: right
Right. $\frac{I}{C}t$ = {answer}.
:::

::: misses
- [any] Droop rate $\frac{I}{C_H}$, times the hold time.
:::
:::

::: check
kind: choice

## Why does a transmission gate pair an NMOS and a PMOS switch?

- [ ] To double the current it can carry
- [x] So one device conducts well where the other runs out of overdrive, keeping the resistance bounded over the whole signal range
- [ ] To cancel kT/C noise
- [ ] To make it switch faster

::: right
Right. The NMOS conducts near ground, the PMOS near the supply, and together they cover rail to rail.
:::

::: misses
- [1] Current capacity isn't the reason; signal range is.
- [3] kT/C noise depends only on the capacitor.
- [4] Speed is a side effect at best.
:::
:::

::: check
kind: derivation
vars: R = 1..10000, C = 0.0000000000001..0.000000001, N = 6..20, T = 200..400

## A switch of resistance R samples onto capacitance C for an N-bit converter, at temperature T.

::: step
answer: R*C*ln(2^(N + 1))

### What's the acquisition time to half an LSB?
:::

::: step
answer: sqrt(1.380649e-23*T/C)

### What RMS noise is frozen on C?
:::

::: right
Right. Speed wants a small C; low noise wants a large one.
:::
:::

::: explain
## Why is the kT/C noise of a sample-and-hold independent of the switch's resistance?

::: model
The switch's resistance produces thermal noise whose density grows with the resistance, but the resistance and the hold capacitor also form a low-pass filter whose bandwidth shrinks as the resistance grows. The total noise voltage on the capacitor is the density integrated over that bandwidth, and the resistance cancels: four kT R times one over four RC is kT over C. When the switch opens, whatever noise voltage the capacitor holds at that instant is frozen, with RMS value the square root of kT over C. Only a larger capacitor reduces it.
:::
:::

::: practice

::: check
given: R = 50 | 400; C = 2 | 20; N = 10 | 14
answer: R*C*1e-12*ln(2^(N + 1))*1e9
unit: ns
tolerance: 0.5%

## {R} Ω, {C} pF, {N} bits. Acquisition time?

::: misses
- [any] $RC\ln2^{N + 1}$.
:::
:::

::: check
given: C = 0.5 | 5 | 50
answer: sqrt(1.380649e-23*300/(C*1e-12))*1e6
unit: µV
tolerance: 0.5%

## kT/C noise on {C} pF at 300 K?

::: misses
- [any] $\sqrt{kT/C}$.
:::
:::
:::
