exercise316l.mws

Supplement to my lectures on Linear Systems

R. Brigola, Georg-Simon-Ohm-Hochschule Nürnberg

Solution for the Exercise on the Design a Specified Butterworth Lowpass Filter

As an application example for a LTI-System design a Butterworth Filter   (S. Butterworth, 1930):

At first, calculate the necessary order of the filter and the cutoff  angular frequency Omega   according to its specification

as we have done in classroom.

( Reference for example:  R. Brigola   Fourieranalysis, Distributionen und Anwendungen, Vieweg, pg. 208 )

Specification:

To be concrete, calculate H for K=1,  passband edge at  3 kHz, stopband edge at 5 kHz, minimal passband gain 0.9, maximal stopband gain 0.1.

 

Then,  calculate the n zeroes   z[0] , ... , z[n-1]     with negative real parts of

                                      Q(z) = 1+(-1)^n*(z/Omega)^(2*n)  ,   i.e .      Q(z) = 1+(z/(j*Omega))^(2*n)    

Give the resulting frequency characteristics H of the Butterworth filter of order n and angular cutoff  frequency   Omega   (bandwidth).

Plot the frequency characteristics, the phase shift and delay of the filter.

H is given by

                                      H(omega) = K*Omega^n/product(I*omega-z[k],k = 0 .. n-1)

 

Solution:

At first calculate the necessary order of the filter and its cutoff frequency from the given specification

       

>    restart:

>    K:=1.0;

K := 1.0

>    H1:=0.9;

H1 := .9

>    H2:=0.1;

H2 := .1

>    w1:=3000*(2*Pi);

w1 := 6000*Pi

>    w2:=5000*(2*Pi);

w2 := 10000*Pi

>    ord:=evalf(ln((K^2/H1^2-1)/(K^2/H2^2-1))/(2*ln(w1/w2)));

ord := 5.917019181

>    n:=floor(ord)+1; # Order of the necessary Butterworth Filter

n := 6

>    Omega:=sqrt(w1*exp(-ln(K^2/H1^2-1)/(2*n))*w2*exp(-ln(K^2/H2^2-1)/(2*n)));

Omega := 6794.585498*Pi

>    evalf(Omega/(2*Pi));  # Cutoff frequency in Hz

3397.292749

>   

   H can be represented with the Butterworth polynomial    P(s) = product(s-z[k]/Omega,k = 0 .. n-1)    in the form   

                                                             H(omega) = K/P(I*omega/Omega)               

  

   The zeroes   z[k]   of   Q   with negative real parts  are easily calculated by hand and give the zeroes of   P  

>    zero:=array(1..n);

zero := array(1 .. 6,[])

 

  The zeroes of P are known to be  ( you can compare them with the Maple solutions of  Q(z)=0. Extract the zeroes with negative real part )

>    for k from 1 to n do

>    zero[k]:=evalc(exp(I*((2*k-1)*Pi/(2*n)+Pi/2)));

>    end do;

zero[1] := -cos(5/12*Pi)+sin(5/12*Pi)*I

zero[2] := -1/2*2^(1/2)+1/2*I*2^(1/2)

zero[3] := -cos(1/12*Pi)+sin(1/12*Pi)*I

zero[4] := -cos(1/12*Pi)-I*sin(1/12*Pi)

zero[5] := -1/2*2^(1/2)-1/2*I*2^(1/2)

zero[6] := -cos(5/12*Pi)-I*sin(5/12*Pi)

    Therefore the polynomial P is given by

>    P:=unapply(simplify(evalf(expand(product((s-zero[m]),m=1..n)))),s);

P := proc (s) options operator, arrow; 9.141620172*s^3+7.464101613*s^4+3.863703305*s^5+s^6+7.464101614*s^2+1.+3.863703306*s end proc

>   

 

 Now the frequency characteristics of the Butterworth lowpass is

>    H:=unapply(K/P(I*omega/Omega),omega);

H := proc (omega) options operator, arrow; 1.0/(-.2914300088e-10*I*omega^3/Pi^3+.3502076850e-14*omega^4/Pi^4+.2668019077e-18*I*omega^5/Pi^5-.1016300627e-22*omega^6/Pi^6-.1616782530e-6*omega^2/Pi^2+1.+....

>   

>    plot(abs(H(t*Omega)),t=0..2,thickness=3,labels=["cutoff frequency scaled to 1",gain]); # plot the filter gain

[Maple Plot]

>    plot(abs(H(t*(2*Pi))),t=0..9000,colour=blue,thickness=3,labels=["frequency in Hz",gain]); # plot the filter gain

[Maple Plot]

  The gain can also be represented as

  

>    H_abs:=unapply(K/sqrt(1+(w/evalf(Omega))^(2*n)),w);

H_abs := proc (w) options operator, arrow; 1.0/(1+.1117495833e-51*w^12)^(1/2) end proc

>    plot(H_abs(t*Omega),t=0..2,thickness=3,labels=["cutoff frequency scaled to 1",gain]);

[Maple Plot]

 

  The frequency response can also be represented as a curve in the complex plane as follows.

 Observe, that this is a qualitative graphics  only unless you compute complex values for certain frequencies,

 to see where you are on the curve for these.

>    with(plots):complexplot(H(w),w=0..20*Omega,thickness=3);

[Maple Plot]

  We zoom the curve for high frequencies

>    complexplot(H(w),w=15*Omega..30*Omega,thickness=3);

[Maple Plot]

   This shows approximately, that the curve near the origin crosses again the imaginary axis and approximates the origin from the left lower quadrant.

  A mathematically well-educated engineer can see from that behavier of the curve - it begins for w=0 on the positive real axis,

  goes in the mathematically negative direction to the origin, while crossing exactly as many quadrants of the complex plane as the filter order n (here n=6) indicates.

  These facts tell that engineer, that the filter is stable (no resonance frequencies exist, a bounded input generates also a bounded output, it has the so-called BIBO-stability)      

   Remark for your future: A filter with rational frequency response is unstable, when the denominator polynomial has coefficients less or equal to zero !   

   Filters with frequency responses as above with respect to their start point for w=0, their orientation and number of quadrant crossings are stable.

  Phase shift of the filter

>    assume(w,real);

>    phi:=w->-sum(argument(I*w-Omega*zero[m]),m=1..n);

phi := proc (w) options operator, arrow; -sum(argument(w*I-Omega*zero[m]),m = 1 .. n) end proc

>    plot(phi(t*Omega),t=0..2,colour=blue,thickness=3,labels=["cutoff frequency scaled to 1","Phase shift"]);

[Maple Plot]

>   

    Group delay of the filter in seconds, you see that approximately  the filter has only the superb delay of only 0.2 ms

>    delay:=w->-diff(phi(w*Omega),w); # observe, that the chain rule is used here, when the derivative is computed

delay := proc (w) options operator, arrow; -diff(phi(w*Omega),w) end proc

>    plot(delay(w)/Omega,w=0..2,colour=red,thickness=3,labels=["cutoff frequency scaled to 1","Group delay in s"]);

[Maple Plot]

>   

  We observe that for frequencies < (1/2 * cutoff frequency) the gain and the delay are almost independent of the frequency.

 Thus that filter provides high-fidelity transmission for an input with a bandwidth < Omega/2.

   Let's test a few values

>    abs(H(Omega));

.7071067819

>    20*log10(%); # damping in dB at the cutoff frequency

-3.010299948

>    abs(H(w1));

.9035696218

>    abs(H(w2));

.9792318835e-1

>    20*log10(%); # damping in dB at the stopband edge

-20.18228908

   Let's calculate a table of  the Butterworth polynomials P  of order 2 to 10 as it can be found in references on circuit synthesis

>    restart:

>    for n from 2 to 10 do

>    for k from 1 to n do

>    zero[k]:=evalc(exp(I*((2*k-1)*Pi/(2*n)+Pi/2))):

>    end do;

>    print('Order'=n);

>    P:=simplify(evalf(expand(product((s-zero[m]),m=1..n)))):

>    end do;

Order = 2

P := s^2+1.414213562*s+1.

Order = 3

P := s^3+2.*s^2+1.+2.*s

Order = 4

P := 3.414213564*s^2+1.+2.613125930*s^3+2.613125930*s+s^4

Order = 5

P := 3.236067976*s+5.236067974*s^2+5.236067975*s^3+3.236067977*s^4+1.+s^5

Order = 6

P := 3.863703306*s+7.464101614*s^2+9.141620173*s^3+7.464101613*s^4+1.+3.863703305*s^5+s^6

Order = 7

P := 4.493959205*s+10.09783467*s^2+14.59179387*s^3+14.59179388*s^4+10.09783468*s^5+4.493959207*s^6+s^7+.9999999998

Order = 8

P := 5.125830894*s+13.13707118*s^2+21.84615096*s^3+25.68835592*s^4+1.+21.84615101*s^5+13.13707118*s^6+5.125830896*s^7+s^8

Order = 9

P := 1.+5.758770482*s+16.58171874*s^2+31.16343748*s^3+41.98638575*s^4+41.98638572*s^5+31.16343746*s^6+16.58171873*s^7+s^9+5.758770483*s^8

Order = 10

P := 1.+6.392453227*s+20.43172906*s^2+42.80206105*s^3+64.88239629*s^4+s^10+74.23342922*s^5+64.88239629*s^6+42.80206105*s^7+6.392453220*s^9+20.43172908*s^8

>   

Learn more on filters and how filters can be realized by circuits. See for example

Wikipedia: Butterworth lowpass filters