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 Wikipedia: 
Where 

First Order IIR Low‑Pass Filter Coefficient Calculator
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!







