3
$\begingroup$

For example, I want to feed a DC into a low pass filter. The the filter's first several output will not have the same DC value I want.

  1. Does it mean that I need to dispose first several results?

  2. How many shall I dispose?

  3. What is the technical term describing this phenomenon, step response?

  4. Does it only happen to DC or to other frequency signals as well?

Here comes sample code and diagram:

Fs = 64e3;
f = 8e3;
T = 1/Fs;
t = 0:T:0.002;
input = 0.002*cos(2*pi*f*t);
input_with_DC = input+0.5;

[b,a]=cheby1(1,2,0.4);
output = filter(b,a,input_with_DC);

plot(input_with_DC)
hold
plot(output,'r')

enter image description here

It can be seen from above diagram that the DC rises at first and then approach to the actual DC value.

$\endgroup$
  • 2
    $\begingroup$ The filter has a delay and its output is not really useful at the start. Picture a FIR filter with many taps, all initially zero. As the signal shifts into the filter, the taps start to "fill out" and the filter's output starts to be meaningful. For $n$ taps, you'll want to wait at least $n/2$ samples before using the filter's output. $\endgroup$ – MBaz Mar 24 '16 at 13:59
  • $\begingroup$ Thanks for your reply. Why n/2 instead of n? What about for IIR filters? Must we experiment with step responses? $\endgroup$ – richieqianle Mar 24 '16 at 14:00
  • 1
    $\begingroup$ I'm not an expert on filters; $n/2$ is a rule of thumb number based on my experience. There's no harm in discarding the first $n$ samples; it may even be more accurate. $\endgroup$ – MBaz Mar 24 '16 at 14:03
  • 1
    $\begingroup$ See also ccrma.stanford.edu/~jos/fp/Transient_Response_Steady_State.html $\endgroup$ – Matthias W. Mar 25 '16 at 11:03
  • $\begingroup$ @MatthiasW. Truly great material. Simple and clear, thanks! $\endgroup$ – richieqianle Mar 25 '16 at 14:16
2
$\begingroup$

You have to judge yourself if for your purposes you need to get rid of the first few output values. The phenomenon you observe is determined by two factors. The first is the delay of the filter (which is usually frequency dependent). This delay is a consequence of the causality of the filter. For a linear phase FIR filter that delay is independent of frequency and equals $(N-1)/2$ samples, where $N$ is the filter length (as pointed out in a comment by MBaz). The other factor lies in the nature of low pass filters and has nothing to do with a non-ideal (causal) implementation. It is the non-zero rise time that any low pass filter exhibits, even an ideal (non-causal) brick-wall filter. The rise time is proportional to the inverse of the cut-off frequency.

For minimum-phase filters with a very low order (as in your example), the first factor plays only a small role, so the delay you observe is mainly caused by the non-zero rise time of the low pass filter. If you decrease the cut-off frequency you will observe an increase in rise time and vice versa. Note that the input signal that your filter sees is actually a jump from zero (no input signal) to a DC value (plus some small signal), so you pretty much see the system's step response.

In general the response to a change in the input signal is called transient response, and it is not restricted to a change in DC value.

$\endgroup$
  • $\begingroup$ Thanks Matt, truly nice explained! In my application, I want to measure system output DC value after a known stimulus given to the system. I do not really care if the DC is accurate (say 0.9 - 1.1 gain comparing with real DC is good enough). Noise rejection is very important. If this is the case and if the step response get to 1 at 100th data, can I simply use, say, the 10th data, which has the gain of 0.05 comparing with unit step, and compensate it with gain of 20? $\endgroup$ – richieqianle Mar 25 '16 at 14:08
  • $\begingroup$ I think my question is actually: what is the transient response of signals at other frequencies, especially the behavior of noises. If they are suppressed as well at the first several samples, I think my previous way would be fine. But if they are not suppressed at 10th samples then my way would be bad. $\endgroup$ – richieqianle Mar 25 '16 at 14:10
  • $\begingroup$ Could you please comment on my previous comment? $\endgroup$ – richieqianle Mar 31 '16 at 14:13
  • $\begingroup$ @richieqianle: I'm not sure if I understand your question. The phenomenon (rise time) has nothing to do with suppression. $\endgroup$ – Matt L. Mar 31 '16 at 15:28
  • $\begingroup$ My original question is: the purpose of the lpf is to get rid of high frequency noises and only retain accurate DC value and then be captured by ADC. The problem is when there is a DC change(time point is known), there will always be a transient, say 10 seconds to be stable, and at 0.5 second the gain is 0.1*DC. My question then becomes: can I capture the data at 0.5s and then multiply it by 1/0.1 ? $\endgroup$ – richieqianle Apr 1 '16 at 4:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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