DMC, Inc.
DSP low-pass IIR Filter

DSP Low-Pass IIR Filter Calculator 

There are countless DSP (Digital Signal Processing) techniques out there, and many of them can look intimidating at first glance. In this calculator, we’ll keep things simple and focus on the most practical and widely used case in embedded firmware: a first-order low-pass filter, with a gain of 1. This filter is similar to the classic RC (resistor-capacitor) analog filter and is sometimes called a digital RC filter. 

Calculate Filter Coefficient

The first step to implement this filter is to calculate the filter coefficient, which depends on the sample rate and desired cut-off frequency. 

The formula to calculate this coefficient is from Wikipediafilter coefficient formula

Where fc from a formula is the filter cut-off frequency, and delta t formula is the sampling period (but it is easier to enter it as a Sampling Frequency, Fs). 

First Order IIR Low‑Pass Filter Coefficient Calculator

Enter samppling frequency (Fs, Hz):
Coeficient a:
Coeficient b (for reference, b = 1 − a):
Eqvivalent RC filter time constant (for reference):

Filter Implementation

Knowing the filter coefficient  a, it is pretty easy to implement our filter: 

filter_output = filter_output + a * (new_sample - filter_output) 

Where: 

  • filter_output is a variable that must survive between calls, it can be a static variable, something global, etc.  
  • a is a coefficient we just calculated above 
  • new_sample is a new ADC sample 

The filter calculations should be called on every sample, so it may be a good idea to implement them inside the ADC interrupt. However, you can also run the filter on an array of values—whatever works best for your architecture. 

Don’t forget that the filter calculations should generally use real (float) values! 

Learn more about DMC’s Embedded Development and Programming services and contact us for your next project!