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.
-
$\begingroup$ Please also read What should I do when someone answers my question?. $\endgroup$– Matt L.May 13, 2015 at 15:57
-
$\begingroup$ looks stable to me. FIRs implemented in the normal "transversal" manner are always stable. $\endgroup$– robert bristow-johnsonMay 13, 2015 at 18:52
2 Answers
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$.
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.
-
$\begingroup$ Thanks for the replies. Are there ways to improve the phase shift and the transient effect? $\endgroup$– dritechMay 13, 2015 at 15:50
-
$\begingroup$ 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. $\endgroup$– MBazMay 13, 2015 at 15:53
-
$\begingroup$ @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. $\endgroup$– Matt L.May 13, 2015 at 15:53
-
$\begingroup$ Also, can the filter affect the signal amplitude in any way? $\endgroup$– dritechMay 13, 2015 at 15:58
-
$\begingroup$ @dritech, of course, that's the whole point of the filter. The output's amplitude depends on the input's frequency. $\endgroup$– MBazMay 13, 2015 at 16:10