---
title: Ladder networks and digital-to-analog converters
heading: The R-2R ladder, and turning a number into a voltage
eyebrow: C1 · Lesson 23 · Ladders and DACs
xp: 40
---

::: hook
Every time a phone plays sound or a microcontroller sets a motor's speed, a number becomes a voltage. The simplest circuit that does it is made only of resistors and switches: the R-2R ladder, which needs just two resistor values however many bits it has. It's a DC circuit you can analyze with the tools of this course, superposition and Thevenin, and it shows why precision matters: a small error in one resistor can make the output step backward when the number goes up.
:::

::: play
- A 4-bit converter's output against its input code, 0 to 15. The dashed staircase is ideal: every step is one **LSB**, $V_\text{ref}/16$.
- The slider makes the most significant bit's weight a few percent wrong. Watch the step between codes 7 and 8.
- Below about −12.5%, code 8 gives *less* than code 7: the converter is no longer monotonic.
:::
:::

```sim plot
view: graph
x: x = 0..15
y: V = 0..5 V
slider: Vr = 1..5 step 0.1 = 5 V
slider: d = -20..20 step 0.5 = 0 %
plot: Vr/16*floor(x) | label: ideal | dashed | color: ch2 | samples: 1600
plot: Vr/16*(8*(1 + d/100)*(floor(x/8) - 2*floor(x/16)) + 4*(floor(x/4) - 2*floor(x/8)) + 2*(floor(x/2) - 2*floor(x/4)) + (floor(x) - 2*floor(x/2))) | label: with the MSB off | samples: 1600
readout: LSB, mV = 1000*Vr/16 | digits: 4
readout: step from 7 to 8, in LSBs = 8*(1 + d/100) - 7 | digits: 3
```

::: predict
## An 8-bit converter has a 5 V reference. How big is one step of the output?

- [ ] 0.625 V
- [ ] 50 mV
- [x] About 19.5 mV
- [ ] About 2 mV

::: reveal
About 19.5 mV. Eight bits give $2^8 = 256$ codes, so each step is $\frac{5}{256} = 19.5$ mV, and the full-scale output (code 255) is $5 \times \frac{255}{256} = 4.98$ V. Each extra bit halves the step.
:::
:::

::: nameit
## Ladders from the far end

A **ladder** network alternates series and shunt elements. Work from the far end toward the input, combining as you go. In an **R-2R ladder**, every rung is a 2R resistor and every series link an R: at the last node, 2R ∥ 2R = R; add the series R to get 2R; in parallel with the next rung's 2R that's R again. Looking toward the far end from any node, the ladder is always R. That's why it divides cleanly by two at each step.

## The R-2R converter

Each bit of an $N$-bit code switches its 2R rung to $V_\text{ref}$ (bit 1) or ground (bit 0). By superposition, bit $k$ alone contributes $V_\text{ref}/2^{N-k}$ at the output, halving at each node it passes, so

$$V_\text{out} = V_\text{ref}\frac{D}{2^N}$$

for the code $D$ read as a binary number, with an output (Thevenin) resistance of R whatever the code. The **LSB** is $V_\text{ref}/2^N$, and the largest output is $V_\text{ref}(1 - 2^{-N})$.

## Binary-weighted converters

The obvious alternative uses resistors R, 2R, 4R, ... into a summing node. It needs a spread of $2^{N-1}$ in values: for 12 bits, from R to 2048R, all matched in ratio. The R-2R ladder needs only two values, which is why it's the one built on chips.

## Accuracy

The most significant bit carries half the full scale, so its error matters most. If its weight is off by a fraction δ, the step from code $2^{N-1} - 1$ to $2^{N-1}$ is off by $2^{N-1}\delta$ LSBs. Keeping that within half an LSB needs $|\delta| \le 2^{-N}$: 0.024% for 12 bits, far tighter than ordinary resistors, which is why converters are trimmed or built from matched elements on one chip.
:::

::: example
## An 8-bit R-2R converter with a 5 V reference gets the code 10100101. What does it output?

::: solution
1. **Convert the code.** 10100101 in binary is
   $$128 + 32 + 4 + 1 = 165$$
2. **Output.**
   $$\begin{aligned} V_\text{out} &= 5 \times \frac{165}{256} \\ &= 3.223\ \text{V} \end{aligned}$$

**Answer:** the converter outputs 3.223 V.
:::
:::

::: example
## A 12-bit converter is built with binary-weighted resistors. What spread of values does it need, and how well must the MSB match?

::: solution
1. **Spread of values.** The resistors run from R to
   $$2^{11}R = 2048R$$
2. **How well the MSB must match.** For the mid-scale step to be within half an LSB, the MSB's weight must be right to
   $$2^{-12} = 0.024\%$$

**Answer:** the resistors span R to 2048R, and the MSB must be right to 0.024%.
:::
:::

::: example
## An 8-bit R-2R DAC with R = 10 kΩ and a 5 V reference drives a 100 kΩ load directly. What gain error does the load cause?

::: solution
1. **The ladder's output.** An R-2R ladder's output looks like the ideal voltage behind a resistance R, whatever the code.
2. **Divider with the load.** The 100 kΩ load forms a divider with it:
   $$\frac{100}{100 + 10} = 0.909$$
   a 9.1% gain error, the same at every code.
3. **Full scale.**
   $$5 \times \frac{255}{256} = 4.98\ \text{V}$$
   comes out as 4.53 V.
4. **The fix.** A buffer amplifier fixes it, which is why DAC chips either include one or specify a minimum load.

**Answer:** the load causes a 9.1% gain error, so full scale drops from 4.98 V to 4.53 V.
:::
:::

::: check
given: N = 8 | 10 | 12 | 16; V = 2.5 | 3.3 | 5
answer: V/2^N*1000
unit: mV
tolerance: 0.5%

## An {N}-bit converter has a {V} V reference. How big is one LSB?

::: right
Right. $V_\text{ref}/2^N$ = {answer}.
:::

::: misses
- [V/N*1000] Bits multiply the number of levels: $2^N$.
- [any] Not yet. $V_\text{ref}/2^N$.
:::
:::

::: check
given: N = 8 | 10; V = 3.3 | 5; D = 100 | 200 | 255
answer: V*D/2^N
unit: V
tolerance: 0.5%

## An {N}-bit converter with a {V} V reference gets code {D}. What does it output?

::: right
Right. $V_\text{ref}D/2^N$ = {answer}.
:::

::: misses
- [any] Not yet. $V_\text{out} = V_\text{ref}D/2^N$.
:::
:::

::: check
given: N = 4 | 8 | 12; V = 1 | 5 | 10
answer: V*(1 - 2^(-N))
unit: V
tolerance: 0.001%

## What is the largest output of an {N}-bit converter with a {V} V reference?

::: right
Right. $V_\text{ref}(1 - 2^{-N})$ = {answer}.
:::

::: misses
- [V] The top code is $2^N - 1$, one LSB short of the reference.
- [any] Not yet. Code $2^N - 1$.
:::
:::

::: check
given: R = 5 | 10 | 20
answer: R
unit: kΩ
tolerance: 0.5%

## An R-2R ladder uses R = {R} kΩ. What resistance do you see looking from any node toward the far end?

::: right
Right. It's always R: {answer}.
:::

::: misses
- [2*R] At the last node, 2R ∥ 2R = R, and each step repeats that.
- [any] Not yet. Combine from the far end: 2R ∥ 2R, plus R, ...
:::
:::

::: check
given: N = 8 | 10 | 14
answer: 2^(N - 1)
tolerance: 0.1%

## A binary-weighted {N}-bit converter's smallest resistor is R. How many times R is its largest?

::: right
Right. $2^{N-1}$ = {answer}.
:::

::: misses
- [2^N] The MSB uses R and the LSB $2^{N-1}R$.
- [any] Not yet. Each bit doubles the resistor.
:::
:::

::: check
given: N = 8 | 12 | 16
answer: 100*2^(-N)
tolerance: 0.5%

## For an {N}-bit converter, how precisely (in percent) must the MSB's weight be set for the mid-scale step to stay within half an LSB?

::: right
Right. $2^{-N}$ = {answer}%.
:::

::: misses
- [100*2^(-N + 1)] The MSB error shows up as $2^{N-1}\delta$ LSBs; keep that within ½.
- [any] Not yet. Solve $2^{N-1}\delta = \frac12$.
:::
:::

::: check
kind: parts
given: N = 8 | 10 | 12; R = 10 | 50; L = 100 | 1000; D = 100 | 200

## An {N}-bit R-2R DAC (R = {R} kΩ, 5 V reference) gets code {D} and drives a {L} kΩ load.

::: part
answer: 5*D/2^N
unit: V
tolerance: 0.5%

### What would it output unloaded?

::: misses
- [any] $V_{ref}\frac{D}{2^N}$.
:::
:::

::: part
answer: 5*D/2^N*L/(L + R)
unit: V
tolerance: 0.5%

### What does it output into the load?

::: misses
- [any] The ladder's output resistance is R.
:::
:::
:::

::: check
kind: derivation
vars: V = 1..10, N = 4..16, D = 0..1000

## An N-bit converter with reference V gets code D.

::: step
answer: V/2^N

### How big is one LSB?
:::

::: step
answer: D*V/2^N

### What's its output?
:::

::: step
answer: (2^N - 1)*V/2^N

### What's its full-scale output?
:::

::: right
Right. Full scale is one LSB short of the reference.
:::
:::

::: explain
## Why does an R-2R converter need only two resistor values, while a binary-weighted one needs a different value for every bit?

::: model
In a binary-weighted converter, each bit's weight comes directly from its own resistor, so the weights 1, 2, 4, ... must be built as resistors R, 2R, 4R, ..., a different value per bit, up to thousands of times R. In an R-2R ladder, each node sees the same resistance R toward the far end, so every node halves whatever passes through it. The binary weights come from the structure of the ladder repeating the same halving, not from different resistor values, so two values, matched to each other, are enough for any number of bits.
:::
:::

::: practice

::: check
given: b = 3 | 6 | 9
answer: 2^b
tolerance: 0.1%

## How many output levels does a {b}-bit converter have?

::: misses
- [any] $2^b$.
:::
:::

::: check
given: R = 1 | 2.2 | 4.7 | 10 | 20 | 33 | 47
answer: R*2*R*2/(R*2 + R*2)
unit: kΩ
tolerance: 0.5%

## What is 2R in parallel with 2R, for R = {R} kΩ?

::: misses
- [any] Two equal resistors in parallel: half of one.
:::
:::

::: check
given: d = 0.1 | 1 | 5; N = 4 | 8
answer: 2^(N - 1)*d/100
tolerance: 0.5%

## An {N}-bit converter's MSB weight is off by {d}%. By how many LSBs is the mid-scale step wrong?

::: misses
- [any] $2^{N-1}\delta$.
:::
:::
:::
