| Author |
Message |
Marko
Guest
|
Posted:
Thu Dec 22, 2005 11:34 pm Post subject:
Help to interpret impulse response of an fixed point IIR fil |
|
|
I have done an impulse response of an IIR filter. The impulse response of
the filter does not return to zero but stops at a level close to zero (I
think it’s because limitations in fraction bits). The filter is implemented
in fixed point arithmetic’s.
And when I make an FFT of the impulse response de 0 Hz gain is not 0 dB as I
would like it to be.
But when I run a step response I get almost perfect 0 Hz gain of 0 dB.
So the problem is that the FFT of the impulse response says the gain is not
0 dB at 0 Hz but the step response says the gain is 0 dB at 0 Hz?
What should I do? |
|
| Back to top |
|
 |
dbell
Guest
|
Posted:
Thu Dec 22, 2005 11:57 pm Post subject:
Re: Help to interpret impulse response of an fixed point IIR |
|
|
Not 0 dB? What is it?
Are you applying a window?
What's the FFT size?
How is your FFT calibrated to dB?
Dirk |
|
| Back to top |
|
 |
Marko
Guest
|
Posted:
Fri Dec 23, 2005 1:08 am Post subject:
Re: Help to interpret impulse response of an fixed point IIR |
|
|
I can't check the 0 Hz dB value right now.
The FFT is performed on the impulse response and it's 48000 samples.
The FFT is calibrated to 0 dB by taking the FFT of the input signal (the
impulse) and taking the FFT of the impulse response. And then subtracting.
FFT_FILTER = FFT_OUTPUT - FFT_INPUT
I do something like this in MATLAB:
fft_x = 20*log10(abs(fft(x))); % fft of input impulse
fft_y = 20*log10(abs(fft(y))); % fft of impulse response
N = length(fft_x);
fs = 4800; % sample freq
f = (0:N-1)*fs/N;
close all
figure
plot(f, fft_y-fft_x)
grid on
"dbell" <dbell@niitek.com> skrev i meddelandet
news:1135274250.739759.298540@f14g2000cwb.googlegroups.com...
| Quote: | Not 0 dB? What is it?
Are you applying a window?
What's the FFT size?
How is your FFT calibrated to dB?
Dirk
|
|
|
| Back to top |
|
 |
Tim Wescott
Guest
|
Posted:
Fri Dec 23, 2005 1:16 am Post subject:
Re: Help to interpret impulse response of an fixed point IIR |
|
|
Marko wrote:
| Quote: | I have done an impulse response of an IIR filter. The impulse response of
the filter does not return to zero but stops at a level close to zero (I
think it’s because limitations in fraction bits). The filter is implemented
in fixed point arithmetic’s.
I believe you have diagnosed the problem correctly.
And when I make an FFT of the impulse response de 0 Hz gain is not 0 dB as I
would like it to be.
That's not surprising.
But when I run a step response I get almost perfect 0 Hz gain of 0 dB.
That is also not surprising.
So the problem is that the FFT of the impulse response says the gain is not
0 dB at 0 Hz but the step response says the gain is 0 dB at 0 Hz?
No. The problem is that you are using a method of analyzing linear |
systems (the FFT) on a nonlinear system (a filter with quantization),
and expecting the results to be consistent with linear system theory.
If your filter settles out close enough to your DC value to be
acceptable then call it good, and don't sweat the impulse response
issues. If it doesn't then you need to use higher precision math or you
need to juggle your filter algorithm around to better use the precision
you have. You didn't say if it was 1st-order, 2nd or higher, or how you
are implementing your algorithm.
--
Tim Wescott
Wescott Design Services
http://www.wescottdesign.com |
|
| Back to top |
|
 |
Marko
Guest
|
Posted:
Fri Dec 23, 2005 1:16 am Post subject:
Re: Help to interpret impulse response of an fixed point IIR |
|
|
I’m implementing the filter in an Texas Instruments DSP in Q-math (fixed
point library routines).
I’m running/simulating the filter as second order sections in Simulink using
C28x IQmath Library. The filter coefficients are calculated in FDAtool.
The filter is an 8th order Butterworth filter. But I hade a similar result
with a 4th order Butterworth as well at DC (0 Hz).
But now I know what error I did. Looking at a nonlinear system thinking it
was linear.
How should I check the implemented filter transfer function? I should check
DC-gain with a step function you said, but what about the rest? Should I try
the filter with different sinus waves and check the output amplitudes?
Thanks :-)
"Tim Wescott" <tim@seemywebsite.com> skrev i meddelandet
news:aZudnccwIfaYnDbeRVn-uw@web-ster.com...
| Quote: | Marko wrote:
I have done an impulse response of an IIR filter. The impulse response
of
the filter does not return to zero but stops at a level close to zero (I
think it’s because limitations in fraction bits). The filter is
implemented
in fixed point arithmetic’s.
I believe you have diagnosed the problem correctly.
And when I make an FFT of the impulse response de 0 Hz gain is not 0 dB
as I
would like it to be.
That's not surprising.
But when I run a step response I get almost perfect 0 Hz gain of 0 dB.
That is also not surprising.
So the problem is that the FFT of the impulse response says the gain is
not
0 dB at 0 Hz but the step response says the gain is 0 dB at 0 Hz?
No. The problem is that you are using a method of analyzing linear
systems (the FFT) on a nonlinear system (a filter with quantization),
and expecting the results to be consistent with linear system theory.
If your filter settles out close enough to your DC value to be
acceptable then call it good, and don't sweat the impulse response
issues. If it doesn't then you need to use higher precision math or you
need to juggle your filter algorithm around to better use the precision
you have. You didn't say if it was 1st-order, 2nd or higher, or how you
are implementing your algorithm.
--
Tim Wescott
Wescott Design Services
http://www.wescottdesign.com |
|
|
| Back to top |
|
 |
robert bristow-johnson
Guest
|
Posted:
Fri Dec 23, 2005 1:16 am Post subject:
Re: Help to interpret impulse response of an fixed point IIR |
|
|
Tim Wescott wrote:
| Quote: | Marko wrote:
I have done an impulse response of an IIR filter. The impulse response of
the filter does not return to zero but stops at a level close to zero (I
think it's because limitations in fraction bits). The filter is implemented
in fixed point arithmetic's.
The problem is that you are using a method of analyzing linear
systems (the FFT) on a nonlinear system (a filter with quantization),
and expecting the results to be consistent with linear system theory.
If your filter settles out close enough to your DC value to be
acceptable then call it good, and don't sweat the impulse response
issues.
|
Tim, i think that guy's problem is simply a case of limit cycling on
the quantization. it can be dealt with by "first-order noise shaping
with a zero at z=1" or simply called "fraction saving". that DC
blocking filter trick at DSPguru.com deals with this issue.
r b-j |
|
| Back to top |
|
 |
Tim Wescott
Guest
|
Posted:
Fri Dec 23, 2005 1:16 am Post subject:
Re: Help to interpret impulse response of an fixed point IIR |
|
|
Marko wrote:
| Quote: | I’m implementing the filter in an Texas Instruments DSP in Q-math (fixed
point library routines).
I’m running/simulating the filter as second order sections in Simulink using
C28x IQmath Library. The filter coefficients are calculated in FDAtool.
The filter is an 8th order Butterworth filter. But I hade a similar result
with a 4th order Butterworth as well at DC (0 Hz).
But now I know what error I did. Looking at a nonlinear system thinking it
was linear.
How should I check the implemented filter transfer function? I should check
DC-gain with a step function you said, but what about the rest? Should I try
the filter with different sinus waves and check the output amplitudes?
Thanks :-)
"Tim Wescott" <tim@seemywebsite.com> skrev i meddelandet
news:aZudnccwIfaYnDbeRVn-uw@web-ster.com...
Marko wrote:
I have done an impulse response of an IIR filter. The impulse response
of
the filter does not return to zero but stops at a level close to zero (I
think it’s because limitations in fraction bits). The filter is
implemented
in fixed point arithmetic’s.
I believe you have diagnosed the problem correctly.
And when I make an FFT of the impulse response de 0 Hz gain is not 0 dB
as I
would like it to be.
That's not surprising.
But when I run a step response I get almost perfect 0 Hz gain of 0 dB.
That is also not surprising.
So the problem is that the FFT of the impulse response says the gain is
not
0 dB at 0 Hz but the step response says the gain is 0 dB at 0 Hz?
No. The problem is that you are using a method of analyzing linear
systems (the FFT) on a nonlinear system (a filter with quantization),
and expecting the results to be consistent with linear system theory.
If your filter settles out close enough to your DC value to be
acceptable then call it good, and don't sweat the impulse response
issues. If it doesn't then you need to use higher precision math or you
need to juggle your filter algorithm around to better use the precision
you have. You didn't say if it was 1st-order, 2nd or higher, or how you
are implementing your algorithm.
--
Tim Wescott
Wescott Design Services
http://www.wescottdesign.com
If you're mostly interested in the transfer function then doing it with |
sine waves is probably best. I haven't tried it, but doing the FFT
method and either subtracting out the steady-state error from the whole
thing or truncating the decaying exponential past the "interesting" part
may give good results. Which method is really best depends on how
you're going to use the filter and how much confidence you're going to
have in the result.
--
Tim Wescott
Wescott Design Services
http://www.wescottdesign.com |
|
| Back to top |
|
 |
Tim Wescott
Guest
|
Posted:
Fri Dec 23, 2005 7:22 am Post subject:
Re: Help to interpret impulse response of an fixed point IIR |
|
|
robert bristow-johnson wrote:
| Quote: | Tim Wescott wrote:
Marko wrote:
I have done an impulse response of an IIR filter. The impulse response of
the filter does not return to zero but stops at a level close to zero (I
think it's because limitations in fraction bits). The filter is implemented
in fixed point arithmetic's.
The problem is that you are using a method of analyzing linear
systems (the FFT) on a nonlinear system (a filter with quantization),
and expecting the results to be consistent with linear system theory.
If your filter settles out close enough to your DC value to be
acceptable then call it good, and don't sweat the impulse response
issues.
Tim, i think that guy's problem is simply a case of limit cycling on
the quantization. it can be dealt with by "first-order noise shaping
with a zero at z=1" or simply called "fraction saving". that DC
blocking filter trick at DSPguru.com deals with this issue.
r b-j
Closely related to http://www.wescottdesign.com/articles/sigmadelta.html. |
--
Tim Wescott
Wescott Design Services
http://www.wescottdesign.com |
|
| Back to top |
|
 |
Fred Marshall
Guest
|
Posted:
Fri Dec 23, 2005 7:43 am Post subject:
Re: Help to interpret impulse response of an fixed point IIR |
|
|
"Tim Wescott" <tim@seemywebsite.com> wrote in message
news:yfmdnXCPfaXDzDbenZ2dnUVZ_tmdnZ2d@web-ster.com...
| Quote: | robert bristow-johnson wrote:
Tim Wescott wrote:
Marko wrote:
I have done an impulse response of an IIR filter. The impulse response
of
the filter does not return to zero but stops at a level close to zero (I
think it's because limitations in fraction bits). The filter is
implemented
in fixed point arithmetic's.
The problem is that you are using a method of analyzing linear
systems (the FFT) on a nonlinear system (a filter with quantization),
and expecting the results to be consistent with linear system theory.
If your filter settles out close enough to your DC value to be
acceptable then call it good, and don't sweat the impulse response
issues.
Tim, i think that guy's problem is simply a case of limit cycling on
the quantization. it can be dealt with by "first-order noise shaping
with a zero at z=1" or simply called "fraction saving". that DC
blocking filter trick at DSPguru.com deals with this issue.
r b-j
Closely related to http://www.wescottdesign.com/articles/sigmadelta.html.
|
I'm surprised that no one has mentioned the fact that you can't really do an
FFT of the impulse response of an IIR filter. The response at DC is the
integral of the impulse response. But, in this case it's been truncated.
This means that some part of the integral is missing. It's supposed to sum
to zero but it doesn't. Are 48000 samples a little or a lot in terms of
this particular impulse response and the sampling rate?
I'm not suggesting that this is the likely cause of the problem seen. Just
that it shouldn't be neglected out of hand.
I'm sure someone will point out why this isn't a very important
consideration in this case and THAT will answer the question!
Fred |
|
| Back to top |
|
 |
Tim Wescott
Guest
|
Posted:
Fri Dec 23, 2005 7:56 am Post subject:
Re: Help to interpret impulse response of an fixed point IIR |
|
|
Fred Marshall wrote:
| Quote: | "Tim Wescott" <tim@seemywebsite.com> wrote in message
news:yfmdnXCPfaXDzDbenZ2dnUVZ_tmdnZ2d@web-ster.com...
robert bristow-johnson wrote:
Tim Wescott wrote:
Marko wrote:
I have done an impulse response of an IIR filter. The impulse response
of
the filter does not return to zero but stops at a level close to zero (I
think it's because limitations in fraction bits). The filter is
implemented
in fixed point arithmetic's.
The problem is that you are using a method of analyzing linear
systems (the FFT) on a nonlinear system (a filter with quantization),
and expecting the results to be consistent with linear system theory.
If your filter settles out close enough to your DC value to be
acceptable then call it good, and don't sweat the impulse response
issues.
Tim, i think that guy's problem is simply a case of limit cycling on
the quantization. it can be dealt with by "first-order noise shaping
with a zero at z=1" or simply called "fraction saving". that DC
blocking filter trick at DSPguru.com deals with this issue.
r b-j
Closely related to http://www.wescottdesign.com/articles/sigmadelta.html.
I'm surprised that no one has mentioned the fact that you can't really do an
FFT of the impulse response of an IIR filter. The response at DC is the
integral of the impulse response. But, in this case it's been truncated.
This means that some part of the integral is missing. It's supposed to sum
to zero but it doesn't. Are 48000 samples a little or a lot in terms of
this particular impulse response and the sampling rate?
I'm not suggesting that this is the likely cause of the problem seen. Just
that it shouldn't be neglected out of hand.
I'm sure someone will point out why this isn't a very important
consideration in this case and THAT will answer the question!
Fred
Good point. Assuming the response has mostly died off taking the FFT |
should be valid, though.
--
Tim Wescott
Wescott Design Services
http://www.wescottdesign.com |
|
| Back to top |
|
 |
Marko
Guest
|
Posted:
Sun Dec 25, 2005 4:37 pm Post subject:
Re: Help to interpret impulse response of an fixed point IIR |
|
|
Thank you all :-)
"Tim Wescott" <tim@seemywebsite.com> skrev i meddelandet
news:qPCdneG2_JeoxDbeRVn-pg@web-ster.com...
| Quote: | Fred Marshall wrote:
"Tim Wescott" <tim@seemywebsite.com> wrote in message
news:yfmdnXCPfaXDzDbenZ2dnUVZ_tmdnZ2d@web-ster.com...
robert bristow-johnson wrote:
Tim Wescott wrote:
Marko wrote:
I have done an impulse response of an IIR filter. The impulse
response
of
the filter does not return to zero but stops at a level close to zero
(I
think it's because limitations in fraction bits). The filter is
implemented
in fixed point arithmetic's.
The problem is that you are using a method of analyzing linear
systems (the FFT) on a nonlinear system (a filter with quantization),
and expecting the results to be consistent with linear system theory.
If your filter settles out close enough to your DC value to be
acceptable then call it good, and don't sweat the impulse response
issues.
Tim, i think that guy's problem is simply a case of limit cycling on
the quantization. it can be dealt with by "first-order noise shaping
with a zero at z=1" or simply called "fraction saving". that DC
blocking filter trick at DSPguru.com deals with this issue.
r b-j
Closely related to
http://www.wescottdesign.com/articles/sigmadelta.html.
I'm surprised that no one has mentioned the fact that you can't really
do an
FFT of the impulse response of an IIR filter. The response at DC is the
integral of the impulse response. But, in this case it's been
truncated.
This means that some part of the integral is missing. It's supposed to
sum
to zero but it doesn't. Are 48000 samples a little or a lot in terms of
this particular impulse response and the sampling rate?
I'm not suggesting that this is the likely cause of the problem seen.
Just
that it shouldn't be neglected out of hand.
I'm sure someone will point out why this isn't a very important
consideration in this case and THAT will answer the question!
Fred
Good point. Assuming the response has mostly died off taking the FFT
should be valid, though.
--
Tim Wescott
Wescott Design Services
http://www.wescottdesign.com |
|
|
| Back to top |
|
 |
Noway2
Guest
|
Posted:
Mon Dec 26, 2005 5:15 pm Post subject:
Re: Help to interpret impulse response of an fixed point IIR |
|
|
It sounds like what you are after is a Bode plot of your filter, which
is simply a 20*log(mag) versus frequency and a phase versus frequency
plot. You should be able to use your simulation tool to run a plot of
both the 's' equation and your 'z' equation and compare the results. I
use Mathcad (what I have available) for this by calculating the
response on an array of 'jw' for the 's' equation and 'e^j*w' for the z
equation that runs from very small to Fsample/2.
I will also implement the equation in direct form (in mathcad) and plot
the response versus various test inputs. This helps to show the
transient response of the filter and show that the DC values are as
intended. |
|
| Back to top |
|
 |
|
|
|
|