Digital Filters

This page is work in progress. More practical calculations for digital filters will be added.

First order IIR filter

In my book “Embedded Software for the IoT”, there is a chapter on Statistical Process Control. This introduces a simple-filter called EWMA – Exponentially Weighted Moving Average. It is the simplest possible low-pass IIR Filter:

y[n] = \alpha* x[n] + (1-\alpha)*y[n-1]

In other words, this filter has an output that corresponds to a fraction (less than 1) of the input plus 1 minus the same fraction times the previous output. If \alpha is close to one, the filter has a short impulse-response, and as \alpha goes towards 0 the impulse-response goes towards infinity.

Typically, filters are designed from their “3 dB cutoff frequency” – f_c . If we first introduce an intermediate variable – \beta – we can calculate the constant \alpha based on the cutoff frequency and the sampling frequency f_s .

\beta = cos(2\pi f_c/f_s)

\alpha = \beta-1+\sqrt{\beta^2-4\beta+3}

The above is easily done in Excel. You can see more on this filter here.