Choosing Sampling Rates & Filters for Motion Sensors
This guide walks you through selecting the sampling rate and filter settings for motion tracking sensors (accelerometers, gyroscopes, IMUs). You’ll learn how to match the sensor’s data acquisition to the dynamics of your application, avoid aliasing and noise artifacts, and choose appropriate low-pass filters. We’ll cover the key trade-offs between responsiveness and noise reduction, and provide practical steps for both new and existing systems.
What You’ll Need
- Motion sensor datasheet (specs for accelerometer, gyroscope, or IMU)
- Knowledge of your application’s motion frequency range (e.g., human movement is typically 0.5–10 Hz, machinery vibration can be up to several kHz)
- Microcontroller or data acquisition system with adjustable sampling rate and filter settings
- Optional: data logging software (e.g., serial monitor, Python) to test and visualize signals
Step-by-Step
- Determine the highest frequency of interest in your motion. Estimate the fastest movement your sensor will see. For human motion (walking, running, gestures), the fundamental frequencies are usually below 10 Hz, but impacts can have higher components. For machinery, check vibration specs or use a reference accelerometer. This frequency is your signal bandwidth (f_max).
- Set your sampling rate to at least 2× f_max, but ideally 5–10× f_max. The Nyquist theorem requires a minimum of 2× to avoid aliasing, but in practice, use at least 5× to capture signal shape and allow for filter roll-off. For example, if your motion has components up to 50 Hz, sample at 250–500 Hz. If you’re not sure, start with 100 Hz for human motion, 1000 Hz for vibration analysis.
- Check the sensor’s maximum output data rate. Many IMUs have configurable output data rates (e.g., 100 Hz, 200 Hz, 400 Hz, 1 kHz). Choose the lowest rate that is at least your calculated sampling rate to reduce power and data load. If your required rate is not available, pick the next higher one.
- Choose a low-pass filter cutoff frequency. The filter should pass the frequencies of interest and attenuate noise above that. Set the cutoff (where the signal is reduced by 3 dB) to about 1.5–2× f_max. For human motion with f_max=10 Hz, a cutoff of 15–20 Hz is typical. For vibration up to 500 Hz, use a cutoff of 750–1000 Hz.
- Select the filter type and order. Common options are Butterworth (maximally flat passband), Chebyshev (sharper roll-off but ripple), and Bessel (linear phase, good for time-domain). For motion tracking, a 2nd-order Butterworth is often a good balance. Higher order filters (4th, 6th) give steeper roll-off but add phase lag.
- If using a digital filter, set the cutoff frequency in the software. For example, in Python with scipy.signal.butter, you specify the cutoff as a fraction of the Nyquist frequency (sampling rate / 2). If sampling at 100 Hz and cutoff is 20 Hz, the normalized cutoff is 20 / (100/2) = 0.4.
- Test with a known motion. Move the sensor in a controlled way (e.g., sinusoidal oscillation at a known frequency) and record the output. Verify that the signal amplitude is preserved at your f_max and that noise is reduced. Adjust cutoff if necessary.
- Check for phase lag. If your application requires real-time orientation or precise timing, excessive filtering can delay the signal. Measure the delay by comparing a step input to the filtered output. If lag is too high, increase the cutoff or reduce filter order.
- Consider using a notch filter for specific interference. If you have 50/60 Hz power line noise, a notch filter at that frequency can remove it without affecting nearby motion frequencies.
- Document your settings. Record the sampling rate, filter type, cutoff, and order in your code or project notes for reproducibility.
Common Mistakes
- Sampling too slowly: If sampling below the Nyquist rate, high-frequency motion will alias into lower frequencies, corrupting your data. This is often seen as ghost signals in the frequency spectrum.
- Setting the filter cutoff too high: This lets in noise, especially from high-frequency vibrations or electrical interference, making the signal jittery.
- Setting the filter cutoff too low: This removes real motion components, causing lag and missing fast movements. For example, a 5 Hz cutoff on a running sensor will blur the impact peaks.
- Ignoring phase lag: Filters delay the signal. In real-time applications like drone stabilization, excessive lag can cause instability.
- Using the same settings for different motion types: A walking motion and a vibrating machine have different frequency content; copying settings without adjustment leads to poor results.
- Forgetting the filter’s effect on amplitude: At the cutoff frequency, the signal is attenuated by 3 dB (about 30% reduction). If you need accurate amplitudes, keep your cutoff well above your highest frequency of interest.
Tips
- Start with a higher sampling rate than you think you need. You can always downsample later, but you can’t recover information lost by undersampling.
- Use a low-pass filter that is at least one order higher than the sensor’s internal filter. Many sensors have a built-in digital low-pass filter; adding another in software can create unexpected roll-off.
- For orientation estimation (e.g., with a gyroscope), consider a complementary filter or Kalman filter instead of a simple low-pass, as they fuse accelerometer and gyroscope data with different frequency responses.
- Test with actual data. Record a few seconds of real motion and plot the frequency spectrum (FFT) to see where the noise is. This helps you choose a precise cutoff.
- If using an IMU, check the datasheet for the sensor’s internal noise density. This tells you the noise level per Hz, which helps predict the effect of filtering.
- When in doubt, use a cutoff of 2× the expected motion frequency and a sampling rate of 10× that. This is a safe starting point for many applications.
Troubleshooting
- Signal is noisy even after filtering: Check if the noise is electrical (e.g., 50/60 Hz). Try a notch filter or increase the low-pass cutoff if the noise is at a higher frequency. Also ensure proper grounding and shielding.
- Signal is laggy or delayed: Reduce the filter order or increase the cutoff frequency. If using a digital filter, try a Bessel filter for a more linear phase response.
- Aliasing artifacts appear (e.g., high-frequency vibration shows up as low-frequency wobble): Increase the sampling rate. If you can’t, you must use an analog anti-aliasing filter before the ADC.
- Filtered signal has overshoot or ringing: This is common with high-order or Chebyshev filters. Switch to a Butterworth or Bessel filter with a lower order.
- The sensor output is saturated or clipping: Reduce the sensor’s range (e.g., from ±16g to ±2g) if your motion is within a smaller range, or adjust the filter to avoid amplifying noise.
- Data rate is too high for your microcontroller: Reduce the sampling rate if possible, or use a lower output data rate on the sensor. You can also downsample in software after filtering.
Frequently Asked Questions
What is the Nyquist rate and why does it matter?
The Nyquist rate is twice the highest frequency in your signal. Sampling below this causes aliasing, where high-frequency components appear as low-frequency artifacts. To avoid this, sample at least at the Nyquist rate, but in practice much higher.
How do I know the frequency content of my motion?
You can estimate from the application: human walking is about 1–2 Hz, running up to 5 Hz, gestures up to 10 Hz. For machinery, check the rotation speed or use a reference accelerometer to measure. You can also record a sample and perform an FFT to see the spectrum.
Should I use a hardware or software filter?
Hardware filters (analog) are needed before the ADC to prevent aliasing, especially if your sampling rate is low. Software filters are more flexible and can be adjusted after data collection. For most motion tracking, a software low-pass filter is sufficient if the sampling rate is high enough.
What is the difference between a low-pass and a band-pass filter?
A low-pass filter passes frequencies below a cutoff and attenuates higher ones. A band-pass filter passes a specific range of frequencies and rejects both lower and higher. For general motion tracking, a low-pass is typically used. Band-pass is useful when you only care about a specific frequency band, like detecting a particular vibration.
Can I use the same settings for accelerometer and gyroscope?
Often yes, but gyroscopes are more sensitive to high-frequency noise, so you might need a lower cutoff for the gyro. Also, gyro drift can be an issue; a high-pass filter might be needed to remove DC offset. Test each sensor separately.
What is phase lag and why is it bad?
Phase lag is the delay between the actual motion and the filtered signal. It’s bad because it makes the response feel sluggish and can cause instability in control systems. Lower-order filters and higher cutoff frequencies reduce lag, but they let in more noise.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.