Forums

Fast response filter?

Started by Luiz Carlos January 15, 2004
Is there a way to define the response time of a filter?
What can I do to obtain a filter where it's impulse response is
limited to a certain period of time?
Ok, an IIR filter has an infinite impulse response, but it becomes
very small after some time!

Luiz Carlos
"Luiz Carlos" <oen_no_spam@yahoo.com.br> wrote in message
news:3fd8f66b.0401150822.5e0eaf50@posting.google.com...
> Is there a way to define the response time of a filter? > What can I do to obtain a filter where it's impulse response is > limited to a certain period of time? > Ok, an IIR filter has an infinite impulse response, but it becomes > very small after some time! >
Luiz Carlos, I just posted an arm-waving description in the thread "Few taps for FSK" - so did others. Fred
Fred Marshall wrote:

> "Luiz Carlos" <oen_no_spam@yahoo.com.br> wrote in message > news:3fd8f66b.0401150822.5e0eaf50@posting.google.com... > >>Is there a way to define the response time of a filter? >>What can I do to obtain a filter where it's impulse response is >>limited to a certain period of time? >>Ok, an IIR filter has an infinite impulse response, but it becomes >>very small after some time! >> > > > Luiz Carlos, > > I just posted an arm-waving description in the thread "Few taps for FSK" - > so did others. > > Fred
There's another issue, too. The impulse response of linear-phase filters peaks at their centers, while in minimum-phase filters, it peaks early. A filter needn't be exactly minimum phase to exhibit a relatively early peak. I call such filters "prompt" when I think about them, but I don't know if anyone else does. Using prompt filters can make the difference between success and failure in digital servo design. Jerry -- Engineering is the art of making what you want from things you can get. &#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;
"Jerry Avins" <jya@ieee.org> wrote in message
news:4006d13a$0$18908$61fed72c@news.rcn.com...
> Fred Marshall wrote: > > > "Luiz Carlos" <oen_no_spam@yahoo.com.br> wrote in message > > news:3fd8f66b.0401150822.5e0eaf50@posting.google.com... > > > >>Is there a way to define the response time of a filter? > >>What can I do to obtain a filter where it's impulse response is > >>limited to a certain period of time? > >>Ok, an IIR filter has an infinite impulse response, but it becomes > >>very small after some time! > >> > > > > > > Luiz Carlos, > > > > I just posted an arm-waving description in the thread "Few taps for
FSK" -
> > so did others. > > > > Fred > > There's another issue, too. The impulse response of linear-phase filters > peaks at their centers, while in minimum-phase filters, it peaks early. > A filter needn't be exactly minimum phase to exhibit a relatively early > peak. I call such filters "prompt" when I think about them, but I don't > know if anyone else does. Using prompt filters can make the difference > between success and failure in digital servo design. > > Jerry
Luis Carlos, I could have been more informative. Jerry is right, minimum phase provides promptness and, if we're talking about FIR filters, a minimum phase filter is a shorter filter for the same magnitude response vs. a linear phase filter. The quick rule of thumb is that the length of the filter is directly related to the width of the narrowest transition regions in the frequency response - the sharpness of the band edges. Now, you did say "limited to a certain period of time" and I take that to mean "limited in length" because one could also consider a long filter with most of its energy limited to a shorter period of time - but with a long unit sample response - like an IIR filter would give. So, for the shortest possible length, use minimum phase design and make the frequency band edges as wide as possible. A simple way to get minimum phase should be to design for linear phase and then move all the zeros (roots) that are outside the unit circle to their conjugate locations inside the unit circle (which will double all of the inside zeros). I'm pretty sure that would work - haven't tried it. There is a relationship between stopband (minimum) attenutation and transition width because a filter with a given transition width and large stopband attenutation also has a narrower transition width with lower (minimum) stopband attenuation. This may be a second order effect but suggests that keeping the stopband attenuation to a reasonable level will help keep the filter short as well. There are more complicated explanations for this also. Surely if you design a filter with very stringent requirements, the filter will be longer. Fred
"> Now, you did say "limited to a certain period of time" and I take
that to
> mean "limited in length" because one could also consider a long filter with > most of its energy limited to a shorter period of time - but with a long > unit sample response - like an IIR filter would give.
Yes, it doesn't matter if it is a FIR or IIR. I wanted to know if I could, for example, use more poles ans zeroes to obtain the same frequency response (modulo), but faster in time. Maybe another aproach! A filter that considers the transients too, no only the steady state.
> So, for the shortest possible length, use minimum phase design and make the > frequency band edges as wide as possible. A simple way to get minimum phase > should be to design for linear phase and then move all the zeros (roots) > that are outside the unit circle to their conjugate locations inside the > unit circle (which will double all of the inside zeros). I'm pretty sure > that would work - haven't tried it.
Can you point out some tool for designing FIR filters that are not linear phase? The ones I know only generate linear phase FIR filters! I've made this question because sometimes we have a very small period of time to detect one frequency, and normal (FIR, Butterworth, Cauer, Chebichev...) band pass filters tend to have a "long" response time. But maybe we can use another aproach, another transform that has a faster response. I haven't tryed, but if we take some samples of our input data, window these samples, padd with a lot of zeroes, and then make a DFT, we can have fast and good precision spectrum estimator, isn't it? I've made and interesting experience yesterday. I took a low pass filter (Fs=8000Hz, Fpass=1000Hz, band pass ripple=0.5dB, Faten=1700Hz, aten=45dB, Cauer, bilinear transform => fourth order filter), and fed it whith: -infinite to 0: signal = +1 0 to +infinite: signal = cos (n*2*pi*500/8000) (500Hz) (infinite = 1000 points!!!) Note that there is no discontinuities in this signal or it's derivative, so it is contains only two frequencys, 0Hz until 0, and then 500Hz. But the filter "created" a "spectral noise" to transit from 0Hz to 500Hz, even though the two frequencys are in it passband! And this "deformation" is proportional to the response time. So I'm asking myself what those filters in the DA converter are doing with my "pure" audio??? Sometime ago, someone asked why we are using so high sampling frequencys in the new digital audio standards. Maybe here is the response. Higher sampling frequencys implies in more transition band for the low pass filters (DA stage), with less taps and then, less distortion. Luiz Carlos
Luiz Carlos wrote:

   ...

> I've made and interesting experience yesterday. I took a low pass > filter (Fs=8000Hz, Fpass=1000Hz, band pass ripple=0.5dB, Faten=1700Hz, > aten=45dB, Cauer, bilinear transform => fourth order filter), and fed > it whith: > -infinite to 0: signal = +1 > 0 to +infinite: signal = cos (n*2*pi*500/8000) (500Hz) > (infinite = 1000 points!!!)
OK so far.
> Note that there is no discontinuities in this signal or it's > derivative, so it is contains only two frequencys, 0Hz until 0, and > then 500Hz.
Not so. Try taking the Fourier transform of this signal, or more simply, think about what combination of frequencies you need in order to create it. Your signal is a step that ends abruptly at t=0, and a cosine that begins there. Both parts contain transients, as you know. Your experiment proves that the transients of one don't exactly cancel the transients of the other. Why are you surprised?
> But the filter "created" a "spectral noise" to transit from 0Hz to > 500Hz, even though the two frequencys are in it passband! > And this "deformation" is proportional to the response time. > So I'm asking myself what those filters in the DA converter are doing > with my "pure" audio??? > > Sometime ago, someone asked why we are using so high sampling > frequencys in the new digital audio standards. Maybe here is the > response. Higher sampling frequencys implies in more transition band > for the low pass filters (DA stage), with less taps and then, less > distortion.
The transients are in the signal. They are not generated by the filter. Jerry -- Engineering is the art of making what you want from things you can get. &#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;
oen_no_spam@yahoo.com.br (Luiz Carlos) wrote in message news:<3fd8f66b.0401160256.18e970d0@posting.google.com>...
> "> Now, you did say "limited to a certain period of time" and I take > that to > > mean "limited in length" because one could also consider a long filter with > > most of its energy limited to a shorter period of time - but with a long > > unit sample response - like an IIR filter would give.
>snip<
> I've made and interesting experience yesterday. I took a low pass > filter (Fs=8000Hz, Fpass=1000Hz, band pass ripple=0.5dB, Faten=1700Hz, > aten=45dB, Cauer, bilinear transform => fourth order filter), and fed > it whith: > -infinite to 0: signal = +1 > 0 to +infinite: signal = cos (n*2*pi*500/8000) (500Hz) > (infinite = 1000 points!!!) > Note that there is no discontinuities in this signal or it's > derivative, so it is contains only two frequencys, 0Hz until 0, and > then 500Hz. > But the filter "created" a "spectral noise" to transit from 0Hz to > 500Hz, even though the two frequencys are in it passband! > And this "deformation" is proportional to the response time. > So I'm asking myself what those filters in the DA converter are doing > with my "pure" audio???
The test signal you created actually has a very broad spectrum at the transition point from 0Hz to 500Hz. Regards Robert
"Luiz Carlos" <oen_no_spam@yahoo.com.br> wrote in message
news:3fd8f66b.0401160256.18e970d0@posting.google.com...
> "> Now, you did say "limited to a certain period of time" and I take > that to > > mean "limited in length" because one could also consider a long filter
with
> > most of its energy limited to a shorter period of time - but with a long > > unit sample response - like an IIR filter would give. > > Yes, it doesn't matter if it is a FIR or IIR. I wanted to know if I > could, for example, use more poles ans zeroes to obtain the same > frequency response (modulo), but faster in time. Maybe another > aproach! A filter that considers the transients too, no only the > steady state.
Well, it does matter if it's a FIR or an IIR if you want less compute load. Otherwise, if you aren't too picky about phase response then yes you can - approach the same frequency response either way - at least in many situations.
> > > So, for the shortest possible length, use minimum phase design and make
the
> > frequency band edges as wide as possible. A simple way to get minimum
phase
> > should be to design for linear phase and then move all the zeros (roots) > > that are outside the unit circle to their conjugate locations inside the > > unit circle (which will double all of the inside zeros). I'm pretty
sure
> > that would work - haven't tried it. > > Can you point out some tool for designing FIR filters that are not > linear phase? The ones I know only generate linear phase FIR filters!
Well, you can use something like Octave or Matlab or Scilab to determine the roots of the polynomial represented by the filter coefficients. Then, you can change the value of some of those roots as above. Then, using the same math tool you can expand the factors back into a polynomial - whose coefficients will be the filter coefficients. I don't know of a tool that just does it in one step. There may be one.
> > I've made this question because sometimes we have a very small period > of time to detect one frequency, and normal (FIR, Butterworth, Cauer, > Chebichev...) band pass filters tend to have a "long" response time. > But maybe we can use another aproach, another transform that has a > faster response.
Unless you do what I suggested earlier to get shorter transient response, No.
> > I haven't tryed, but if we take some samples of our input data, window > these samples, padd with a lot of zeroes, and then make a DFT, we can > have fast and good precision spectrum estimator, isn't it?
There is time spent in "take some samples". Forget the zero padding. The resolution you get is inversely proportional to the length of time you sample. So, if you passed these samples through a FIR filter you might get the successive output samples sooner.
> > I've made and interesting experience yesterday. I took a low pass > filter (Fs=8000Hz, Fpass=1000Hz, band pass ripple=0.5dB, Faten=1700Hz, > aten=45dB, Cauer, bilinear transform => fourth order filter), and fed > it whith: > -infinite to 0: signal = +1 > 0 to +infinite: signal = cos (n*2*pi*500/8000) (500Hz) > (infinite = 1000 points!!!) > Note that there is no discontinuities in this signal or it's > derivative, so it is contains only two frequencys, 0Hz until 0, and > then 500Hz. > But the filter "created" a "spectral noise" to transit from 0Hz to > 500Hz, even though the two frequencys are in it passband! > And this "deformation" is proportional to the response time. > So I'm asking myself what those filters in the DA converter are doing > with my "pure" audio???
As Jerry pointed out, what you're seeing is in the signal itself. Neither of them are purely one frequency because of the abrupt change at t=0.
> > Sometime ago, someone asked why we are using so high sampling > frequencys in the new digital audio standards. Maybe here is the > response. Higher sampling frequencys implies in more transition band > for the low pass filters (DA stage), with less taps and then, less > distortion.
No. The minimum filter length possible is determined by the transition band width and the ripple specs. And, the minimum transition band width possible is determined by the filter length and the ripple specs. Sampling at a higher frequency doesn't change the relative situation. For example: If the transition is .02 of the sampling frequency then the filter needs to be perhaps 1/0.02 = 50 samples long. If you increase the sampling frequency by a factor of 3 and hold the transition width constant in Hz, then the transition fraction becomes 0.02/3 = 0.006666 and the filter length needs to be around 150 samples. Note that the time length of both filters is the same - to correspond with the transition width being the same in Hz. Fred

Luiz Carlos wrote:
> > Can you point out some tool for designing FIR filters that are not > linear phase? The ones I know only generate linear phase FIR filters!
If you want a minimum phase FIR version of any mixed or linear phase FIR try: -----------------------Matlab code follows--------------------------- function y = minphase(x) %minphase - minimum phase from mixed phase FIRs % y = minphase(x) returns the minimum phase versions of the FIRs % in the columns of x %Double the impulse response lengths with zeros x = [x; zeros(size(x))]; %Number of impulse responses m = size(x,2); %Size of each n = size(x,1); %The weighting function wn = [ones(1,m); 2*ones(n/2-1,m); ones(1,m); zeros(n/2-1,m)]; %The work y = real(ifft(exp(fft(wn.*real(ifft(log(abs(fft(x))))))))); %Return half the result y = y(1:n/2;); -----------------------End of code---------------------------------- Note that in "The work" line only the magnitude of the fft of the input FIRs are used so that this could be easily modified to work from just a magnitude specification. Bob -- "Things should be described as simply as possible, but no simpler." A. Einstein
"Bob Cain" <arcane@arcanemethods.com> wrote in message
news:400836DB.42168D63@arcanemethods.com...
> > > Luiz Carlos wrote: > > > > Can you point out some tool for designing FIR filters that are not > > linear phase? The ones I know only generate linear phase FIR filters! > > If you want a minimum phase FIR version of any mixed or linear phase FIR
try:
> > -----------------------Matlab code follows--------------------------- > function y = minphase(x) > %minphase - minimum phase from mixed phase FIRs > % y = minphase(x) returns the minimum phase versions of the FIRs > % in the columns of x > > %Double the impulse response lengths with zeros > x = [x; zeros(size(x))]; > %Number of impulse responses > m = size(x,2); > %Size of each > n = size(x,1); > %The weighting function > wn = [ones(1,m); 2*ones(n/2-1,m); ones(1,m); zeros(n/2-1,m)]; > %The work > y = real(ifft(exp(fft(wn.*real(ifft(log(abs(fft(x))))))))); > %Return half the result > y = y(1:n/2;); > -----------------------End of code----------------------------------
Bob, Input this linear phase filter: [-1 0 2 -1 2 -1 2 0 -1] and you will find the resulting output from above has roots that fall outside the unit circle. So, that can't be right can it? I found another version that looks a bit different and the results are different. The roots fall inside the unit circle. function y = minphase(x) %MINPHASE minimum phase % MINPHASE(x) returns minumum phase versions of impulse responses in x % y = MINPHASE(x) returns the minimum phase impulse responses derived from x. % x = column matrix of impulse responses m = size(x,2); n = size(x,1); odd = fix(rem(n,2)); wn = [ones(1,m); 2*ones((n+odd)/2-1,m) ; ones(1-rem(n,2),m); zeros((n+odd)/2-1,m)]; y = real(ifft(exp(fft(wn.*real(ifft(log(abs(fft(x))))))))); That last expression is a mouthful isn't it!! I don't know but it seems simpler (well, easier to understand) to do something like this: x=...... roots(x) [then those roots of x that are outside the unit circle, replace with their reciprocal real and imaginary parts] I haven't figured out what to do with scaling..... Fred