Data Acquisition: Sampling, Quantisation and ENOB
A "16-bit" data-acquisition card promises one part in 65 536. In practice its readings scatter over a dozen codes, a vibration at shows up as a tone in a record, and the datasheet's small print says "ENOB 13.1 bits at 1 kHz". This lesson treats the ADC as a measuring instrument: what sampling does to the spectrum, what quantisation adds, how to specify the anti-alias filter, and how to measure the effective number of bits that the "16 bits" really deliver. The theory of sampling and quantisation is in Signals and Fourier and Quantization; here it becomes a specification.
Sampling and aliasing
Sampling at cannot distinguish a frequency from for any integer : every input component appears in the band to at its alias frequency
Once aliased, a component cannot be removed by any digital processing. The only cure is to keep it out before the sampler: an anti-alias filter.
Simulation. A input sampled at appears at . With the anti-alias filter on (4th-order Butterworth at ) the readout gives its attenuation at : only about , so the alias is reduced to about a ninth, not removed. Move up to and the same signal is far inside the passband; move above and watch the alias fold again.
Quantisation
An ideal -bit converter over a full-scale range has an LSB of and rounds each sample to the nearest code. For a busy signal the error is uniform within , so its rms value is
for a full-scale sine (the is : a full-scale sine of amplitude has power , the noise , and ). Real converters add thermal noise, reference noise, clock jitter, differential and integral non-linearity (DNL, INL) and distortion. All of it is captured by SINAD, the ratio of the signal to everything else (noise and distortion), which defines the effective number of bits:
SFDR (spurious-free dynamic range) is the ratio of the signal to the largest single spur, the figure that matters when you look for a weak tone in a spectrum. Oversampling by a factor OSR and filtering to the band of interest spreads white quantisation noise over a wider band and keeps only of it: dB more SNR, half a bit per doubling (more with noise shaping, the sigma-delta trick in Inside the DMM).
Worked example: measuring the ENOB of a 12-bit channel
Given: a 12-bit ADC, , ; a test sine at of full scale; the front end adds rms of noise and a little second- and third-order distortion.
Find: the ideal SNR, the measured SINAD, SFDR and ENOB from a 4096-point FFT.
Solve: , , ideal SNR . The test uses coherent sampling: the input frequency is chosen so the record holds a whole, odd number of cycles (127 in 4096 samples), so no window is needed and every harmonic lands exactly on a bin:
import numpy as np
# A 12-bit ADC, +/-1 V full scale, sampling a nearly full-scale sine coherently (whole number of cycles).
N, fs, bits = 4096, 100e3, 12
cycles = 127 # odd and prime to N: every code region gets exercised
f_in = cycles * fs / N
t = np.arange(N) / fs
rng = np.random.default_rng(8)
x = 0.98 * np.sin(2 * np.pi * f_in * t)
x = x + 0.0008 * x**2 + 0.0004 * x**3 # small 2nd and 3rd order distortion of the front end
x = x + 120e-6 * rng.standard_normal(N) # input-referred noise, 120 uV rms
q = 2.0 / 2**bits # LSB size
codes = np.clip(np.round(x / q), -2**(bits - 1), 2**(bits - 1) - 1)
y = codes * q
P = np.abs(np.fft.rfft(y)) ** 2
P[0] = 0 # ignore DC
k = cycles
signal = P[k]
harm_bins = [(h * k) % N for h in range(2, 6)]
harm_bins = [b if b <= N // 2 else N - b for b in harm_bins]
noise_dist = P.sum() - signal
sinad = 10 * np.log10(signal / noise_dist)
sfdr = 10 * np.log10(signal / np.max(np.delete(P, [0, k])))
enob = (sinad - 1.76) / 6.02
print(f"f_in = {f_in:.2f} Hz ({cycles} cycles in {N} samples), LSB = {1e6 * q:.1f} uV")
print(f"ideal 12-bit SNR = {6.02 * bits + 1.76:.2f} dB; quantisation noise q/sqrt(12) = {1e6 * q / np.sqrt(12):.1f} uV rms")
print(f"measured SINAD = {sinad:.2f} dB, SFDR = {sfdr:.1f} dB, ENOB = {enob:.2f} bits")
print("harmonics (dBc):", ", ".join(f"H{h}: {10 * np.log10(P[b] / signal):.1f}" for h, b in zip(range(2, 6), harm_bins)))f_in = 3100.59 Hz (127 cycles in 4096 samples), LSB = 488.3 uV
ideal 12-bit SNR = 74.00 dB; quantisation noise q/sqrt(12) = 141.0 uV rms
measured SINAD = 66.27 dB, SFDR = 68.1 dB, ENOB = 10.72 bits
harmonics (dBc): H2: -68.1, H3: -80.4, H4: -100.1, H5: -108.5
Check: the noise alone () would give an SNR of ; the second harmonic at pulls SINAD down to , i.e. effective bits. The SFDR equals the second-harmonic level. Improving the front end's linearity is worth more than a 16-bit ADC here.
Specifying the anti-alias filter
For a 16-bit system, an alias should be pushed below the noise floor, about below full scale, by the time the input reaches the lowest frequency that folds back into the band of interest, . A Butterworth filter falls at per decade above its cutoff, so the required order depends dramatically on how much faster than you sample:
import numpy as np
# Anti-alias filter: signals of interest up to 1 kHz, 16-bit ADC, interference up to the folding band.
bits, f_pass = 16, 1e3
needed = 6.02 * bits + 1.76 # attenuation to push a full-scale alias below the noise
for fs in (5e3, 10e3, 50e3):
f_stop = fs - f_pass # lowest input frequency that folds back onto 0..1 kHz
# Butterworth: attenuation 20*n*log10(f/fc) far above fc, with fc = f_pass (-3 dB at the band edge)
n = needed / (20 * np.log10(f_stop / f_pass))
print(f"fs = {fs / 1e3:4.0f} kHz: alias band starts at {f_stop / 1e3:4.0f} kHz, needs {needed:.0f} dB "
f"-> Butterworth order {int(np.ceil(n))}")fs = 5 kHz: alias band starts at 4 kHz, needs 98 dB -> Butterworth order 9
fs = 10 kHz: alias band starts at 9 kHz, needs 98 dB -> Butterworth order 6
fs = 50 kHz: alias band starts at 49 kHz, needs 98 dB -> Butterworth order 3
Sampling ten times faster ( instead of ) needs only a 3rd-order filter instead of a 9th. That is why modern DAQ systems oversample and filter digitally. In practice, the attenuation is needed only for interference that is actually present, so you can relax the requirement once you know the environment.
DAQ details that bite
- Multiplexed inputs share one ADC: switching channels needs settling time, and a high source impedance plus the ADC's sampling capacitor gives crosstalk (the previous channel's charge). Buffer high-impedance sources, or slow the scan. Simultaneous-sampling cards have one ADC (or sample-and-hold) per channel, needed for phase-sensitive measurements such as power.
- SAR ADC inputs draw a charge pulse at each conversion; the driver (or an RC with a large capacitor) must settle to within half an LSB in the acquisition time.
- Aperture jitter limits the SNR of a high-frequency input to : at caps it at .
- Single-ended vs differential inputs: referenced single-ended inputs share the DAQ's ground with the sensor; differential inputs reject ground differences up to their common-mode range (next lesson).
Guided lab: the ENOB of a microcontroller ADC
Hand calculation. A 12-bit microcontroller ADC with a reference has and an ideal SNR of . Datasheets of such ADCs commonly give ENOB around to bits, i.e. a SINAD of about to .
Simulation. Run the ENOB program with your board's numbers (bits, fs), or replace the synthetic y by your recorded samples.
What you would measure. Feed a sine from a generator, centred at with about (through a resistor and with the generator's offset set first, checked on a scope), sample 4096 points at a rate that makes the number of cycles odd and coprime with 4096, and compute SINAD. Expect an ENOB of to bits. It is often lower with the supply as the reference and while the processor, USB or radio is busy, because their switching noise couples into the reference; compare the supply as reference with an external reference, and a busy with a quiet processor.
Hazards and safe setup. Never drive an ADC pin outside to : set the generator's offset and amplitude with the output disabled and check them on a scope before connecting, and keep the series resistor to limit current into the pin's protection diodes.
Pitfalls
- Relying on digital filtering to remove aliases (too late).
- Testing an ADC with a non-coherent frequency and no window, and blaming the ADC for the leakage.
- Quoting the resolution (bits) as the accuracy.
- Scanning multiplexed channels from high-impedance sources at full speed.
Practice
- What are the LSB and ideal SNR of a 16-bit ADC with a range?
- A converter's SINAD is . What is its ENOB?
- A vibration is sampled at . Where does it appear?
Answer
- ; SNR .
- bits.
- .
Test yourself
The ideal SNR of an N-bit ADC for a full-scale sine is
- dB
- dB
- dB
- dB
ENOB is computed from
- the number of output bits
- SINAD:
- SFDR only
- the LSB size
Oversampling by 16 and filtering to the original band improves the SNR (white noise) by about
- 3 dB
- 6 dB
- 12 dB
- 24 dB
Why must aliasing be prevented before the ADC?
- aliases are always small
- once sampled, an alias is indistinguishable from a real in-band signal
- digital filters are too slow
- it is not necessary with 24 bits