IIR Filter Design

Objective 

Objective of this experiment is to build an IIR Low Pass, High Pass, band Pass and Band Stop filter for the required specifications in analog domain and transform it to the digital domain using impulse invariant and bilinear transformation.

Specification:  

Specification:  

 Filter type  : Low Pass  Butterworth 

Pass band attenuation : 3 dB at 100 Hz

Stop band Attenuation : 30 dB at 200 Hz

Sampling Frequency : 8000 Hz

Design Procedure

Recall, how we have designed low pass butterworth filter in the classroom lecture.

Step 1Find the value of N given all the above  specifications.

                        Matlab command to use :     buttord( )  % returns order and and cutoff frequency (wc)

   Note : wp, ws given to the above command should be digital frequency in rad/s , therefore divide  the analog frequency in rad/s

by a sampling frequency.

Step 2Find the pole locations for the given value of 'N'

  Matlab command to use :   buttap( N)  % returns zeros,poles,and gain.

Step 3 :  Using Pole Locations , construct H(s)

Matlab command to use :  zp2tf (zeros,poles,kf)    % returns coefficients of the denominator polynomial

Step 4 : Do de-normalization and filter transformation if required

Matlab command to use :  lp2lp(  ) % denormalize filter coefficients.

Step 5: Plot the magnitude response to check whether the designed filter meets the given specification.

Matlab Command to use : freqs ( ) % returns magnitude and freq axis 

Coding for Low pass Filter Design

(Go through the code thoroughly, make sure you understand each and every line of the code by exploring it)

Output

Observe the Graph , at x = 100 (Hz), the attenuation is 3 dB and at x = 200 (Hz) the attenuation is 30 dB. It satisfies the required specifications. So what we have designed is the right one. 


HP,BP and BS Analog Butterworth Filter 

Having learned the procedure to design a low pass filter, now you should be able to design a high pass filter for the above specification. Now , the stop band frequency is 100 Hz and pass band frequency is 200 Hz. 

Hint : Make use of lp2hp ( ) function in the line number 21 of the above code snippet to design a High pass filter.

Refer to  the Matlab Documentation to know more about to design band pass and band stop filter.

Digital Transformation 

Once if we built analog filter, we can transform it into a digital filter either using impulse invariant technique or bilinear transformation. Lets see about impulse invariant technique.

Procedure:

Step 1 : Obtain the  locations of poles and zeros of the Analog Filter 

Remember, the poles and zeros locations of the analog filters are stored in the variable  'normalized_poles, normalized_zeros' in the previous code. So we can make use of that.

Step 2 :  Map the poles in S-domain to Z-domain using impulse invariant technique. 

Matlab command : impinvar(normalized_zeros,normalized_poles,1) % Guess why 1 is passed as third argument

Plot the Frequency response of the digital filter using 'freqz( )'

Coding 

[num,den]=impinvar(normalized_zeros,normalized_poles,1)

figure

[a,b]=freqz(num,den);% 

plot(b,20*log10(abs(a))); 

axis([0 0.5 -50 0])

title('Digital LP ButterWoth Filter using Impulse Invariant');

xlabel(' Frequency in rad/sample'); 

ylabel('Magnitude in dB');

grid on

Output

Observe that, 3 dB attenuation occurs at x = 0.078 and 30 dB attenuation occurs at x =  0.157.

Can you justify Why?