Taps for simple IIR Filter in GNU Radio

  • Thread starter Thread starter Swamp Thing
  • Start date Start date
  • Tags Tags
    Filter
AI Thread Summary
The discussion revolves around the user's experimentation with GNU Radio to implement a 2nd order IIR filter at a frequency of 170 Hz, using a sample rate of 16,000 samples per second. The user derived the filter taps using Mathematica, confirming their functionality through a simulation that produced the expected resonant frequency. However, upon inputting the calculated feedforward and feedback taps into GNU Radio's IIR block, the output did not match the expected results. The user noted that changing the polarity convention in the IIR block led to instability and erratic behavior in the filter's response. A suggestion was made to examine the source code of the IIR block to better understand the calculations being performed, highlighting the advantages of open-source software for troubleshooting such issues.
Swamp Thing
Insights Author
Messages
1,028
Reaction score
763
I am experimenting with GNU Radio (using the Companion graphical editor) to do some simple audio processing.

As my first experiment, I am trying to set up a very simple 2nd order IIR filter at 170 Hz with a sample rate of 16000 samples/sec. I used this Mathematica code to find the taps:
Code:
fs=16000;
fr=170 (* Center Frequency *)
\[CapitalTheta]=N[2 Pi fr / fs ]

r=0.99; (* this controls the Q *)

t1=2 r Cos[\[CapitalTheta]]
t2= -r*r
{t1,t2} (* these are the tap values that I want to use in GNU Radio's IIR block *)

Here's how I verify within Mathematica that the filter should work OK:
Code:
y1=0;
y2=0;
yyy=Reap[For[i=0,i<400,i++,
       x=If[i<4,10,0];  (* inputs a short pulse to the system *)
       y=x + t1* y1 + t2*y2;
      Sow[y];
        y2=y1;
        y1=y;

    ]
][[2,1]];
ListPlot[yyy,PlotRange->All]

And this gives this plot, where I can verify that the resonant frequency is around 170 Hz as intended.

1728912835643.png


Now when I enter the feedforward taps into the GNU Radio IIR as [1] and the feedback taps as [1.97559, -0.9801] --- which I got from the first code block above and which works in the test filter above --- I get nothing resembling the above.

The impulse response in GNU Radio looks like this:

iir.png


Now, the IIR block has a dropdown that selects the so-called "old" or "new" convention for the polarities of the tap values. If I change that option, I get the following, where the filter seems to have become unstable and is "hunting" at the sample rate.
iir-2.png


So if anyone knows about the quirks of the IIR block in GNU Radio, please help me understand this. Thanks.
 
Technology news on Phys.org
I don't use GNU Radio but I've done some IIRs using liquid-dsp. My suggestion is to look at the source code for the IIR block. Walk through what it's actually calculating for the inputs you've given it. The one nice thing about open source is you have the source.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top