Implement ButterworthLowPassFilter #838
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements the ButterworthLowPassFilter. The filter is described by the following transfer function
where$\omega_c$ is the cutoff frequency and $N$ is the order of the filter and $s$ is the Laplace variable.
To compute the coefficient of the filter we split the problem in three steps:
Compute the transfer function of the continuous system
What follows is taken from Passive and Active Network Analysis and Synthesis, Aram Budak, Houghton Mifflin, 1974 and from https://dsp.stackexchange.com/questions/79498/butterworth-filter-poles$\omega_c$ in the s-plane. The poles are given by
The poles of the Butterworth filter are evenly spaced on a circle of radius
where$k = 0, 1, \ldots, N-1$ and $j$ is the imaginary unit. By construction, the Butterworth filter does not have zeros. The gain of the filter is given by
Compute the transfer function of the discrete system
As mentioned before, the transfer function of the discrete system is obtained by the bilinear transform
The poles of the discrete system are obtained by substituting the poles of the continuous system in the bilinear transformation as explained in https://it.mathworks.com/help/signal/ref/bilinear.html The poles of the discrete system are given by
where$p_k$ are the poles of the continuous system, $\delta t$ is the sampling time and $k = 0, 1, \ldots, N-1$ . All the zeros of the continuous system are mapped to -1. Finally, the gain of the discrete system is given by
Compute the coefficients of the discrete system
Once we have the poles and the gain of the discrete system we can compute the coefficients of the
filter by applying the Vieta's formulas. The transfer function of the discrete system is given by
Once the numerator and the denominator are computed we can easily antitransform the transfer function to obtain the coefficients of the filter as
where$x[k]$ is the input of the filter and $y[k]$ is the output of the filter.