How does an ADC work and what are its key parameters?
Short answer: Most MCU ADCs are successive approximation (SAR) converters: a sample-and-hold capacitor captures the input voltage, then an internal DAC and comparator perform a binary search, deciding one bit per step from the most significant bit down. Key parameters are resolution, sampling time, conversion rate, the reference voltage, and accuracy figures (offset, gain error, INL/DNL, ENOB).
Conversion: code = Vin / Vref × (2^N − 1) (approximately Vin / Vref × 2^N). A 12-bit ADC with Vref = 3.3 V has an LSB of 3.3 / 4096 ≈ 0.81 mV. Reading 2048 means about 1.65 V.
Key parameters
| Parameter | What to know |
|---|---|
| Resolution | 10, 12, 16 bits; number of output codes |
| Sampling time | time to charge the sampling capacitor; too short with a high source impedance gives readings that are too low |
| Conversion rate | samples per second (e.g. 1–5 Msps on STM32) |
| Reference voltage | accuracy and noise of Vref directly limit accuracy; use a separate filtered VREF+ pin or an external reference for precision |
| Offset and gain error | constant and proportional errors, removable by calibration |
| INL / DNL | non-linearity; DNL > 1 LSB means missing codes |
| ENOB | effective number of bits after noise and distortion; often 1–2 bits below nominal |
Sampling techniques
- Timer-triggered conversions give an exact, jitter-free sample rate (required for signal processing); software-triggered sampling in a loop does not.
- Scan mode + DMA: convert several channels in sequence into a buffer with no CPU work; circular DMA with half/full interrupts gives continuous double-buffered streaming.
- Injected/priority channels: sample critical signals (motor current) at precise moments in the PWM cycle.
- Oversampling and averaging: averaging 4^k samples adds k bits of effective resolution for slow signals, if there is some noise (dither) present. Many MCUs have hardware oversampling.
- Anti-aliasing: filter the input (RC low-pass) below half the sample rate (Nyquist), or high-frequency noise folds into the measurement.
Driving the input: the sampling capacitor (a few pF) must charge through the source impedance within the sampling time. A high-impedance sensor (e.g. a 100 kΩ divider) needs a longer sampling time, a buffer op-amp, or a capacitor at the pin (which acts as a charge reservoir).
Other ADC types: sigma-delta (high resolution, slower: weigh scales, audio, energy metering), pipelined and flash (very fast).