# Help to interpret impulse response of an fixed point IIR filter

Started by December 22, 2005
```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&#4294967295;s because limitations in fraction bits). The filter is implemented
in fixed point arithmetic&#4294967295;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?

```
```Not 0 dB?  What is it?

Are you applying a window?

What's the FFT size?

How is your FFT calibrated to dB?

Dirk

```
```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
> Not 0 dB?  What is it?
>
> Are you applying a window?
>
> What's the FFT size?
>
> How is your FFT calibrated to dB?
>
> Dirk
>

```
```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&#4294967295;s because limitations in fraction bits). The filter is implemented
> in fixed point arithmetic&#4294967295;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

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com
```
```I&#4294967295;m implementing the filter in an Texas Instruments DSP in Q-math (fixed
point library routines).

I&#4294967295;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&#4294967295;s because limitations in fraction bits). The filter is
implemented
> > in fixed point arithmetic&#4294967295;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
>
> --
>
> Tim Wescott
> Wescott Design Services
> http://www.wescottdesign.com

```
```Marko wrote:
> I&#4294967295;m implementing the filter in an Texas Instruments DSP in Q-math (fixed
> point library routines).
>
>
>
> I&#4294967295;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&#4294967295;s because limitations in fraction bits). The filter is
>
> implemented
>
>>>in fixed point arithmetic&#4294967295;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
>>
>>--
>>
>>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
```
```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

```
```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
>

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com
```
```"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
>>

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

```
```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
>>>
>>
>
>
> 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
```