Vous êtes sur la page 1sur 13

# Instituto Politcnico Nacional

3BM3

Ingeniera Binica

## Lab. Practice No.3: IIR Filters (Low Pass)

1. - Objectives
Understand the usage and characteristics of analog and digital filters Comprehend their main features and its differences. 3.2 Formulas and Mathematical Expressions The transfer function of the analog Filter is:

## The transfer function of digital filter is:

2. - Introduction
A filter is a device that suppresses some components that we dont need or want from a main signal. This means the removing of a group of frequencies or a specific domain of frequencies. There are different types of filters, but the classification that is related to the practice split the genre in two classifications: Analogic and Digital. A digital filter is a system that performs mathematical operations on a sampled, discretetime signal to reduce or enhance certain components of that specific signal. On the other hand, an analog filter is the opposite of the digital, is an electronic circuit operating continuous-time analog signals, this circuit can be modeled mathematically. For a low pass filter, the transfer function is defined by: 3.3 MATLAB Code For the sum of sines:

## Where t can be took as RC or as 1/*fc Relationship of frequency in S and Z domain:

Equation 2

3.-Development
3.1 Procedure -First off all an ECG signal must be downloaded from Physiobank database in order to process it. -Design a digital and analog filter in order to apply those filters to the signal we desire to filter. -Sketch the signal before and after the filtering processes in both types of filters. -Test the designed filters with the downloaded ECG signal and a function that consist in the sum of different sine functions. A sampling frequency will be of 1000 Hz and a cut off frequency of 60 Hz.

%Fc 1000Hz fs=1000; t=0:(1/fs):(0.5-1/fs); x=sin(2*pi*50*t)+sin(2*pi*100*t)+ sin(2*pi*150*t)+sin(2*pi*200*t)+s in(2*pi*250*t); plot(t(1:150),x(1:150)); xlabel('Time (s)') ylabel('Amplitude') title('Sine') X=fft(x(1,:)); le=length(x); X=X(1:(le/2)); f=((0:(le/2-1))*(fs/2))/((le/2)1); figure,plot(f,abs(X)),xlabel('Fre quency (Hz)'),ylabel('Amplitude'),title( 'Sine Frequency'); A=[2.3815 -1.6185]; B=[0.3815 0.3815]; figure,freqz(B,A,60000,1000) title('Bode Giagram of Digital Filter') C=[(1/(120*pi)) 1]; D=1; P = bodeoptions; P.FreqUnits = 'Hz'; FA=tf(D,C); figure,bode(FA,P); title('Bode Diagram of Analog Filter'); [yo,to]=lsim(FA,x(1,:),t(1,:)); figure,plot(to(1:150),yo(1:150)); xlabel('Time (s)') ylabel('Amplitude') title('Analog Filter Output'); X=fft(yo); le=length(yo); X=X(1:(le/2));

## Instituto Politcnico Nacional Unidad Profesional Interdisciplinaria de Ingeniera y Tecnologa Avanzada

f=((0:(le/2-1))*(fs/2))/((le/2)1); figure,plot(f,abs(X)),xlabel('Fre quency (Hz)'),ylabel('Amplitude'),title( 'Analog Output Frequency'); [y,zf]=filter(B,A,x); figure,plot(t(1:150),y(1:150)); xlabel('Time (s)') ylabel('Amplitude') title('Digital Filter Output') X=fft(y); le=length(y); X=X(1:(le/2)); f=((0:(le/2-1))*(fs/2))/((le/2)1); figure,plot(f,abs(X)),xlabel('Fre quency (Hz)'),ylabel('Amplitude'),title( 'Digital Output Frequency'); figure hold on; xlabel('Time (s)') ylabel('Amplitude') title('Analog Filter vs. Original Signal') plot(t(1:150),x(1:150),'black') plot(to(1:150),yo(1:150)) h=legend('Original Signal','Analog Signal'); set(h,'interpreter','none') figure hold on; xlabel('Time (s)') ylabel('Amplitude') title('Digital Filter vs. Original Signal') plot(t(1:150),x(1:150),'black') plot(t(1:150),y(1:150),'r') h=legend('Original Signal','Digital Signal'); set(h,'interpreter','none')
For the ECG signal, a 10 sec normal sinus Rhythm ECG signal was downloaded from Physiobank ATM (the data of the signal is saved in the variable ECG):

fs=128; t=0:(1/fs):(10-1/fs); x=ecg; plot(t(1:150),x(1:150)); xlabel('Time (s)') ylabel('Amplitude') title('ECG Signal') X=fft(x(1,:)); le=length(x);

X=X(1:(le/2)); f=((0:(le/2-1))*(fs/2))/((le/2)1); figure,plot(f,abs(X)),xlabel('Fre quency (Hz)'),ylabel('Amplitude'),title( 'ECG Frequency'); A=[2.3815 -1.6185]; B=[0.3815 0.3815]; figure,freqz(B,A,60000,1000) title('Bode Giagram of Digital Filter') C=[(1/(120*pi)) 1]; D=1; P = bodeoptions; P.FreqUnits = 'Hz'; FA=tf(D,C); figure,bode(FA,P); title('Bode Diagram of Analog Filter'); [yo,to]=lsim(FA,x(1,:),t(1,:)); figure,plot(to(1:150),yo(1:150)); xlabel('Time (s)') ylabel('Amplitude') title('Analog Filter Output'); X=fft(yo); le=length(yo); X=X(1:(le/2)); f=((0:(le/2-1))*(fs/2))/((le/2)1); figure,plot(f,abs(X)),xlabel('Fre quency (Hz)'),ylabel('Amplitude'),title( 'Analog Output Frequency'); [y,zf]=filter(B,A,x); figure,plot(t(1:150),y(1:150)); xlabel('Time (s)') ylabel('Amplitude') title('Digital Filter Output') X=fft(y); le=length(y); X=X(1:(le/2)); f=((0:(le/2-1))*(fs/2))/((le/2)1); figure,plot(f,abs(X)),xlabel('Fre quency (Hz)'),ylabel('Amplitude'),title( 'Digital Output Frequency'); figure hold on; xlabel('Time (s)') ylabel('Amplitude') title('Analog Filter vs. Original Signal') plot(t(1:150),x(1:150),'black') plot(to(1:150),yo(1:150))

## Instituto Politcnico Nacional Unidad Profesional Interdisciplinaria de Ingeniera y Tecnologa Avanzada

h=legend('Original Signal','Analog Signal'); set(h,'interpreter','none') figure hold on; xlabel('Time (s)') ylabel('Amplitude') title('Digital Filter vs. Original Signal') plot(t(1:150),x(1:150),'black') plot(t(1:150),y(1:150),'r') h=legend('Original Signal','Digital Signal'); set(h,'interpreter','none')
between the two type of filters but it looks like there is a better response in the analog one.

5.-Conclution
The particular features of both filters made each one of them unique to certain applications due to its response in bode sketch. But there is another observation that is related to the signal which is needed to filter, there is a different response if it is an analog signal or a pure digital signal. This affects the performance of both filters.

6.-Bibliography
- Grafakos, Loukas (2004), Classical and Modern Fourier Analysis, Prentice-Hall -Kammler, David (2000), A First Course in Fourier Analysis, Prentice Hall -James, J.F. (2011), A Student's Guide to Fourier Transforms (3rd ed.), New York: Cambridge University Press

4.-Results
Analyzing the filtering of the function composed by the sum of sinus functions demonstrates a slight difference between the filters, especially that the magnitude of original signal is diminished and smoothened in the digital filter rather than the analog. This difference becomes more significant when we analyze the ECG signal because the digital filtering is better than the analog one. In the frequency domain we see a slight difference

Annex (Graphs)

10

11

12

13