Sunteți pe pagina 1din 44

Khalifa University of Science, Technology and Research Communication Engineering Department

ELEC 402 Signal Processing Laboratory

Experiment No.1

CONTINUOUS-TIME SIGNALS & SYSTEMS

Lab Performer

Lab Instructor:

Fall 2012

ELEC 402 Lab Report #1

Table of Contents
Table of Contents _______________________________________________ 2 List of Figures _________________________________________________ 3 1. Introduction _________________________________________________ 5
1.1 Objectives _________________________________________________________________ 10

2. Codes and Results ___________________________________________ 11 3. Conclusion _________________________________________________ 43

2|P age

ELEC 402 Lab Report #1

List of Figures
Figure 1: LPF .................................................................................................................................. 6 Figure 2: HPF ................................................................................................................................. 7 Figure 3: BPF.................................................................................................................................. 8 Figure 4: BSF ................................................................................................................................ 10 Figure 5: LPF ................................................................................................................................ 13 Figure 6: HPF ............................................................................................................................... 14 Figure 7: BPF................................................................................................................................ 14 Figure 8: BSF ................................................................................................................................ 15 Figure 9: Impulse & phase response for LPF ............................................................................ 17 Figure 10: Impulse & phase response for HPF ......................................................................... 17 Figure 11: Impulse & phase response for BPF .......................................................................... 18 Figure 12: Impulse & phase response for BSF .......................................................................... 18 Figure 13: SPtool ......................................................................................................................... 20 Figure 14: LPS from SPtool ......................................................................................................... 20 Figure 15: Original signal before filtering ................................................................................. 21 Figure 16: Freq. response of original signal .............................................................................. 21 Figure 17: The signal after passing it through LPF................................................................... 21 Figure 18: Freq. response after passing the signal through LPF ............................................. 22 Figure 19: HPS from SPtool ........................................................................................................ 22 Figure 20: The signal after passing it through HPF .................................................................. 23 Figure 21: Freq. response after passing the signal through HPF ............................................ 23 Figure 22: The signal after passing it through BPF .................................................................. 24 Figure 23: Freq. response after passing the signal through BPF ............................................ 24 Figure 24: The signal after passing it through BSF .................................................................. 25 Figure 25: Freq. response after passing the signal through BSF ............................................. 25 Figure 26: LPF (w=100Hz) ......................................................................................................... 26 Figure 27: HPF (w=400Hz)......................................................................................................... 27 Figure 28: BPF (w1=100Hz, w2=400Hz) .................................................................................. 27 Figure 29: BSF (w1=400Hz, w2=400Hz)................................................................................... 28 Figure 30: Impulse and step response of LPF (w=100Hz) ...................................................... 28 Figure 31: Impulse and step response of HPF (w=400Hz) ...................................................... 29 Figure 32: Impulse and step response of BPF (w1=100Hz, w2=400Hz) ............................... 29 Figure 33: Impulse and step response of BSF (w1=100Hz, w2=400Hz) ................................ 29 Figure 34: Freq. response after passing the signal through LPF ............................................. 30 Figure 35: Freq. response after passing the signal through HPF ............................................ 30 Figure 36: Freq. response after passing the signal through BPF ............................................ 30 Figure 37: Freq. response after passing the signal through BSF ............................................. 31 Figure 38: LPF (3rd order) .......................................................................................................... 31 Figure 39: HPF (3rd order) .......................................................................................................... 32 Figure 40: BPF (3rd order) .......................................................................................................... 32 Figure 41: BSF (3rd order) .......................................................................................................... 32 Figure 42: Impulse and step response of the 3rd order LPF .................................................... 33
3|P age

ELEC 402 Lab Report #1

Figure 43: Impulse and step response of the 3rd order HPF .................................................... 33 Figure 44: Impulse and step response of the 3rd order BPF .................................................... 33 Figure 45: Impulse and step response of the 3rd order BSF .................................................... 34 Figure 46: Freq. response of LPF (3rd order) ............................................................................ 34 Figure 47: Freq. response of HPF (3rd order)............................................................................ 34 Figure 48: Freq. response of BPF (3rd order) ............................................................................ 35 Figure 49: Freq. response of BSF (3rd order) ............................................................................ 35 Figure 50: LPF (5th order) ........................................................................................................... 36 Figure 51: HPF (5th order) .......................................................................................................... 36 Figure 52: BPF (5th order) ......................................................................................................... 36 Figure 53: BSF (5th order) ........................................................................................................... 37 Figure 54: Impulse and step response of the 5th order LPF..................................................... 37 Figure 55: Impulse and step response of the 5th order HPF .................................................... 37 Figure 56: Impulse and step response of the 5th order BPF .................................................... 38 Figure 57: Impulse and step response of the 5th order BSF..................................................... 38 Figure 58: Freq. response of LPF (5th order) ............................................................................ 38 Figure 59: Freq. response of HPF (5th order) ............................................................................ 39 Figure 60: Freq. response of BPF (5th order) ............................................................................ 39 Figure 61: Freq. response of BSF (5th order) ............................................................................ 39 Figure 62: LPF for different filter orders................................................................................... 40 Figure 63: Audio signal in time domain .................................................................................... 41 Figure 64: Audio signal after passing it through LPF ............................................................... 41 Figure 65: Audio signal after passing it through HPF .............................................................. 41 Figure 66: Audio signal after passing it through BPF............................................................... 42 Figure 67: Audio signal after passing it through BSF ............................................................... 42

4|P age

ELEC 402 Lab Report #1

1. Introduction Continuous time filters:


An ideal frequency-selective lter is a system that passes a prespecied range of frequency components without any attenuation but completely rejects the remaining frequency components. The range of input frequencies that is left unaffected by the lter is referred to as the pass band of the lter, while the range of input frequencies that are blocked from the output is referred to as the stop band of the lter. In terms of the magnitude spectrum, the absolute value of the transfer function |H(w)| of the frequency lter, therefore, toggles between the values of A and zero as a function of frequency w. The gain |H(w)| is A, typically set to one, within the pass band, while |H(w)| is zero within the stop band. Depending upon the range of frequencies within the pass and stop bands, an ideal frequency-selective lter is categorized in four different categories. These categories are dened in the following:

Low Pass Filters:


A low pass filter is an electronic filter that passes low frequency signals but attenuates (reduces the amplitude of) signals with frequencies higher than the cutoff frequency. The actual amount of attenuation for each frequency varies from filter to filter. It is sometimes called a high-cut filter, or treble cut filter when used in audio applications.

5|P age

ELEC 402 Lab Report #1

Figure 1: LPF

The transfer function Hlp (w) of an ideal low pass lter is dened as follows:

where (wc) is referred to as the cut-off frequency of the lter. The pass band of the low pass lter is given by |w| wc, while the stop band of the low pass lter is given by: wc < |w| < Low-pass filters exist in many different forms, including electronic circuits (such as a hiss filter used in audio), anti-aliasing filters for conditioning signals prior to analog-to-digital conversion, digital filters for smoothing sets of data, acoustic barriers, blurring of images, and so on. The moving average operation used in fields such as finance is a particular kind of low-pass filter, and can be analyzed with the same signal processing techniques as are used for other low-pass filters. Low-pass filters provide a smoother form of a signal, removing the short-term fluctuations, and leaving the longer-term trend.

6|P age

ELEC 402 Lab Report #1

High Pass Filters:


A high-pass filter (HPF) is an electronic filter that passes high frequency signals but attenuates (reduces the amplitude of) signals with frequencies lower than the cutoff frequency. The actual amount of attenuation for each frequency varies from filter to filter. A high-pass filter is usually modeled as a linear time-invariant system. It is sometimes called a low-cut filter or bass-cut filter.

Figure 2: HPF

The transfer function Hhp (w) of an ideal high pass lter is dened as follows:

where (wc) is the cut-off frequency of the lter. The pass band of the high pass lter is given by: wc < |w| < |w| wc.
7|P age

while the stop band of the high pass lter is given by:

ELEC 402 Lab Report #1

High-pass filters have many uses, such as blocking DC from circuitry sensitive to non-zero average voltages or RF devices. They can also be used in conjunction with a low-pass filter to make a bandpass filter.

Band Pass Filters:


A band-pass filter is a device that passes frequencies within a certain range and rejects (attenuates) frequencies outside that range.An example of an analogue electronic bandpass filter is an RLC circuit (a resistorinductorcapacitor circuit). These filters can also be created by combining a low-pass filter with a high-pass filter. An ideal bandpass filter would have a completely flat passband (e.g. with no gain/attenuation throughout) and would completely attenuate all frequencies outside the passband. Additionally, the transition out of the passband would be instantaneous in frequency. In practice, no bandpass filter is ideal. The filter does not attenuate all frequencies outside the desired frequency range completely; in particular, there is a region just outside the intended passband where frequencies are attenuated, but not rejected.

Figure 3: BPF

8|P age

ELEC 402 Lab Report #1

The bandwidth of the filter is simply the difference between the upper and lower cutoff frequencies. The transfer function Hbp(w) of an ideal bandpass lter is dened as follows:

where wc1 and wc2 are collectively referred to as the cut-off frequencies of the ideal bandpass lter. The lower frequency wc1 is referred to as the lower cutoff, while the higher frequency wc2 is referred to as the higher cut off. Unlike the highpass lter, the bandpass lter has a nite bandwidth as it only allows a range of frequencies (wc1 w wc2) to be passed through the lter. Outside of electronics and signal processing, one example of the use of band-pass filters is in the atmospheric sciences. It is common to band-pass filter recent meteorological data with a period range of, for example, 3 to 10 days, so that only cyclones remain as fluctuations in the data fields.

Band Stop Filters:


In signal processing, a band-stop filter or band-rejection filter is a filter that passes most frequencies unaltered, but attenuates those in a specific range to very low levels. It is the opposite of a band-pass filter.

9|P age

ELEC 402 Lab Report #1

Figure 4: BSF

The transfer function Hbs(w) of an ideal bandstop lter is dened as follows:

Where wc1 and wc2, are respectively referred to as the lower cut-off and higher cut-off frequencies of the ideal bandstop lter. The ideal bandstop lter is the converse of the ideal bandpass lter as it eliminates a certain range of frequencies (wc1 w wc2) from the input signal.

1.1 Objectives The objective of this experiment is to receive the fundamental concepts of continuous-time signals and system. Also to design and implement CT filters and to verify their performance.

10 | P a g e

ELEC 402 Lab Report #1

2. Codes and Results Task 1: Filters


In this task we shall design all four types of filters; low-pass, high-pass, band-pass and band-stop filters. For each filter we shall find the amplitude frequency response, phase frequency response, impulse response and unit step response. Also, we shall change the order of the filters and the cutoff frequencies. Then, using MATLAB digital signal processing tool we shall create two different types of signals and compare them to the previous obtained results. a) Using Matlab, design low-pass, high-pass, band-pass and band-stop Butterworth filters of order 2, 3 and 5. Select several cutoff frequencies. MATLAB code
clc clear

% part(a): n=2; % filters of 2nd order wc1=2000*2*pi; % 1st cutoff frequency wc2=8000*2*pi; % 2nd cutoff frequency fs=1e6; % sampling freq. ws=2*pi*fs; [LP_B,LP_A]=butter(n,wc1,'s'); % LPF [HP_B,HP_A]=butter(n,wc2,'high','s'); % HPF [BP_B,BP_A]=butter(n,[wc1 wc2],'s'); % BPF [BS_B,BS_A]=butter(n,[wc1 wc2],'stop','s'); % BSF

Comment:
butter designs lowpass, bandpass, highpass, and bandstop digital and analog Butterworth filters. Butterworth filters are characterized by a magnitude response that is maximally flat in the passband and monotonic overall.

Digital domain: butter(n,Wn,'ftype') designs an n oreder highpass, lowpass, or bandstop filter, where the string 'ftype' is one of the following:

11 | P a g e

ELEC 402 Lab Report #1

'high' for a highpass digital filter with normalized cutoff frequency Wn 'low' for a lowpass digital filter with normalized cutoff frequency Wn 'stop' for an order 2*n bandstop digital filter if Wn is a two-element vector, Wn = [w1 w2]. The stopband is w1 < < w2.

Analog domain: in the analog domain we add to the command s, as in: butter(n,Wn,'ftype','s') designs an n order highpass, lowpass, or bandstop filter using theftype values described above.

b) Plot amplitude frequency response and phase frequency response of the designed filters. 2nd order filters & w1=2000Hz, w2=8000Hz:

MATLAB code
% cont. to the above code: f=(0:1e6); % freq. response h_LP=freqs(LP_B,LP_A,2*pi*f); h_HP=freqs(HP_B,HP_A,2*pi*f); h_BP=freqs(BP_B,BP_A,2*pi*f); h_BS=freqs(BS_B,BS_A,2*pi*f);

% % % %

LPF HPF BPF BSF

figure(1) % LPF subplot(2,1,1);semilogx(f,abs(h_LP),'Linewidth',2);grid %abs: ampl. response title('Low Pass Filter'); xlabel('Frequency') ylabel('Amplitude') subplot(2,1,2);semilogx(f,angle(h_LP),'Linewidth',2); %angle: phase response grid xlabel('Phase') ylabel('Amplitude')

figure(2) % HPF subplot(2,1,1);semilogx(f,abs(h_HP),'Linewidth',2);grid %abs: ampl. response title('High Pass Filter'); xlabel('Frequency') ylabel('Amplitude') subplot(2,1,2);semilogx(f,angle(h_HP),'Linewidth',2); %angle: phase response grid xlabel('Phase') ylabel('Amplitude') 12 | P a g e

ELEC 402 Lab Report #1

figure(3) % BPF subplot(2,1,1);semilogx(f,abs(h_BP),'Linewidth',2);grid %abs: ampl. response title('Band Pass Filter'); xlabel('Frequency') ylabel('Amplitude') subplot(2,1,2);semilogx(f,angle(h_BP),'Linewidth',2); %angle: phase response grid xlabel('Phase') ylabel('Amplitude')

figure(4) % BSF subplot(2,1,1);semilogx(f,abs(h_BS),'Linewidth',2);grid %abs: ampl. response title('Band Stop Filter'); xlabel('Frequency') ylabel('Amplitude') subplot(2,1,2);semilogx(f,angle(h_BS),'Linewidth',2); %angle: phase response grid xlabel('Phase') ylabel('Amplitude')

Low Pass Filter 1

Amplitude

0.5

0 0 10

10

10

10 Frequency

10

10

10

Amplitude

-1 -2 -3 -4 0 10
1 2 3 4 5 6

10

10

10 Phase

10

10

10

Figure 5: LPF

13 | P a g e

ELEC 402 Lab Report #1

HIGH PASS Amplitdue frequency response 1

Amplitude

0.5

0 0 10

10

10 10 frequency HIGH PASS Phase frequency response

10

10

10

4 3

Phase

2 1 0 0 10
1 2 3 4 5 6

10

10

10 frequency

10

10

10

Figure 6: HPF

Band Pass Filter 1.5

Amplitude

0.5

0 0 10

10

10

10 Frequency

10

10

10

Amplitude

2 0 -2 -4 0 10
1 2 3 4 5 6

10

10

10 Phase

10

10

10

Figure 7: BPF

14 | P a g e

ELEC 402 Lab Report #1

Band Stop Filter 1

Amplitude

0.5

0 0 10

10

10

10 Frequency

10

10

10

Amplitude

2 0 -2 -4 0 10
1 2 3 4 5 6

10

10

10 Phase

10

10

10

Figure 8: BSF

Comment: The (freqs) command that we used in this part of the code returns the complex frequency response H(j) (Laplace transform) of an analog filter

given the numerator and denominator coefficients in vectors b and a. h = freqs(b,a,w) returns the complex frequency response of the analog filter specified by coefficient vectors b and a. 1- For LPF its clear that the cutoff frequency is 2000Hz, at 0.7 amplitude. (Any freq. higher than 2kHzgets filtered out). 2- For HPF cutoff frequency is 8000Hz, at 0.7 amplitude. (Any freq. lower than 8kHz gets filtered out. 3- For BPF and BSF the cutoff frequencies are 2000Hz and 8000Hz. For BPF any frequency out of this range gets filtered out, and the BSF passes all frequencies except those inside this range.

15 | P a g e

ELEC 402 Lab Report #1

c) Plot impulse response and step unit of the designed filters. MATLAB code
% part(c) TF_LP=tf(LP_B,LP_A); % tf = transfer function TF_HP=tf(HP_B,HP_A); TF_BP=tf(BP_B,BP_A); TF_BS=tf(BS_B,BS_A); figure(5) subplot(2,1,1);impulse(TF_LP);grid title('Impulse response-LPS'); xlabel('Frequency') ylabel('Amplitude') subplot(2,1,2);step(TF_LP); grid title('Step response-LPF'); xlabel('Frequency') ylabel('Amplitude') figure(6) subplot(2,1,1);impulse(TF_HP);grid title('Impulse response-HPF'); xlabel('Frequency') ylabel('Amplitude') subplot(2,1,2);step(TF_HP); grid title('Step response-HPF'); xlabel('Frequency') ylabel('Amplitude') figure(7) subplot(2,1,1);impulse(TF_BP);grid title('Impulse response-BPF'); xlabel('Frequency') ylabel('Amplitude') subplot(2,1,2);step(TF_BP); grid title('Step response-BPF'); xlabel('Frequency') ylabel('Amplitude') figure(8) subplot(2,1,1);impulse(TF_BS);grid title('Impulse response-BSF'); xlabel('Frequency') ylabel('Amplitude') subplot(2,1,2);step(TF_BS); grid title('Step response-BSF'); xlabel('Frequency') ylabel('Amplitude')

16 | P a g e

ELEC 402 Lab Report #1

Impulse response-LPS 6000 4000

Amplitude

2000 0 -2000

4 Frequency (sec) Step response-LPF

7 x 10

8
-4

1.5

Amplitude

0.5

6 x 10

7
-4

Frequency (sec)

Figure 9: Impulse & phase response for LPF

x 10

Impulse response-HPF

Amplitude

-5

-10

0.2

0.4

0.6

0.8

1.2

1.4

1.6

1.8 x 10
-4

Frequency (sec) Step response-HPF 1

Amplitude

0.5

-0.5

0.5 Frequency (sec)

1.5 x 10
-4

Figure 10: Impulse & phase response for HPF

17 | P a g e

ELEC 402 Lab Report #1

2 1

x 10

Impulse response-BPF

Amplitude

0 -1 -2

4 Frequency (sec) Step response-BPF

7 x 10

8
-4

Amplitude

0.5

-0.5

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9 x 10

1
-3

Frequency (sec)

Figure 11: Impulse & phase response for BPF

2 0

x 10

Impulse response-BSF

Amplitude

-2 -4 -6

6 x 10

7
-4

Frequency (sec) Step response-BSF 1.5

Amplitude

0.5

4 Frequency (sec)

7 x 10

8
-4

Figure 12: Impulse & phase response for BSF

18 | P a g e

ELEC 402 Lab Report #1

Comment: The (tf (num,den) ) command that we used in this part of the code creates a continuoustime transfer function with numerator(s) and denominator(s) specified by num and den. The output sys is a TF object storing the transfer function data. impulse calculates the unit impulse response of a dynamic system model. step calculates the step response of a dynamic system. d) Create signals combining several sinusoid curves (e.g. a sum of 2Hz, 10Hz, 50Hz, 200Hz, 500Hz, 1000Hz, 4000Hz and 10000Hz) and filter them using the designed filters. Compare plots of the original and filtered signals. MATLAB code
%part(d) f1=2*2*pi; t=0:(1/fs):(3/f1); f2=10*2*pi; f3=200*2*pi; f4=500*2*pi; f5=1000*2*pi; f6=4000*2*pi; f7=10000*2*pi; x=sin(f1*t)+sin(f2*t)+sin(f3*t)+sin(f4*t)+sin(f5*t)+sin(f6*t)+sin(f7*t); [LP_b,LP_a]=butter(n,wc1/(ws/2)); [HP_b,HP_a]=butter(n,wc2/(ws/2),'high'); [BP_b,BP_a]=butter(n,[wc1/(ws/2) wc2/(ws/2)]); [BS_b,BS_a]=butter(n,[wc1/(ws/2) wc2/(ws/2)],'stop');

We created the signal by summing the sine signals, and then we used the (sptool) that opens SPTool, a suite of four tools: Signal Browser, Filter Design and Analysis Tool, FVTool, and Spectrum Viewer. These tools provide access to many of the signal, filter, and spectral analysis functions in the toolbox. SPtool allows for:

Analyze signals listed in the Signals list box with the Signal Browser Design or edit filters with the Filter Design and Analysis Tool Analyze filter responses for filters listed in the Filters list box with FVTool Apply filters in the Filters list box to signals in the Signals list box Create and analyze signal spectra with the Spectrum Viewer

19 | P a g e

ELEC 402 Lab Report #1

Figure 13: SPtool

To use the SPtool the filtered signals must be in the digital domain, so we removed s from the previous command. The obtained results were as follow: LPF:

Magnitude Response 1

0.8

Magnitude

0.6

0.4

0.2

0 10
-1

10

Figure 14: LPS from SPtool

10 Frequency (mHz)

10

20 | P a g e

ELEC 402 Lab Report #1

Before filtering the signal:

Figure 15: Original signal before filtering

Figure 16: Freq. response of original signal

Figure 17: The signal after passing it through LPF

21 | P a g e

ELEC 402 Lab Report #1

Figure 18: Freq. response after passing the signal through LPF

From the above figures its clear that any frequency components greater than 2000Hz are filtered out by LPF, i.e. the of 4000Hz and 10000Hz frequency components were filtered out. HPS:
Magnitude Response 1 0.9 0.8 0.7

Magnitude

0.6 0.5 0.4 0.3 0.2 0.1 0 10


-1

10

10 Frequency (kHz)

10

Figure 19: HPS from SPtool

The signal after passing through HPF and its frequency response are shown in the following figures:

22 | P a g e

ELEC 402 Lab Report #1

Figure 20: The signal after passing it through HPF

Figure 21: Freq. response after passing the signal through HPF

From the above figures, as expected the low frequency components were filtered out by HPF, i.e. all the frequency components below 8000Hz were filtered.

23 | P a g e

ELEC 402 Lab Report #1

BPF:

Figure 22: The signal after passing it through BPF

Figure 23: Freq. response after passing the signal through BPF

From the above figures the BPF filtered out all frequencies beyond the range of 2000Hz till 8000Hz. (only 4000Hz should be passed)

24 | P a g e

ELEC 402 Lab Report #1

BSF:

Figure 24: The signal after passing it through BSF

Figure 25: Freq. response after passing the signal through BSF

The BSF passed all the frequency components except those which fall in the range from 2000Hz till 8000Hz, i.e. the freqcency component 4000Hz was filtered.

25 | P a g e

ELEC 402 Lab Report #1

Now we repeat the parts from (a) till (d) for the following values: 2nd order filters & w1=100Hz, w2=400Hz: Repeating part (a+b): MATLAB code
n=2; % filters of 2nd order wc1=100*2*pi; % 1st cutoff frequency wc2=400*2*pi; % 2nd cutoff frequency

The obtained results:


LOW PASS Amplitdue frequency response 1

Amplitude

0.5

0 0 10

10

10 10 frequency LOW PASS Phase frequency response

10

10

10

0 -1

Phase

-2 -3 -4 0 10
1 2 3 4 5 6

10

10

10 frequency

10

10

10

Figure 26: LPF (w=100Hz)

Obviously the cutoff frequency changed to 100Hz, and any frequency higher than this got filtered out.

26 | P a g e

ELEC 402 Lab Report #1

HIGH PASS Amplitdue frequency response 1

Amplitude

0.5

0 0 10

10

10 10 frequency HIGH PASS Phase frequency response

10

10

10

4 3

Phase

2 1 0 0 10
1 2 3 4 5 6

10

10

10 frequency

10

10

10

Figure 27: HPF (w=400Hz)

The cutoff frequency changed to 400Hz, and any frequency lower than this got filtered out.

BAND PASS Amplitdue frequency response 1

Amplitude

0.5

0 0 10

10

10 10 frequency BAND PASS Phase frequency response

10

10

10

4 2

Phase

0 -2 -4 0 10
1 2 3 4 5 6

10

10

10 frequency

10

10

10

Figure 28: BPF (w1=100Hz, w2=400Hz)

27 | P a g e

ELEC 402 Lab Report #1

BAND STOP Amplitdue frequency response 1

Amplitude

0.5

0 0 10

10

10 10 frequency BAND STOP Phase frequency response

10

10

10

4 2

Phase

0 -2 -4 0 10
1 2 3 4 5 6

10

10

10 frequency

10

10

10

Figure 29: BSF (w1=400Hz, w2=400Hz)

In the BPF and BSF the cutoff frequencies changed to 100Hz and 400Hz, and any frequency outside this range got filtered out in case of BPF, and for BSF any frequency except whats within this range gets passed. In other words changing the cutoff frequency only affects the BW of the filters. In this case we reduced the BW. Repeating part (c):
Impulse Response 300 200

Amplitude

100 0 -100

0.002

0.004

0.006

0.008

0.01

0.012

0.014

0.016

0.018

Time (seconds) Step Response 1.5

Amplitude

0.5

0.005 Time (seconds)

0.01

0.015

Figure 30: Impulse and step response of LPF (w=100Hz)

28 | P a g e

ELEC 402 Lab Report #1

Impulse Response 2000

Amplitude

-2000

-4000

0.5

1.5

2.5

3.5 x 10
-3

Time (seconds) Step Response 1

Amplitude

0.5

-0.5

0.5

1.5 Time (seconds)

2.5 x 10

3
-3

Figure 31: Impulse and step response of HPF (w=400Hz)

Impulse Response 1000 500

Amplitude

0 -500 -1000

0.005 Time (seconds) Step Response

0.01

0.015

Amplitude

0.5

-0.5

0.002

0.004

0.006

0.008

0.01

0.012

0.014

0.016

0.018

0.02

Time (seconds)

Figure 32: Impulse and step response of BPF (w1=100Hz, w2=400Hz)

Impulse Response 1000 0

Amplitude

-1000 -2000 -3000

0.002

0.004

0.006 Time (seconds) Step Response

0.008

0.01

0.012

1.5

Amplitude

0.5

0.002

0.004

0.006

0.008

0.01

0.012

0.014

0.016

0.018

Time (seconds)

Figure 33: Impulse and step response of BSF (w1=100Hz, w2=400Hz)

29 | P a g e

ELEC 402 Lab Report #1

Repeating part (c): Then using SPtool we found the frequency response:

Figure 34: Freq. response after passing the signal through LPF

Figure 35: Freq. response after passing the signal through HPF

Figure 36: Freq. response after passing the signal through BPF

30 | P a g e

ELEC 402 Lab Report #1

Figure 37: Freq. response after passing the signal through BSF

The LPF filtered out the high frequency components (500, 1000, 4000 & 10000Hz). The HPF removed the low frequency components (2, 10 & 50Hz), and passed the high frequencies. The frequencies from 100 to 400 Hz were passed by the BPF, and filtered out by the BSF. 3rd order filters & w1=2000Hz, w2=8000Hz: Repeating part (a+b): MATLAB code
n=3; % filters of 2nd order wc1=2000*2*pi; % 1st cutoff frequency wc2=8000*2*pi; % 2nd cutoff frequency

The obtained results:


Low Pass Filter 1

Amplitude

0.5

0 10
0

10

10

10 Frequency

10

10

10

4 2

Amplitude

0 -2 -4 0 10

10

10

10 Phase

10

10

10

Figure 38: LPF (3rd order)

31 | P a g e

ELEC 402 Lab Report #1

HIGH PASS Amplitdue frequency response 1

Amplitude

0.5

0 0 10

10

10 10 frequency HIGH PASS Phase frequency response

10

10

10

4 2

Phase

0 -2 -4 0 10
1 2 3 4 5 6

10

10

10 frequency

10

10

10

Figure 39: HPF (3rd order)


BAND PASS Amplitdue frequency response 1

Amplitude

0.5

0 0 10

10

10 10 frequency BAND PASS Phase frequency response

10

10

10

4 2

Phase

0 -2 -4 0 10
1 2 3 4 5 6

10

10

10 frequency

10

10

10

Figure 40: BPF (3rd order)


BAND STOP Amplitdue frequency response 1

Amplitude

0.5

0 0 10

10

10 10 frequency BAND STOP Phase frequency response

10

10

10

4 2

Phase

0 -2 -4 0 10
1 2 3 4 5 6

10

10

10 frequency

10

10

10

Figure 41: BSF (3rd order)

32 | P a g e

ELEC 402 Lab Report #1

Repeating part (c):

Impulse Response 6000 4000

Amplitude

2000 0 -2000

0.2

0.4

0.6 Time (seconds) Step Response

0.8

1.2 x 10
-3

1.5

Amplitude

0.5

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9 x 10

1
-3

Time (seconds)

Figure 42: Impulse and step response of the 3rd order LPF

5 0

x 10

Impulse Response

Amplitude

-5 -10 -15

1 Time (seconds) Step Response x 10

2
-4

Amplitude

0.5

-0.5

1 Time (seconds)

2 x 10

3
-4

Figure 43: Impulse and step response of the 3rd order HPF

x 10

Impulse Response

Amplitude

-1

-2 0

0.2

0.4

0.6

0.8

1.2

1.4 x 10
-3

Time (seconds) Step Response 0.4 0.2

Amplitude

0 -0.2 -0.4

0.2

0.4

0.6

0.8 Time (seconds)

1.2

1.4

1.6 x 10
-3

Figure 44: Impulse and step response of the 3rd order BPF

33 | P a g e

ELEC 402 Lab Report #1

x 10

Impulse Response

Amplitude

-5

-10

4 Time (seconds) Step Response

7 x 10

8
-4

1.5 1

Amplitude

0.5 0 -0.5

0.2

0.4

0.6 Time (seconds)

0.8

1.2 x 10
-3

Figure 45: Impulse and step response of the 3rd order BSF

Repeating part (d):

Figure 46: Freq. response of LPF (3rd order)

Figure 47: Freq. response of HPF (3rd order)

34 | P a g e

ELEC 402 Lab Report #1

Figure 48: Freq. response of BPF (3rd order)

Figure 49: Freq. response of BSF (3rd order)

5th order filters & w1=2000Hz, w2=8000Hz: Repeating part (a+b): MATLAB code
n=5; % filters of 2nd order wc1=2000*2*pi; % 1st cutoff frequency wc2=8000*2*pi; % 2nd cutoff frequency

The obtained results:

35 | P a g e

ELEC 402 Lab Report #1

Low Pass Filter 1.5

Amplitude

1 0.5

0 0 10

10

10

10 Frequency

10

10

10

Amplitude

2 0 -2 -4 0 10
1 2 3 4 5 6

10

10

10 Phase

10

10

10

Figure 50: LPF (5th order)

High Pass Filter 1.5

Amplitude

1 0.5

0 0 10

10

10

10 Frequency

10

10

10

Amplitude

2 0 -2 -4 0 10
1 2 3 4 5 6

10

10

10 Phase

10

10

10

Figure 51: HPF (5th order)


Band Pass Filter 1.5

Amplitude

1 0.5

0 0 10

10

10

10 Frequency

10

10

10

Amplitude

2 0 -2 -4 0 10
1 2 3 4 5 6

10

10

10 Phase

10

10

10

Figure 52: BPF (5th order)

36 | P a g e

ELEC 402 Lab Report #1

Band Stop Filter 1.5

Amplitude

1 0.5

0 0 10

10

10

10 Frequency

10

10

10

Amplitude

2 0 -2 -4 0 10
1 2 3 4 5 6

10

10

10 Phase

10

10

10

Figure 53: BSF (5th order)

Repeating part (c):


Impulse response-LP S 6000 4000

Amplitude

2000 0 -2000

0.2

0.4

0.6

0.8

1.2

1.4

1.6

1.8 x 10

2
-3

Frequency (seconds) Step response-LP F 1.5

Amplitude

0.5

0.2

0.4

0.6

0.8

1.2

1.4 x 10
-3

Frequency (seconds)

Figure 54: Impulse and step response of the 5th order LPF

x 10

Impulse response-HP F

Amplitude

-1

-2

0.5

1.5

2.5

3.5 x 10
-4

Frequency (seconds) Step response-HP F 1

Amplitude

0.5

-0.5

0.5

1.5

2.5

3.5 x 10
-4

Frequency (seconds)

Figure 55: Impulse and step response of the 5th order HPF

37 | P a g e

ELEC 402 Lab Report #1

2 1

x 10

Impulse response-BP F

Amplitude

0 -1 -2

0.5

1.5

2.5 x 10
-3

Frequency (seconds) Step response-BP F 0.5

Amplitude

-0.5

0.5

1.5 Frequency (seconds)

2.5 x 10

3
-3

Figure 56: Impulse and step response of the 5th order BPF

5 0

x 10

Impulse response-BSF

Amplitude

-5 -10 -15

8 x 10

9
-4

Frequency (seconds) Step response-BSF 1.5 1

Amplitude

0.5 0 -0.5

0.2

0.4

0.6

0.8

1.2

1.4

1.6

1.8 x 10

2
-3

Frequency (seconds)

Figure 57: Impulse and step response of the 5th order BSF

Repeating part (d):

Figure 58: Freq. response of LPF (5th order)

38 | P a g e

ELEC 402 Lab Report #1

Figure 59: Freq. response of HPF (5th order)

Figure 60: Freq. response of BPF (5th order)

Figure 61: Freq. response of BSF (5th order)

39 | P a g e

ELEC 402 Lab Report #1

Comment: That the higher the Butterworth filter order, the higher the number of cascaded stages there are within the filter design, and the closer the filter becomes to the ideal "brick wall" response, i.e. the filter provides a sharper roll off. As shown in the following figure for LPF:

Figure 62: LPF for different filter orders

In terms of the amplitude response the Butterworth filter response is flat within its passband and then rolls off with an ultimate linear roll off rate of -6 dB per octave (-20 dB per decade). A second-order filter decreases at -12 dB per octave, etc. The ultimate roll off rate is actually the same for all low pass and high pass filters. e) Select several .wav files and process them using the designed filters. MATLAB code
%part(e) [Xa,Fs,nbits]=wavread('C:\Users\Kustar\Desktop'); XaL=Xa(:,1) XaR=Xa(:,2)

The obtained graphs: First the original audio signal that we imported:

40 | P a g e

ELEC 402 Lab Report #1

Figure 63: Audio signal in time domain

Then we passed this signal through lowpass filter, the result is shown below:

Figure 64: Audio signal after passing it through LPF

Then through highpass filter, the result is shown below:

Figure 65: Audio signal after passing it through HPF

41 | P a g e

ELEC 402 Lab Report #1

Then through bandpass filter, the result is shown below:

Figure 66: Audio signal after passing it through BPF

Finally through bandstop filter, the result is shown below:

Figure 67: Audio signal after passing it through BSF

Comment: [y, Fs, nbits] = wavread(filename) loads a WAVE file specified by the string filename, returning the number of bits per sample (nbits). XaL and XaR means that we are dividing the signal to left and right since we are dealing with stero. From the above graphs we notice that using the Butterworth filters are good for audio applications. Since the Butterworth was derived on the basis that the behavior below the cut-off frequency was more important than at any other frequency.

42 | P a g e

ELEC 402 Lab Report #1

3. Conclusion
At completion of this laboratory session the aim that was set at the beginning of this report were achieved, as we designed different types of different orders of Butterworth filters and for different cutoff frequencies. We used Butterworth filter, that is a type of signal processing filter designed to have as flat frequency response as possible (no ripples) in the pass-band and zero roll off response in the stop-band. Butterworth filters are one of the most commonly used digital filters in motion analysis and in audio circuits. They are fast and simple to use. Since they are frequency-based, the effect of filtering can be easily understood and predicted. However, one main disadvantage of the Butterworth filter is that it achieves this pass band flatness at the expense of a wide transition band as the filter changes from the pass band to the stop band. It also has poor phase characteristics as well. The filters that we designed were: Low pass filter: It passes low-frequency signals and filters out frequencies higher that the cutoff frequency. High pass filter: It passes high-frequency signals and filters out any frequencies lower than the cutoff frequency. Band pass filter: It passes frequencies within a certain range and filteres out frequencies outside that range. Band stop filter: It passes all frequencies except those within the cutoff frequency range. To study the filters we first designed a second order filter (lowpass, highpass, bandpass and bandstop filters) with cutoff frequency (2kHz/8kHz). Then we found the amplitude frequency response, phase frequency response, impulse response and unit step response. After that we changed the cutoff frequency (100Hz/400Hz) and plotted the same curves again. We also changed the order of the filters and plotted the curves again. What we observed from that is: Reducing the cutoff frequency range resulted in a reduction in the spectrum BW for the frequency response, as well as for the impulse and step responses. By increasing the order of the filters even more noise frequencies can be eliminated from the inputted signal, meaning that the actual response of the filter approaches its ideal characteristics as the filters provide a sharper roll off.

43 | P a g e

ELEC 402 Lab Report #1

We also created a signal which was a summation of sine signals, passed through the filters and compared the plots using SPtool in MATLAB. Then finally we processed several .wav files using the designed filters, it is good for audio applications, since Butterworth filter basis is that the behavior below the cut-off frequency was more important than at any other frequency.

44 | P a g e

S-ar putea să vă placă și