14 Software Examples
14 – 6
14.4
CASCADED BIQUAD IIR FILTER
A second-order biquad IIR filter section is represented by the transfer
function (in the z-domain):
H(z) = Y(z)/X(z) = ( B
0
+ B
1
z
–1
+ B
2
z
–2
)/( 1 + A
1
z
–1
+ A
2
z
–2
)
where A
1
, A
2
, B
0
, B
1
and B
2
are coefficients that determine the desired
impulse response of the system H(z). The corresponding difference
equation for a biquad section is:
Y(n) = B
0
X(n) + B
1
X(n–1) + B
2
X(n–2) – A
1
Y(n–1) – A
2
Y(n–2)
Higher-order filters can be obtained by cascading several biquad sections
with appropriate coefficients. The biquad sections can be scaled separately
and then cascaded in order to minimize the coefficient quantization and
the recursive accumulation errors.
A subroutine that implements a high-order filter is shown in Listing 14.2.
A circular buffer in program memory contains the scaled biquad
coefficients. These coefficients are stored in the order: B
2
, B
1
, B
0
, A
2
and A
1
for each biquad. The individual biquad coefficient groups must be stored
in the order that the biquads are cascaded.
.MODULE
biquad_sub;
{
Nth order cascaded biquad filter subroutine
Calling Parameters:
SR1=input X(n)
I0 —> delay line buffer for X(n-2), X(n-1),
Y(n-2), Y(n-1)
L0 = 0
I1 —> scaling factors for each biquad section
L1 = 0 (in the case of a single biquad)
L1 = number of biquad sections
(for multiple biquads)
I4 —> scaled biquad coefficients
L4 = 5 x [number of biquads]
M0, M4 = 1
M1 = -3
M2 = 1 (in the case of multiple biquads)
M2 = 0 (in the case of a single biquad)