     • date post

28-Nov-2015
• Category

## Documents

• view

17

1

Embed Size (px)

description

dsp

### Transcript of Lecture 21

• Digital Filter Design procedure: 1. Specify Discrete-Time domain filter requirements

(LP,HP,; p, s, ; p, s) 2. Use easiest (T=2) inverse bilinear transformation to

warp frequencies to Continuous-Time domain :

3. Design analog filter for (p, s, , p, s ) and obtain Ha(s)=BCT(s)/ACT(s)

4. Convert to Discrete-time domain, using bilinear transformation, to obtain the rational transfer function G(z)=BDT(z)/ADT (z)

)2(tan)2(tan sspp

1

1

1

1|)()(

z

zs

a sHzG

• Analog Filter Design procedure

1. Develop specifications of an analog lowpass filter prototype HLP(s) (choose P=1) from specifications of desired analog filter HD() using a frequency transformation s=F() (e.g. HP to LP: )

2. Design the prototype analog lowpass filter

3. Derive the transfer function HD() of the desired filter by inverse frequency transformation =F-1(s)

ss

pp

Point 3 of previous slide is realized by:

• )1(log20 10 pp

)(log20 10 ss

Peak passband ripple:

Minimum stopband attenuation

20101p

p

2010s

s

Peak ripple values p and s are obtained by inverting formulas:

Example: p=0.15 dB p=0.017121 s=41 dB s=0.0089125

• )1(log20 210max

Maximum passband attenuation

As

1log20 10

Minimum stopband attenuation

Inverting formulas:

110 102max

2010s

A

Example: max=0.5 dB

2=0.12202 s=40 dB A=100

• RECURSION:

Chebyshev polynomials and Chebyshev filters

Type 1 Chebyshev filter

Type 2 Chebyshev filter

• Exercise: Given the Chebyshev polynomial of order 5, i.e. T5(x), for -2 x 2: Plot

Plot

Plot

Plot

)(25 xT

)(5 xT

)(1.01/1 25 xT

)(

101/1

12

5 xT

(corresponding to squared amplitude of a Type1 filter)

(corresponding to squared amplitude of a Type2 filter)

x=-2:1/100:2;

%Chebyshev Type1 polynomial y=16*x.^5-20*x.^3+5*x;

plot(x,y);

pause

axis([-2 2 -2 2]);

pause

plot(x,y.^2);

axis([-2 2 -2 2]);

pause

%Chebyshev Type1 filter plot(x,1./(1+0.1*y.^2))

pause

%Chebyshev Type2 filter y2=16*x.^-5-20*x.^-3+5*x.^-1;

plot(x,1./(1+10*y2.^-2))

Try also using higher order polynomials

• )(5 xT

)(25 xT

)(1.01/1 25 xT

)(

101/1

12

5 xT

• Analog lowpass filter design It is realized in Matlab by one of the following (see help of single functions):

Butterworth: [N,Wn]=buttord(Wp,Ws,Rp,Rs,s);

[B,A]=butter(N,Wn,s);

Chebyshev Type 1: [N,Wn]=cheb1ord(Wp,Ws,Rp,Rs,s);

[B,A]=cheby1(N,Rp,Wn,s);

Chebyshev Type 2: [N,Wn]= cheb2ord(Wp,Ws,Rp,Rs,s);

[B,A]= cheby2(N,Rs,Wn,s);

Elliptic: [N,Wn]=ellipord(Wp,Ws,Rp,Rs,s);

[B,A]=ellip(N,Rp,Rs,Wn,s);

Wp,Ws in rad/s Rp decibels of peak-to-peak passband ripple Rs minimum stopband attenuation in dB

• Frequency transformations from LP analog filters in Matlab: [NUMT,DENT] = lp2lp(NUM,DEN,Wo)

transforms the analog lowpass filter prototype NUM(s)/DEN(s) with unity cutoff frequency of 1 rad/sec to a lowpass filter with cutoff frequency Wo (rad/sec) [NUMT,DENT] = lp2hp(NUM,DEN,Wo)

transforms the analog lowpass filter prototype with a cutoff angular frequency of 1 rad/s into highpass filters with desired cutoff angular frequency Wo [NUMT,DENT] = lp2bp(NUM,DEN,Wo,Bw)

transforms analog lowpass filter prototypes with a cutoff angular frequency of 1 rad/s into bandpass filters with desired center frequency Wo and bandwidth Bw [NUMT,DENT] = lp2bs(NUM,DEN,Wo,Bw)

transforms analog lowpass filter prototypes with a cutoff angular frequency of 1 rad/s into bandstop filters with desired center frequency Wo and bandwidth Bw

• Bilinear transformation in Matlab: [num,den]=bilinear(NUM,DEN,fs)

converts an s-domain transfer function Ha(s) given by coefficients NUM and DEN to a discrete time equivalent G(z) given by coefficients num and den Row vectors NUM and DEN specify the coefficients of the numerator and denominator, respectively, in descending powers of s fs is the sampling frequency in hertz (fs=0.5 for the simplified condition T=2) bilinear returns the coefficients of the discrete-time equivalent filter in row vectors num and den in descending powers of z (ascending powers of z1)

• Design a digital filter according to the following requirements: Lowpass, 1 dB ripple in passband, p=0.4, stopband attenuation 40 dB at s=0.5 and attenuation increasing with frequency.

Passband ripples, stopband monotonic Chebyshev1 We assume T=2 simplifies bilinear transformation Warp band-edges to continuous-time domain:

ss

p

p

/0.125.0tan2

tan

/7265.02.0tan2

tan

Magnitude specifications: 1 dB passband ripple

5087.08913.0101

1 20/12

40 dB stopband attenuation

10001.0101 20/40 AA

09.7

cosh

1cosh

1

21

p

s

A

N

Required Chebyshev1 filter order:

i.e. needs N=8

Filter design example

• Filter design example (continued)

Design analog filter and then map it to discrete time domain: N=8;

Wp=0.7265;

pbripple=1.0;

[B,A]=cheby1(N,pbripple,Wp,s);

[b,a]=bilinear(B,A,0.5); %we assumed T=2

[H,W]=freqs(B,A,0:1/100:2);

plot(W,20*log10(abs(H)));

axis([0 2 -60 5]);

[HD,w]=freqz(b,a);

plot(w/pi,20*log10(abs(HD)));

axis([0 1 -60 5]);

)( jH Analog filter

/

)( jeHD Digital filter

• Design of Highpass IIR Digital Filter Chebyshev Type 1 Specifications: passband edge: 700 Hz stopband edge: 500 Hz passband ripple: 1dB minimum stopband attenuation: 32 dB sampling frequency: 2kHz

Fp=700;

Fs=500;

alpha_p=1;

alpha_s=32;

FT=2000;

%Normalized angular bandedge (in rad/sample) wp=2*pi*Fp/FT;

ws=2*pi*Fs/FT;

%Assuming T=2 in inverse bilinear transformation Wp=tan(wp/2); %in rad/s Ws=tan(ws/2);

Wp_lp=1; %Normalized passband edge Ws_lp=Wp_lp*Wp/Ws; %Frequency transformation HP to LP

Band-edges of the discrete-time HP filter

Band-edges of the continuous-time HP filter

Band-edges of the continuous-time LP prototype

• %find filter order and pass-band edge frequency [N,Wn]=cheb1ord(1,Ws_lp,alpha_p,alpha_s,'s');

%Design the LP prototype [B,A]=cheby1(N,alpha_p,Wn,'s');

%Apply frequency transformation LP to HP [BT,AT]=lp2hp(B,A,Wp);

%Apply bilinear transformation to get the discrete-time filter (again T=2) [num,den]=bilinear(BT,AT,0.5);

%Plot the amplitude of obtained transfer function [H,w]=freqz(num,den);

plot(w/pi,20*log10(abs(H)));

axis([0 1 -50 5]); %Zoom )(

jeH

/

• Design of Highpass IIR Digital Filter - Elliptic Specifications: passband edge: 250 Hz stopband edge: 200 Hz passband ripple: 1dB minimum stopband attenuation: 80 dB sampling frequency: 1kHz

Fp=250;

Fs=200;

alpha_p=1;

alpha_s=80;

FT=1000;

wp=2*pi*Fp/FT;

ws=2*pi*Fs/FT;

Wp=tan(wp/2);

Ws=tan(ws/2);

Wp_lp=1;

Ws_lp=Wp_lp*Wp/Ws;

[N,Wn]=ellipord(1,Ws_lp,alpha_p,alpha_s,'s');

[B,A]=ellip(N,alpha_p,alpha_s,Wn,'s');

[BT,AT]=lp2hp(B,A,Wp);

[num,den]=bilinear(BT,AT,0.5);

[H,w]=freqz(num,den);

plot(w/pi,20*log10(abs(H)));

• [N,Wn]=ellipord(wp/pi,ws/pi,alpha_p,alpha_s);

[num1,den1]=ellip(N,alpha_p,alpha_s,Wn,high);

[H1,w]=freqz(num1,den1);

plot(w/pi,20*log10(abs(H1)),'r');

The design procedure of the previous slide can be realized automatically by Matlab with a direct digital design:

Use of ellipord and ellip directly in the discrete time domain!

Matlab is applying bilinear transformation and frequency transformation for us.

• Digital lowpass filter design It is directly realized in Matlab by one of the following (see help of single functions):

Butterworth: [N,Wn]=buttord(Wp,Ws,Rp,Rs);

[b,a]=butter(N,Wn);

Chebyshev Type 1: [N,Wn]=cheb1ord(Wp,Ws,Rp,Rs);

[b,a]=cheby1(N,Rp,Wn);

Chebyshev Type 2: [N,Wn]= cheb2ord(Wp,Ws,Rp,Rs);

[b,a]= cheby2(N,Rs,Wn);

Elliptic: [N,Wn]=ellipord(Wp,Ws,Rp,Rs);

[b,a]=ellip(N,Rp,Rs,Wn);

Wp,Ws normalized frequencies in the range 01. (1 corresponds to half the sampling rate) Rp decibels of peak-to-peak passband ripple Rs minimum stopband attenuation in dB

• Design of Butterworth digital filters using the function butter : Lowpass: [b,a]=butter(N,Wn,low);

Highpass: [b,a]=butter(N,Wn,high);

Bandpass: [b,a]=butter(N,[Wn1,Wn2]); %two passband edge frequencies Bandstop: [b,a]=butter(N,[Wn1,Wn2],stop); %two stopband edge frequencies Note: bandpass and bandstop filters will have order 2*N Wn are normalized frequencies in the range 01 Similar syntax holds for cheby1, cheby2, ellip (see help of these functions).

• Exercise 1: Design digital Butterworth filters with the following specifications: Order N=5; Sampling frequency fs=8000 Hz 1. Lowpass, cutoff frequency= 1000 Hz 2. Highpass, cutoff frequency = 2000 Hz 3. Bandpass, pass band = [1000, 2000] Hz 4. Bandstop, stop band = [1000, 2000] Hz Lowpass filter using directly digital design: fs=8000;

N=5;

fc=1000;

[b,a]=butter(N,fc/(fs/2),low);

[H,w]=freqz(b,a);

subplot(2,2,1);

plot(w/pi*fs/2,abs(H));

xla