---
title: Analog switches and multiplexers
heading: MOSFETs as switches for signals, and the resistance, charge and leakage they bring along
eyebrow: C6 · Lesson 30 · Analog switches and multiplexers
xp: 40
---

::: hook
Lesson 29's sample-and-hold needed a switch that could connect a signal to a capacitor and then let go of it cleanly. The same part routes eight sensors into one ADC, changes an amplifier's gain or a filter's corner under software control, and chops signals in auto-zero amplifiers. It's a MOSFET, or rather a pair of them, used as a voltage-controlled resistor. An ideal switch would be zero ohms on and infinite off and would add nothing to the signal. A real one has an on-resistance that changes with the signal, dumps a little charge every time it opens, leaks when it's off, and couples high frequencies through its capacitance. Each of those sets a limit you can calculate.
:::

::: play
- On-resistance against signal voltage for a CMOS transmission gate on a 5 V supply: an NMOS and a PMOS in parallel, each with $k$ = 1 mA/V² and threshold 0.7 V. The two dashed curves are each device alone.
- The NMOS conducts well near ground and stops near the top; the PMOS does the opposite. In parallel, with matched devices, their conductances add to a constant across the middle.
- Lower the supply and watch the flat region shrink: below about twice the threshold, there's a gap where neither device is on.
:::

```sim plot
view: graph
x: v = 0..5
y: R = 0..2000
slider: VDD = 1.5..5 step 0.1 = 5
plot: 1/(1e-3*(VDD - v - 0.7)*step(VDD - v - 0.7) + 1e-3*(v - 0.7)*step(v - 0.7) + 1e-9) | label: transmission gate, Ω
plot: 1/(1e-3*(VDD - v - 0.7)*step(VDD - v - 0.7) + 1e-9) | dashed | label: NMOS alone
plot: 1/(1e-3*(v - 0.7)*step(v - 0.7) + 1e-9) | dashed | color: ch3 | label: PMOS alone
readout: flat on-resistance in Ω = 1/(1e-3*(VDD - 1.4))
```

::: predict
## An NMOS switch on a 5 V supply ($V_t$ = 0.7 V) passes signals well near ground. What happens to a 4.5 V signal?

- [ ] It passes with the same resistance
- [ ] It passes with a little more resistance
- [x] The switch can't fully pass it: the NMOS turns off as its source rises within a threshold of the gate
- [ ] It's inverted

::: reveal
The NMOS needs its gate at least a threshold above the signal, so with 5 V on the gate it stops conducting once the signal nears 4.3 V (less, with the body effect). Signals near the positive rail need a PMOS, whose gate is pulled to ground, and a switch that must pass the whole range uses both in parallel: the transmission gate.
:::
:::

::: nameit
## The MOSFET as a resistor

With almost no voltage across it, a MOSFET in triode is a resistor whose conductance is set by its overdrive. For a signal at $v$ with the gates at $V_{DD}$ (NMOS) and 0 (PMOS):

$$G_n = k_n(V_{DD} - v - V_{tn}), \qquad G_p = k_p(v - |V_{tp}|)$$

each zero when its overdrive is negative. In a **transmission gate** they're in parallel, and with $k_n = k_p = k$ and equal thresholds, wherever both conduct

$$G = k(V_{DD} - 2V_t)$$

is independent of the signal. The body effect raises the thresholds as the signal moves from the bulk's rail, so real switches show a gentle bump in the middle instead of a flat line. At low supply voltages there's a gap near mid-supply where neither device conducts, which is why low-voltage switches boost their gates with charge pumps.

## Errors a switch adds

- **On-resistance and its variation:** in series with a load $R_L$ it forms a divider, $R_L/(R_L + R_{on})$, and any change of $R_{on}$ with the signal is distortion. Feed the switch into a high impedance, such as an op amp's input, and $R_{on}$ hardly matters.
- **Bandwidth and settling:** $R_{on}$ (plus the source's resistance) charges the load and the switch's own capacitance. Settling to within $\varepsilon$ takes $\tau\ln(1/\varepsilon)$; for an $N$-bit converter's half LSB, $\varepsilon = 2^{-(N + 1)}$.
- **Charge injection:** when the switch opens, the channel's charge $Q_{ch} \approx WLC_{ox}(V_{GS} - V_t)$ leaves through both ends, roughly half each, and the half that lands on a hold capacitor $C_H$ makes a step $\Delta V \approx Q_{ch}/2C_H$. The gate's falling edge also couples through the overlap capacitance. A larger $C_H$ shrinks the step but slows the circuit; complementary or dummy switches cancel much of it.
- **Leakage:** an off switch leaks nanoamps or less, which through a source resistance $R_s$ is an error of $I_{leak}R_s$. In a multiplexer, every off channel's leakage lands on the shared output.
- **Off isolation and crosstalk:** an open switch is still a capacitance $C_{off}$, so a signal at frequency $f$ couples into a load $R_L$ with a gain of about $2\pi fC_{off}R_L$ while that's small.

## Multiplexers

A multiplexer is $N$ switches sharing one output. The output node carries the capacitance of every switch, on or off, so its settling time grows with the channel count, and break-before-make timing keeps two channels from shorting together during a change.
:::

::: example
## A transmission gate on 5 V has matched devices with $k$ = 1 mA/V² and $|V_t|$ = 0.7 V (ignore the body effect). Find its on-resistance at 0.5 V, 2.5 V and 4.5 V.

::: solution
1. **At 2.5 V.** Both devices conduct:
   $$\begin{aligned} G_n &= 10^{-3}(5 - 2.5 - 0.7) \\ &= 1.8\ \text{mS} \\ G_p &= 10^{-3}(2.5 - 0.7) \\ &= 1.8\ \text{mS} \end{aligned}$$
   so $R_{on}$ = 1/3.6 mS = 278 Ω.
2. **From 0.7 to 4.3 V.** The sum is $k(5 - 1.4)$ = 3.6 mS anywhere in this range, so the resistance stays 278 Ω.
3. **At 0.5 V.** Only the NMOS conducts:
   $$10^{-3}(5 - 0.5 - 0.7) = 3.8\ \text{mS}$$
   which is 263 Ω.
4. **At 4.5 V.** Only the PMOS conducts, with the same 263 Ω.
5. **Compare.** The resistance varies only 5% across the whole range, against an NMOS alone that goes from 263 Ω to open.

**Answer:** the on-resistance is 263 Ω at 0.5 V, 278 Ω at 2.5 V and 263 Ω at 4.5 V.
:::
:::

::: example
## A switch with $W$ = 10 µm, $L$ = 1 µm and $C_{ox}$ = 5 fF/µm² opens with 3 V of overdrive onto a 10 pF hold capacitor. Estimate the charge-injection step.

::: solution
1. **Channel charge.**
   $$\begin{aligned} Q_{ch} &= WLC_{ox}V_{ov} \\ &= 10 \times 1 \times 5\ \text{fF} \times 3 \\ &= 150\ \text{fC} \end{aligned}$$
2. **Step on the hold capacitor.** About half goes to the hold capacitor:
   $$\frac{75\ \text{fC}}{10\ \text{pF}} = 7.5\ \text{mV}$$
3. **In LSBs.** For a 12-bit converter with a 5 V range (an LSB of 1.2 mV), that's six LSBs.
4. **Reducing it.** Quadrupling the capacitor gets it under two LSBs but quadruples the charging time; a half-size dummy switch, shorted and driven by the opposite clock, absorbs most of the charge instead.

**Answer:** the charge-injection step is about 7.5 mV.
:::
:::

::: example
## An 8-channel multiplexer has 100 Ω on-resistance and 5 pF per channel at its output, drives a 20 pF ADC input, and each source has 1 kΩ of resistance. How long must the ADC wait after a channel change to settle within half an LSB at 12 bits? What error does 1 nA of total leakage add?

::: solution
1. **Time constant.** The output node has $8 \times 5 + 20$ = 60 pF, charged through 1.1 kΩ:
   $$\tau = 66\ \text{ns}$$
2. **Settling time.** Half an LSB at 12 bits is $2^{-13}$, so
   $$\begin{aligned} t &= \tau\ln 2^{13} \\ &= 9.01 \times 66\ \text{ns} \\ &= 595\ \text{ns} \end{aligned}$$
3. **Leakage error.** The leakage flows through the selected source's 1 kΩ: 1 µV, far below an LSB.
4. **With a high-impedance source.** With a 1 MΩ sensor it would be 1 mV, nearly an LSB, which is why high-impedance sources get a buffer before the multiplexer.

**Answer:** the ADC must wait 595 ns, and the leakage adds only 1 µV.
:::
:::

::: check
given: VDD = 3.3 | 5 | 12; k = 0.5 | 1 | 2; Vt = 0.5 | 0.7
answer: 1/(k*1e-3*(VDD - 2*Vt))
unit: Ω
tolerance: 0.5%

## A transmission gate has matched devices with $k$ = {k} mA/V² and $|V_t|$ = {Vt} V on a {VDD} V supply. What is its on-resistance where both devices conduct?

::: right
Right. The conductances add to $k(V_{DD} - 2V_t)$, so $R_{on}$ = {answer}.
:::

::: misses
- [1/(k*1e-3*(VDD - Vt))] That's one device with the signal at 0. In the middle, each device has less overdrive, but together they make $k(V_{DD} - 2V_t)$.
- [1/(2*k*1e-3*(VDD - 2*Vt))] The two conductances already add to $k(V_{DD} - 2V_t)$; don't double it.
- [any] Not yet. $G_n + G_p = k(V_{DD} - v - V_t) + k(v - V_t)$.
:::
:::

::: check
given: VDD = 5 | 12; k = 0.5 | 2; v = 0.5 | 1 | 2
answer: 1/(k*1e-3*(VDD - v - 0.7))
unit: Ω
tolerance: 0.5%

## An NMOS switch ($k$ = {k} mA/V², $V_t$ = 0.7 V) has its gate at {VDD} V. What is its on-resistance with the signal at {v} V?

::: right
Right. $1/(k(V_{DD} - v - V_t))$ = {answer}.
:::

::: misses
- [1/(k*1e-3*(VDD - 0.7))] The overdrive is measured from the source, which sits at the signal voltage.
- [1/(k*1e-3*(VDD - v))] Subtract the threshold.
- [any] Not yet. $G = k(V_{GS} - V_t)$ with $V_{GS} = V_{DD} - v$.
:::
:::

::: check
given: W = 5 | 10 | 20; L = 0.5 | 1; Cox = 5 | 8; od = 2 | 3; CH = 2 | 10 | 50
answer: W*L*Cox*1e-15*od/2/(CH*1e-12)*1e3
unit: mV
tolerance: 0.5%

## A switch with $W$ = {W} µm, $L$ = {L} µm and $C_{ox}$ = {Cox} fF/µm² opens with {od} V of overdrive onto a {CH} pF capacitor. If half the channel charge lands there, how big is the step?

::: right
Right. $Q_{ch}/2C_H$ with $Q_{ch} = WLC_{ox}V_{ov}$: {answer}.
:::

::: misses
- [W*L*Cox*1e-15*od/(CH*1e-12)*1e3] Only about half the charge goes to the hold side.
- [W*L*Cox*1e-15/2/(CH*1e-12)*1e3] Multiply by the overdrive to get the channel charge.
- [any] Not yet. $\Delta V = WLC_{ox}V_{ov}/(2C_H)$.
:::
:::

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

## A multiplexer output with {C} pF is charged through {R} Ω in total. How long until it settles within half an LSB at {N} bits?

::: right
Right. $RC\ln 2^{N + 1}$ = {answer}.
:::

::: misses
- [R*C*1e-12*ln(2^N)*1e9] Half an LSB is $2^{-(N + 1)}$, one more bit.
- [R*C*1e-12*1e9] One time constant only reaches 63%.
- [R*C*1e-12*log(2^(N + 1))*1e9] Use the natural logarithm.
- [any] Not yet. $t = \tau\ln(1/\varepsilon)$ with $\varepsilon = 2^{-(N + 1)}$.
:::
:::

::: check
given: f = 0.1 | 1 | 3; C = 1 | 2 | 5; R = 50 | 100 | 1000
answer: 20*log(2*pi*f*1e6*C*1e-12*R)
tolerance: 1%

## An open switch has {C} pF across it and feeds a {R} Ω load. Estimate its off isolation at {f} MHz, in dB (a negative number), while the coupling is small.

::: right
Right. The coupling is about $2\pi fC_{off}R_L$, so the isolation is {answer} dB. It worsens by 20 dB per decade of frequency.
:::

::: misses
- [10*log(2*pi*f*1e6*C*1e-12*R)] It's a voltage ratio: use 20 log.
- [20*log(1/(2*pi*f*1e6*C*1e-12*R))] That's the inverse, a positive number. Isolation is the small output over the input.
- [any] Not yet. $20\log_{10}(2\pi fC_{off}R_L)$.
:::
:::

::: check
kind: choice

## Why do analog switches use an NMOS and a PMOS in parallel instead of a single, larger NMOS?

- [x] An NMOS can't pass signals near its gate voltage, and a PMOS can't pass signals near ground; together they cover the whole range
- [ ] A PMOS has lower resistance than an NMOS of the same size
- [ ] Two devices halve the charge injection
- [ ] A single NMOS would leak too much when off

::: right
Right. Each device's overdrive falls as the signal approaches the rail its gate is driven from, so each fails at one end. In parallel, one is strong wherever the other is weak, and with matched devices the total conductance is flat.
:::

::: misses
- [2] A PMOS is usually weaker per unit width, because holes are less mobile.
- [3] Complementary charges can partly cancel, but that's a bonus; the reason is the signal range.
- [4] Off leakage isn't the issue. A single NMOS simply turns off near the top of the range.
:::
:::

::: check
kind: derivation
vars: k = 1e-4..1e-2, VDD = 2..12, Vt = 0.3..0.9, v = 1..1.5

## Show that a matched transmission gate's conductance doesn't depend on the signal where both devices conduct.

::: step
answer: k*(VDD - v - Vt)

### What is the NMOS's conductance with the signal at $v$?
:::

::: step
answer: k*(v - Vt)

### And the PMOS's?
:::

::: step
answer: k*(VDD - 2*Vt)

### What is their sum?
:::

::: right
Right. $v$ cancels: the NMOS loses exactly what the PMOS gains as the signal rises.
:::
:::

::: check
kind: python
given: VDD = 1.8 | 3.3 | 5; Vt = 0.5 | 0.7

## Sweep a transmission gate's on-resistance with the body effect. Each device's threshold rises with its source-to-bulk voltage: $V_{tn} = V_{t} + \gamma(\sqrt{2\phi + v} - \sqrt{2\phi})$ for the NMOS (bulk at 0) and $|V_{tp}| = V_t + \gamma(\sqrt{2\phi + V_{DD} - v} - \sqrt{2\phi})$ for the PMOS (bulk at $V_{DD}$), with $\gamma$ = 0.4 V$^{1/2}$ and $2\phi$ = 0.7 V. With $k$ = 1 mA/V² for both and `VDD` = {VDD} V, `Vt` = {Vt} V, write `ron(v)` (return `float('inf')` where neither conducts) and set `rmax`, the largest finite on-resistance over 2001 evenly spaced points from 0 to `VDD`, and `gap`, the total width in volts of the points where neither conducts (count the points times the spacing).

```python starter
def ron(v):
    return 1 / (1e-3 * (VDD - 2 * Vt))
rmax = ron(VDD / 2)
gap = 0.0
print(rmax, gap)
```

```python solution
import math
g, p2 = 0.4, 0.7
def ron(v):
    vtn = Vt + g * (math.sqrt(p2 + v) - math.sqrt(p2))
    vtp = Vt + g * (math.sqrt(p2 + VDD - v) - math.sqrt(p2))
    G = 1e-3 * max(0.0, VDD - v - vtn) + 1e-3 * max(0.0, v - vtp)
    return 1 / G if G > 0 else float('inf')
pts = [VDD * i / 2000 for i in range(2001)]
rs = [ron(v) for v in pts]
rmax = max(r for r in rs if r != float('inf'))
gap = sum(1 for r in rs if r == float('inf')) * VDD / 2000
print(rmax, gap)
```

```python tests
import math
g, p2 = 0.4, 0.7
def ref(v):
    vtn = Vt + g * (math.sqrt(p2 + v) - math.sqrt(p2))
    vtp = Vt + g * (math.sqrt(p2 + VDD - v) - math.sqrt(p2))
    G = 1e-3 * max(0.0, VDD - v - vtn) + 1e-3 * max(0.0, v - vtp)
    return 1 / G if G > 0 else float('inf')
for v in (0.0, VDD / 4, VDD / 2, VDD):
    a, b = ron(v), ref(v)
    assert (a == b == float('inf')) or abs(a - b) < 1e-9 * b, f"ron({v}) should include the body effect on both thresholds."
pts = [VDD * i / 2000 for i in range(2001)]
rs = [ref(v) for v in pts]
assert abs(rmax - max(r for r in rs if r != float('inf'))) < 1e-9 * rmax, "rmax is the largest finite value on the grid."
assert abs(gap - sum(1 for r in rs if r == float('inf')) * VDD / 2000) < 1e-12, "gap counts the grid points where neither device conducts."
```

::: right
Right. With the body effect, the resistance peaks at mid-supply instead of staying flat, and on a 1.8 V supply a gap opens where neither device conducts at all: the reason low-voltage switches boost their gate drive.
:::
:::

::: explain
## A data-acquisition board multiplexes eight thermocouple amplifiers and one 100 kΩ potentiometer into a 16-bit ADC. The thermocouple readings are fine, but the potentiometer's reading depends on which channel was read just before it. Explain why, and suggest two fixes.

::: model
When the multiplexer switches to the potentiometer, the output node and the ADC's sampling capacitor still hold the previous channel's voltage, and they must charge to the new value through the potentiometer's source resistance, up to tens of kilohms at mid-travel, plus the switch's on-resistance. With tens of picofarads, the time constant is about a microsecond, and settling within half an LSB at 16 bits takes about twelve time constants, longer than the ADC waits, so some of the previous channel's voltage remains: a memory effect. The low-impedance amplifier outputs settle quickly, which is why they're fine. Fixes: buffer the potentiometer with an op amp so every channel drives the multiplexer from a low impedance; lengthen the acquisition time for that channel or read it twice and discard the first; or add a capacitor at the potentiometer's wiper much larger than the sampling capacitor, so the charge sharing barely disturbs it.
:::
:::

::: practice

::: check
given: k = 0.5 | 1 | 4; VDD = 3.3 | 5
answer: 1/(k*1e-3*(VDD - 1.4))
unit: Ω
tolerance: 0.5%

## A matched transmission gate ($|V_t|$ = 0.7 V) with $k$ = {k} mA/V² runs on {VDD} V. What is its mid-range on-resistance?

::: misses
- [1/(k*1e-3*(VDD - 0.7))] Subtract both thresholds.
- [any] $1/(k(V_{DD} - 2V_t))$.
:::
:::

::: check
given: Q = 50 | 200; CH = 5 | 20
answer: Q/2/CH
unit: mV
tolerance: 0.5%

## A switch releases {Q} fC of channel charge, half onto a {CH} pF hold capacitor. What step does it cause?

::: misses
- [Q/CH] Only half the charge goes to the capacitor.
- [any] $\Delta V = Q/2C_H$; femtocoulombs over picofarads is millivolts.
:::
:::
:::
