Uploaded by نواف الجهني

Module5

advertisement
YANBU INDUSTRIAL COLLEGE
DEPARTMENT
OF
ELECTRONICS AND INSTRUMENTATION ENGINEERING TECHNOLOGY
(EIET)
EEET-431
DIGITAL SIGNAL PROCESSING
STUDY MATERIAL
(Week #11) Module: 5
BASIC FILTERING
AND
DIGITAL FILTER REALIZATION
 Any discrete-time system that modifies (reshapes) certain
frequencies is called a filter.
 Frequency-selective filters pass only certain frequencies
 In this chapter, we concentrate on design of causal
frequency-selective filters
Filters Illustration
Filters are designed to remove noise above a cutoff frequency
Classic filters types
 Butterworth
 Chebyshev
 Elliptic
 Bessel
Classical Filter Types Responses
Butterworth
Chebyshev Type I
Elliptic
Chebyshev Type II
Bessel
Windowing and Spectra
Signal
and DFT
Windowed Signal
and DFT
Wider main lobe,
The Basic on Filters
 Filters work by using one or both of the following methods:
 Delay a copy of the input signal (by x number of samples), and combine the
delayed input signal with the new input signal.

(Finite Impulse Response, FIR, or feed-forward filter)
1
y[ n] = ( x[ n] + x[ n − 1] + x[ n − 2])
3
 Delay a copy of the output signal (by x number of samples), and combine it
with the new input signal.

(Infinite Impulse Response, IIR, feed-back filter)
Filter Terms
 Types:
 Lowpass,
 Highpass,
 Bandpass,
 Bandreject (Notch)
 Terms
 Cutoff frequency,
 Center frequency,
 Bandwidth, Slope, Gain.
Filter Configurations
Lowpass
filter
Transition
band
Bandpass
filter
5-8
Highpass
filter
Bandstop
filter
Filter Specifications
0
Magnitude (dB)
Rp
Transition
band
Passband
0
Wp
Normalized frequency
Stopband
Ws
1
The Math
 First, how we label things:
 x is the input signal
 y is the output signal
 n is the sample index (all samples are numbered, or indexed)




x[0] is the first sample of input;
y[0] is the first sample of output.
x[n] is the current sample;
x[n - 1] is the previous sample.
FIR (The Math)
 Simple Lowpass Filter (averaging):
 output = half_of_current_input + half_of_previous_input
 y[n] = ½ . ( x[n] + x[n - 1] )
 Simple Highpass Filter (difference):×
 output = half_of_current input - half_of_previous_input
 y[n] = ½ . ( x[n]) - x[n - 1] )
 The Order of the filter is equal to the number of samples taken in
 Generally, higher the order – the more samples you look back to take an
average or difference. This results in more attenuation of frequencies
Care and Handling
 FIR filters are always stable
 Efficient hardware realization
 Prevent phase distortion
 Startup transients have finite duration
 Drawbacks:
 Higher filter order than IIR filters

More computation than an IIR with similar effect
 IIR filters are computationally less expensive than FIR filters for greater
shaping potential.
 Drawbacks: phase distortion and ringing
 Feedback coefficients have to remain below 1.0, or the filter becomes unstable
Difference Equation And Digital Filtering
 Let x(n) and y(n) be a DSP system’s input and output,
respectively. We can express the relationship between the
input and the output of a DSP system by the following
difference equation:
We observe that the DSP system output is
the weighted summation of the:

Current input value x(n) and its past
values: x(n -1), . . . , x(n-M), and, past
output sequence: y(n -1), . . . , y(n - N).
Difference Equation Illustrations
y (n=
) x(n) + 2 x(n − 1) + 0.5 y (n − 1)
x(n)
1
z−1
+
y(n)
0.5
2
z−1
y(n − 1)
x(n − 1)
y (n=
) x(n) − 0.9 x(n − 1) − 0.1x(n − 2) − 0.3 y (n − 1) + 0.04 y (n − 2)
x(n)
x(n − 1)
x(n − 2)
1
+
y(n)
z−1 −0.9
−0.3 z−1
z−1 −0.1
0.04 z−1
+
y(n − 1)
y(n − 2)
Example #1
(a) Ans.:
 At n = 0,
 At n = 1,
 At n = 2,
 At n = 3,
x(0) = 1,
x(1) = 0.5,
x(2) = 0.25,
x(3) = 0.125,
y(0) = -0.5
y(1) = 1.0
y(2) = 0.25
y(3) = 0.75
Solution
details given
next
Example #1 (continue …)
Solution:
Example #1 (continue …)
Solution:
Example #2
Solution:
 MATLAB code and plots of the input and system output y(n)
are depicted next.
Example #2 (continue …)
% MATLAB Program
% compute y(n)=2x(n)-4x(n-1)-0.5y(n-1)-0.5y(n-2)
% Non-zero initial conditions:
% y(-2)=1, y(-1)=0, x(-1) =-1, and x(n)=(0.8)^n*u(n)
clc; close all; clear all;
y = zeros(1, 20);
y = [ 1 0 y];
%set up a vector to store y(n)
%add initial condition of y(-2) and y(-1)
n = 0 : 1 : 19
%compute time indexes
x = (0.8).^n;
x = [ 0 -1 x];
%compute 20 input samples of x(n)
%add initial condition of x(-2)=0 and x(-1)=1
for n = 3 : 22
y(n) = 2*x(n) - 4*x(n-1) - 0.5*y(n-1) - 0.5*y(n-2); %compute 20 outputs of y(n)
end
n = 0 : 1 : 19;
subplot(3, 1, 1); stem( n, x(3 : 22) ); grid; ylabel('Input x(n)'); xlabel('Sample number');
Subplot(3, 1, 2); stem( n, y(3:22) ); grid;
xlabel('Number of samples, n; part (a)'); ylabel('Output y(n)');
y(3:22)
%output y(n)
Example #2 (continue …)
% MATLAB Program
% compute y(n)=2x(n)-4x(n-1)-0.5y(n-1)-0.5y(n-2)
% Zero- initial conditions:
% y(-2)=0, y(-1)=0, x(-1) =0, and x(n)=(0.8)^n*u(n)
y = zeros(1, 20);
y = [ 0 0 y];
%set up a vector to store y(n)
%add zero initial condition of y(-2) and y(-1)
n = 0 : 1 : 19;
%compute time indexes
x =(0.8).^n;
x = [ 0 0 x];
%compute 20 input samples of x(n)
%add zero initial condition of x(-2)=0 and x(-1)=0
for n = 3 : 22
y(n) = 2*x(n) - 4*x(n-1) - 0.5*y(n-1) - 0.5*y(n-2); %compute 20 outputs of y(n)
end
n= 0 : 1 : 19;
subplot(3, 1, 3); stem( n, y(3 : 22) ); grid;
xlabel('Number of samples, n; part (b)'); ylabel('Output y(n)');
y(3:22)
%output y(n)
Example #2 (continue …)
The input
sequence
Response
with initial
conditions
Response with
zero initial
conditions
Difference Equation And Transfer Function
 Let x(n) and y(n) be a DSP system’s input and output,
respectively. We can express the relationship between the
input and the output of a DSP system by the following
difference equation:
 With an assumption that all initial conditions of this
system are zero, and with X(z) and Y(z) denoting the ztransforms of x(n) and y(n), respectively, taking the ztransform of the above Equation yields
ZT
Difference Equation And Transfer Function
(continue …)
Rearranging equation yields:
where H(z) is defined as the transfer function with its
numerator and denominator polynomials defined below:
Hence, the z-transfer function can be illustrated as:
Example #3
a)
b)
Example #3 (continue …)
(a) Solution:
Example #4
Convert each of the following transfer functions into its
difference equation.
a)
b)
Example #4 (continue …)
(a) Solution:
Dividing the numerator and the denominator by z2 to obtain the
transfer function whose numerator and denominator polynomials
have the negative power of z, it follows that
We write the transfer function using the ratio of Y(z) to X(z):
Example #4 (continue …)
By distributing Y(z) and X(z), we yield
Applying the inverse z-transform and using the shift
property, we get
Writing the output y(n) in terms of inputs and past outputs
leads to
Example #5
Example #5 (continue …)
(a) Solution:
Example #5 (continue …)
(b) Solution:
Example #5 (continue …)
(c) Solution:
Example #6
%MATLAB program
H = frequency response vector
W = angular frequency vector
[H W] = freqz( [1 2 1], [1 -0.5 0.25], 512 );
subplot(2,1,1); plot(W, abs(H),'k');grid;
xlabel('Frequency (radians)');
ylabel('Absolute magnitude');
subplot(2,1,2); plot(W, angle(H)*180/pi,'k'); grid;
xlabel('Frequency (radians)');
ylabel('Phase (degrees)');
Example #7
Example #7 (continue…)
(a) Solution:
>> freqz( [1 -1 1], [1 -0.9 0.81], 512, 8000)
Notch filter
Example #7 (continue…)
(c) Solution:
H(z)
H(z) = Y(z)/X(z)
Y(z)/X(z)
Y(z)(
) = X(z) (
)
y (n=
) x(n) − x(n − 1) + x(n − 2) + 0.9 y (n − 1) − 0.81 y (n − 2)
Download