zp = baseFilter(analogFilter, order, A_ripple, normalized);
This function constructs a ZerosAndPoles transfer function description of low pass filters with a cut-off angular frequency of one rad/s and a gain of one. Filters returned by this function are the starting point to construct other filters by transformation of the filter transfer function:
zp(p) = 1 / ( product( p + a[i] ) * product(p^2 + b[i]*p + a[i]) )
using the following rules:
Desired filter | Transformation |
---|---|
High pass filter | replace "p" by "1/p" |
Band pass filter |
replace "p" by "(p + 1/p)/w_band" (w_band = (f_max - f_min)/sqrt(f_min*f_max)) |
Stop pass filter |
replace "p" by "w_band/(p + 1/p)" (w_band = (f_max - f_min)/sqrt(f_min*f_max)) |
Filter with cut-off angular frequency w_cut | replace "p" by "p/w_cut" |
For more details see also [Tietze2002], pp. 815-852.
// Generate a Butterworth high pass base filter of order 3 import ZP = Modelica_LinearSystems2.ZerosAndPoles; import Modelica_LinearSystems2.Types; ZP zp_filter; algorithm zp_filter = ZP.Internal.baseFilter(Types.AnalogFilter.Butterworth, order = 3); // zp_filter = 1 / ( (p + 1)*(p^2 + p + 1) )
encapsulated function baseFilter import Modelica; import Modelica.Math; import Modelica.Utilities.Streams; import Modelica_LinearSystems2.Utilities.Types; import Modelica_LinearSystems2.ZerosAndPoles; input Types.AnalogFilter analogFilter = Types.AnalogFilter.CriticalDamping "Analog filter characteristics (CriticalDamping/Bessel/Butterworth/Chebyshev)"; input Integer order(min = 1) = 2 "Order of filter"; input Real A_ripple(unit = "dB") = 0.5 "Pass band ripple (only for Chebyshev filter)"; input Boolean normalized = true "True, if amplitude at f_cut = -3db, otherwise unmodified filter"; output ZerosAndPoles filter(redeclare Real n1[0], redeclare Real n2[0, 2], redeclare Real d1[if analogFilter == Types.AnalogFilter.CriticalDamping then order else mod(order, 2)], redeclare Real d2[if analogFilter == Types.AnalogFilter.CriticalDamping then 0 else integer(order/2), 2]) "Filter transfer function"; end baseFilter;