0% found this document useful (0 votes)
82 views11 pages

University of Engineering & Technology Lahore: Theory

This document describes designing a Chebyshev digital IIR filter in MATLAB. It provides the theory behind Chebyshev filters and discusses their design. The document contains two assignments: 1. Design a lowpass Chebyshev-1 analog filter with a passband cutoff of 0.2π, passband ripple of 1dB, stopband cutoff of 0.3π, and stopband ripple of 16dB. Plot the filter response. 2. Design a lowpass Chebyshev-1 digital filter with passband cutoff of 0.2π, passband ripple of 1dB, stopband cutoff of 0.3π, and stopband attenuation of 15dB. Plot the filter response

Uploaded by

Engr Umer Cheema
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
82 views11 pages

University of Engineering & Technology Lahore: Theory

This document describes designing a Chebyshev digital IIR filter in MATLAB. It provides the theory behind Chebyshev filters and discusses their design. The document contains two assignments: 1. Design a lowpass Chebyshev-1 analog filter with a passband cutoff of 0.2π, passband ripple of 1dB, stopband cutoff of 0.3π, and stopband ripple of 16dB. Plot the filter response. 2. Design a lowpass Chebyshev-1 digital filter with passband cutoff of 0.2π, passband ripple of 1dB, stopband cutoff of 0.3π, and stopband attenuation of 15dB. Plot the filter response

Uploaded by

Engr Umer Cheema
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Registration# 2014_EE_453

University of Engineering & Technology Lahore

Faculty of Engineering

Experiment # 11

Title: Chebyshev Digital IIR Filters

Equipment Required: Personal computer (PC) with windows operating system and MATLAB
software

Theory:
There are three basic prototypes (Butterworth, Chebyshev, Elliptic) of IIR filters are widely used
in practice. We have discussed butterworth analog and digital filter in previous lab. In this lab, we
will design chebyshev filter and its transformation in digital filters.
There are two types of Chebyshev filters. The Chebyshev-I filters have equiripple response in
the passband, while the Chebyahev-II filters have epiripple response in the stopband.
Butterworth filters have monotonic response in both bands. By choosing a filter that has an
equiripple rather than a monotonic behavior, we can obtain a lower-order filter. Therefore,
Chebyshev filters provide lower order than Butterworth filters for the same specifications

where N is the order of the filter, ϵ is the passband ripple factor, which is related to Rp, and
𝑇𝑁 (X) is the Nth-order Chebyshev polynomial given

The equiripple response of the Chebyshev filters is due to this polynomial 𝑇𝑁 (x). Its key properties
are
(a) for 0 < x < 1, 𝑇𝑁 (x) oscillates between -1 and 1,
(b) for 1< x < ∞, 𝑇𝑁 (x) increases monotonically to ∞.
There are two possible shapes of |𝐻𝑎 (𝑗𝛺)|2,one for N odd and one for N even as shown below.
Note that X = Ω/𝛺𝑐 is the normalized frequency.
Designing Equations:
MATLAB provides a function called [z, p, k] =cheb1ap(N, Rp) to design a normalized Chebyshev-
I analog prototype filter of order N and pass band ripple Rp and that returns zeros in z array, poles
in p array, and the gain value k. Un-normlized Chebyshev-I filter with arbitrary R is achieved by
scaling the array p of the normalized filter by R,. Similar to the Butterworth prototype, this filter
has no zeros. In the following function, called u-chb1ap(N, Rp, Omegac), we design an un-
normalized Chebyshev-I analog prototype filter that returns Ha(s) in the direct form.

N = Order of the filter


𝛺𝑐 = 𝐶𝑢𝑡𝑜𝑓𝑓 𝑓𝑟𝑒𝑞𝑢𝑒𝑛𝑐𝑦
𝛺𝑝 = 𝑃𝑎𝑠𝑠𝑏𝑎𝑛𝑑 𝑐𝑢𝑡𝑜𝑓𝑓 𝑓𝑟𝑒𝑞𝑢𝑒𝑛𝑐𝑦

𝛺𝑠 = 𝑆𝑡𝑜𝑝𝑏𝑎𝑛𝑑 𝑐𝑢𝑡𝑜𝑓𝑓 𝑓𝑟𝑒𝑞𝑢𝑒𝑛𝑐𝑦


𝑅𝑝 = 𝑃𝑎𝑠𝑠𝑏𝑎𝑛𝑑 𝑟𝑖𝑝𝑝𝑙𝑒

𝐴𝑠 = 𝑠𝑡𝑜𝑝𝑏𝑎𝑛𝑑 𝑟𝑖𝑝𝑝𝑙𝑒
Assignment 1:
Design a lowpass chebyshev-1 analog filter using to satisfy
Passband cutoff = 0.2π; Passband ripple: = 1dB
Stopband frequency = 0.3π; Stopband ripple: = 16dB
Plot magnitude response, phase response and magnitude in dB of analog filter.
function [b,a] = afd_chb1(Wp,Ws,Rp,As);
% Analog Lowpass Filter Design: Chebyshev-1
% -----------------------------------------
% [b,a] = afd_chb1(Wp,Ws,Rp,As);
% b = Numerator coefficients of Ha(s)
% a = Denominator coefficients of Ha(s)
% Wp = Passband edge frequency in rad/sec; Wp > 0
% Ws = Stopband edge frequency in rad/sec; Ws > Wp > 0
% Rp = Passband ripple in +dB; (Rp > 0)
% As = Stopband attenuation in +dB; (As > 0)
%
if Wp <= 0
error('Passband edge must be larger than 0')
end
if Ws <= Wp
error('Stopband edge must be larger than Passband edge')
end
if (Rp <= 0) | (As < 0)
error('PB ripple and/or SB attenuation ust be larger than 0')
end
ep = sqrt(10^(Rp/10)-1); A = 10^(As/20);
OmegaC = Wp; OmegaR = Ws/Wp; g = sqrt(A*A-1)/ep;
N = ceil(log10(g+sqrt(g*g-1))/log10(OmegaR+sqrt(OmegaR*OmegaR-1)));
fprintf('\n*** Chebyshev-1 Filter Order = %2.0f \n',N)
[b,a]=u_chb1ap(N,Rp,OmegaC);
End

function [b,a] = u_chb1ap(N,Rp,Omegac);


% Unnormalized Chebyshev-1 Analog Lowpass Filter Prototype
% --------------------------------------------------------
% [b,a] = u_chb1ap(N,Rp,Omegac);
% b = numerator polynomial coefficients
% a = denominator polynomial coefficients
% N = Order of the Elliptic Filter
% Rp = Passband Ripple in dB; Rp > 0
% Omegac = Cutoff frequency in radians/sec
%
[z,p,k] = cheb1ap(N,Rp); a = real(poly(p)); aNn = a(N+1);
p = p*Omegac; a = real(poly(p)); aNu = a(N+1);
k = k*aNu/aNn;
b0 = k; B = real(poly(z)); b = k*B;
end

function [db,mag,pha,w] = freqs_m(b,a,wmax);


% Computation of s-domain frequency response: Modified version
% ------------------------------------------------------------
% [db,mag,pha,w] = freqs_m(b,a,wmax);
% db = Relative magnitude in db over [0 to wmax]
% mag = Absolute magnitude over [0 to wmax]
% pha = Phase response in radians over [0 to wmax]
% w = array of 500 frequency samples between [0 to wmax]
% b = Numerator polynomial coefficents of Ha(s)
% a = Denominator polynomial coefficents of Ha(s)
% wmax = Maximum frequency in rad/sec over which response is desired
%
w = [0:1:500]*wmax/500; H = freqs(b,a,w);
mag = abs(H); db = 20*log10((mag+eps)/max(mag)); pha = angle(H);
end

function [C,B,A] = sdir2cas(b,a);


% DIRECT-form to CASCADE-form conversion in s-plane
% -------------------------------------------------
% [C,B,A] = sdir2cas(b,a)
% C = gain coefficient
% B = K by 3 matrix of real coefficients containing bk’s
% A = K by 3 matrix of real coefficients containing ak’s
% b = numerator polynomial coefficients of DIRECT form
% a = denominator polynomial coefficients of DIRECT form
%
Na = length(a)-1; Nb = length(b)-1;
% compute gain coefficient C
b0 = b(1); b = b/b0; a0 = a(1); a = a/a0; C = b0/a0;
%
% Denominator second-order sections:
p= cplxpair(roots(a)); K = floor(Na/2);
if K*2 == Na % Computation when Na is even
A = zeros(K,3);
for n=1:2:Na
Arow = p(n:1:n+1,:); Arow = poly(Arow);
A(fix((n+1)/2),:) = real(Arow);
end
elseif Na == 1 % Computation when Na = 1
A = [0 real(poly(p))];
else % Computation when Na is odd and > 1
A = zeros(K+1,3);
for n=1:2:2*K
Arow = p(n:1:n+1,:); Arow = poly(Arow);
A(fix((n+1)/2),:) = real(Arow);
end
A(K+1,:) = [0 real(poly(p(Na)))];
end
% Numerator second-order sections:
z = cplxpair(roots(b)); K = floor(Nb/2);
if Nb == 0 % Computation when Nb = 0
B = [0 0 poly(z)];
elseif K*2 == Nb % Computation when Nb is even
B = zeros(K,3);
for n=1:2:Nb
Brow = z(n:1:n+1,:); Brow = poly(Brow);
B(fix((n+1)/2),:) = real(Brow);
end
elseif Nb == 1 % Computation when Nb = 1
B = [0 real(poly(z))];
else % Computation when Nb is odd and > 1
B = zeros(K+1,3);
for n=1:2:2*K
Brow = z(n:1:n+1,:); Brow = poly(Brow);
B(fix((n+1)/2),:) = real(Brow);
end
B(K+1,:) = [0 real(poly(z(Nb)))];
End

Wp = 0.2*pi; Ws = 0.3*pi; Rp = 1; As = 16;


Ripple = 10 ^ (-Rp/20); Attn = 10 ^ (-As/20);
% Analog filter design:
[b,a] = afd_chb1(Wp,Ws,Rp,As);
%Chebyshev-1 Filter Order = 4
% Calculation of second-order sections:
[C,B,A] = sdir2cas(b,a)
% Calculation of Frequency Response:
[db,mag,pha,w] = freqs_m(b,a,0.5*pi);
% Calculation of Impulse response:
[ha,x,t] = impulse(b,a);
figure(1)
plot(w,mag); hold on
legend('magnitude plot')
figure(2)
plot(w,pha); hold on
legend('phase plot')
figure(3)
plot(w,db); hold on
legend('magnitude in db plot')
figure(4)
plot(t,ha);
legend('impulse responce')
Graph
Assignment 2:
Design a lowpass chebyshev-1 digital filter using to satisfy
𝜔𝑝 = 0.2π; 𝑅𝑝 = 1dB
𝜔𝑠 = 0.3π; 𝐴𝑠 = 15dB
Plot magnitude response, phase response and magnitude in dB of analog filter.
function [b,a] = afd_chb1(Wp,Ws,Rp,As);
% Analog Lowpass Filter Design: Chebyshev-1
% -----------------------------------------
% [b,a] = afd_chb1(Wp,Ws,Rp,As);
% b = Numerator coefficients of Ha(s)
% a = Denominator coefficients of Ha(s)
% Wp = Passband edge frequency in rad/sec; Wp > 0
% Ws = Stopband edge frequency in rad/sec; Ws > Wp > 0
% Rp = Passband ripple in +dB; (Rp > 0)
% As = Stopband attenuation in +dB; (As > 0)
%
if Wp <= 0
error('Passband edge must be larger than 0')
end
if Ws <= Wp
error('Stopband edge must be larger than Passband edge')
end
if (Rp <= 0) | (As < 0)
error('PB ripple and/or SB attenuation ust be larger than 0')
end
ep = sqrt(10^(Rp/10)-1); A = 10^(As/20);
OmegaC = Wp; OmegaR = Ws/Wp; g = sqrt(A*A-1)/ep;
N = ceil(log10(g+sqrt(g*g-1))/log10(OmegaR+sqrt(OmegaR*OmegaR-1)));
fprintf('\n*** Chebyshev-1 Filter Order = %2.0f \n',N)
[b,a]=u_chb1ap(N,Rp,OmegaC);
end
function [b,a] = imp_invr(c,d,T)
% Impulse Invariance Transformation from Analog to Digital Filter
% ...............................................................
% [b,d] = imp_invr(c,d,T)
% b = Numerator polynomial in z^(-1) of the digital filter
% a = Denominator polynomial in z^(-1) of the digital filter
% c = Numerator polynomial in s of the analog filter
% d = Denominator polynomial in s of the analog filter
% T = Sampling (transformation) parameter

[R,p,k] = residue(c,d);
p = exp(p*T);
[b,a] = residuez(R,p,k) ;
b = real(b'); a = real(a');
end
function [C,B,A] = dir2par(b,a);
% Dim-form to PWLEL-form conversion
% -------------------------------------
% [C,B,A] = dir2par(b,a)
% C = Polynomial part when length(b) >= length(a)
% B = K by 2 matrix of real coefficients containing bk's
% A = K by 3 matrix of real coefficients containing ak's
% b = numerator polynomial coefficients of DIRECT form
% a = denominator polynomial coefficients of DIRECT form

M = length(b) ; N = length(a);
[r1,p1,C] = residuez(b,a);
p = cplxpair(p1,10000000*eps);
I = cplxcomp(p1 ,p);
r = r1(I);
K = floor(N/2); B = zeros(K,2); A = zeros(K,3);
if K*2 == N; %N even, order of A(z) odd, one factor is first order
for i=1:2:N-2
Brow = r(i:1:i+1,:);
Arow = p(i:1:i+1,:);
[Brow,Arow] = residuez(Brow,Arow,[]);
B(fix((i+1)/2), :) = real(Brow) ;
A(fix((i+1)/2), :) = real(Arow);
end
[Brow,Arow] = residuez(r(N-1) ,p(N-1), []) ;
B(K,:) = [real(Brow) 0]; A(K,:) = [real(Arow) 0];
else
for i=1:2:N-1
Brow = r(i:1:i+1,:);
Arow = p(i:1:i+1,:);
[Brow,Arow] = residuez(Brow, Arow,[] );
B(fix((i+1)/2), :) = real(Brow) ;
A(fix((i+1)/2), :) = real(Arow);
end
end

% Digital Filter Specifications:


wp = 0.2*pi; % digital Passband freq in rad
ws = 0.3*pi; % digital Stopband freq in rad
Rp = 1; % Passband ripple in
As = 15; % Stopband attenuation in dB
% Analog Prototype Specifications: Inverse mapping for frequencies
T = 1; % Set T=1
OmegaP = wp / T; % Prototype Passband freq
OmegaS = ws / T; % Prototype Stopband freq
% Analog Chebyshev-1 Prototype Filter Calculation:
[cs,ds] = afd_chb1(OmegaP,OmegaS,Rp,As);
%Chebyshev-1 Filter Order = 4
% Impulse Invariance transformation:
[b,a] = imp_invr(cs,ds,T); [C,B,A] = dir2par(b,a)
figure(1)
plot(w,mag); hold on
legend('magnitude plot')
figure(2)
plot(w,pha); hold on
legend('phase plot')
figure(3)
plot(w,db); hold on
legend('magnitude in db plot')
figure(4)
plot(t,ha)
legend('impulse responce')
• Compare graphs of analog and digital filters and comment in your own words.

You might also like