Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
20705 Discussions

band pass FIR filter and weird response

Altera_Forum
Honored Contributor II
1,501 Views

Dear all,  

 

I have used altera quartus 12.0 FIR II compiler to generate a bandpass filter. The filter uses 11bits coefficients with 17bit data entry and has 80 taps. 

 

I put all that into simulation and I've injected a DC-like signal to see step response of the filter. See following picture: http://belohrad.web.cern.ch/belohrad/broken_filter_data.png  

 

On the picture you can see filter input signal beamdataxdny which is being filtered and the filter's response is in filteredbeamdataxd

 

The input signal starts at zero, then it is pulled for a short time into the minimum possible value (-32768) and the it is pulled to maximum value of 32767, where it stays for a long time. 

 

Should we have a true bandpass filter, one would say to see a sort of 'chirp' response, what I exactly see. But one would expect as well, that the chirp will disappear and the filter goes back into a steady state, with zero output value. 

 

But apparently this is not the case at all. Because chirp goes off, and the filter's output value stabilizes at 65534 instead of zero. 

 

What is even more mysterious for me is, that when I reinjected another signal http://belohrad.web.cern.ch/belohrad/broken_filter_data1.png , this time I have injected a proper sine-wave like signal with amplitude of '3' and then I set the input signal to zero, the FIR filter reacts this time correctly: first a chirp response due to transition, then correct filtering and when signal disappears, the filter's output value goes to zero. 

 

 

So now my question: what is wrong with this filter? Did I specify something incorrectly when designing it? 

 

any help kindly appreciated 

 

 

david
0 Kudos
6 Replies
Altera_Forum
Honored Contributor II
487 Views

Try first pass impulse input e.g. [32767 zeros) then you should get the actual coeffs out (though scaled). That way you know its impulse response is correct.

0 Kudos
Altera_Forum
Honored Contributor II
487 Views

Short summary of a rather long post, you have 2 LSB output error (signed value -2) with full scale DC input.  

That's most likely a truncation error due to the no so high coefficient resolution. Normal operation so far.
0 Kudos
Altera_Forum
Honored Contributor II
487 Views

Kaz: yes, I've verified this. the impulse response seems to be correct within given 11bits.. 

 

FvM: this is interesting comment, but I'm not sure whether I understand your comment. Could you extend it a bit more? My input vector is 16 bits (sorry for my first post where I mistakenly said 17). The filter output vector is 34 bits long (33 downto 0) signed. Hence output 65534 does change 16 lsbs on already 34-bit long 'signed' type. Where did you get 2LSB error? 

 

Thanks 

 

.d.
0 Kudos
Altera_Forum
Honored Contributor II
487 Views

I think you need to judge output values after scaling them back so that you get unity gain at some reference frequency point.

0 Kudos
Altera_Forum
Honored Contributor II
487 Views

I just modelled a bandpass filter without scaling down and found out 

it is possible to get a dc value as high as your 65534: 

 

h = fir1(79,[.1 .2]); 

h = round(h*1024); 

x = [zeros(1,100) -32768 ones(1,1000)*32767]; 

y1 = filter(h,1,x); 

y2 = round(y1/1024); 

 

you will see y1 has a high residual dc that is scaled down by 1024 in y2. 

The actual value depends on your filter unity gain and filter's dc removal.
0 Kudos
Altera_Forum
Honored Contributor II
487 Views

Dear All,  

 

thanks for those hints. I see the problem. I'll try to increase depth of my coefficients and play a bit with unity gain to see what I can get. The 'ultimate' goal is to get unity gain with sub-LSB DC error of course :)
0 Kudos
Reply