PS

Priya Sharma

1 week ago

I'm implementing a digital low-pass filter for real-time sensor data processing, but the output signal has significant delay and phase distortion. How can I minimize this while maintaining good frequency response?

I'm working on a project that involves processing accelerometer data in real-time for motion detection. I've designed a Butterworth low-pass filter with a cut-off frequency of 5 Hz using Python's scipy.signal library, but when I apply it to the streamed data, there's a noticeable lag and the phase response isn't linear, which affects my timing calculations. I've tried adjusting the filter order, but higher orders increase the delay, and lower orders don't filter enough noise. I'm constrained by a microcontroller with limited computational power, so efficiency is key.

0
2 Comments

Discussion

SB

Sukriti Bhattacharyya
6 days ago

To minimize delay and phase distortion in real-time signal processing, consider switching from an IIR filter like Butterworth to a linear-phase FIR filter, which has a constant group delay and no phase distortion. Here's a practical approach using Python with scipy:

  • Design a linear-phase FIR filter: Use the scipy.signal.firwin function to design a low-pass filter. For example:
    import numpy as np
    from scipy.signal import firwin, lfilter
    N = 64 # Filter order, adjust based on your constraints
    cutoff = 5 # Cut-off frequency in Hz
    fs = 100 # Sampling frequency in Hz (adjust as per your system)
    taps = firwin(N, cutoff, fs=fs)
    This ensures linear phase, but note that FIR filters typically have higher latency than IIR filters for the same attenuation.
  • Optimize for real-time processing: If latency is critical, use a lower-order filter or implement a moving average filter as a simple FIR option. Alternatively, consider using a Bessel filter (IIR) which has better phase linearity than Butterworth, though it may still have some delay.
  • Check resource constraints: On a microcontroller, you might pre-compute filter coefficients and use efficient convolution algorithms. Refer to the scipy signal documentation for more details and examples.

For your accelerometer data, ensure the sampling frequency is sufficiently high to avoid aliasing, and test with simulated data to balance performance and latency.

0
KM

Koushtubh Munshi
1 week ago

Following this, I'm dealing with similar issues in audio processing.
0