Analogue-to-Digital Conversion: Sampling, Bits and DACs

By Engr. Henry Akpan

Bridging the Analogue and Digital Worlds

The real world is analogue: temperature, sound pressure, light level and voltage all vary smoothly and can take any value. Computers, phones and microcontrollers are digital: they work only with numbers made of 0s and 1s. Whenever a phone records your voice, a digital thermometer reads a sensor or a music player drives a loudspeaker, a conversion happens between the two worlds. This tutorial explains analogue-to-digital conversion (ADC) and digital-to-analogue conversion (DAC): sampling, the Nyquist rule and aliasing, quantisation, resolution and bit depth, how converters work, and calculations of data rates, with examples from audio, sensors and communication.

Analogue and Digital Signals

  • An analogue signal varies continuously in time and can take any value within its range. The voltage from a microphone is analogue.
  • A digital signal exists only at separate instants of time and can take only a limited set of values, each represented by a binary code.

Digital signals have big advantages. They can be copied, stored and transmitted without gradually losing quality, because a receiver only has to decide whether each pulse is a 0 or a 1, and small amounts of noise don't change that decision. They can also be processed, compressed, encrypted and error-checked by computers.

Step 1 of Analogue-to-Digital Conversion: Sampling

An ADC measures the analogue signal at regular intervals. The number of measurements per second is the sampling rate (or sampling frequency), fs, in hertz.

The sampling rate must be high enough to capture the fastest changes in the signal. The Nyquist–Shannon sampling theorem states:

The sampling frequency must be more than twice the highest frequency in the signal: fs > 2fmax.

  • Human hearing reaches about 20 kHz, so CD audio is sampled at 44.1 kHz, a little over twice 20 kHz.
  • Telephone speech is limited to about 3.4 kHz and sampled at 8 kHz.

Aliasing. If a signal contains frequencies above half the sampling rate, they are not simply lost: they appear in the digital version as false lower frequencies, called aliases. The same effect makes a car's wheels in a film appear to spin slowly backwards, because the camera samples the picture 24 or 30 times a second. To prevent aliasing, ADCs have an anti-aliasing filter that removes frequencies above fs/2 before sampling.

Step 2: Quantisation and Bit Depth

Each sample's voltage must be converted into one of a fixed set of levels, each represented by a binary number. An n-bit converter has 2ⁿ levels.

  • 8 bits: 2⁸ = 256 levels.
  • 10 bits: 1,024 levels (common in microcontrollers such as Arduino boards).
  • 12 bits: 4,096 levels.
  • 16 bits: 65,536 levels (CD audio).

The resolution is the smallest change in voltage the converter can detect, the size of one step:

resolution = voltage range / 2ⁿ.

(Some books use 2ⁿ − 1 in the denominator; for large n the difference is tiny.)

Example 1. An 8-bit ADC has an input range of 0 to 5 V. Find its resolution.

Resolution = 5/256 ≈ 0.0195 V, about 20 mV. A 10-bit ADC over the same range resolves 5/1024 ≈ 4.9 mV.

Example 2. The same 8-bit ADC receives an input of 3.20 V. What binary code does it output?

Level = 3.20/5 × 256 = 163.8, which is rounded down to 163 by a typical converter. In binary, 163 = 10100011. Converting back, this code represents 163 × 5/256 ≈ 3.184 V. The 16 mV difference is the quantisation error.

Quantisation error is always up to one step (or half a step if the converter rounds). More bits mean smaller steps, less error and less quantisation noise. Each extra bit doubles the number of levels and improves the signal-to-noise ratio by about 6 dB.

Data Rate and File Size

The number of bits produced each second is the bit rate:

bit rate = sampling rate × bits per sample × number of channels.

Example 3. Find the bit rate of CD audio (44.1 kHz, 16 bits, stereo) and the storage needed for one minute.

Bit rate = 44,100 × 16 × 2 = 1,411,200 bit/s, about 1.4 Mbit/s. One minute is 1,411,200 × 60 = 84.7 million bits = 10.6 million bytes, about 10.6 MB. Compressed formats such as MP3 and AAC reduce this roughly ten-fold by discarding sounds the ear is unlikely to notice.

There is always a trade-off: higher sampling rates and more bits give better quality but bigger files and need faster transmission.

How an ADC Works

  • Flash ADC: compares the input with every level at once using a bank of comparators. Very fast, but needs 2ⁿ − 1 comparators, so it is used only for low bit depths, as in some oscilloscopes and radar.
  • Successive approximation ADC: finds the code one bit at a time, like a guessing game. It first tests whether the input is above half the range (setting the most significant bit), then whether it is above three-quarters or one-quarter, and so on. An n-bit conversion takes n steps. This is the most common type in microcontrollers.
  • Sigma-delta ADC: samples very fast at low resolution and uses digital filtering to achieve very high resolution. Used for high-quality audio and precise measurements.

Digital-to-Analogue Conversion (DAC)

A DAC does the reverse: it turns a binary number into a proportional voltage. For an n-bit DAC with reference voltage Vref:

Vout = Vref × (code / 2ⁿ).

Example 4. A 4-bit DAC has Vref = 8 V. Find the output for the code 1011.

1011 in binary is 11 in decimal, so Vout = 8 × 11/16 = 5.5 V. Each step is 8/16 = 0.5 V.

A simple DAC uses a binary-weighted resistor network feeding an op-amp summing amplifier: each bit switches in a resistor whose value is half of the previous one, so each bit contributes twice as much current as the next. The more practical R-2R ladder uses only two resistor values, which are easier to make accurately.

The DAC output is a staircase. A reconstruction filter (a low-pass filter) smooths the steps into a continuous waveform before it reaches an amplifier and loudspeaker.

Where ADCs and DACs Are Used

  • Phones: the microphone signal is converted by an ADC; received speech is turned back into sound by a DAC.
  • Sensors and data logging: a microcontroller's ADC reads thermistors, light-dependent resistors and pressure sensors.
  • Digital broadcasting and mobile networks carry speech and video as digitised, compressed data.
  • Medical equipment such as ECG machines digitises tiny body signals for display and analysis.
  • Control systems: a DAC can set the speed of a motor or the brightness of a lamp from a computer.

Summary

  • Analogue-to-digital conversion involves sampling (in time) and quantisation (in voltage).
  • Nyquist rule: sample at more than twice the highest signal frequency, or aliasing occurs.
  • An n-bit converter has 2ⁿ levels; resolution = range/2ⁿ; quantisation error is up to one step.
  • Bit rate = sampling rate × bits per sample × channels.
  • A DAC gives Vout = Vref × code/2ⁿ, followed by a smoothing filter.

Related Tutorials