Hello everybody. A question from not an expert of notch filters. Suppose I have to filter out a specific frequency noise (e.g. a 50 Hz noise) from an acquired signal. Suppose my filter has not to work online, i.e. I can collect signal samples (its a digitalized signal) and then filter noise out. I would like to compute the Fourier transform of the signal, put the 50Hz frequency amplitude to zero and go back to time domain. What are the drawbacks for such a simple frequency domain notch filter? Regards, Ska

# Frequency domain notch filter

Started by ●January 23, 2008

Reply by ●January 23, 20082008-01-23

skaggio wrote:> Hello everybody. > > A question from not an expert of notch filters. > > Suppose I have to filter out a specific frequency noise (e.g. a 50 Hz > noise) from an acquired signal. Suppose my filter has not to work online, > i.e. I can collect signal samples (its a digitalized signal) and then > filter noise out. I would like to compute the Fourier transform of the > signal, put the 50Hz frequency amplitude to zero and go back to time > domain. > What are the drawbacks for such a simple frequency domain notch filter?Harmonics of the noise. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������

Reply by ●January 23, 20082008-01-23

On 23 Jan., 18:45, Jerry Avins <j...@ieee.org> wrote:> skaggio wrote: > > Hello everybody. > > > A question from not an expert of notch filters. > > > Suppose I have to filter out a specific frequency noise (e.g. a 50 Hz > > noise) from an acquired signal. Suppose my filter has not to work online, > > i.e. I can collect signal samples (its a digitalized signal) and then > > filter noise out. I would like to compute the Fourier transform of the > > signal, put the 50Hz frequency amplitude to zero and go back to time > > domain. > > What are the drawbacks for such a simple frequency domain notch filter? > > Harmonics of the noise.Because he said 50Hz notch, he may not care. But he'll eventually get a ugly impulse response when just "putting the 50Hz to zero", and maybe a high residual spectrum around the zeroed 50Hz bin if the sample rate is not a exact (and constant) match so the 50Hz spreads into multiple bins. This could be avoided with some kind of "windowing" function processing the bin's around 50Hz to give a filter with a shorter impulse response and tolerance for "bin spreading".

Reply by ●January 23, 20082008-01-23

filter001@desinformation.de wrote:> On 23 Jan., 18:45, Jerry Avins <j...@ieee.org> wrote: >> skaggio wrote: >>> Hello everybody. >>> A question from not an expert of notch filters. >>> Suppose I have to filter out a specific frequency noise (e.g. a 50 Hz >>> noise) from an acquired signal. Suppose my filter has not to work online, >>> i.e. I can collect signal samples (its a digitalized signal) and then >>> filter noise out. I would like to compute the Fourier transform of the >>> signal, put the 50Hz frequency amplitude to zero and go back to time >>> domain. >>> What are the drawbacks for such a simple frequency domain notch filter? >> Harmonics of the noise. > > Because he said 50Hz notch, he may not care. > > But he'll eventually get a ugly impulse response when just "putting > the 50Hz to zero", and maybe a high residual spectrum around the > zeroed 50Hz bin if the sample rate is not a exact (and constant) match > so the 50Hz spreads into multiple bins. > This could be avoided with some kind of "windowing" function > processing the bin's around 50Hz to give a filter with a shorter > impulse response and tolerance for "bin spreading".He didn't write just "50 Hz", he wrote "50 Hz noise". The source of 50 Hz noise is usually the power line, and power-line noise is commonly rich with harmonics. He will indeed get a weird impulse response if he tries to filter by zeroing the 50 Hz bin of an FFT. There are other ways to make notch filters. Twin T anyone? :-) Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������

Reply by ●January 23, 20082008-01-23

"skaggio" <andrea.scaggiante@gmail.com> wrote in message news:wfCdnVXMTpJw5granZ2dnUVZ_vqpnZ2d@giganews.com...> Hello everybody. > > A question from not an expert of notch filters. > > Suppose I have to filter out a specific frequency noise (e.g. a 50 Hz > noise) from an acquired signal. Suppose my filter has not to work online, > i.e. I can collect signal samples (its a digitalized signal) and then > filter noise out. I would like to compute the Fourier transform of the > signal, put the 50Hz frequency amplitude to zero and go back to time > domain. > What are the drawbacks for such a simple frequency domain notch filter? >* You have to remember to also zero out the (fs-50Hz) component. * No harmonics will be dealt with. * You should realize that zeroing out those samples is the same thing as adding (really, subtracting but it may not appear to you to to be so) a 50Hz sinusoid to the time domain version of the signal - with a rectangular window. The leakage frequencies associated with the sinusoid and the fft aren't handled at all. [Try this: start with a pure 50Hz sampled signal sequence. FFT it. Subtract only the 50Hz and fs-50Hz samples. What's the result in the FFT samples? Then IFFT what's left. What's the result in the time domain samples? It matters if fs is related to 50Hz or not. Are the results what you expect? ... what you would want?] * A better notch filter would be one that has a zero at 50Hz, is as narrow as possible (and no narrower). The width will be inversely proportional to the length of the filter if it's FIR or the effective length of the impulse response of the filter if it's IIR. Fred

Reply by ●January 24, 20082008-01-24

> >"skaggio" <andrea.scaggiante@gmail.com> wrote in message >news:wfCdnVXMTpJw5granZ2dnUVZ_vqpnZ2d@giganews.com... >> Hello everybody. >> >> A question from not an expert of notch filters. >> >> Suppose I have to filter out a specific frequency noise (e.g. a 50 Hz >> noise) from an acquired signal. Suppose my filter has not to workonline,>> i.e. I can collect signal samples (its a digitalized signal) and then >> filter noise out. I would like to compute the Fourier transform of the >> signal, put the 50Hz frequency amplitude to zero and go back to time >> domain. >> What are the drawbacks for such a simple frequency domain notchfilter?>> > >* You have to remember to also zero out the (fs-50Hz) component. >Ok>* No harmonics will be dealt with. >Ok, I could do the same for all of the harmonics I want>* You should realize that zeroing out those samples is the same thing as>adding (really, subtracting but it may not appear to you to to be so) a50Hz>sinusoid to the time domain version of the signal - with a rectangular >window. The leakage frequencies associated with the sinusoid and the fft>aren't handled at all. >I'm supposing to use a number of time samples (or proper zero padding) in order to have 50 Hz among the frequency samples so as to remove exactly 50 Hz line (and multiples if required). As suggested by Jerry, I could use a window for the 50Hz neighbourhood.>[Try this: start with a pure 50Hz sampled signal sequence. FFT it. >Subtract only the 50Hz and fs-50Hz samples. What's the result in the FFT>samples? Then IFFT what's left. What's the result in the time domain >samples? It matters if fs is related to 50Hz or not. Are the resultswhat>you expect? ... what you would want?] > >* A better notch filter would be one that has a zero at 50Hz, is asnarrow>as possible (and no narrower). The width will be inversely proportionalto>the length of the filter if it's FIR or the effective length of theimpulse>response of the filter if it's IIR. >I thought to this simple filter in frequency domain (FDF) in order not to distort the signal (apart for 50 Hz delation). Other notch filter would introduce signal distrortion as far as I undestand. The disadvantages for the FDF would be: 1) It cannot work in real time but only offline 2) It could be time consuming 3) I need to have a number N of samples so that exists k so that k*(N*T)^(-1) = 50 Hz (to overcome leakage problems) Advantages: 1) Not signal distortion I thint the single advantage would be better than the 3 disadvantages for my application. Please post comments to understand if is a bad idea.>FredSka

Reply by ●January 24, 20082008-01-24

skaggio asked a "simple" question:> [ snip the not so quite simple question ;][ It wasn't that long ago that I asked the same one ] Here are some online FREE resources. I would suggest browsing them to get oriented. I (a fellow newbie) have found them useful. FAQs on Digital Signal Processing http://www.bdti.com/faq/dsp_faq.htm The Scientist and Engineer's Guide to Digital Signal Processing By Steven W. Smith, Ph.D. http://www.dspguide.com/ How Do I Learn DSP? http://www.redcedar.com/learndsp.htm To experiment I recommend downloading Scilab ( http://www.scilab.org/ ).

Reply by ●January 24, 20082008-01-24

"skaggio" <andrea.scaggiante@gmail.com> wrote in message news:wvGdndasL4vF6AXanZ2dnUVZ_oCvnZ2d@giganews.com...> > >>"skaggio" <andrea.scaggiante@gmail.com> wrote in message >>news:wfCdnVXMTpJw5granZ2dnUVZ_vqpnZ2d@giganews.com... >>> Hello everybody. >>> >>> A question from not an expert of notch filters. >>> >>> Suppose I have to filter out a specific frequency noise (e.g. a 50 Hz >>> noise) from an acquired signal. Suppose my filter has not to work > online, >>> i.e. I can collect signal samples (its a digitalized signal) and then >>> filter noise out. I would like to compute the Fourier transform of the >>> signal, put the 50Hz frequency amplitude to zero and go back to time >>> domain. >>> What are the drawbacks for such a simple frequency domain notch > filter? >>> >> >>* You have to remember to also zero out the (fs-50Hz) component. >> > > Ok > >>* No harmonics will be dealt with. >> > > Ok, I could do the same for all of the harmonics I want > >>* You should realize that zeroing out those samples is the same thing as > >>adding (really, subtracting but it may not appear to you to to be so) a > 50Hz >>sinusoid to the time domain version of the signal - with a rectangular >>window. The leakage frequencies associated with the sinusoid and the fft > >>aren't handled at all. >> > > I'm supposing to use a number of time samples (or proper zero padding) in > order to have 50 Hz among the frequency samples so as to remove exactly 50 > Hz line (and multiples if required). As suggested by Jerry, I could use a > window for the 50Hz neighbourhood. > >>[Try this: start with a pure 50Hz sampled signal sequence. FFT it. >>Subtract only the 50Hz and fs-50Hz samples. What's the result in the FFT > >>samples? Then IFFT what's left. What's the result in the time domain >>samples? It matters if fs is related to 50Hz or not. Are the results > what >>you expect? ... what you would want?] >> >>* A better notch filter would be one that has a zero at 50Hz, is as > narrow >>as possible (and no narrower). The width will be inversely proportional > to >>the length of the filter if it's FIR or the effective length of the > impulse >>response of the filter if it's IIR. >> > > I thought to this simple filter in frequency domain (FDF) in order not to > distort the signal (apart for 50 Hz delation). Other notch filter would > introduce signal distrortion as far as I undestand. > > The disadvantages for the FDF would be: > 1) It cannot work in real time but only offline > 2) It could be time consuming > 3) I need to have a number N of samples so that exists k so that > k*(N*T)^(-1) = 50 Hz (to overcome leakage problems) > > Advantages: > 1) Not signal distortion > > I thint the single advantage would be better than the 3 disadvantages for > my application. > > Please post comments to understand if is a bad idea.Whether the proposed filtering in frequency works in "real time" or not is a matter of getting the real numbers. For example, a linear phase FIR filter with 50 coefficients running at 5kHz will have a transient response of 10msec and a delay of ~5msec - *no matter what*. Let's call that "real time" The filter you propose has a transient response of the length of the data going into the FFT. Using the same numbers and if the FFT has 1024 nonzero samples, that would be a delay of .2048 seconds - *no matter what*. And, doing the FFT, IFFT might be much less than that depending on the hardware you're using (and the software). So maybe you can approach "real time" with no observable penalty - and maybe not. It can be shown that [FFT, multiply, IFFT] is often *faster* than doing a time domain convolution. Not intuitively obvious is it? The longer the filter the better it gets. So, no matter what the filter you choose, it may be faster to do it in the frequency domain. I don't know that I'd get too hung up on simply zeroing a couple of samples. You may as well go ahead and design a notch filter that meets your requirements. You could easily compare the results. Whether you regard there to be no signal distortion is a matter of doing some investigation as the experiments I suggested. That's because there will be some leakage due to the finite window length. The leakage is going to be there and is a type of distortion. Then, if you remove the fundamental and leave the leakage components that's another kind of distortion. Thus the experiment .... a picture is worth 1,000 words. So, I don't know if it's a bad idea for your particular application. That's something you need to decide. It's certainly good to look at the trades as you're doing. Fred

Reply by ●January 24, 20082008-01-24

skaggio wrote:>> "skaggio" <andrea.scaggiante@gmail.com> wrote in message >> news:wfCdnVXMTpJw5granZ2dnUVZ_vqpnZ2d@giganews.com... >>> Hello everybody. >>> >>> A question from not an expert of notch filters. >>> >>> Suppose I have to filter out a specific frequency noise (e.g. a 50 Hz >>> noise) from an acquired signal. Suppose my filter has not to work > online, >>> i.e. I can collect signal samples (its a digitalized signal) and then >>> filter noise out. I would like to compute the Fourier transform of the >>> signal, put the 50Hz frequency amplitude to zero and go back to time >>> domain. >>> What are the drawbacks for such a simple frequency domain notch > filter? >> * You have to remember to also zero out the (fs-50Hz) component. >> > > Ok > >> * No harmonics will be dealt with. >> > > Ok, I could do the same for all of the harmonics I want > >> * You should realize that zeroing out those samples is the same thing as > >> adding (really, subtracting but it may not appear to you to to be so) a > 50Hz >> sinusoid to the time domain version of the signal - with a rectangular >> window. The leakage frequencies associated with the sinusoid and the fft > >> aren't handled at all. >> > > I'm supposing to use a number of time samples (or proper zero padding) in > order to have 50 Hz among the frequency samples so as to remove exactly 50 > Hz line (and multiples if required). As suggested by Jerry, I could use a > window for the 50Hz neighbourhood. > >> [Try this: start with a pure 50Hz sampled signal sequence. FFT it. >> Subtract only the 50Hz and fs-50Hz samples. What's the result in the FFT > >> samples? Then IFFT what's left. What's the result in the time domain >> samples? It matters if fs is related to 50Hz or not. Are the results > what >> you expect? ... what you would want?] >> >> * A better notch filter would be one that has a zero at 50Hz, is as > narrow >> as possible (and no narrower). The width will be inversely proportional > to >> the length of the filter if it's FIR or the effective length of the > impulse >> response of the filter if it's IIR. >> > > I thought to this simple filter in frequency domain (FDF) in order not to > distort the signal (apart for 50 Hz delation). Other notch filter would > introduce signal distrortion as far as I undestand. > > The disadvantages for the FDF would be: > 1) It cannot work in real time but only offline > 2) It could be time consuming > 3) I need to have a number N of samples so that exists k so that > k*(N*T)^(-1) = 50 Hz (to overcome leakage problems) > > Advantages: > 1) Not signal distortion > > I thint the single advantage would be better than the 3 disadvantages for > my application. > > Please post comments to understand if is a bad idea.Fred tried to tell you that there you need to consider are two kinds of distortion. You seem to be aware only of frequency distortion, but you need to consider distortion of the response in time also. The narrower you make a notch, the more you screw up th impulse response. If you filter as you propose, you will cause severe ringing at frequencies in the neighborhood of the notches. You won't like it. Check out the meaning of "impulse response" and do the experiments that Fred suggested. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������

Reply by ●January 24, 20082008-01-24

On Jan 24, 3:24 am, "skaggio" <andrea.scaggia...@gmail.com> wrote:> >"skaggio" <andrea.scaggia...@gmail.com> wrote in message > >news:wfCdnVXMTpJw5granZ2dnUVZ_vqpnZ2d@giganews.com... > >> Hello everybody. > > >> A question from not an expert of notch filters. > > >> Suppose I have to filter out a specific frequency noise (e.g. a 50 Hz > >> noise) from an acquired signal. Suppose my filter has not to work > online, > >> i.e. I can collect signal samples (its a digitalized signal) and then > >> filter noise out. I would like to compute the Fourier transform of the > >> signal, put the 50Hz frequency amplitude to zero and go back to time > >> domain. > >> What are the drawbacks for such a simple frequency domain notch > filter? > > >* You have to remember to also zero out the (fs-50Hz) component. > > Ok > > >* No harmonics will be dealt with. > > Ok, I could do the same for all of the harmonics I want > > > > >* You should realize that zeroing out those samples is the same thing as > >adding (really, subtracting but it may not appear to you to to be so) a > 50Hz > >sinusoid to the time domain version of the signal - with a rectangular > >window. The leakage frequencies associated with the sinusoid and the fft > >aren't handled at all. > > I'm supposing to use a number of time samples (or proper zero padding) in > order to have 50 Hz among the frequency samples so as to remove exactly 50 > Hz line (and multiples if required). As suggested by Jerry, I could use a > window for the 50Hz neighbourhood. > > > > >[Try this: start with a pure 50Hz sampled signal sequence. FFT it. > >Subtract only the 50Hz and fs-50Hz samples. What's the result in the FFT > >samples? Then IFFT what's left. What's the result in the time domain > >samples? It matters if fs is related to 50Hz or not. Are the results > what > >you expect? ... what you would want?] > > >* A better notch filter would be one that has a zero at 50Hz, is as > narrow > >as possible (and no narrower). The width will be inversely proportional > to > >the length of the filter if it's FIR or the effective length of the > impulse > >response of the filter if it's IIR. > > I thought to this simple filter in frequency domain (FDF) in order not to > distort the signal (apart for 50 Hz delation). Other notch filter would > introduce signal distrortion as far as I undestand. > > The disadvantages for the FDF would be: > 1) It cannot work in real time but only offline > 2) It could be time consuming > 3) I need to have a number N of samples so that exists k so that > k*(N*T)^(-1) = 50 Hz (to overcome leakage problems) > > Advantages: > 1) Not signal distortionNot necessarily true. Non 50 Hz frequency signals that are non-bin centered and/or modulated will have a portion of their energy show up in the 50 Hz FFT bin. If you zero that bin, you will distort all those other frequencies. IMHO. YMMV. -- rhn A.T nicholson d.0.t C-o-M