Wednesday, February 6, 2013

Design Equations for Butterworth Lowpass Filters


% Follows Allred, Digital Filters for Everyone, Creative Arts & Sciences House, 2010, pp. 49 - 52

alpha = -2 * (cos(5 * pi / 8) + cos(7 * pi / 8));
beta = 2 * (1 + 2 * cos(5 * pi / 8) * cos(7 * pi / 8));
gamma = tan(pi * fc / Fs);

% First order
D = gamma+1;
b0p = gamma;
b1p = b0p;
a1p = gamma-1
B1 = [b0p b1p] ./ D;
A1 = [1 a1p / D];

% Second order
D=gamma^2+sqrt(2)*gamma+1;
b0p = gamma^2;
b1p = 2 * b0p;
b2p = b0p;
a1p = 2*(gamma^2-1);
a2p = gamma^2-sqrt(2)*gamma+1;
B2 = [b0p b1p b2p] ./ D;
A2 = [1 [a1p a2p] ./ D];

% Third order
D = gamma^3+2*gamma^2+2*gamma+1;
b0p = gamma^3;
b1p = 3 * b0p;
b2p = 3 * b0p;
b3p = b0p;
a1p = 3*gamma^3+2*gamma^2-2*gamma-3;
a2p = 3*gamma^3-2*gamma^2-2*gamma+3;
a3p = gamma^3-2*gamma^2+2*gamma-1;

B3 = [ b0p b1p b2p b3p] ./ D;
A3 = [1 [a1p a2p a3p] ./ D];

% Fourth order
D = gamma^4+alpha*gamma^3+beta*gamma^2+alpha*gamma+1;
b0p = gamma^4;
b1p = 4 * b0p;
b2p = 6 * b0p;
b3p = 4 * b0p;
b4p = b0p;
a1p = 2*(2*gamma^4+alpha*gamma^3-alpha*gamma-2);
a2p = 2*(3*gamma^4-beta*gamma^2+3);
a3p = 2*(2*gamma^4-alpha*gamma^3+alpha*gamma-2);
a4p = gamma^4-alpha*gamma^3+beta*gamma^2-alpha*gamma+1;

B4 = [b0p b1p b2p b3p b4p] ./ D;
A4 = [1 [a1p a2p a3p a4p] ./ D];

No comments:

Post a Comment