Guessing at the discretization, of the Sallen-Key Filter, with Q-Multiplier.

One concept that exists in modern digital signal processing is, that a simple algorithm can often be written, to perform what old-fashioned, analog filters were able to do.

But then, one place where I find lacking progress – at least, where I can find the information posted publicly – is, about how to discretize slightly more complicated analog filters. Specifically, if one wants to design 2nd-order low-pass or high-pass filters, one approach which is often recommended is, just to chain the primitive low-pass or high-pass filters. The problem with that is, the highly damped frequency-response curve that follows, which is evident, in the attenuated voltage gain, at the cutoff frequency itself.

In analog circuitry, a solution to this problem exists in the “Sallen-Key Filter“, which naturally has a gain at the corner frequency of (-6db), which would also result, if two primitive filters were simply chained. But beyond that, the analog filter can be given (positive) feedback gain, in order to increase its Q-factor.

I set out to write some pseudo-code, for how such a filter could also be converted into algorithms…

 


Second-Order...

LP:
for i from 1 to n
    Y[i] := ( k * Y[i-1] ) + ((1 - k) * X[i]) + Feedback[i-1]
    Z[i] := ( k * Z[i-1] ) + ((1 - k) * Y[i])
    Feedback[i] := (Z[i] - Z[i-1]) * k * α
    (output Z[i])

BP:
for i from 1 to n
    Y[i] := ( k * Y[i-1] ) + ((1 - k) * X[i]) + Feedback[i-1]
    Z[i] := ( k * (Z[i-1] + Y[i] - Y[i-1]) )
    Feedback[i] := Z[i] * (1 - k) * α
    (output Z[i])

HP:
for i from 1 to n
    Y[i] := ( k * (Y[i-1] + X[i] - X[i-1]) ) + Feedback[i-1]
    Z[i] := ( k * (Z[i-1] + Y[i] - Y[i-1]) )
    Feedback[i] := Z[i] * (1 - k) * α
    (output Z[i])


Where:

k is the constant that defines the corner frequency via ω, And
α is the constant that peaks the Q-factor.

ω = 2 * sin(π * F0 / h)
k = 1 / (1 + ω), F0 < (h / 4)

h   Is the sample-rate.
F0  Is the corner frequency.

To achieve a Q-factor (Q):
α = (2 + (sin^2(π * F0 / h) * 2) - (1 / Q))
'Damping Factor' = (ζ) = 1 / (2 * Q)


Critical Damping:
ζ = 1 / sqrt(2)
(...)
Q = 1 / sqrt(2)

 

(Algorithm Revised 2/08/2021, 23h40. )

(Computation of parameters Revised 2/09/2021, 2h15. )

 

(Updated 2/10/2021, 18h25… )

Continue reading Guessing at the discretization, of the Sallen-Key Filter, with Q-Multiplier.