DSPRelated.com
Forums

Problem measuring frequency response of filters

Started by Malcolm Haylock January 26, 2004
Hi everyone,

I'm fairly new to DSP and am having trouble measuring the frequency 
response of various (mainly Butterworth) filters that I wish to use in a 
program.

To test the response I'm running the filters on white noise using a 1024 
point buffer (which is what the program will use) then taking the DFT of 
the output. I'm doing this 1000 times and averaging the result.

The results look fine apart from the lowest frequency response. I've 
tried using a Hamming window on the filter output before running the DFT 
but there is still the problem.

Is this a problem with the filter or the DFT or my (probably naive) 
approach.

Thanks,
Malcolm Haylock

Hi!

> I'm fairly new to DSP and am having trouble measuring the frequency > response of various (mainly Butterworth) filters that I wish to use in a > program. > > To test the response I'm running the filters on white noise using a 1024 > point buffer (which is what the program will use) then taking the DFT of > the output. I'm doing this 1000 times and averaging the result. > > The results look fine apart from the lowest frequency response. I've > tried using a Hamming window on the filter output before running the DFT > but there is still the problem. > > Is this a problem with the filter or the DFT or my (probably naive) > approach.
You have three options (that I can think of): 1.) Put a big single number (total number of points) at the begining of the buffer and then filter the buffer. Perform abs(FFT) on the entire buffer afterwards. The buffer should be about 4000 samples long. But try with longer lengths if the frequency response looks "strange". After some length it does not change anymore. 2.) Compute the FFT of the nominator and denominator separately. Divide them in complex. Take the absolute value and thats it. This has drawbacks and may not be able to show frequency responses of the filters that you can get to show with method "1". The number of points is from 1024 to 4096. 3.) What you are doing. Not bad, but very slow. You would get better results if you used more points. That's probably why your low frequencies have problems. Regards! Atmapuri.
Malcolm Haylock <smaugNOSPAM@kagi.com> writes:

> Hi everyone, > > I'm fairly new to DSP and am having trouble measuring the frequency > response of various (mainly Butterworth) filters that I wish to use in > a program. > > To test the response I'm running the filters on white noise using a > 1024 point buffer (which is what the program will use) then taking the > DFT of the output. I'm doing this 1000 times and averaging the result. > > The results look fine apart from the lowest frequency response. I've > tried using a Hamming window on the filter output before running the > DFT but there is still the problem.
Hi Malcolm, The N-point DFT creates N filters of width Fs/N. Usually you want the measurement points to vary nonlinearly as a function of frequency (which is why you usually use a logarithmic frequency axis) when you're measuring frequency response, so this is one aspect in which the DFT doesn't quite match what you want to do. You wind up with lots of bins at the high frequencies that you don't really need and not enough bins at the low frequencies. Windowing won't help this problem. You can simply increase the DFT size until you get the low frequency resolution you need. Or you can go to an alternate measurement technique. For example, you can generate sine waves and measure the power out of the filter after steady-state has been reached. This all applies to measuring a given filter implementation. If you want to examine the response of a theoretical filter, simply use the transfer function (H(z)) and solve for z = e^{j*w*Ts}. -- % Randy Yates % "...the answer lies within your soul %% Fuquay-Varina, NC % 'cause no one knows which side %%% 919-577-9882 % the coin will fall." %%%% <yates@ieee.org> % 'Big Wheels', *Out of the Blue*, ELO http://home.earthlink.net/~yatescr
There is a new branch of science: experimental mathematics :)
I always loved it.

It does not make sense to measure the frequency response of the digital
filter since you have H(Z) determined by the filter stricture. The
|H(Z)| gives you the response in the clear analytical form.

If you insist on the experimental proof then use the delta function
instead of white noise.

Vladimir Vassilevsky
DSP Consultant

http://www.abvolt.com
  
  
Malcolm Haylock wrote:
> > Hi everyone, > > I'm fairly new to DSP and am having trouble measuring the frequency > response of various (mainly Butterworth) filters that I wish to use in a > program. > > To test the response I'm running the filters on white noise using a 1024 > point buffer (which is what the program will use) then taking the DFT of > the output. I'm doing this 1000 times and averaging the result. > > The results look fine apart from the lowest frequency response. I've > tried using a Hamming window on the filter output before running the DFT > but there is still the problem. > > Is this a problem with the filter or the DFT or my (probably naive) > approach. > > Thanks, > Malcolm Haylock
"Malcolm Haylock" <smaugNOSPAM@kagi.com> wrote in message
news:bv2pfu$pp2$1@cpca14.uea.ac.uk...
> Hi everyone, > > I'm fairly new to DSP and am having trouble measuring the frequency > response of various (mainly Butterworth) filters that I wish to use in a > program. > > To test the response I'm running the filters on white noise using a 1024 > point buffer (which is what the program will use) then taking the DFT of > the output. I'm doing this 1000 times and averaging the result. > > The results look fine apart from the lowest frequency response. I've > tried using a Hamming window on the filter output before running the DFT > but there is still the problem. > > Is this a problem with the filter or the DFT or my (probably naive) > approach. > > Thanks, > Malcolm Haylock
Try this link - should take you to a archived thread in Google groups that talks about this topic (else try searching yourself in google groups for a thread with subject 'filter freq response'. http://tinyurl.com/yud6z Cheers Bhaskar
In article <40153265.E4F1F7F0@there.com>,
Vladimir Vassilevsky  <do_not_reply@there.com> wrote:
>There is a new branch of science: experimental mathematics :) >I always loved it.
Is that the branch that contains the connectionist, genetic algorithm, complexity and chaos theory crowd? Interesting stuff indeed, but I didn't think it was that new. When was Lorentz's paper?
>It does not make sense to measure the frequency response of the digital >filter since you have H(Z) determined by the filter stricture. The >|H(Z)| gives you the response in the clear analytical form.
only in a world where there are no such thing as software bugs, incomplete specifications, human transcription errors and typos, etc. If for no other reason, I test my digital filters to make sure I didn't drop a minus sign somewhere during the coding.
>Malcolm Haylock wrote: >> To test the response I'm running the filters on white noise using a 1024 >> point buffer (which is what the program will use) then taking the DFT of >> the output. I'm doing this 1000 times and averaging the result. >> >> The results look fine apart from the lowest frequency response. I've >> tried using a Hamming window on the filter output before running the DFT >> but there is still the problem.
You might want to make sure you are using a buffer much longer than the impulse response in order to cancel out any startup conditions for certain types of filter structures. IMHO. YMMV. -- Ron Nicholson rhn AT nicholson DOT com http://www.nicholson.com/rhn/ #include <canonical.disclaimer> // only my own opinions, etc.
On Mon, 26 Jan 2004 11:45:55 -0800, "Bhaskar Thiagarajan"
<bhaskart@deja.com> wrote:

  (snipped)
> >Try this link - should take you to a archived thread in Google groups that >talks about this topic >(else try searching yourself in google groups for a thread with subject >'filter freq response'. >http://tinyurl.com/yud6z > >Cheers >Bhaskar
Hi Bhaskar, I went further than that website's thread indicated. 8-10 guys here added "testing" ideas to the list that I created. I've had it in the back of my mind that, when I get time, I'll rewrite that list, add the stuff from the other guys here and try to publish it. (I wonder if a magazine will publish an article with 10 authors?) Actually, Malcolm asks a good question. I've always wondered if it's better to test a filter implementation by applying a unit sample impulse, and then FFTing the impulse response, or apply "white" noise and average multiple FFTs of the filter's output. Off the top of my head, I can't answer that simple question. But I will say, I'd never use a filter in an application without testing the living heck out of the filter first. Many filters "work" fine on paper, but not when implemented with finite binary word widths. [-Rick-]
Rick Lyons wrote:

> I've always wondered if it's better to test a > filter implementation by applying a unit sample > impulse, and then FFTing the impulse response, or > apply "white" noise and average multiple > FFTs of the filter's output.
And what about a frequency sweep? I was always thinking that such a signal should give the "visual" frequency response in the time domain, but I never got if it is meaningful...
> Off the top of my head, I can't answer that simple > question.
Well, I guess white noise is a must in non-linear filters, since the impulse maybe does not reflect the real filter performance. bye, -- Piergiorgio Sartor
Piergiorgio Sartor wrote:

   ...

> the impulse maybe does not reflect > the real filter performance.
How not? 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;
Jerry Avins wrote:

>> the impulse maybe does not reflect >> the real filter performance. > > How not?
If the filter is non-linear, it means it cannot neccessarily be decomposed, so the impulse response can be misleading. I think something like "abs(x)" is a simple example of this. bye, -- Piergiorgio Sartor