Post Go back to editing

# Simple example of FIR filter

I received a question about how to implement an FIR filter. Here's a very simple example.

NOTE: Most images are taken from Wikipedia's article on FIR filters: http://en.wikipedia.org/wiki/Finite_impulse_response

Here's what an FIR filter architecture looks like. The bn values are the multipliers for each filter tap.

Here's an example of a moving average filter, which uses three taps, each of which has a coefficient of 1/3.

The expected frequency response is shown here. The derivation can be found on Wikipedia's article.

I implemented a simple stereo FIR in SigmaStudio. I included the Stimulus and Probe cells so we could see the frequency response.

In the Table Editor, I entered in 0.33333 for each coefficient. It's probably better to use as many decimal places as possible for the best precision, but this is just a basic example.

By clicking the Probe and Stimulus windows, we can see that the frequency response matches the theoretical response.

SigmaStudio does not have its own FIR coefficient generation tool, but if you generate coefficients in another piece of software, just enter them directly into the Table Editor in SigmaStudio to realize that filter on the SigmaDSP hardware.

FIR_Example.dspproj.zip

## Top Replies

• Hi Brett, very nice tutorial.

I've an issue. I need to implement FIR filter to achive an optimal filtering based on an inverse frequency response of a loudspeaker. I compute filter coefficients with Matlab, with fir2 function. Some coefficients I get, are greater than DSP limit number representation (16.0) and SigmaStudio gives me an error, obviously. I wonder what should be a solution to this issue.
Thanks to all, bye

Leonardo.

• I'm not sure if there is an easy way to get around the limits of number representation. Anything above 15.99999 will saturate, which effectively breaks the filter response.

I will forward this to the software team to see if they have any ideas for a workaround.

• Hi leonxp,

Here is the response from one member of the software team:

Option 1, use Matlab fixed point toolbox:

Or if they don't have that available normalize, see this discussion:

http://www.dsprelated.com/showmessage/118528/1.php

• Thanks Brett!