DSPRelated.com
Forums

FIR Filter Question

Started by I. R. Khan September 21, 2004
I have read some papers about how to calculate filter coefficients. That is
fine.

Then there are some other papers, which just give expressions for the
frequency response of the filter, and say this is the design. Could any one
please tell me how are these designs useful? My understanding is that to use
these filters, one has to take Fourier Transform of the signal, then
multiply it with frequency response of filter and then do Inverse
Transformation. Is this true, or there is some way to find filter
coefficients from the frequency response of the filter?

A related question: Is the above method of filtering in frequency domain
less accurate as compared to direct implementation using filter
coefficients?

Regards,
Ishtiaq.

one more question:
How do we get the phase response or the delay of the filter if only its
frequency response is given. For example if

D(w) = Sum[c(i) Sin(w(i-1/2)), {i = 1: N}] + Sum[d(i) Sin(w i), {i = 1 :
N}],
where formulas for c(i) and d(i) are given,

then
1. Can we get the coefficients of the filter. how? Are the filter
coefficients related to c(i) and d(i)?
2. How do we know if it is a linear phase filter or not?
3. What is the delay of this filter?

Regards,
Ishtiaq.

I. R. Khan wrote:
> I have read some papers about how to calculate filter coefficients. That is > fine. > > Then there are some other papers, which just give expressions for the > frequency response of the filter, and say this is the design. Could any one > please tell me how are these designs useful? My understanding is that to use > these filters, one has to take Fourier Transform of the signal, then > multiply it with frequency response of filter and then do Inverse > Transformation. Is this true, or there is some way to find filter > coefficients from the frequency response of the filter? > > A related question: Is the above method of filtering in frequency domain > less accurate as compared to direct implementation using filter > coefficients? > > Regards, > Ishtiaq.
Ishtiaq, You haven't understood the papers very well. The filters you read about operate on the samples directly, not on their Fourier transforms. Each new sample as it is acquired is used to compute the next output. The coefficients that puzzle you describe the computation. Read more about IIR filters. Maybe transversal FIR filters will help you to understand the process. Jerry -- Engineering is the art of making what you want from things you can get. ???????????????????????????????????????????????????????????????????????
Thanks Jerry. Now I understand the process. Could you please give a hint (if
not bit detail) about how to get phase response of this filter:

D(w) = Sum[c(i) Sin(w(i-1/2)), {i = 1: N}] + Sum[d(i) Sin(w i), {i = 1 :
N}],
where formulas for c(i) and d(i) are given.

Regards,
Ishtiaq.


"Jerry Avins" <jya@ieee.org> wrote in message
news:41502f6e$0$2646$61fed72c@news.rcn.com...
> I. R. Khan wrote: > > I have read some papers about how to calculate filter coefficients. That
is
> > fine. > > > > Then there are some other papers, which just give expressions for the > > frequency response of the filter, and say this is the design. Could any
one
> > please tell me how are these designs useful? My understanding is that to
use
> > these filters, one has to take Fourier Transform of the signal, then > > multiply it with frequency response of filter and then do Inverse > > Transformation. Is this true, or there is some way to find filter > > coefficients from the frequency response of the filter? > > > > A related question: Is the above method of filtering in frequency domain > > less accurate as compared to direct implementation using filter > > coefficients? > > > > Regards, > > Ishtiaq. > > Ishtiaq, > > You haven't understood the papers very well. The filters you read about > operate on the samples directly, not on their Fourier transforms. Each > new sample as it is acquired is used to compute the next output. The > coefficients that puzzle you describe the computation. Read more about > IIR filters. Maybe transversal FIR filters will help you to understand > the process. > > Jerry > -- > Engineering is the art of making what you want from things you can get. > ??????????????????????????????????????????????????????????????????????? >
I. R. Khan wrote:

> Thanks Jerry. Now I understand the process. Could you please give a
hint (if
> not bit detail) about how to get phase response of this filter: > > D(w) = Sum[c(i) Sin(w(i-1/2)), {i = 1: N}] + Sum[d(i) Sin(w i), {i = 1 : > N}], > where formulas for c(i) and d(i) are given. > > Regards, > Ishtiaq.
There are specific formulas, derived from the Z-transform design methods to do what you want. Rick Lyons's book "Understanding Digital Signal Processing" has a good treatment that can give insights to design as well as analysis. However, if you have decent DSP software tools, you can simply feed a single positive sample -- all others are zero -- into the filter and record the impulse response that comes out. An FFT of the impulse response will give the amplitude and phase responses of the filter. Amplitude is sqrt(Re[x]+Im[x]), and phase is atan2(Im[z]/Re[x]). Jerry -- Engineering is the art of making what you want from things you can get.
Thanks Jerry once again. Would you please comment on this:

From the filter response
D(w) = Sum[c(i) Sin(w(i-1/2)), {i = 1: N}] + Sum[d(i) Sin(w i), {i = 1 :
N}],

it is clear that it is a non linear phase filter. The reason is that to be
linear phase, filter coefficients should be oven/odd symmetric, which
implies that its magnitude response will be represented by one of the
followings:
sin(nw), sin(n-1/2)w, cos(w), cos(n-1/2)w

Is this correct? If yes, then in this case we can say this is a non-linear
phase filter without actually plotting its phase response?

Regards,
Ishtiaq.

"Jerry Avins" <jya@ieee.org> wrote in message
news:4150f1d8$0$2645$61fed72c@news.rcn.com...
> I. R. Khan wrote: > > > Thanks Jerry. Now I understand the process. Could you please give a > hint (if > > not bit detail) about how to get phase response of this filter: > > > > D(w) = Sum[c(i) Sin(w(i-1/2)), {i = 1: N}] + Sum[d(i) Sin(w i), {i = 1 : > > N}], > > where formulas for c(i) and d(i) are given. > > > > Regards, > > Ishtiaq. > > > There are specific formulas, derived from the Z-transform design methods > to do what you want. Rick Lyons's book "Understanding Digital Signal > Processing" has a good treatment that can give insights to design as > well as analysis. However, if you have decent DSP software tools, you > can simply feed a single positive sample -- all others are zero -- into > the filter and record the impulse response that comes out. An FFT of the > impulse response will give the amplitude and phase responses of the > filter. Amplitude is sqrt(Re[x]+Im[x]), and phase is atan2(Im[z]/Re[x]). > > Jerry > -- > Engineering is the art of making what you want from things you can get. > >
I. R. Khan wrote:

> Thanks Jerry once again. Would you please comment on this: > > From the filter response > D(w) = Sum[c(i) Sin(w(i-1/2)), {i = 1: N}] + Sum[d(i) Sin(w i), {i = 1 : > N}], > > it is clear that it is a non linear phase filter. The reason is that to be > linear phase, filter coefficients should be oven/odd symmetric, which > implies that its magnitude response will be represented by one of the > followings: > sin(nw), sin(n-1/2)w, cos(w), cos(n-1/2)w > > Is this correct? If yes, then in this case we can say this is a non-linear > phase filter without actually plotting its phase response? > > Regards, > Ishtiaq.
IIR filters are rarely (never?) linear phase. The condition of symmetric coefficients yielding linear phase applies to transversal FIR filters. I don't understand your filter description. Magnitude responses are rarely trigonometric functions of frequency. It's after midnight. Maybe your equations and terms will make sense in the morning. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
Thanks Jerry. I shall wait for your reply in the morning. Here it is 13:30,
i.e. GMT + 9.
The filter I wrote is not IIR. All my questions were about FIR. To say it
simply, the magnitude response has two summations, one has sin(nw) and other
sin(n-1/2)w.

"Jerry Avins" <jya@ieee.org> wrote in message
news:4150fe2a$0$2659$61fed72c@news.rcn.com...
> I. R. Khan wrote: > > > Thanks Jerry once again. Would you please comment on this: > > > > From the filter response > > D(w) = Sum[c(i) Sin(w(i-1/2)), {i = 1: N}] + Sum[d(i) Sin(w i), {i = 1 : > > N}], > > > > it is clear that it is a non linear phase filter. The reason is that to
be
> > linear phase, filter coefficients should be oven/odd symmetric, which > > implies that its magnitude response will be represented by one of the > > followings: > > sin(nw), sin(n-1/2)w, cos(w), cos(n-1/2)w > > > > Is this correct? If yes, then in this case we can say this is a
non-linear
> > phase filter without actually plotting its phase response? > > > > Regards, > > Ishtiaq. > > IIR filters are rarely (never?) linear phase. The condition of symmetric > coefficients yielding linear phase applies to transversal FIR filters. I > don't understand your filter description. Magnitude responses are rarely > trigonometric functions of frequency. It's after midnight. Maybe your > equations and terms will make sense in the morning. > > Jerry > -- > Engineering is the art of making what you want from things you can get. > &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295; >
I. R. Khan wrote:

> Thanks Jerry. I shall wait for your reply in the morning. Here it is 13:30, > i.e. GMT + 9. > The filter I wrote is not IIR. All my questions were about FIR. To say it > simply, the magnitude response has two summations, one has sin(nw) and other > sin(n-1/2)w.
sin((n-1)x)? What is 'w' here? How would I assign numbers to the coefficients? Work out a simple trial case -- show me if you like -- and see if the sines all evaluate to 0, 1, and -1. Some authors like to show how clever they are by exhibiting tricks like that. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
"I. R. Khan" <ir_khan@hotmail.com> wrote in message 
news:2r9nclF177220U1@uni-berlin.de...
>I have read some papers about how to calculate filter coefficients. That is > fine. > > Then there are some other papers, which just give expressions for the > frequency response of the filter, and say this is the design. Could any > one > please tell me how are these designs useful? My understanding is that to > use > these filters, one has to take Fourier Transform of the signal, then > multiply it with frequency response of filter and then do Inverse > Transformation. Is this true, or there is some way to find filter > coefficients from the frequency response of the filter? > > A related question: Is the above method of filtering in frequency domain > less accurate as compared to direct implementation using filter > coefficients?
Ishtiaq, The method of using such filters goes like this: 1) Establish the filter response in the frequency domain (a complex function of frequency). The length of the array or frequency sequence needs to be the same as the signal sequences you will filter - because the multiplication is point-for-point of course. 2) Get a signal sample that has the same number of samples as the filter - or, if you wish, get a shorter sample and add enough zeros at the end to yield the same number of samples as the filter. 3) FFT the signal thus generated. 4) Multiply the signal's FFT by the frequency domain filter. 5) IFFT the result to get the time-domain filtered signal. Use overlap methods if subsequent sequences are to be processed and concatenated into a longer temporal sequence. Note: This method can be much more computationally efficient than time-domain convolution! Not an intuitively obvious thing is it? The longer the sequences the more this is the case. Now, if the filter is defined in the frequency domain in the first place, then it has to be a complex sequence. If it is not a complex sequence then it must be purely real. If it's pureley real then it must have an IFFT that is real and even in the time domain - a symmetrical FIR filter. So, to get the time domain version of the filter you take the IFFT of the frequency samples. It's that simple. More advanced topics might be: - is the filter "centered" in frequency so that the IFFT result is purely real? You may have to rotate the samples in frequency first depending on how you have them stored / defined. - is the filter specification really a (real) magnitude response of a filter that's really complex? In that case you have to figure out how to manipulate the frequency response before doing the IFFT. There are lots of discussions on this sort of thing and it's fair to say that you'd be more interested in phase. Otherwise, a real, even frequency magnitude response might well be IFFT'd to get a real, symmetrical FIR filter in the time domain. Fred