Skip to content

Second-Order Filter ​

Second-order low-pass, high-pass, band-pass or notch filter with natural frequency f0, damping ratio ζ and gain K. Discretized with the bilinear (Tustin) transform prewarped at f0, so the corner sits exactly at f0 and lightly damped filters stay stable at any time step. f0 must be below half the sample rate (1/(2·Δt)); a higher value is pulled just below it with a logged error. The filter starts in steady state for its first input.

Category: Continuous

Overview ​

The Second-Order Filter is a configurable biquad: one block that can be a low-pass, high-pass, band-pass or notch filter. You set the natural frequency f0, the damping ratio ζ and the passband gain K.

Typical uses:

  • Low-pass: anti-aliasing ahead of a sampled controller, or smoothing a measured quantity.
  • Notch: removing a known ripple from a measurement, such as the 100 / 120 Hz ripple on a single-phase power signal or the 2nd harmonic on a DC link.
  • Band-pass: pulling out one frequency, for example to track an oscillation mode.

Transfer functions ​

All four types share the denominator D(s)=s2+2ζω0s+ω02, with ω0=2πf0:

TypeH(s)Gain at DCGain at f0Gain at high frequency
Low-passKω02/D(s)KK/2ζ0
High-passKs2/D(s)0K/2ζK
Band-passK⋅2ζω0s/D(s)0K0
NotchK(s2+ω02)/D(s)K0K

For a low-pass or high-pass, ζ=0.707 gives the maximally flat (Butterworth) response. Smaller values give a resonant peak at f0. For a band-pass or notch, ζ sets the width: the band between the −3 dB points is 2ζf0 wide, so a smaller ζ gives a narrower band or notch.

Discretization ​

This block is the one exception to the forward-Euler rule of the control domain (see Chapter 17). Forward Euler on a lightly damped second-order section is stable only when ω0Δt<2ζ, which a sharp notch would break at ordinary time steps. The filter instead uses the bilinear (Tustin) transform with prewarping:

s→c1−z−11+z−1,c=ω0tan⁡(ω0Δt/2).

The bilinear transform is stable at any time step. Prewarping makes the discrete response equal the continuous one exactly at f0, so the corner of a low-pass and the null of a notch sit where you set them. Away from f0 the frequency axis is slightly compressed. The effect is negligible well below the sample rate and grows as you approach it.

The coefficients are computed once, on the first step. The filter then runs as a direct-form-II-transposed biquad with two state values.

Limits and start-up ​

  • f0 must lie below half the sample rate, 1/(2Δt). A higher value is pulled to just below that limit, with an error in the run log.
  • A negative ζ would be unstable, so its magnitude is used, with an error in the run log.
  • The filter starts in steady state for its first input. Feed it a constant and the output is that constant times the DC gain from the first sample: K for a low-pass or notch, 0 for a high-pass or band-pass. There is no start-up transient.

Ports ​

PortKindSignalNotes
inControl inputReal
outControl outputReal

Parameters ​

ParameterTypeDefaultUnitsDescriptionID
TypeChoice: Low-pass / High-pass / Band-pass / NotchLow-pass—Low-pass = Kω0²/D(s). High-pass = Ks²/D(s). Band-pass = K·2ζω0·s/D(s), gain K at f0. Notch = K(s²+ω0²)/D(s). D(s) = s² + 2ζω0·s + ω0².type
f0Number50Hz (also rad/s)Natural (corner or centre) frequency. Must be below half the sample rate.f0
ζNumber0.707—Damping ratio. 0.707 gives a maximally flat low-pass; smaller values give a resonant peak (low-pass, high-pass) or a narrower band (band-pass, notch).zeta
KNumber1—Gain in the passband.K

In the course ​