I need to high pass filter a signal, and my design just isn't cutting it. The part that's making it tricky is that I can't tolerate lag. I am sampling at 20Hz, the signal I care about is 1/12 to 1/4Hz, and my system has to be as real time as possible (a lag of 2 seconds for signal processing is about all I can handle). The corner frequency is flexible, but has to be below 1/10Hz worst case.

I have been using an IIR-like lowpass filter like this:

signal_low_freq(n) = (signal_low_freq(n-1)*(filter_constant - 1) + (sensor_data(n))) /filter_constant;

signal_ac(n) = sensor_data(n) - signal_low_freq(n);

where filter_constant = 165.

It has low latency, but also introduces a large amount of phase related error (I measured it at about 100 samples of lag).

I have used Matlab's fdatool, and can get great results with a high order FIR filter, but that's obviously far too much lag.

Does anybody have a good solution to this DSP problem?

As a note: in the audio range, it's analogous to sampling at 48kHz and high-pass filtering with a corner frequency somewhere between 150Hz and 240Hz.

  • \$\begingroup\$ Is that the exact code? -- 'cause you're missing an index for sensor data in the first line. Can you pop up a figure for the step response of your filter, and signal_low_freq? \$\endgroup\$ Nov 13, 2013 at 21:25
  • \$\begingroup\$ Good catch on the missing index, I fixed it. It's practically line by line the code, with all the names changed so nobody gets upset. The filter I outlined is garbage and doesn't work well at all, but DSP isn't my strongest skill set and I don't know what else to do that won't introduce major lag. \$\endgroup\$
    – Bob
    Nov 14, 2013 at 0:03

1 Answer 1


I'm afraid you're up against a fundamental limitation of real, causal physical systems. You're asking for a filter that can distinguish between signals that have periods of 12 to 16 seconds, but only allowing it to "look at" a 2-second segment (1/6 to 1/8 of the period) of the waveform in question. It simply isn't possible to get no phase shift and low delay under these circumstances.

Can you provide some more context for this problem? What is the nature of the signals, and why is such low processing latency required?

  • \$\begingroup\$ I thought I might be hitting a wall; I was hoping someone with more experience could bend the rules and steer me to a solution. The problem is inertial, relating to accelerometer data, and trying to get position when in sinusoidal motion in real time. If the position isn't almost real time it becomes useless. I know you need to filter out low freq error (dc and bias drift) right up front,and I havent seen anything but Kalman filters as a solution. The IIR-ish filter I describe takes care of some of the low freq, but has awful phase characteristics, introducing a pile of low freq. error. \$\endgroup\$
    – Bob
    Nov 14, 2013 at 13:08
  • \$\begingroup\$ Ah. In that case, you're taking an approach that's too simplistic. The DC and low-frequency components you want to reject are much lower frequency than your inertial signal, so you use a very low cutoff freqeuncy filter (a couple of orders of magnitude below your signal frequency) to separate them. This filter can be a simple recursive filter, or a sophisticated Kalman filter and yes, it can take a long time to initialize. But then, when you subtract its output from the raw signal, the navigation signal is left over with virtually no effect on its phase/delay characteristics. \$\endgroup\$
    – Dave Tweed
    Nov 14, 2013 at 13:47
  • \$\begingroup\$ When I was looking at phase characteristics of, e.g., IIR filters in Matlab's fdatool, it had horrible phase characteristics at my signal frequencies, even if I pushed the corner frequency well below my signal. Is there a specific type of IIR or other recursive filter that I'm missing that wouldn't effect my signal's phase as much? \$\endgroup\$
    – Bob
    Nov 14, 2013 at 14:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.