Electrical Engineering › Section W · Signal conversion and data transmission › Topic W.1
Analog-to-digital and digital-to-analog conversion
Sound, temperature and light are analog, but processors work in numbers. Converters sit at that boundary, and their sampling rate, resolution and architecture decide how faithfully a digital system can sense and drive the real world.
Sampling and the Nyquist rule
An analog-to-digital converter (ADC) turns a voltage into a number, as anticipated in "Digital and analog quantities, logic levels, and waveforms". First a sample-and-hold circuit captures the input at regular instants and holds it steady while conversion runs. The sampling rate \(f_s\) must exceed twice the highest frequency present: \(f_s > 2f_{max}\). Half the sampling rate, \(f_s/2\), is the Nyquist frequency. Any component above it is aliased: after sampling it looks exactly like a lower frequency and cannot be removed. So an anti-aliasing low-pass filter, like those in "R-C low-pass and high-pass filters" but usually steeper, removes those components before the ADC.
Worked example: an alias appears
A system samples at \(f_s = 10\,\text{kHz}\), so its Nyquist frequency is 5 kHz. A 7 kHz tone leaks in because the anti-aliasing filter is missing. 1. The tone is above 5 kHz, so it will alias. 2. A sampled tone at \(f\) is indistinguishable from one at \(|f - kf_s|\) for any whole number \(k\). 3. With \(k = 1\): \(|7 - 10| = 3\,\text{kHz}\), which lies below the Nyquist frequency. 4. The digital data therefore shows a 3 kHz tone that was never in the signal. 5. Check: a 12 kHz tone would appear at \(|12 - 10| = 2\) kHz. Only filtering before sampling prevents this.
Quantisation and resolution
After sampling, the ADC quantises each held value to one of \(2^n\) codes, where \(n\) is its number of bits. With reference voltage \(V_{ref}\) the step size, or LSB (least significant bit), is
Every input within one step gives the same code, so the conversion always carries a quantisation error of up to one step, or up to half a step in converters whose thresholds are offset by half an LSB. Each extra bit halves the step. A 12-bit ADC with a 3.3 V reference has steps of \(3.3 \div 4096 \approx 0.806\) mV, while a 10-bit one has steps of about 3.22 mV.
Worked example: reading a temperature sensor
A sensor gives 10 mV per degree Celsius into a 12-bit ADC with a 2.5 V reference, and the ADC returns the code 1311. 1. Step size: \(2.5 \div 4096 = 0.610\) mV. 2. Input voltage: \(1311 \times 0.610\,\text{mV} = 800\) mV, to three significant figures. 3. Temperature: \(800 \div 10 = 80.0\) °C. 4. Resolution in degrees: \(0.610 \div 10 = 0.061\) °C per step, far finer than most sensors are accurate. 5. Check the range: full scale is about 2.5 V, or 250 °C, so 80 °C sits about a third of the way up, and \(1311 \div 4096 \approx 0.32\).
The flash ADC
Most ADCs rest on the comparator, an op-amp used without feedback, as in "Single-ended, differential, and operational amplifiers": its output goes high when the non-inverting input exceeds the inverting one. A flash ADC uses a chain of equal resistors to set \(2^n - 1\) threshold voltages, with one comparator per threshold. Every comparator below the input reads high, giving a thermometer pattern, and a priority encoder turns the highest active comparator into a binary code. Conversion takes one step, so flash ADCs are the fastest kind. The cost is size: an 8-bit flash ADC needs 255 comparators, and each extra bit doubles the count.
The successive-approximation ADC
The successive-approximation (SAR) ADC finds the code by binary search. A successive-approximation register sets the most significant bit, an internal DAC turns the trial code into a voltage, and a comparator says whether the input is at least that large. If it is, the bit stays at 1; if not, it is cleared. The register then tries the next bit, and so on down to the LSB. An n-bit SAR ADC therefore needs n comparison steps whatever the input, so the conversion time is fixed. Good speed, low power and modest size make SAR converters the usual choice inside microcontrollers.
Worked example: an 8-bit SAR conversion
An 8-bit SAR ADC with \(V_{ref} = 2.56\,\text{V}\) has 10 mV steps; convert 1.375 V. Each trial voltage is code × 10 mV. 1. Try 10000000 (1.28 V): input larger, keep. 2. Try 11000000 (1.92 V): too big, clear. 3. Try 10100000 (1.60 V): clear. 4. Try 10010000 (1.44 V): clear. 5. Try 10001000 (1.36 V): keep. 6. Try 10001100 (1.40 V): clear. 7. Try 10001010 (1.38 V): clear. 8. Try 10001001 (1.37 V): keep. The result is \(10001001_2 = 137\), representing 1.37 V, within one step of the input. Eight bits took exactly eight steps.
Dual-slope and delta-sigma ADCs
A dual-slope ADC integrates the input for a fixed time, then integrates a reference of opposite sign and counts how long the output takes to return to zero; that count is proportional to the input. Choosing the fixed time as a whole number of mains cycles, such as 1/60 s, averages out mains hum, which is why digital multimeters use it, though it is slow. A delta-sigma ADC samples far faster than the Nyquist rate with a simple 1-bit converter in a feedback loop, then a digital filter averages the bit stream into high-resolution words. Delta-sigma converters reach 16 to 24 bits and dominate audio and precision measurement.
Digital-to-analog converters
A digital-to-analog converter (DAC) does the reverse. A binary-weighted DAC feeds each bit through a resistor into an op-amp summing amplifier, with values R, 2R, 4R, 8R and so on, so each bit contributes in proportion to its weight. Wide ranges of precise values are hard to make, so the R/2R ladder, using only two resistor values, is preferred. For an ideal n-bit DAC with input code D, the output magnitude is
A 4-bit DAC with \(V_{ref} = 8.0\,\text{V}\) has 0.5 V steps: code 1011 gives \(8.0 \times \frac{11}{16} = 5.5\,\text{V}\), and full scale, 1111, gives 7.5 V.
Converter performance and testing
Resolution is the step size, or the number of bits. Accuracy compares the actual output with the ideal one. Linearity measures how far the steps depart from a straight line; differential nonlinearity (DNL) compares each step with the ideal LSB. A monotonic DAC never steps down when its input code rises. Settling time is how long the output takes to settle near its final value after a code change. Testers drive a DAC with a counting sequence and look for nonmonotonic steps, wrong step sizes or an offset; an ADC fed a slow ramp is checked for missing codes, incorrect codes and offset. A cheaper output is PWM: a filtered pulse train whose average follows the duty cycle.
Common mistakes to avoid
First, sampling at exactly twice the highest frequency: the rule needs more than twice, and real filters need extra margin. Second, hoping to remove aliases after sampling: they must be filtered out before. Third, dividing by \(2^n - 1\) instead of \(2^n\) for the step size. Fourth, expecting a SAR ADC's time to depend on the input: it always takes n steps. Fifth, confusing resolution with accuracy: a 16-bit converter with a poor reference can still be inaccurate.
Key takeaways
An ADC samples, holds, quantises and encodes. Sample above twice the highest frequency, \(f_s > 2f_{max}\), and filter before sampling, because components above \(f_s/2\) alias to \(|f - kf_s|\). The step size is \(V_{ref}/2^n\). Flash ADCs use \(2^n - 1\) comparators and are fastest; SAR ADCs binary-search in n steps; dual-slope ADCs integrate and reject mains hum; delta-sigma ADCs oversample for high resolution. DACs use binary-weighted resistors or an R/2R ladder, with \(V_{out} = V_{ref} D/2^n\). Judge converters by resolution, accuracy, linearity, monotonicity and settling time.
Flashcards
Flashcard
Analog-to-digital converter: voltage in, number out
Test your understanding
Question 1 of 5
What is the step size of an 8-bit ADC with a 5.12 V reference?
Question 2 of 5
A system samples at 8 kHz with no anti-aliasing filter. A 5 kHz tone is present at the input. At what frequency does it appear in the sampled data?
Question 3 of 5
How many comparators does a 6-bit flash ADC need?
Question 4 of 5
A weighing scale needs 24-bit resolution, and a few conversions per second is fast enough. Which ADC type suits it best?
Question 5 of 5
An ideal 4-bit DAC has an 8.0 V reference. What is its output for the input code 0110?
