← ME-6 · INTERFACING THE REAL WORLD

ADC & sampling

YOU WILL BE ABLE TO
  • Explain quantisation and compute an ADC's resolution.
  • State the Nyquist criterion and explain aliasing.
  • Describe the role of an anti-aliasing filter.
  • Explain sample-and-hold and why the source impedance matters.

Everything in Circuit Analysis and most of Microelectronics has treated voltage as a continuous quantity. A microcontroller cannot hold a continuous quantity — it holds numbers. The analogue-to-digital converter is the bridge, and crossing it costs two things: precision, because a continuous range becomes a finite set of levels, and time, because a continuous signal becomes a sequence of instants. Both costs are quantifiable, and mishandling either produces measurements that look plausible and are wrong.

Quantisation first. An NN-bit converter divides its reference range into 2N2^N levels, so the smallest distinguishable step — the least significant bit — is the reference divided by that count. Any reading carries an inherent uncertainty of half an LSB, before any other error source.

LSB=Vref2N\text{LSB} = \frac{V_{ref}}{2^N}quantisation error=±12 LSB\text{quantisation error} = \pm\tfrac{1}{2}\,\text{LSB}resolution and its error floor
ResolutionLevelsLSB at 3.33.3 V
8-bit25612.9 mV
10-bit10243.22 mV
12-bit40960.806 mV
16-bit65 53650.4 µV
Resolution against reference: the Pico's ADC is 12-bit, so its steps are under a millivolt.

Now time. Sampling a continuous signal at intervals discards everything between samples, and that discarded information can make a fast signal masquerade as a slow one. The Nyquist-Shannon criterion states the condition for this not to happen: the sampling rate must exceed twice the highest frequency present in the signal.

fs>2fmaxf_s > 2 f_{max}the Nyquist criterion
timetrue signalapparent (aliased)
Aliasing: sampled too slowly, a fast signal is indistinguishable from a much slower one.

One more subtlety, and it explains a whole class of mysterious ADC errors. Most converters sample by briefly connecting the input to a small internal capacitor, then measuring that capacitor's voltage while disconnected — a sample-and-hold. The capacitor must charge to the input voltage within the sampling window, and that charging is CA-5's RC transient with RR being the SOURCE's output impedance. Feed the ADC from a high-impedance source and the capacitor never finishes charging, so every reading is low.

vinsampleCH+−U1vout
Sample-and-hold: the switch closes briefly to charge C_H, then opens while the converter measures it.
WORKED EXAMPLE

Reading the CA-2 light sensor properly

  1. The LDR divider's Thevenin resistance is about 3.33.3 kΩ bright, 9.19.1 kΩ dark (your CA-4 and ME-4 capstones).
  2. The RP2040's sample capacitor is small, but its datasheet recommends a source impedance well under about 1010 kΩ for full accuracy.
  3. In darkness the divider is right at that limit, so the darkest readings will be the least trustworthy — a systematic error that varies with the very quantity being measured.
  4. The fix is ME-4's follower: buffer the divider, and the ADC sees an output impedance of a fraction of an ohm regardless of light level.
Buffer high-impedance sources — the error is worst exactly where the signal is weakest.
WORKED EXAMPLE

Choosing a sampling rate

  1. A temperature sensor's signal contains nothing above 22 Hz, but the wiring picks up 6060 Hz mains hum.
  2. Nyquist on the SIGNAL suggests fs>4f_s > 4 Hz — but the hum is also present at the input, and sampling at 44 Hz would alias 6060 Hz down to 00 Hz, appearing as a fixed temperature offset that drifts.
  3. Correct procedure: low-pass filter below 22 Hz to remove the hum, THEN sample at 1010 Hz for comfort.
  4. Nyquist applies to what actually arrives at the converter, not to what you intended to measure.
Filter first, then sample — the criterion governs the input, not the intention.

PRACTICE

Q1

A 10-bit ADC has a 55 V reference. What is its LSB size?

Q2

A signal contains components up to 11 kHz. What is the minimum sampling rate, and what rate would you actually choose?

Q3

A 12-bit ADC on a 3.33.3 V reference reads a code of 2048. What input voltage does that correspond to, and what is the uncertainty?

Q4

Explain why an anti-aliasing filter must come before the ADC rather than being applied in software afterwards.

ADC & sampling · ME-6 · iLearnSTEM Electronics