S2 · Lesson 53 · Project: a SAR ADC with capacitor mismatch
A behavioral model, its DNL and INL by the histogram test, and its ENOB by FFT
A successive-approximation converter is a capacitor DAC, a comparator and a little logic doing a binary search. Its accuracy is the DAC's: each bit's capacitor should be exactly twice the next, and random mismatch (lesson 34) makes them not quite. In this project you'll build a behavioral model of a 10-bit SAR ADC with random capacitor mismatch, then measure it the way a lab would. A slow ramp and a histogram of output codes give the DNL and INL. A coherently sampled sine and an FFT give the SINAD and effective number of bits. Then you can see how much matching a design needs.
Predict
A 10-bit SAR ADC's MSB capacitor is 2 LSB larger than it should be, and everything else is perfect. Where does its worst DNL appear?
At midscale. Every code below 512 uses only the smaller capacitors; every code from 512 up adds the MSB. An MSB that's too large makes the jump from 511 to 512 happen 2 LSB late, so code 511 is 2 LSB too wide: DNL = +2 there. The same error shows as an INL bow of ±1 LSB, and it costs about 0.8 effective bits. Mismatches in smaller capacitors show up at the quarter-scale and eighth-scale transitions, more weakly.
Name it
The model
- Capacitor DAC: bit k (k = 0 for the LSB) has a capacitor of unit capacitors, each with independent relative mismatch σ, so its weight is with standard normal. A dummy unit capacitor completes the array, and the total is .
- DAC level for a code with bits : .
- Binary search: start from code 0; for k from N − 1 down to 0, try setting bit k, and keep it if ≥ the DAC level of the trial code. Vectorize over an array of inputs.
The histogram test
Feed a slow, uniform ramp across full scale, many samples per code, and count how many samples land in each code (dropping the two end codes, which collect out-of-range inputs). Then
with the INL's end-point straight line removed.
The sine test
Sample a sine of amplitude just under full scale with an integer, odd number of cycles in the record (coherent sampling, so no window is needed), convert, and take the FFT of the codes. SINAD is the signal bin's power over everything else except DC; .
What you'll write
make_dac(N, sigma, seed=1)returning(w, total), andsar(vin, w, total, vref=1.0)returning integer codes.dnl_inl(w, total, per_code=64)returning(dnl, inl)arrays for codes 1 to .enob(w, total, samples=4096, cycles=127)returning(enob, sinad_dB).
Worked example
What DNL and INL does a 10-bit DAC with its MSB 0.5 LSB heavy have?
Show the solution
- Midscale transition. The MSB's extra 0.5 LSB delays the midscale transition by 0.5 LSB, so code 511 is 1.5 LSB wide.
- DNL. That makes DNL = +0.5 at code 511, and zero elsewhere.
- INL. After removing the end-point line, the INL steps by 0.5 at midscale and so swings ±0.25 LSB.
- Check against the model. The model's histogram test returns exactly that: DNL 0.5 at code 511, maximum INL 0.25.
Answer DNL is +0.5 LSB at code 511 and zero elsewhere, and INL swings ±0.25 LSB.
Worked example
With unit mismatch of 0.5%, how big is a typical worst-case DNL for 10 bits?
Show the solution
- Midscale spread. The midscale transition swaps all 1023 unit capacitors' worth of bits, so its error has spread and it's usually the worst.
- Simulated arrays. Across 200 random arrays the median worst DNL is 0.15 LSB.
- The tails. The tails are long: one of those arrays drew an MSB error beyond 3σ and reached 0.57 LSB.
- Design consequence. Production yield is set by those tails, so designers size unit capacitors (and therefore kT/C noise and power) for the mismatch spec at 3σ or more.
Answer a typical worst-case DNL is about 0.15 LSB (a midscale spread of 0.16 LSB), though a rare array can reach 0.57 LSB.
Check
Step 1. Write make_dac and the vectorized sar.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Step 2. Write dnl_inl(w, total, per_code=64) by the histogram test.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Step 3. Write enob(w, total, samples=4096, cycles=127) by the coherent sine test.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
An 8-bit SAR DAC uses unit capacitors with 0.5% mismatch. What's the spread of its midscale DNL?
Check
A SAR DAC's MSB is 1 LSB heavy. What's the peak INL after removing the end-point line?
Check
A 12-bit SAR ADC samples at 1 MS/s, spending one clock cycle sampling and one per bit. What internal clock does it need?
Write units the way you normally would: 1.5 MHz, 1500 kHz and 0.0015 GHz are the same answer.
Explain why
Why is a SAR converter's linearity set by its capacitor matching rather than its comparator?
A SAR converter compares the input with a sequence of DAC voltages and keeps or drops each bit. The comparator only has to say which of two voltages is larger; its offset shifts every decision by the same amount, which looks like a constant offset of the whole transfer curve, not a nonlinearity, and its noise adds random error to each conversion. The code thresholds themselves, where each output code begins and ends, are set entirely by the DAC's voltages, which come from capacitor ratios. If the capacitors aren't exactly binary weighted, the thresholds are unevenly spaced, and that uneven spacing is exactly what DNL and INL measure.
Practice
Keep practicing
6 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.