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.
Nyquist
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
| 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.