How does an FIR filter work in GNU Radio

An FIR filter (Finite Impulse Response filter) in GNU Radio works by applying a weighted sum of a finite number of input samples to produce each output sample. Let’s break it down carefully.


1. The FIR Filter Concept


2. FIR Filters in GNU Radio

In GNU Radio, FIR filters are implemented with the gr::filter::fir_filter_XXX blocks. Common blocks include:

  • Low Pass Filter – allows frequencies below a cutoff.
  • High Pass Filter – passes frequencies above a cutoff.
  • Band Pass / Band Stop – passes or blocks a band of frequencies.
  • Custom FIR Filter – where you provide your own taps.

The filter block in GNU Radio has these key parameters:

ParameterMeaning
TapsArray of coefficients . This defines the filter response.
Decimation / InterpolationDownsample or upsample while filtering. Useful in multirate designs.
Input / Output typeFloat, complex, or integer.

3. How it Processes Data

  • The block maintains a buffer of the last samples.
  • For each new sample, it multiplies the buffered samples by the coefficients.
  • It sums the products to get one output sample.
  • In decimating FIR filters, it only outputs one sample every inputs (reducing the data rate).
  • In interpolating FIR filters, it inserts zeros between samples before applying the filter.

4. Designing FIR Coefficients

GNU Radio can generate taps for you using:

  • firdes modulefirdes.low_pass()firdes.high_pass(), etc.
  • Parameters for firdes:
    • gain – scaling factor
    • sample_rate – input sample rate
    • cutoff_freq – frequency to pass/block
    • transition_width – how sharp the filter is
    • window – e.g., Hamming, Blackman, Kaiser

Example in Python:

from gnuradio import filter

taps = filter.firdes.low_pass(
    gain=1,
    sampling_freq=32000,
    cutoff_freq=5000,
    transition_width=1000,
    window=filter.firdes.WIN_HAMMING
)

fir = filter.fir_filter_fff(1, taps)  # decimation=1, float input/output

This creates a low-pass FIR filter that you can connect in your GNU Radio flowgraph.


5. Visualization

If you want to see what the FIR filter does:

  • Connect the input to a Signal Source.
  • Connect the output to a QT GUI Frequency Sink.
  • You can observe the attenuation of unwanted frequencies and the preservation of desired ones.

✅ Key Takeaways:

  • FIR filters are non-recursive weighted sums of inputs.
  • In GNU Radio, the main parameter is the tap array, which defines the frequency response.
  • They are inherently stable and linear-phase (if designed symmetrically).
  • They can perform low-pass, high-pass, band-pass, band-stop, and custom filtering.

Here’s an ASCII-style illustration of how an FIR filter works in GNU Radio, with taps, delays, and summation:

Copy code

Input x[n] —>( )—+— y[n] —> Output

             |      |

             |      v

             |    [+]  <– summation of all tap products

             |

             +– h[0] * x[n]

             |

             +– Delay —> h[1] * x[n-1]

             |

             +– Delay —> h[2] * x[n-2]

             .

             .

             +– Delay —> h[N-1] * x[n-(N-1)]

Explanation:

Each input sample x[n] enters the filter.

The Delays hold the previous input samples.

Each sample is multiplied by a coefficient (tap) h[k].

The sum of all products produces the output y[n].

In GNU Radio, the FIR block does this automatically for each sample in real time.

By Admin

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.