# GNU Radio IIR Filter Taps

**URL:** <https://www.ruby-forum.com/t/gnu-radio-iir-filter-taps/242049>\
**Category:** GNU Radio\
**Created:** [May 22, 2015, 7:21pm UTC](https://www.ruby-forum.com/t/gnu-radio-iir-filter-taps/242049 "2015-05-22T19:21:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [May 22, 2015, 7:21pm UTC](https://www.ruby-forum.com/t/gnu-radio-iir-filter-taps/242049/1 "2015-05-22T19:21:44Z")

</div>

Hello,

I’ve been trying to move the fm De-emphasis (an IIR filter, I’m pretty  
sure) functionality of the WBFM\_Receive block into an FPGA, and I’m a  
little confused as to how the taps work.

I’m in fm\_emph.py and can see the taps listed as

btaps = [b0, b1]  
ataps = [1, a1]

I had assumed this is a first-order IIR filter, and am basing my simple  
algorithm on a structure as seen in this link

[![](https://www.mikroe.com/img/publication/various-electronic-books/digital-filter-design/chapter/ch3/fig3-2-20.gif) ](https://www.mikroe.com/img/publication/various-electronic-books/digital-filter-design/chapter/ch3/fig3-2-20.gif)

Is there something I’m missing? I don’t seem to be getting the correct  
results based off my input data.

Thanks,  
Keyur

---

<div class="post-metadata">

**Author:** ![Keyur\_Parikh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/c2a13f/32.png) [@Keyur\_Parikh](https://www.ruby-forum.com/u/Keyur_Parikh)\
**Post date:** [May 22, 2015, 7:32pm UTC](https://www.ruby-forum.com/t/gnu-radio-iir-filter-taps/242049/2 "2015-05-22T19:32:15Z")

</div>

Keyur Parikh [removed\_email\_address@domain.invalid] wrote:

> I’m in fm\_emph.py and can see the taps listed as
> 
> btaps = [b0, b1]  
> ataps = [1, a1]

This looks like “MATLAB form”. If so, the difference equation should be  
y(n) = b0_x(n) + b1_x(n) - a1\*y(n-1)

Mark

---

<div class="post-metadata">

**Author:** ![Keyur\_Parikh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/c2a13f/32.png) [@Keyur\_Parikh](https://www.ruby-forum.com/u/Keyur_Parikh)\
**Post date:** [May 22, 2015, 10:42pm UTC](https://www.ruby-forum.com/t/gnu-radio-iir-filter-taps/242049/3 "2015-05-22T22:42:07Z")

</div>

Mark,

Thanks for your reply. Quick question: the second term isn’t b1\*x(n-1)?

Keyur

---

<div class="post-metadata">

**Author:** ![Keyur\_Parikh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/c2a13f/32.png) [@Keyur\_Parikh](https://www.ruby-forum.com/u/Keyur_Parikh)\
**Post date:** [May 24, 2015, 12:07am UTC](https://www.ruby-forum.com/t/gnu-radio-iir-filter-taps/242049/4 "2015-05-24T00:07:59Z")

</div>

Hey, I wanted to post a correction to this for anyone who might come  
across  
this. I had previously read a discussion from Tom R. and some other  
GNU gods discussing the sign of the feedback taps needing to be negated;  
when working with the test bench data, that is still the case.

Normally the gain reported from the feedback filters is subtracted, as  
in  
the equation that Mark posted above. However, when looking at the actual  
function in iir\_filter.cc it turns out that the feedback coefficients  
are  
added.

acc = d\_fftaps[0] \* static\_cast\<gr\_complexd\>(input);  
for(i = 1; i \< n; i ++)  
acc += (d\_fftaps[i] \* static\_cast\<gr\_complexd\>(d\_prev\_input[latest\_n +  
i]));  
for(i = 1; i \< m; i ++)  
acc += (d\_fbtaps[i] \* static\_cast\<gr\_complexd\>(d\_prev\_output[latest\_m  
+  
i]));

This means you can either do one of two things when dealing with the  
feedback. You can either negate the value of the reported coefficient  
when  
using it in the equation above, or change the operation of the equation.  
Get your taps from fm\_emph.py as above, and utilize them in the  
following  
equation:

y(n) = b0_x(n) + b1_x(n-1) + a1\*y(n-1)

When doing this, the calculated values match what we printed to a file  
while under operation.

---

<div class="post-metadata">

**Author:** ![Keyur\_Parikh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/c2a13f/32.png) [@Keyur\_Parikh](https://www.ruby-forum.com/u/Keyur_Parikh)\
**Post date:** [May 22, 2015, 10:46pm UTC](https://www.ruby-forum.com/t/gnu-radio-iir-filter-taps/242049/5 "2015-05-22T22:46:13Z")

</div>

Sorry, you’re right, it should be b1\*x(n-1). --Mark
