Digital Filters
Contents
Tags :
A nice open access book on digital filter is accessible here: https://ccrma.stanford.edu/~jos/filters/filters.html
Analog to Digital Filter
In order to convert an analog filter (Laplace domain) to a digital filter (z-domain), the c2d command can be used (doc).
Let’s define a simple first order low pass filter in the Laplace domain:
|
|
To obtain the equivalent digital filter:
|
|
There are several methods to go from the analog to the digital domain, Tustin is the one I use the most as it ensures the stability of the digital filter provided that the analog filter is stable.
Bilinear transform
The bilinear transform also known as the Tustin’s method (see the wikipedia page) is used to convert a continuous-time system representations to discrete-time.
It uses the fact that \(z = e^{sT} \approx \frac{1 + sT/2}{1-sT/2}\).
To go from the Laplace domain to the z-domain, we just have to use the following approximation:
\begin{equation} \boxed{s \approx \frac{2}{T_s} \frac{z - 1} {z + 1} = \frac{2}{T_s}\frac{1 - z^{-1}}{1 + z^{-1}}} \end{equation}
Standard Digital Filters
First order low pass filter
\begin{equation} G(s) = \frac{1}{1 + s/\omega_0} \end{equation}
Using the bilinear transform, we obtain:
\begin{equation} G(z) = \frac{a(1 + z^{-1})}{1 + b z^{-1}} \end{equation}
with:
\begin{align} a &= \frac{2}{T_s\omega_0} + 1\\ b &= \frac{2}{T_s\omega_0} - 1 \end{align}
If we want to compute how the filter output \(y[n]\) depends on previous output \(y[n-1]\), previous input \(x[n-1]\) and current input \(x[n]\) we can write:
\begin{equation} y[n] = G(z) x[n] \end{equation}
By developing the relation and using the fact that \(z^{-1} x[n] = x[n-1]\), we obtain:
\begin{align} y[n] &= a (x[n] + x[n-1]) + b y[n-1] \\ &= \left( \frac{2}{T_s \omega_0} + 1 \right) (x[n] + x[n-1]) + \left(\frac{2}{T_s\omega_0} - 1\right) y[n-1] \end{align}