Uploaded by Jordan van Hunnik

3331 Final Project

advertisement
ECE3331 Laboratory Report Page |1
ECE 3331B
Laboratory Project
Jordan van Hunnik
251162271
April 7th, 2023
ECE3331 Laboratory Report Page |2
Content
Low Pass Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
High Pass Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7
Notch Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1 IIR Low Pass Filter
An infinite-impulse response (IIR) low-pass filter that has the magnitude response below
0.1 for frequencies between (180 – XY/ 5) Hz and 200 Hz, and the magnitude response between
0.9 and 1.1 for frequencies between 0 and (10 + XY/ 5) Hz, where XY are the last two digits of your
student number.
For all filters, use sampling frequency of 400 Hz.
1.1 Meeting Requirements
XY = 71
|H(ω)| ≤ 0.1 : 165.8 Hz < f ≤ 200 Hz
0.9 < |H(ω)| ≤ 1.1 : 0 Hz < f ≤ 24.2 Hz
ω 0 = [2π(165.8)/(400)] = 2.604 rad/sample
ω 1 = [2π(24.2)/(400)] = 0.38 rad/sample
1.2 Theoretical Rationale
The design criteria implies that poles should be placed for the frequencies between zero
and 24.2 Hz as to emphasize them. On the contrary, the frequencies from 165.8 to 200 Hz
should therefore be de-emphasized, and thus zeros should be placed for these frequencies.
Placing poles follows the general form of p = re+/-jw and placing zeros follows the form z =
e+/-jw. These poles and zeros should be placed in complex conjugate pairs as to obtain real
coefficients. The resulting form of the above requirements follows:
b(1 + 2𝑒 −𝑗𝑤 + 𝑒 −2𝑗𝑤 )
]
1 + 2𝑟𝑐𝑜𝑠(𝜔𝑜 )𝑒 −𝑗𝑤 + 𝑟2 𝑒 −2𝑗𝑤
b(1 + 2𝑧 −1 + 𝑧 −2 )
H(z) = [
]
1 + 2𝑟𝑐𝑜𝑠(𝜔𝑜 )𝑧 −1 + 𝑟2 𝑧 −2
H(ω) = [
ECE3331 Laboratory Report Page |3
1.3 Pole-Zero Plot
Figure 1.3.1 : Zero-Pole Plot
sampleFreq = 400;
r = 0.10;
omega0 = (2 * pi * 165.8) /
sampleFreq;
omega1 = (2 * pi * 24.2) / sampleFreq;
lowPassTF = (1 + 2 * exp(-1i * omega1)
+ exp(-2i * omega1)) / (1 - 2 * r *
cos(omega0) * exp(-1i * omega1) + r^2
* exp(-2i * omega1));
gain = 0.9 * (1 / abs(lowPassTF));
numerator = gain * [1, 2, 1];
denominator = [1, -2 * r *
cos(omega0), r^2];
[poles, zeros] = pzmap(numerator,
denominator);
zplane(zeros, poles);
hold on;
fvtool(numerator, denominator);
18 [r,p,k] = residue(numerator,
denominator);
Figure 1.3.2 : MATLAB Code
1.4 Impulse Response & Frequency Response
Figure 1.4.1: Magnitude Response
ECE3331 Laboratory Report Page |4
Figure 1.4.2: Phase Response
Figure 1.4.3: Impulse Response
The last line of code, line 18, gathers the coefficients needed (r’, ‘p’, ‘k’) to define
the frequency response and obtain the corresponding difference equation.
ECE3331 Laboratory Report Page |5
r = 0.2536 – 1.6834i, 0.2536 + 1.6834i
p = -0.1117 + 0.0665i, -0.1117 – 0.0665i
k = 0.2854
The simplified form of H(z) can then be defined as:
𝐻(𝑧) =
0.2536 − 1.6834𝑗
0.2536 + 1.6834𝑗
+
+ 0.2854
𝑧 + 0.1117 − 0.0665𝑗 𝑧 + 0.1117 + 0.0665𝑗
1.702𝑒 −𝑗1.4213
1.702𝑒 𝑗1.4213
𝐻(𝑧) =
+
+ 0.2854
1 − 0.13𝑒 −𝑗0.537 𝑧 −1 1 − 0.13𝑒 𝑗0.537 𝑧 −1
Defining the impulse function H(n):
𝐻 (𝑛) = [2(1.702)(0.13)𝑛 𝑐𝑜𝑠(0.537𝑛 − 1.421)]𝑢(𝑛) + 0.2854𝛿(𝑛)
Defining the frequency response H(ω):
𝐻(ω) =
0.2854 + 0.5708e−jω + 0.2854e−2jω
1 + 0.2233𝑒 −𝑗𝜔 + 0.0169𝑒 −2𝑗𝜔
1.5 Difference Equation
Deriving the difference equation:
𝐻(𝑧) =
𝑌(𝑧) 0.2854 + 0.5708z −1 + 0.2854z −2
=
𝑋(𝑧)
1 + 0.2233𝑧 −1 + 0.0169𝑧 −2
𝑌(𝑧)[1 + 0.2233𝑧 −1 + 0.0169𝑧 −2 ] = 𝑋(𝑧)[0.2854 + 0.5708z −1 + 0.2854z −2 ]
𝑦(𝑛) + 0.2233𝑦(𝑛 − 1) + 0.0169𝑦(𝑛 − 2) = 0.2854𝑥(𝑛) + 0.5708𝑥(𝑛 − 1) + 0.2854𝑥(𝑛 − 2)
𝑦(𝑛) = 0.2854𝑥(𝑛) + 0.5708𝑥(𝑛 − 1) + 0.2854𝑥(𝑛 − 2) − 0.2233𝑦(𝑛 − 1) − 0.0169𝑦(𝑛 − 2)
1.5 Block Diagram
ECE3331 Laboratory Report Page |6
1.7 Simulations
Figure 1.6.1: Simulink Implementation
Figure 1.6.2: Response from 0.1 < f < 200Hz
Figure 1.6.3: Response from 165.8 < f < 200Hz
ECE3331 Laboratory Report Page |7
Figure 1.6.4: Response from 0 < f <2 4.2 Hz
The simulated frequency response shown in figures 1.6 have validated our model.
2 IIR High Pass Filter
An IIR high-pass filter that has the magnitude response below 0.1 for frequencies 0-20 Hz,
and the magnitude response between (0.7 + XY/ 400) and 1.05 for frequencies between 180 Hz and
200 Hz, where XY are the last two digits of your student number.
For all filters, use sampling frequency of 400 Hz.
2.1 Meeting Requirements
XY = 71
|H(ω)| ≤ 0.1 : 0 Hz < f ≤ 20 Hz
0.88 < |H(ω)| ≤ 1.05 : 180 Hz < f ≤ 200 Hz
ω 0 = [2π(20)/(400)] = 0.314 rad/sample
ω 1 = [2π(180)/(400)] = 2.827 rad/sample
ECE3331 Laboratory Report Page |8
2.2 Theoretical Rationale
Through the same concept introduced in section 1.2 of this report, and extending its
applications to high-pass filters, poles are to be placed for the high frequencies, and zeros for the
low frequencies. Therefore, we begin by placing a complex conjugate pair of zeros at ω 0 . For
stability, one pair of complex conjugate poles. As noted, zeros follow the form, z=e +/-jw and poles
follow the form, p=re+/-jw . The resulting form of the above requirements follows:
b(1 − 2𝑒 −𝑗𝑤 + 𝑒 −2𝑗𝑤 )
]
1 + 𝑟2 𝑒 −2𝑗𝑤
b(1 − 2𝑧 −1 + 𝑧 −2 )
]
H(z) = [
1 + 𝑟2 𝑧 −2
H(ω) = [
2.3 Pole-Zero Plot
Fs = 400;
r = 0.30;
w0 = (2*pi*180)/Fs;
w1 = (2*pi*20)/Fs;
tf = (1 - 2*exp(-1i*w0) + exp(-2i*w0))/(1 +
r^2*exp(-2i*w0));
gain = 0.95 * (1/abs(tf));
num = gain*[1, -2, 1];
den = [1, 0, r^2];
[p,z] = pzmap(num, den);
zplane(z,p);
hold on;
fvtool(num, den);
[r,p,k] = residue(num, den);
Figure 2.3.1: Pole-Zero Plot
2.4 Impulse Response & Frequency Response
Figure 2.3.2: MATLAB Code
ECE3331 Laboratory Report Page |9
Figure 2.4.1: Magnitude Response
Figure 2.4.2: Phase Response
E C E 3 3 3 1 L a b o r a t o r y R e p o r t P a g e | 10
Figure 2.4.3: Impulse Response
The last line of code, line 18, gathers the coefficients needed (‘r’, ‘p’, and ‘k’) to define the
frequency response and obtain the corresponding difference equation.
r = -0.2615 - 0.3966i, -0.2615 + 0.3966i
p = 0.3i, -0.3i
k = 0.2615
The simplified form of H(z) can then be defined as:
𝐻(𝑧) =
−0.2615 − 0.3966𝑗 −0.2615 + 0.3966𝑗
+
+ 0.2615
𝑧 − 0.3𝑗
𝑧 + 0.3𝑗
𝐻(𝑧) =
0.4751𝑒 −𝑗2.1537
𝜋
1 − 0.3𝑒 𝑗 2 𝑧 −1
+
0.4751𝑒 𝑗2.1537
𝜋
1 + 0.3𝑒 𝑗2 𝑧 −1
+ 0.2615
Defining the impulse function H(n):
𝜋
𝐻(𝑛) = [2(0.4751) (0.3)𝑛 𝑐𝑜𝑠 (2.1537𝑛 − )] 𝑢(𝑛) + 0.2615𝛿(𝑛)
2
Defining the frequency response H(ω):
𝐻(ω) =
0.2615 − 0.5230e−jω + 0.2615e−2jω
1 + 0.09𝑒 −2𝑗𝜔
E C E 3 3 3 1 L a b o r a t o r y R e p o r t P a g e | 11
2.5 Difference Equation
Deriving the difference equation:
𝐻(𝑧) =
𝑌(𝑧) 0.2615 − 0.5230z −1 + 0.2615z −2
=
𝑋(𝑧)
1 + 0.09𝑧 −2
𝑌(𝑧)[1 + 0.09𝑧 −2 ] = 𝑋(𝑧)[0.2615 − 0.5230z −1 + 0.2615z −2 ]
𝑦(𝑛) + 0.09𝑦(𝑛 − 2) = 0.2615𝑥(𝑛) − 0.5230𝑥(𝑛 − 1) + 0.2615𝑥(𝑛 − 2)
𝑦(𝑛) = 0.2615𝑥(𝑛) − 0.5230𝑥(𝑛 − 1) + 0.2615𝑥(𝑛 − 2) − 0.09𝑦(𝑛 − 2)
2.6 Block Diagram
E C E 3 3 3 1 L a b o r a t o r y R e p o r t P a g e | 12
2.7 Simulations
Figure 2.7.1: Implemented Simulink
Figure 2.7.2: Frequency response from 0 < f < 200Hz
Figure 2.7.3: Frequency response from 0Hz < f < 20Hz
E C E 3 3 3 1 L a b o r a t o r y R e p o r t P a g e | 13
Figure 2.7.4: Frequency response from 180Hz < f < 200Hz
The simulated frequency response shown in figures 2.7 have validated our model.
3 IIR Single Notch Filter
An IIR single notch filter that completely removes frequency ( 90 + XY/ 2 ) Hz, where XY
are the last two digits of your student number. The filter’s magnitude response for frequencies
between 0-10 HZ and between 190-200 Hz must lie between 0.9 and 1.1.
For all filters, use sampling frequency of 400 Hz.
3.1 Meeting Requirements
XY = 71
|H(ω)| = 0 : f = 125.5 Hz
0.9 < |H(ω)| ≤ 1.1 : 0 Hz < f ≤ 10 Hz
0.9 < |H(ω)| ≤ 1.1 : 190 Hz < f ≤ 200 Hz
ω 0 = [2π(125.5)/(400)] = 1.971 rad/sample
ω 1 = [2π(10)/(400)] = 0.1570 rad/sample
E C E 3 3 3 1 L a b o r a t o r y R e p o r t P a g e | 14
3.2 Theoretical Rationale
In an ideal notch filter, the magnitude at some specified frequency will be zero. To
implement this, a complex conjugate pair of zeros should be place at that specified frequency. For
stability and to meet design criterion, a pair of complex conjugate poles should be placed to
ensure that the desired frequencies aren’t cut out by the filter. As noted, zeros follow the form,
z=e+/-jw and poles follow the form, p=re +/-jw . The resulting form of the above requirements follows:
b(1 − 2𝑟𝑐𝑜𝑠(𝜔𝑜 )𝑒 −𝑗𝑤 + 𝑒 −2𝑗𝑤 )
]
1 − 2𝑟𝑐𝑜𝑠(𝜔𝑜 )𝑒 −𝑗𝑤 + 𝑟2 𝑒 −2𝑗𝑤
b(1 − 2𝑟𝑐𝑜𝑠(𝜔𝑜 )𝑧 −1 + 𝑧 −2 )
H(z) = [
]
1 − 2𝑟𝑐𝑜𝑠(𝜔𝑜 )𝑧 −1 + 𝑟2 𝑧 −2
H(ω) = [
3.3 Pole-Zero Plot
Fs = 400;
r = 0.65;
w0 = 2*pi*125.5/Fs;
w1 = 2*pi*10/Fs;
H = (1 - 2*cos(w0)*exp(-1i*w1) +
exp(-2i*w1))/(1 - 2*r*cos(w0)*exp(1i*w1) +r^2*exp(-2i*w1));
b0 = 1/abs(H);
num = b0*[1, -2*cos(w0), 1];
den = [1, -2*r*cos(w0), r^2];
[p, z] = pzmap(num, den);
zplane(z, p);
fvtool(num, den);
[res, poles, gain] = residue(num,
den);
Figure 3.3.1: Pole-Zero Plot
Figure 3.3.2: MATLAB Code
E C E 3 3 3 1 L a b o r a t o r y R e p o r t P a g e | 15
3.4 Impulse Response & Frequency Response
Figure 3.4.1: Magnitude Response
Figure 3.4.2: Phase Response
E C E 3 3 3 1 L a b o r a t o r y R e p o r t P a g e | 16
Figure 3.4.3: Impulse Response
The last line of code, line 18, gathers the coefficients needed (r’, ‘p’, ‘k’) to define the frequency
response and obtain the corresponding difference equation.
r = 0.0948-0.2950i, 0.0948+0.2950i
p = -0.2535-0.5985i, -0.2535+0.5985i
k = 0.6947
The simplified form of H(z) can then be defined as:
𝐻(𝑧) =
0.0948 − 0.2950i
0.0948 + 0.2950i
+
+ 0.6947
𝑧 + 0.2535 − 0.5985𝑗 𝑧 + 0.2535 + 0.5985𝑗
𝐻(𝑧) =
0.309𝑒 −𝑗1.2598
0.309𝑒 𝑗1.2598
+
+ 0.6947
1 − 0.65𝑒 𝑗1.17 𝑧 −1 1 − 0.65𝑒 −𝑗1.17 𝑧 −1
Defining the impulse function H(n):
𝐻(𝑛) = [2(0.309)(0.65)𝑛 𝑐𝑜𝑠(1.2598𝑛 − 1.17)]𝑢(𝑛) + 0.6947𝛿(𝑛)
Defining the frequency response H(ω):
𝐻(ω) =
0.6948 + 0.5417e−jω + 0.6947e−2jω
1 + 0.5609𝑒 −𝑗𝜔 + 0.4225𝑒 −2𝑗𝜔
E C E 3 3 3 1 L a b o r a t o r y R e p o r t P a g e | 17
3.5 Difference Equation
Deriving the difference equation:
𝐻(𝑧) =
𝑌(𝑧) 0.6948 + 0.5417z −1 + 0.6947z −2
=
𝑋(𝑧)
1 + 0.5609𝑧 −1 + 0.4225𝑧 −2
𝑌(𝑧)[1 + 0.5609𝑧 −1 + 0.4225𝑧 −2 ] = 𝑋(𝑧)[0.6948 + 0.5417z −1 + 0.6947z −2 ]
𝑦(𝑛) + 0.5609𝑦(𝑛 − 1) + 0.4225𝑦(𝑛 − 2) = 0.6948𝑥(𝑛) + 0.5417𝑥(𝑛 − 1) + 0.6947𝑥(𝑛 − 2)
𝑦(𝑛) = 0.6948𝑥(𝑛) + 0.5417𝑥(𝑛 − 1) + 0.6947𝑥(𝑛 − 2) − 0.5609𝑦(𝑛 − 1) − 0.4225𝑦(𝑛 − 2)
3.6 Block Diagram
3.7 Simulations
Figure 3.7.0
E C E 3 3 3 1 L a b o r a t o r y R e p o r t P a g e | 18
Figure 3.7.1: Frequency response from 0Hz < f < 200Hz
Figure 3.7.2: Frequency response from 123Hz < f < 128Hz
Figure 3.7.3: Frequency response from 190Hz < f < 200Hz
E C E 3 3 3 1 L a b o r a t o r y R e p o r t P a g e | 19
Figure 3.7.4: Frequency response from 0Hz < f < 10Hz
The simulated frequency response shown in figures 3.7 have validated our model.
Download