# FIR Filter phase shift and stability

I designed an FIR highpass filter which is causing a phase shift to the output. The output signal is also not stable (?) on start. Are these normal or am I doing something wrong? If these are normal, what causes these? (Attached is a diagram showing the input in blue and the output in red). Thanks.

This is perfectly normal. At the beginning you see the transient effect because the signal suddenly starts and the filter was at rest before (zero initial condition). A causal filter will always add some phase shift to your signal. This phase shift is usually frequency dependent, but for a linear phase FIR filter the resulting delay is independent of frequency.

If $H(e^{j\omega})$ is the frequency response of the filter and $\phi(\omega)=\arg\{H(e^{j\omega})\}$ is its phase response, then the phase shift experienced by a sinusoid with frequency $\omega_0$ is simply $\phi(\omega_0)$, i.e. the corresponding time delay equals $-\phi(\omega_0)/\omega_0$.

• Matt - The phase shift is linear with respect frequency and therefore not independent of frequency – David May 13 '15 at 17:26
• @David: You're right, I meant the delay. Will edit it ... thanks. – Matt L. May 13 '15 at 17:31

A digital filter always has a delayed output. Think of the FIR filter as a shift register. At each time instant, all samples are shifted; one new sample enters the filter and the last sample is discarded. This introduces a delay as the the samples propagate through the filter. The important property of a (linear phase) FIR filter is that all frequencies are delayed by the same amount.

What you're seeing at the beginning of the output is normal and is also related to the structure of the FIR filter. At the start, the shift register is loaded with zeros. This produces a "transient" response. As more and more samples enter the filter, the output becomes more meaningful. Usually, you should wait until the filter is at least half full before evaluating its output.

• Thanks for the replies. Are there ways to improve the phase shift and the transient effect? – dritech May 13 '15 at 15:50
• What do you mean by 'improve'? If you want to reduce the length of the transient effect, then you need to reduce the order of the filter, but this will also reduce its effectiveness. Note, however, that in most applications the delay and the transient effect are not a problem. – MBaz May 13 '15 at 15:53
• @dritech: Not in real-time processing. With offline-processing you're of course free to do what you like, such as throw away the first samples (transient), and shift the output to align with the input. – Matt L. May 13 '15 at 15:53
• Also, can the filter affect the signal amplitude in any way? – dritech May 13 '15 at 15:58
• @dritech, of course, that's the whole point of the filter. The output's amplitude depends on the input's frequency. – MBaz May 13 '15 at 16:10