0% found this document useful (0 votes)
26 views7 pages

DSP Exp8 B2 Grp3

Uploaded by

SREELEKHA K R
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views7 pages

DSP Exp8 B2 Grp3

Uploaded by

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

IIR Filter Design

Ritu Ann Roy George Rahul Anand Ravi Yadav Rahul Chaudhary
B170106EC B170518EC B170556EC B170912EC
B-Batch B-Batch B-Batch B-Batch
NIT Calicut NIT Calicut NIT Calicut NIT Calicut

Abstract—The objective of this experiment is to design IIR


Filter for different Specifications.

I. THEORY

A. Butterworth Filter

The Butterworth filter is a type of signal processing filter


designed to have a frequency response as flat as possible in the
passband. It is also referred to as a maximally flat magnitude
filter. It was first described in 1930 by the British engineer and
physicist Stephen Butterworth in his paper entitled ”On the
Theory of Filter Amplifiers”. Plot of the gain of Butterworth
low-pass filters of orders 1 through 5, with cut-off frequency 1
The frequency response of the Butterworth filter is maximally
flat (i.e. has no ripples) in the passband and rolls off towards
zero in the stopband. When viewed on a logarithmic Bode B. Chebychev Filter
plot, the response slopes off linearly towards negative infinity.
A first-order filter’s response rolls off at 6 dB per octave Chebyshev filters are analog or digital filters having a
(20 dB per decade) (all first-order lowpass filters have the steeper roll-off than Butterworth filters, and have passband
same normalized frequency response). A second-order filter ripple (type I) or stopband ripple (type II). Chebyshev filters
decreases at 12 dB per octave, a third-order at 18 dB and have the property that they minimize the error between the
so on. Butterworth filters have a monotonically changing idealized and the actual filter characteristic over the range of
magnitude function with , unlike other filter types that have the filter but with ripples in the passband. This type of filter is
non- monotonic ripple in the passband and/or the stopband. named after Pafnuty Chebyshev because its mathematicalchar-
Compared with a Chebyshev Type I/Type II filter or an elliptic acteristics are derived from Chebyshev polynomials. The type I
filter, the Butterworth filter has a slower roll-off, and thus Chebyshev filters are called usually as just ”Chebyshev filters”,
will require a higher order to implement a particular stopband the type II ones are usually called ”inverse Chebyshev filters”.
specification, but Butterworth filters have a more linear phase Because of the passband ripple inherent in Chebyshev filters,
response in the pass-band than Chebyshev Type I/Type II and the ones that have a smoother response in the passband but a
elliptic filters can achieve. more irregular response in the stopband are preferred for some
applications. Type I Chebyshev filters are the most common
types of Chebyshev filters. The gain (or amplitude) response,
G n (), as a function of angular frequency of the nth-order
low-pass filter is equal to the absolute value of the transfer
function H n (s) evaluated at s = j :

D. Bilinear Transformation

The bilinear transform (also known as Tustin’s method)


is used in digital signal processing and discrete-time control
C. Impulse Invariance Transformation
theory to transform continuous-time system representations to
discrete-time and vice versa.
Impulse invariance is a technique for designing discrete-
time infinite- impulse-response (IIR) filters from continuous-
time filters in which the impulse response of the continuous-
time system is sampled to produce the impulse response
of the discrete-time system. The frequency response of the
discrete-time system will be a sum of shifted copies of the
frequency response of the continuous-time system; if the
continuous-time system is approximately band-limited to a
frequency less than the Nyquist frequency of the sampling,
then the frequencyresponse of the discrete-time system will be
approximately equal to it for frequencies below the Nyquist
frequency.
II. AIM

A. Question I

1. Design and implement a low pass Butterworth filter


using (a) Impulse Invariance Transformation (IIT) (b) Bilinear
Transformation (BLT) The specifications are given below. Pass
band edge frequency = 1000 Hz; Stop band edge frequency =
2000 Hz; Minimum stop band attenuation = 30 dB; Maximum
pass band attenuation = 0.5 dB; Sampling Frequency = 8000
Hz; Plot the magnitude spectrum and phase spectrum.

B. Question II

Design and implement a low pass Chebychev filter using IIT


for the specifications given in Qn.1. Compare the two designs.

C. Question III

Determine the transfer function and plot the gain response of


an elliptic IIR low pass filter with the following specifications:
Passband edge f p =800Hz, Stopband edge f st = 1 KHz,
passband ripple of 0.5 dB, minimum stopband attenuation of
40 dB and sampling rate f s = 4 KHz.

D. Question IV

Generate two different signals with different frequencies,


one signal in passband and the other signal in the stopband.
Show the results for all the above filters.
III. OBSERVATIONS AND INFERENCES B. Question II

A. Question I

Fig. 3. Low pass chebyshev filter using IIT

Chebyshev filter distort the signal even in the passband due


to ripples in passband region.

C. Question III

Fig. 1. Low pass butterworth filter using BLT

The frequency range is wrapped up during BLT transfor-


mation but in case of IIT transformation it does not wrap up
frequency.

Fig. 4. Magnitude response of elliptic IIR LPF

Fig. 2. Low pass butterworth filter using IIT Fig. 5. Phase response of elliptic IIR LPF
Elliptical filter has very sharp cut-off frequency i.e. the roll
off factor is very large

D. Question IV

Fig. 8. Chebychev LPF output

Fig. 6. Fft of input signal

Fig. 9. IIR LPF output

Elliptical filter has large ripples in stop band and elliptical


filter have more order than Butterworth and Chebyshev filter
for same cut-off frequency.
IV. CODES
A. Question I

1 %Exp8_Q1_BLT_Butterworth
2 clc;
3 clear;
4 close all;
5 fsamp = 8000; % sampling frequency
6 fp = 1000; % pass band frequency
7 fs = 2000; % stop band frequency
8 As = 30; % stop band attenuation in dB
9 Ap = 0.5; % pass band attenuation in dB
10 dp=10ˆ(-Ap/20);
11 ds=10ˆ(-As/20);
12 T = 1/fsamp;
Fig. 7. Butterworth LPF output 13 % Digital frequencies
14 wp = (2*pi*fp)/fsamp; 40 for i = 1:N
15 ws = (2*pi*fs)/fsamp; 41 H(Z) =H(Z)+ r_bw(i)*((p_z(i))ˆ(Z));
16 % Analog frequenices 42 end
17 Os = (2/T) * tan(ws/2); 43 end
18 Op = (2/T) * tan(wp/2); 44 figure()
19 %Order 45 freqz(H);
20 N = ceil((0.5*log10(((1/(ds*ds))-1)/ 46 title('Butterworth Filter - IIT');
21 ((1/(dp*dp))-1)))
22 /log10(Os/Op))
23 %cutoff frequency
24 Oc = Op/(1/(dp*dp)-1)ˆ(1/(2*N)); B. Question II
25 syms a b c s z hs;
26 a=1;
27 p=1;
28 for i=1:N/2 1 %Exp8_Q2_cheby
29 b=2*sin((2*i-1)*pi/(2*N)); 2 clc;
30 p = p*poly2sym([a,b*Oc,Oc*Oc]); 3 clear all;
31 end 4 close all;
32 den = sym2poly(p); 5 T = 1;
33 num=OcˆN; 6 fsam=8000; % sampling frequency
34 7 fp = 1000; % pass band frequency
35 syms Hs; 8 fs = 2000; % stop band frequency
36 % transfer function in s-domain 9 As = 30; % stop band attenuation in dB
37 Hs=poly2sym(num,s)/poly2sym(den,s) 10 Ap = 0.5; % pass band attenuation in dB
38 s1=(2*(1-zˆ-1))/(T*(1+zˆ-1)); 11 %Digital Frequencies
39 % using BLT to transform from s to z domain 12 wp = (2*pi*fp)/8000;
40 Hz=subs(Hs,s,s1) 13 ws = (2*pi*fs)/8000;
41 [numd dend]= numden(Hz); 14 %Attenuation
42 freqz(sym2poly(numd),sym2poly(dend)); 15 dp=power(10,-Ap/20);
43 title('Butterworth filter - BLT'); 16 ds=power(10,-As/20);
17 %Analog frequencies
18 Op = wp/T; %pass band edge frequency
19 Os = ws/T; %stop band edge frequency
20 %Order
1 %Exp8_Q1_IIT_Butterworth 21 N=ceil(acosh(sqrt((1/(ds*ds)-1)/
2 clc; 22 (1/(dp*dp)-1)))/acosh(Os/Op))
3 clear; 23 e=sqrt(1/(dp*dp)-1);
4 close all; 24 % cutoff frequency
5 T = 1; 25 Oc=Op*cosh(1/N * acosh(1/e));
6 fp = 1000; % pass band frequency 26 yn=(1/2)*(power((sqrt(1+1/(e*e))+(1/e)),1/N)
7 fs = 2000; % stop band frequency 27 -power((sqrt(1+1/(e*e))+(1/e)),-1/N));
8 As = 30; % stop band attenuation in dB 28 k=1:N/2;
9 Ap = 0.5; % pass band attenuation in dB 29 b=2*yn*sin((2*k-1)*pi/(2*N));
10 %Digital Frequencies 30 c=yn*yn+(cos((2*k-1)*pi/(2*N))
11 wp = (2*pi*fp)/8000; 31 .*cos((2*k-1)*pi/(2*N)));
12 ws = (2*pi*fs)/8000; 32 syms p s h z
13 %Analog frequencies 33 p = s*s+b*Op*s+c*Op*Op;
14 Op = wp/T; %pass band edge frequency 34 deno = prod(p)
15 Os = ws/T; %stop band edge frequency 35 num1 = power(wp,N)*prod(c*dp); %Changed..
16 %Attenuation 36 if(rem(N,2)==1)
17 dp = 10ˆ(-Ap/20); 37 deno = deno*(s+Op*C0);
18 ds = 10ˆ(-As/20); 38 num1 = num1*C0/power(dp,(N-1)/2);
19 %Order 39 end
20 N = ceil((0.5*log10(((1/(ds*ds))-1)/ 40 den1 = sym2poly(deno);
21 ((1/(dp*dp))-1)))/log10(Os/Op)) 41 t=tf(num1,den1,'variable','s');%transfer ...
22 %cutoff frequency function in s-domain
23 Oc = Op/(1/(dp*dp)-1)ˆ(1/(2*N)); 42
24 %We get N = 7, which is odd 43 [r p k]=residue(num1,den1);%partial fraction
25 poles = zeros(1,N); 44 discrete=0;
26 for i = 1:N 45 for k=1:length(r)
27 poles(i) = Oc*exp( (1i*pi*(N + 2*i ... 46 discrete=discrete+(z*r(k))/(z-exp(p(k)));
-1))/(2*N)); 47 end
28 end 48 [num ,den] = numden(discrete);
29 z = [] ; % No zeros since butterworth filter 49 num = sym2poly(num);
30 k = (Oc)ˆN; 50 den = sym2poly(den);
31 [b a] = zp2tf(z,poles,k); 51 % transfer function in z-domain
32 %To get partial fraction terms 52 H=tf(num,den,-1,'variable','z');
33 [r_bw, p_bw, k_bw] = residue(b,a); 53 w=0:100:100000;
34 % Now to get the s- pk form to 1-eˆpkTzˆ-1 ... 54 figure()
form: 55 freqz(num,den); % frequency ...
35 for i = 1:N response in z-domain
36 p_z(i) = exp(p_bw(i)); 56 title('Magnitude and Phase Response of ...
37 end Chebyshev Filter');
38 H = zeros(1,100);
39 for Z = 1:100
C. Question III

1 %Exp8_Q3_IIR_LPF
2 clc
3 clearvars
4 p_gain=0.9440;
5 s_gain=0.03162
6 p_band=800
7 s_band=1000
8 fs=8000
9 wp=2*pi*p_band/fs
10 ws=2*pi*s_band/fs
11 p_gain_db=-20*log10(p_gain)
12 s_gain_db=-20*log10(s_gain)
13 [b,a] = ellip(7, p_gain_db, s_gain_db, wp);
14 fvtool(b,a);

D. Question IV

1 %Exp8_Q4_SIGNAL FILTERING
2
3 t = 0:1e-5:10/500;
4 xt = 0:1/8000:10/500;
5 xs1 = sin(2*pi*500*xt);
6 xs2 = sin(2*pi*3000*xt);
7 xs = xs1+xs2;
8 figure
9 ns = length(xs);
10 f = (-ns/2:ns/2-1)*(8000/ns);
11 plot(f,fftshift(abs(fft(xs))));
12 title('FFT of IP');
13 figure
14 y=filter(b2,a2,xs);
15 pow = fftshift(abs(fft(y))).ˆ2/ns;
16 plot(f,pow);
17 title('Lowpass filter OP');

V. RESULT
A. Question I
A low pass butterworth filter is designed and implemented
using BLT and IIT with the given specifications and the
magnitude and phase spectrum is plotted.
B. Question II
A low pass chebychev filter is designed and implemented
using IIT with the given specifications and the magnitude and
phase spectrum is plotted.
C. Question III
An elliptic IIR low pass filter with the given specifications
is implemented and the gain response is plotted.
D. Question IV
Signals with different frequencies are generated in passband
and stopband and filtered using these filters and the results are
plotted and verified.

You might also like