Ground Embedded KO Subscribe

Notes / Sensors & Signal Processing

Sampling and aliasing

Measure a signal at intervals and fast changes disguise themselves as slow false signals. The Nyquist frequency, and why a filter is needed before sampling.

GROUND EMBEDDED · NOTESensors & Signal Processing 02Sampling and aliasingMCUTempI2CIMUSPIHallGPIORangeUARTCurrentADC

Nyquist

Real signalSample instantsValue read
With fewer than two samples per cycle, a false waveform slower than the real signal appears.

The highest frequency that a sampling frequency fs can represent correctly is fs/2 (the Nyquist frequency). Faster components do not disappear; they fold down to lower frequencies and mix in. This is aliasing.

Example: sampling at 1 kHz with 990 Hz PWM noise mixed in shows a false 10 Hz ripple in the measurements. It is the same effect as a wheel appearing to turn backwards on video.

Once mixed, it cannot be removed

A digital filter after sampling cannot tell the folded-in false 10 Hz from a real 10 Hz. So everything above fs/2 has to be filtered out before sampling, with an analog low-pass filter (an anti-aliasing filter).

Practical measures

SensorAnalog low-pass filterADCDigital filter
Cut the fast components before the ADC.
Method Description
RC filter In front of the ADC input, with the cut-off well below fs/2
Oversampling Sample much faster and average down
Synchronous sampling Sample at the same point of the PWM period (motor current)
Sensor's built-in filter The DLPF setting of an IMU

A digital sensor (an IMU) samples internally too, so set its output data rate (ODR) and built-in low-pass bandwidth together.

FREE PDFGet the 3 free ebooksIf you want to keep reading this topic as one book: BLDC motor control, serial communication and sensors at book length. PDFs are in Korean.Get them free →