Data Converters at Working Depth: R–2R and Weighted DACs, ADC Arithmetic, Sigma-Delta, INL/DNL/ENOB, Sample-and-Hold, PGA, Microcontroller Timing and On-Board AI

Section 7 of the IN paper asks for the analog front end (multiplexer, programmable-gain amplifier, sample-and-hold), ADCs (successive approximation, integrating, flash, sigma-delta), DACs (weighted R, R-2R ladder, current steering), their specifications (resolution, quantization, INL, DNL, ENOB, settling time), embedded systems, data acquisition, IoT and basic AI — and the first chapter described all of it in prose with no ladder, no conversion arithmetic and no timer calculation. This chapter supplies the numbers. An 8-bit R–2R DAC with a 5 V reference has an LSB of 19.53 mV and code 0xA5 gives 3.223 V using only two resistor values. A 12-bit converter on a 10 V range has a step of 2.44 mV, a quantisation noise of 0.705 mV rms and an ideal SNR of 74.0 dB; a measured SINAD of 62 dB means only 10.0 effective bits. A flash ADC of 8 bits needs 255 comparators, a dual-slope ADC with a 20 ms integration rejects 50 Hz, and a first-order sigma-delta at OSR 64 reaches about 9.1 bits from a 1-bit quantiser.
Overview

DACs: Weighted-Resistor, R–2R Ladder and Current Steering

2 min read · 1 part

A DAC of n bits turns a code D (0 … 2ⁿ − 1) into V_out = V_ref·D/2ⁿ; one LSB is V_ref/2ⁿ and full scale is V_ref(1 − 2⁻ⁿ). Binary-weighted resistor DAC: each bit switches a resistor R, 2R, 4R, … into an inverting op-amp summing node, V_out = −V_ref(R_f/R)Σ b_i 2^(i−(n−1)); for a 4-bit DAC with R_f = R/2 and V_ref = 5 V, code 1011 gives −5 × 0.5 × (1 + 0 + ¼ + ⅛) = -3.4375 V. Its flaw is the resistor spread 2^(n−1):1 — 128:1 at 8 bits — and an error of 0.4% in the MSB resistor already equals an LSB. The R–2R ladder uses only two values R and 2R; at every node the resistance looking toward the LSB end is 2R, so each bit current halves in sequence: V_out = V_ref·D/2ⁿ with 8 bits and 5 V: LSB = 19.53 mV, code 0xA5 (165) gives 5 × 165/256 = 3.223 V. It is easy to match two resistor values on a chip, so R–2R is the standard integrated DAC.

Current-steering DAC. Binary-weighted (or unary, 2ⁿ − 1 equal) current sources are steered by switches between the output and a dummy node, so the switches never change a node voltage and the converter is fast (hundreds of MS/s); the output is a current that a resistor or op-amp turns into voltage. A segmented design splits the MSBs into equal thermometer-coded unary sources (no large major-carry glitch, DNL-friendly) and the LSBs into binary-weighted ones. Specifications: resolution n, LSB size, full-scale error, offset, INL (deviation from the straight line through the end points, in LSB), DNL (deviation of each step from 1 LSB; > −1 LSB guarantees monotonicity), settling time (to within ½ LSB), and glitch energy at major-code transitions such as 0111…1 → 1000…0.

DAC typeResistor valuesStrengthWeakness
Binary-weighted resistorR … 2^(n−1)RSimple conceptHuge spread, poor matching
R–2R ladderR and 2R onlyEasy to match on chipMajor-carry glitch
Current steeringCurrent sourcesFastest, low glitch if segmentedOutput is a current

A DAC of n bits turns a code D (0 … 2ⁿ − 1) into V_out = V_ref·D/2ⁿ; one LSB is V_ref/2ⁿ and full scale is V_ref(1 − 2⁻ⁿ). Binary-weighted resistor DAC: each bit switches a resistor R, 2R…

ADC Arithmetic and Architectures

2 min read · 2 parts

An n-bit ADC on a full-scale range FSR has a step q = FSR/2ⁿ and a quantisation error of ±q/2 (uniform, so rms q/√12 = 0.289q). For 12 bits and 10 V: q = 2.44 mV, v_n = 0.705 mV rms, and for a full-scale sine the ideal SQNR = 6.02n + 1.76 = 74.0 dB. To resolve 0.1% needs 2ⁿ ≥ 1000, n = 10 bits. ENOB = (SINAD − 1.76)/6.02: a measured SINAD of 62 dB gives 10.0 bits, whatever the datasheet bit count. Flash: one comparator per level, 2ⁿ − 1 = 255 for 8 bits, one clock per conversion, but the comparator count (and power) doubles with each bit. Successive approximation: a binary search with a DAC, n clock cycles per conversion, so 12 bits at a 1 MHz clock takes 12 µs (≈ 83 kS/s before acquisition) — the best compromise of speed, resolution and power for data acquisition.

Dual-slope (integrating): integrate V_in for a fixed time T₁ (N₁ clock counts), then integrate −V_ref until the output returns to zero in time T₂; V_in = V_ref·T₂/T₁, independent of R, C and the clock frequency. With V_ref = 10 V, a 100 kHz clock, N₁ = 2000 (T₁ = 20 ms, a whole number of 50 Hz periods, so mains interference averages to zero) and V_in = 3.2 V: T₂ = 6.4 ms, count 640, conversion time ≤ 2T₁ = 40 ms — hence the 3½-digit bench meter. Sigma-delta: a 1-bit quantiser inside a feedback loop, running at an oversampling ratio OSR = f_s/2f_B, shapes the quantisation noise to high frequency; a digital decimation filter removes it. For an L-th order modulator SQNR ≈ 6.02N + 1.76 − 10log[π^(2L)/(2L + 1)] + (20L + 10)log OSR; with N = 1, OSR = 64: first order 56.8 dB (9.1 bits), second order 85.2 dB (13.9 bits) — resolution bought with oversampling instead of precision components, at a cost in bandwidth, so it dominates low-frequency, high-resolution instrumentation (weighing, temperature).

ADCConversion timeHardwareTypical use
Flash1 clock2ⁿ − 1 comparatorsVideo, oscilloscopes
SARn clocks1 comparator + DACData acquisition, MCUs
Dual-slope≤ 2T₁ (tens of ms)Integrator + counterDigital multimeters
Sigma-deltaOSR × samples1-bit modulator + filterWeighing, temperature, audio
How a dual-slope ADC converts
  1. Integrate V_in for fixed T₁T₁ = 20 ms, whole 50 Hz periods
  2. Integrate −V_ref back to zeroTakes time T₂
  3. V_in = V_ref·T₂/T₁Independent of R, C and clock

An n-bit ADC on a full-scale range FSR has a step q = FSR/2ⁿ and a quantisation error of ±q/2 (uniform, so rms q/√12 = 0.289q). For 12 bits and 10 V: q = 2.44 mV, v_n = 0.705 mV rms, and…

INL, DNL, ENOB, Sample-and-Hold, PGA and Multiplexing

2 min read · 2 parts

DNL is the deviation of each code width from 1 LSB; INL is the accumulated deviation of the transfer curve from the ideal straight line, and for an end-point fit INL[k] is the running sum of DNL. DNL = −1 LSB means a code of zero width — a missing code. Take DNL = [0.2, −0.5, 0.8, −1.0, 0.3] LSB: INL = 0.2, -0.3, 0.5, -0.5, -0.2 LSB, and the fourth code is missing. DNL > −1 for every code guarantees a monotonic converter; INL ≤ ½ LSB is what makes a converter "accurate to its resolution". Dynamic range = 20 log(full scale/rms noise floor); ENOB from SINAD as above; aperture jitter t_j limits SNR to −20 log(2πf_in t_j): 1 ps jitter allows 104 dB at 1 MHz but only 64 dB at 100 MHz — clock quality can limit a fast converter more than its architecture.

Sample-and-hold. A switch charges a hold capacitor C_h; in hold the capacitor leaks, giving a droop rate I_leak/C_h: 10 nA into 1 nF droops 10 V/s, so a 12-bit, 10 V converter (½ LSB = 1.22 mV) tolerates a hold time of only 0.12 ms. The acquisition time to settle within ½ LSB is t = RC ln(2^(n+1)): R = 1 kΩ, C = 1 nF, n = 12 gives 9.0 µs — the minimum sampling interval the S/H allows. Programmable-gain amplifier: choose the gain so the signal fills the ADC range; for a 0–50 mV sensor into a 5 V ADC the gain is 100 (and its resolution with a 12-bit ADC becomes 1.2 µV at the input). Analog multiplexer: one ADC shared by N channels; the ADC must run at N × the per-channel rate (8 channels × 10 kS/s = 80 kS/s), and the source must settle after each switch (S/H plus a buffer), with crosstalk between adjacent channels a specification.

SpecificationDefinitionWorked value
LSB (12 bit, 10 V)FSR/2ⁿ2.44 mV
Quantisation noiseq/√120.705 mV rms
Ideal SQNR (12 bit)6.02n + 1.7674.0 dB
ENOB at SINAD 62 dB(SINAD − 1.76)/6.0210.0 bits
Acquisition timeRC ln 2^(n+1)9.0 µs

DNL is the deviation of each code width from 1 LSB; INL is the accumulated deviation of the transfer curve from the ideal straight line, and for an end-point fit INL[k] is the running sum…

Microcontroller Timing, Interfaces, IoT Power Budget and AI in Instrumentation

3 min read · 3 parts

IoT node power. A node draws 20 mA for 1 s every 10 minutes and 5 µA asleep: average current = (20 mA × 1 s + 5 µA × 599 s)/600 s = 38.3 µA, so a 2400 mAh cell lasts 2.4 Ah/38.3 µA = 62,622 h ≈ 7.1 years (before self-discharge) — the duty cycle, not the active current, sets battery life. A data acquisition system chains sensor → conditioning → multiplexer → S/H → ADC → processor → storage or radio; virtual instrumentation replaces the front panel by software on a PC with the same hardware. AI in instrumentation: (i) sensor linearisation — fit the inverse characteristic from calibration data; (ii) calibration and tuning — adapt parameters from data; (iii) signal classification — assign a measurement to a known class. A two-line example: a sensor reading V = 0.02, 1.01, 2.03, 3.00, 4.02 V at 0, 25, 50, 75, 100 °C fits V = 0.0400T + 0.018, so T = (V − 0.018)/0.0400, with a worst residual of 15 mV (0.38 °C); a non-linear sensor needs a polynomial or a small neural network, trained on a held-out split to avoid over-fitting the calibration points.

InterfaceWiresAddressingTypical rate
UART2 (TX, RX)Point to point9.6 kbaud – 1 Mbaud
SPI4 (SCLK, MOSI, MISO, CS)Chip select per deviceUp to tens of Mbit/s
I²C2 (SDA, SCL)7-bit address100 kbit/s – 3.4 Mbit/s
🎯 DAC output and converter quality
An n-bit R–2R DAC gives V_out = V_ref × D/2ⁿ: with 8 bits, V_ref = 5 V and code 128, V_out = 2.5 V and one step is 5/256 = 19.5 mV. An ideal n-bit converter has a signal-to-quantisation-noise ratio of 6.02n + 1.76 dB, so 8 bits give 49.9 dB, and the effective number of bits from a measured SINAD is (SINAD − 1.76)/6.02. Oversampling by a factor of 4 buys about one extra bit for a plain converter, and a sigma-delta converter with noise shaping buys much more.

Timers and serial links. A periodic interrupt comes from a timer: with f_clk = 16 MHz, prescaler 64 and a wanted 1 kHz tick, counts = 16 MHz/(64 × 1000) = 250, so an 8-bit timer reloads at…

Key takeaways

  • DAC: LSB = V_ref/2ⁿ; weighted resistors need a 2^(n−1):1 spread, the R–2R ladder only R and 2R; current steering is fastest and segmentation tames glitches.
  • ADC: step q = FSR/2ⁿ, quantisation noise q/√12, SQNR = 6.02n + 1.76 dB, ENOB = (SINAD − 1.76)/6.02; flash needs 2ⁿ − 1 comparators, SAR n clocks.
  • Dual-slope: V_in = V_ref T₂/T₁, independent of R, C and the clock; T₁ at a mains multiple rejects interference. Sigma-delta buys resolution with oversampling.
  • DNL = −1 LSB is a missing code; INL is the running sum of DNL; S/H droop = I_leak/C_h and acquisition t = RC ln 2^(n+1); aperture jitter limits SNR at high input frequency.
  • Timer counts = f_clk/(prescaler × f_tick); UART divisor = f_clk/(16 × baud); IoT battery life follows the duty cycle; AI in instrumentation means linearisation, calibration and classification.

Practice questions (24)

Attempt each one before opening the answer. Every explanation names the tempting wrong option as well as the right one, because that is where marks are lost.

  1. An 8-bit R–2R ladder DAC uses V_ref = 5 V. For input code 0xA5 (decimal 165) the output voltage in volts (three decimals) is:

    Numerical answer — type the value.

    Show answer

    Answer: 3.223

    V_out = V_ref × 165/256 = 3.223 V; the LSB is 5/256 = 19.53 mV. Dividing by 255 would be the mistake of treating the reference as full scale.
  2. The main reason an R–2R ladder is preferred to a binary-weighted resistor DAC in integrated circuits is that it:

    1. needs only two resistor values, which are easy to match
    2. needs no reference voltage
    3. converts faster than any other DAC
    4. has no glitch at major transitions
    Show answer

    Answer: A — needs only two resistor values, which are easy to match

    A weighted DAC at 8 bits needs resistors spanning 128:1 with the largest matched to 0.4%; the ladder uses only R and 2R. It still glitches at the major carry, and current steering is faster.
  3. A sensor reads V = 0.02, 1.01, 2.03, 3.00, 4.02 V at 0, 25, 50, 75, 100 °C. A least-squares line V = mT + b is fitted as a calibration. A later reading of 2.50 V corresponds, by inverting that line, to a temperature in °C (one decimal) of:

    Numerical answer — type the value.

    Show answer

    Answer: 62.1

    The fit is V = 0.0400T + 0.018; inverting, T = (2.50 − 0.018)/0.0400 = 62.1 °C. This is the simplest form of sensor linearisation by calibration; a non-linear sensor needs a polynomial or small neural network.
Show the other 21 questions
  1. A converter has a measured SINAD of 62 dB. Its effective number of bits is nearest to:

    1. 12
    2. 8
    3. 6
    4. 10
    Show answer

    Answer: D — 10

    ENOB = (SINAD − 1.76)/6.02 = 60.24/6.02 = 10.0. A 12-bit part with a 62 dB SINAD is delivering only 10 bits.
  2. In a dual-slope ADC, V_ref = 10 V, the clock is 100 kHz and the fixed integration period is 2000 counts. For V_in = 3.2 V the second-slope count is:

    Numerical answer — type the value.

    Show answer

    Answer: 640

    T₂ = T₁ V_in/V_ref = 20 ms × 0.32 = 6.4 ms, which is 640 clock counts. The result is independent of R, C and the clock frequency.
  3. Which statements about converter specifications are correct?

    1. A sigma-delta ADC achieves high resolution mainly through oversampling and noise shaping
    2. ENOB is always larger than the nominal bit count
    3. INL is the accumulated deviation from the ideal transfer line
    4. DNL = −1 LSB at a code means that code is missing
    Show answer

    Answer: A — A sigma-delta ADC achieves high resolution mainly through oversampling and noise shaping; C — INL is the accumulated deviation from the ideal transfer line; D — DNL = −1 LSB at a code means that code is missing

    ENOB is at most the nominal bit count, because real noise and distortion only reduce it. The other three statements are the standard definitions.
  4. A sample-and-hold has R = 1 kΩ and C_h = 1 nF. The acquisition time to settle within ½ LSB of a 12-bit converter, t = RC ln(2^(n+1)), in µs (one decimal), is:

    Numerical answer — type the value.

    Show answer

    Answer: 9.0

    ln(2¹³) = 13 × 0.6931 = 9.01, so t = 1 µs × 9.01 = 9.0 µs. Using only one RC time constant would badly under-settle.
  5. A sensor produces 0–50 mV and feeds a 5 V full-scale ADC through a programmable-gain amplifier. The gain that uses the full ADC range is:

    1. 1000
    2. 100
    3. 10
    4. 50
    Show answer

    Answer: B — 100

    G = 5 V/50 mV = 100. A higher gain would clip the top of the signal, a lower one wastes bits of resolution.
  6. A microcontroller with a 16 MHz clock uses a prescaler of 64 to generate a 1 kHz tick from a timer. The timer count between ticks is:

    Numerical answer — type the value.

    Show answer

    Answer: 250

    Timer clock = 16 MHz/64 = 250 kHz; 250 kHz/1 kHz = 250 counts per tick, so an 8-bit timer reloads at 249 (counting 0 … 249).
  7. An IoT node draws 20 mA for 1 s every 10 minutes and 5 µA in sleep. A 2400 mAh battery lasts approximately:

    1. 100 days
    2. 1 year
    3. 30 years
    4. 7 years
    Show answer

    Answer: D — 7 years

    Average current = (20 mA × 1 s + 5 µA × 599 s)/600 s ≈ 38 µA; 2.4 Ah/38 µA ≈ 62 600 h ≈ 7 years. The sleep current and duty cycle dominate, not the 20 mA burst.
  8. A 4-bit DAC with V_ref = 10 V gives V_o = V_ref·D/2⁴. For the input 1010, the output voltage, in V (two decimals), is ____.

    Numerical answer — type the value.

    Show answer

    Answer: 6.25

    D = 1010₂ = 10, so V_o = 10 × 10/16 = 6.25 V (the MSB alone gives 5 V, plus 1.25 V from the third bit). Dividing by 15 instead of 16 gives 6.67 V, a different full-scale convention than the one stated.
  9. The resolution of a 10-bit converter, expressed as a percentage of full scale (1/2¹⁰ × 100, three decimals), is ____.

    Numerical answer — type the value.

    Show answer

    Answer: 0.098

    100/1024 = 0.098 % of full scale. Answering 10 % divides by the number of bits instead of by 2¹⁰, which would make a 10-bit converter barely better than a 4-bit one.
  10. An asynchronous serial link (UART) keeps transmitter and receiver aligned without a shared clock line by

    1. transmitting only when the receiver polls it
    2. using a chip-select line for every byte
    3. sending a separate clock on a dedicated wire
    4. framing each character with a start bit and stop bit(s) at an agreed baud rate
    Show answer

    Answer: D — framing each character with a start bit and stop bit(s) at an agreed baud rate

    The falling start bit re-synchronises the receiver for each character, and both ends must agree on the baud rate. A separate clock wire and chip-select describe synchronous buses such as SPI, which is exactly what UART avoids.
  11. A sample-and-hold is placed ahead of a successive-approximation ADC chiefly to

    1. remove frequencies above Nyquist
    2. convert current to voltage
    3. keep the input constant while the bits are being resolved
    4. amplify the signal to full scale
    Show answer

    Answer: C — keep the input constant while the bits are being resolved

    SAR compares the input with a sequence of trial codes; if the input moves by more than an LSB during the search, the result is wrong. Removing frequencies above Nyquist is the anti-aliasing filter's job, a different block.
  12. A UART runs at 9600 baud with 8 data bits, no parity and 1 stop bit (plus 1 start bit). The maximum throughput, in bytes per second, is ____.

    Numerical answer — type the value.

    Show answer

    Answer: 960

    Each byte costs 1 + 8 + 1 = 10 bit times, so 9600/10 = 960 bytes/s. Dividing by 8 (1200 bytes/s) forgets the framing overhead.
  13. An 8-bit binary-weighted-resistor DAC uses R = 10 kΩ for the MSB. The resistor for the LSB, in kΩ, is ____.

    Numerical answer — type the value.

    Show answer

    Answer: 1280

    Each lower bit doubles the resistor, so the LSB needs 2⁷R = 1280 kΩ. Using 2⁸R = 2560 kΩ miscounts: eight bits span seven doublings. This 128 : 1 spread is why the R–2R ladder is preferred on chips.
  14. The number of comparators in a 6-bit flash ADC is ____.

    Numerical answer — type the value.

    Show answer

    Answer: 63

    A flash ADC compares against every threshold between codes, 2ⁿ − 1 = 63 of them. Answering 64 counts codes rather than the boundaries between them; the exponential growth is why flash converters stop at about 8 bits.
  15. In an ADC transfer curve, one code is found to be 1.5 LSB wide. The differential non-linearity at that code, in LSB, is ____.

    Numerical answer — type the value.

    Show answer

    Answer: 0.5

    DNL = actual width − ideal width = 1.5 − 1 = +0.5 LSB. Answering 1.5 reports the width itself; a DNL of −1 LSB would mean a missing code.
  16. A sample-and-hold uses a 1 nF hold capacitor and the total leakage current at its node is 1 nA. The droop rate, in mV per ms, is ____.

    Numerical answer — type the value.

    Show answer

    Answer: 1

    dV/dt = I/C = 1 nA/1 nF = 1 V/s = 1 mV/ms. Answering 1 V/ms misplaces the factor 1000 between seconds and milliseconds; a bigger capacitor cuts droop but lengthens acquisition.
  17. Training a neural network to map a thermocouple's raw voltage (and cold-junction temperature) to the true process temperature is an example of

    1. unsupervised clustering
    2. supervised classification
    3. supervised regression
    4. reinforcement learning
    Show answer

    Answer: C — supervised regression

    Labelled pairs (reading → reference temperature) train a model whose output is a continuous number, which is regression. Classification is the tempting supervised alternative, but it outputs discrete labels such as "faulty/healthy", not a temperature.
  18. An 8-bit timer is clocked from 16 MHz through a prescaler of 8 and counts 0 → 255. The overflow period, in µs, is ____.

    Numerical answer — type the value.

    Show answer

    Answer: 128

    One tick = 8/16 MHz = 0.5 µs, and overflow takes 256 ticks: 128 µs. Using 255 ticks gives 127.5 µs, missing the step from 255 back to 0.
  19. Without noise shaping, oversampling by a factor OSR improves in-band SQNR by 10 log₁₀(OSR) dB. With OSR = 256 and 6.02 dB per bit, the number of extra effective bits (nearest integer) is ____.

    Numerical answer — type the value.

    Show answer

    Answer: 4

    10 log₁₀256 = 24.08 dB and 24.08/6.02 = 4 bits: each 4× of oversampling buys one bit. Answering 8 treats the gain as 20 log₁₀(OSR), which double-counts; noise shaping is what makes sigma-delta far better than this.
  20. A 12-bit ADC digitises a full-scale 100 kHz sine (peak-to-peak equal to full scale). For the sampling-instant error at the steepest point to stay within ½ LSB, the maximum aperture jitter, in ps (one decimal), is ____.

    Numerical answer — type the value.

    Show answer

    Answer: 388.6

    Max slope = 2πf·(FS/2); require slope × t_j ≤ FS/2¹³, so t_j ≤ 1/(2πf·2¹²) = 388.6 ps. Using 2¹³ in place of 2¹² (about 194 ps) treats the amplitude as the full peak-to-peak range.
  21. Which statements about the I²C and SPI buses are correct?

    1. SPI selects a slave by sending its 7-bit address in the first byte.
    2. I²C lines are open-drain and need pull-up resistors.
    3. SPI is full-duplex: data move on MOSI and MISO at the same time.
    4. I²C uses two lines, SDA and SCL, shared by all devices.
    Show answer

    Answer: B — I²C lines are open-drain and need pull-up resistors.; C — SPI is full-duplex: data move on MOSI and MISO at the same time.; D — I²C uses two lines, SDA and SCL, shared by all devices.

    I²C is a two-wire open-drain bus (hence pull-ups) and addresses slaves in-band; SPI shifts data both ways each clock. SPI selects a slave with a dedicated chip-select line, so the 7-bit address statement transplants I²C behaviour onto SPI.