DSPRelated.com
Forums

FIR notch filters using the Windowing method

Started by Greer April 13, 2005
Hi,

I am trying to obtain a FIR notch filter which is very narrow. For
example, a 50 Hz notch filter to remove mains noise from a 1250Hz signal
say.

Doing this with an IIR filter was easy, I could specify my "notch region"
as small as [49 51]Hz. 

I am now trying to do the same with a FIR filter. I am using Intel
Peformance Primative functions to generate the taps. These use the
windowing method (I think). 

This does not seem to be feasible, as the attenuation at the notch
frequency is pitiful if you define the notch region as [49 51]. 

What I would like to know is:

(1) Does this sound correct to you (I may have made an error somewhere)

(2) I know there are other methods for coefficient generation
(Parks-McClellan etc). Will these allow me to define a very narrow FIR
notch filter with a reasonable number of coefficients?

Many thanks,
Greer






		
This message was sent using the Comp.DSP web interface on
www.DSPRelated.com
"Greer" <Greer.GRAY@oxinst.co.uk> wrote in message 
news:q5WdnZYwX6dsysDfRVn-sw@giganews.com...
> Hi, > > I am trying to obtain a FIR notch filter which is very narrow. For > example, a 50 Hz notch filter to remove mains noise from a 1250Hz signal > say. > > Doing this with an IIR filter was easy, I could specify my "notch region" > as small as [49 51]Hz. > > I am now trying to do the same with a FIR filter. I am using Intel > Peformance Primative functions to generate the taps. These use the > windowing method (I think). > > This does not seem to be feasible, as the attenuation at the notch > frequency is pitiful if you define the notch region as [49 51]. > > What I would like to know is: > > (1) Does this sound correct to you (I may have made an error somewhere) > > (2) I know there are other methods for coefficient generation > (Parks-McClellan etc). Will these allow me to define a very narrow FIR > notch filter with a reasonable number of coefficients? > > Many thanks, > Greer
There's no reason why the windowing method wouldn't work unless the window is too short for the transition band width you require - or, if you define the notch to be too narrow in the idealized version. Roughly speaking, the window length needs to be the reciprocal of the narrowest transition band. So, if 49-51 is the stop band, then what is the width of the transition band? 48-49 and 51-52?? If so, the window would have to be 1/1Hz or 1 second long. The idea is to take an ideal filter - presumably one with zero transition band widths - and convert it into a "real" filter. In effect, you convolve the ideal filter in frequency with a narrowband function that smoothes the edges. Obviously if the "narrowband" function is too wide it will "fill in" the notch you're trying to achieve. If you define a narrowband function that's 1Hz wide then you might define the "ideal" notch to be 48 to 52Hz. Then when it's smoothed over 1Hz, it will reach the stop band level at 49 and at 51 at the edges of the notch. This is equivalent (being suitably careful about array lengths, etc.) to windowing the IFFT of the ideal filter with the IFFT of the narrowband function. This is a verbal "cartoon" of course. The actual choice of the window, etc. will vary the results to some degree. I'll bet that the impulse response of the IIR filter is of similar effective length as the reciprocal of the width of the transition bands it delivers...... :-) Fred
Greer wrote:
> Hi, > > I am trying to obtain a FIR notch filter which is very narrow. For > example, a 50 Hz notch filter to remove mains noise from a 1250Hz signal > say. > > Doing this with an IIR filter was easy, I could specify my "notch region" > as small as [49 51]Hz. > > I am now trying to do the same with a FIR filter. I am using Intel > Peformance Primative functions to generate the taps. These use the > windowing method (I think). > > This does not seem to be feasible, as the attenuation at the notch > frequency is pitiful if you define the notch region as [49 51]. > > What I would like to know is: > > (1) Does this sound correct to you (I may have made an error somewhere) > > (2) I know there are other methods for coefficient generation > (Parks-McClellan etc). Will these allow me to define a very narrow FIR > notch filter with a reasonable number of coefficients? > > Many thanks, > Greer
FIR filters aren't well suited for narrow notches. The number of taps needed inversely relates to the bandwidth, and when the notch is narrow, the filter becomes very long. If a long filter is not a problem for the application, double the number you now use and see if the attenuation improves. If not, then something is wrong. If so, then at some length the design will become acceptable. 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;
why don't you want to use an IIR?

Mark

I've actually been looking into this as well.  IIR notch filters
(parametric) are easy to generate, just need a pole just below a zero
on the unit circle.  But I also need to use a FIR filter for linear
phase reasons.  Standard FIR bandstop designs need a whole bunch of
taps to get a tight notch.  You will easily be in the hundreds if not
thousands of taps for a notch BW equivalent to a parametric IIR notch
filter!  I doubt you will find an easy way to create a very-narrow
notch FIR with a "reasonable" amount of coeffs.  You just dont have a
pole to normalize the rest of the band away from the zero location.

I am looking into doing FIR bandstop (notch) filtering using the
multirate approach outlined in Ch. 6 of Crochiere and Rabiner.   For
narrow band filters the MIPS rate goes down quite a bit even for large
filter lengths.  You double your delay, but nothing is free.  I can
accept that for my app given the amount of MIPS you recover.

"JS" <jshima@timing.com> wrote in message
news:1113428134.269366.272830@o13g2000cwo.googlegroups.com...
> I've actually been looking into this as well. IIR notch filters > (parametric) are easy to generate, just need a pole just below a zero > on the unit circle. But I also need to use a FIR filter for linear > phase reasons. Standard FIR bandstop designs need a whole bunch of > taps to get a tight notch. You will easily be in the hundreds if not > thousands of taps for a notch BW equivalent to a parametric IIR notch > filter! I doubt you will find an easy way to create a very-narrow > notch FIR with a "reasonable" amount of coeffs. You just dont have a > pole to normalize the rest of the band away from the zero location. > > I am looking into doing FIR bandstop (notch) filtering using the > multirate approach outlined in Ch. 6 of Crochiere and Rabiner. For > narrow band filters the MIPS rate goes down quite a bit even for large > filter lengths. You double your delay, but nothing is free. I can > accept that for my app given the amount of MIPS you recover.
Just to amplify, a key point is that the FIR length is dependent on notch bandwidth as a percentage of sample rate. So if you need a 2 Hz notch and you are sampling at 96kHz, that's going to be one long filter! But the same 2 Hz notch with a signal sampled at 200 Hz isn't all that bad. That's why you can achieve significant savings from a multirate approach. -- Jon Harris SPAM blocked e-mail address in use. Replace the ANIMAL with 7 to reply.
in article 1113428134.269366.272830@o13g2000cwo.googlegroups.com, JS at
jshima@timing.com wrote on 04/13/2005 17:35:

> I've actually been looking into this as well. IIR notch filters > (parametric) are easy to generate, just need a pole just below a zero > on the unit circle. But I also need to use a FIR filter for linear > phase reasons.
i think that while the garden variety IIR notch filter isn't strictly phase linear, it is pretty much over nearly all frequencies other than around the notch itself. using an FIR for a IIR filter's job seems to me to be packing a switchblade going to a gunfight. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Jon Harris wrote:

>"JS" <jshima@timing.com> wrote in message >news:1113428134.269366.272830@o13g2000cwo.googlegroups.com... > > >>I've actually been looking into this as well. IIR notch filters >>(parametric) are easy to generate, just need a pole just below a zero >>on the unit circle. But I also need to use a FIR filter for linear >>phase reasons. Standard FIR bandstop designs need a whole bunch of >>taps to get a tight notch. You will easily be in the hundreds if not >>thousands of taps for a notch BW equivalent to a parametric IIR notch >>filter! I doubt you will find an easy way to create a very-narrow >>notch FIR with a "reasonable" amount of coeffs. You just dont have a >>pole to normalize the rest of the band away from the zero location. >> >>I am looking into doing FIR bandstop (notch) filtering using the >>multirate approach outlined in Ch. 6 of Crochiere and Rabiner. For >>narrow band filters the MIPS rate goes down quite a bit even for large >>filter lengths. You double your delay, but nothing is free. I can >>accept that for my app given the amount of MIPS you recover. >> >> > >Just to amplify, a key point is that the FIR length is dependent on notch >bandwidth as a percentage of sample rate. So if you need a 2 Hz notch and you >are sampling at 96kHz, that's going to be one long filter! But the same 2 Hz >notch with a signal sampled at 200 Hz isn't all that bad. That's why you can >achieve significant savings from a multirate approach. > >
More generally, any kind of filtering low in the band tends to be a lot nastier than similar filtering high in the band. Intuitively, what else would you expect? It takes more samples of the low frequencies to see a similar difference in the signal. Regards, Steve
robert bristow-johnson wrote:

>in article 1113428134.269366.272830@o13g2000cwo.googlegroups.com, JS at >jshima@timing.com wrote on 04/13/2005 17:35: > > > >>I've actually been looking into this as well. IIR notch filters >>(parametric) are easy to generate, just need a pole just below a zero >>on the unit circle. But I also need to use a FIR filter for linear >>phase reasons. >> >> > >i think that while the garden variety IIR notch filter isn't strictly phase >linear, it is pretty much over nearly all frequencies other than around the >notch itself. > >using an FIR for a IIR filter's job seems to me to be packing a switchblade >going to a gunfight. > >
"Around" is a rather fluid term. :-) The original poster said he was trying to remove 50Hz from a 1250Hz signal, which sounds like his requirement fits a pretty loose interpretation of the wanted signal not being "around" the interference. However, if this was his only requirement why would he be trying to make the notch as narrow as 49-51Hz? Regards, Steve
JS wrote:
> I've actually been looking into this as well. IIR notch filters > (parametric) are easy to generate, just need a pole just below a zero > on the unit circle. But I also need to use a FIR filter for linear > phase reasons.
Dunno if this will help, but here goes... About a decade ago I wrote some code to subtract weighted sine and cosine waves from an input signal. I set the weights by running a Goertzel transform on the input. In other words, I detected the phase and amplitude of the tone I wanted to reject and then subtracted it out. It seemed to work pretty well, but it /was/ an academic exercise rather than a real-world implementation. My original intent was to build an adaptive filter that minimized the total energy in the output signal by doing the sin/cos subtraction using LMS to set the weights. What I ended up with was the equation for a one-bin DFT: a = (x,c)/(c,c) b = (x,s)/(s,s) These are ratios of dot products where x is the input vector, c is the cos vector, and s is the sin vector. I dunno why this result surprised me, but it did. It made perfect sense, convinced me of the correctness of my mathematics, and proved to me that there really is nothing new under the sun. I opted to use the Goertzel instead of the DFT and ran the code on a block basis. I don't remember the length of the blocks anymore, but it did contain an integer number of sin/cos periods. Maybe one. I did not worry about block boundaries, and /that's/ what made it academic rather than real-world. -- Jim Thomas Principal Applications Engineer Bittware, Inc jthomas@bittware.com http://www.bittware.com (603) 226-0404 x536 Visualize whirled peas.