# How can I high pass (DSP) filter a low frequency signal without introducing lag?

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.

• 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? – Scott Seidman Nov 13 '13 at 21:25
• 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. – Bob Nov 14 '13 at 0:03