# Why is the frequency response different based on the amplitude of the impulse I feed into the filter?

I am working on a 2-pole IIR high-pass filter. The filter is fixed point and it is causing me some issues. I believe I'm just misunderstanding something. I am implementing everything in Octave for now, but eventually it will be implemented in a 32-bit processor. The corner frequency is very low, $2.7\textrm{ Hz}$.

When I test the filter by passing in an impulse and then doing an fft on the output, I get different results based on the magnitude of the impulse.

First, I made the filter using signed 64-bit integers just for testing. So the impulse I feed into the filter looks like this:

Fs = 51200; %sample frequency
impulse = int64( [2^31, zeros(1,Fs*10-1)] ); %multiply by 10 to get 0.1 Hz resolution


Here is the fixed-point impulse response compared against the floating-point impulse response. If I rerun the code but with a larger impulse I get the desired frequency response.

Fs = 51200; %sample frequency
impulse = int64( [2^63, zeros(1,Fs*10-1)] ); %multiply by 10 to get 0.1 Hz resolution They match so closely you can barely see the red, floating-point response.

• Why is there this difference just from changing the amplitude of the input?

• I need to implement this in 32 bits, but when I do, the amplitude of the input is restricted to $2^{31}$ so I end up with the distorted impulse response. How can I fix this or work around this?

• For the fixed point low impulse response you are probably close numerical accuracy of the fixed point numbers at low frequencies where the gain is very low. By increasing the impulse amplitude the numerical accuracy relative to the impulse amplitude becomes smaller. If you would calculate the response for longer you will still see this difference at a lower frequency. – fibonatic Jul 26 '16 at 18:07
• You say that you used 64 integers for the filter coefficients, but afterwards you say that you're using fixed-point numbers. Can you give more information on what exactly you're doing? – MBaz Jul 26 '16 at 18:08
• @MBaz, your question confused me. The processor I am using does not support floating point operations. All operations are done using 32-bit integers. So, they are fixed point. I implemented the filter and tested it in Octave using floating point numbers and it worked great. Then I switched to 32-bit and the response became distorted. So I switched to 64-bit integers to see if the increased resolution would help. It did help as long as the impulse was sufficiently large. When the impulse is dropped to an amplitude of 2^31 (the max amplitude for 32-bit integers), the response distorts. – Joey M. Jul 26 '16 at 19:45
• Could you actually add the values of these taps? – Marcus Müller Jul 26 '16 at 21:12
• @JoeyM. Sorry for causing confusion. In fixed point arithmetic, an N-bit integer is interpreted as having Q bits for the integer part, and N-Q bits for the fractional (decimal) part. You seem to be using N=Q, which seem to me to be less than ideal (but I'm not an expert). Many processors have support for fixed-point libraries where you can specify N and Q, maybe it's worth a shot for you to look into it. – MBaz Jul 26 '16 at 22:10