Digital Signal Processing
Unit II:
Digital Filters: Design and Structures
Dr. Jigarkumar H. Shah
Asst. Prof., ICT department,
PDPU, Gandhinagar
1
Topics to be covered:
Ideal Digital Filters
Practical Filters: Stability and Causality,
FIR and IIR Filters
Linear Phase and Implications
Linear Phase FIR Filters
Linear Phase FIR Filter Design: Methods
Linear Phase FIR Filter Design: Steps
Window Method
IIR Filter Design:
Pole-Zero Placement Method: Low-pass, High-pass,
Band-pass, Notch and All-pass Filters
Overview of Laplace Transform and Analog Filter Design
Analog Filter Standard Frequency Responses and Design
Equations
IIR Filter Coefficients from Analog Filter: Bilinear
Transformation
Basic Structures for FIR and IIR Filter
implementation:
Direct, Transposed, Cascade and Parallel form Structures
Effects of Co-efficient Quantization
Computer Aided Designs are essential to design
2
digital filters.
References:
1. Proakis and Manolakis, “Digital Signal
Processing: Principles, Algorithm &
Application”, Pearson.
2. Oppenheim and Safer: “Discrete Time
Signal Processing”, PHI
3. Emmanuel Ifeacher, and Barrie W. Jervis,
“Digital Signal processing-A Practical
Approach”, Pearson Education
3
Module I:
DT LTI Systems as Frequency
Selective Circuits:
Digital Filters
4
Ideal Digital Filters:
An Ideal Digital Filter is a LTI system; which has frequency response
function that provides H ( ) 1 within certain band of frequencies
(pass band) and H ( ) 0 at other frequencies (stop band). Ideally
phase response is zero.
Frequency Response of Ideal Low-pass Filter:
Repeats periodically with period 2πr outside the plotted
interval
Plot for one period
of 2π: [- π, π ]
5
Frequency Response of Ideal High-pass
Filter and Ideal Band-pass Filter
𝐻ℎ𝑝 (𝜔) = 1 − 𝐻𝑙𝑝 (𝜔) for same cut off frequency
𝐻𝑏𝑝 𝜔 = 𝐻ℎ𝑝 𝜔 + 𝐻𝑙𝑝 𝜔 − 1
with LPF giving higher cut off (𝜔 H)and HPF giving lower cut off (𝜔 L)
Frequency Response of Ideal Band-
stop Filter
𝐻𝑏𝑠 (𝜔) = 1 − 𝐻𝑏𝑝 (𝜔) for same cut off frequencies
7
Concept of Filtering:
Let we have ideal LPF with frequency
response function:
1; −𝜔𝑐 < 𝜔 < 𝜔𝑐
𝐻𝑙𝑝 𝜔 =
0; 𝑒𝑙𝑠𝑒 𝑖𝑛 [−𝜋, 𝜋]
Let input to the filter is: 𝑥 𝑛 =
𝐴1 cos 𝜔1 𝑛 + 𝜑1 + 𝐴2 cos 𝜔2 𝑛 + 𝜑2
Given that 𝜔1 < 𝜔𝑐 and 𝜔2 > 𝜔𝑐
The output is 𝑦 𝑛 = 𝐴1 cos 𝜔1 𝑛 + 𝜑1 .
8
Solution:
1; −𝜔𝑐 < 𝜔 < 𝜔𝑐
𝐻𝑙𝑝 𝜔 =
0; 𝑒𝑙𝑠𝑒
∠𝐻𝑙𝑝 𝜔 = 0
𝑦 𝑛 =
𝐴1 𝐻𝑙𝑝 𝜔1 cos 𝜔1 𝑛 + 𝜑1 + ∠𝐻𝑙𝑝 𝜔1 +
𝐴2 𝐻𝑙𝑝 𝜔2 cos 𝜔2 𝑛 + 𝜑2 + ∠𝐻𝑙𝑝 𝜔2
𝐻𝑙𝑝 𝜔1 =1; 𝐻𝑙𝑝 𝜔2 =0
∠𝐻𝑙𝑝 𝜔1 =∠𝐻𝑙𝑝 𝜔2 =0
𝑦 𝑛 = 𝐴1 cos 𝜔1 𝑛 + 𝜑1 .
9
Why Ideal Filters are non-
realizable?
The frequency response of the ideal lowpass filter in [-π, π ] frequency
range is
The unit impulse response can be written as
Note: sinc(x) = sin(πx)/(πx); sinc(0)=1
hlp(n)≠0 for n<0 Not causal
Magnitude response is square integrable (i.e. having finite energy)
Stable
Note: hlp(n): Not absolute summable , but square summable (relaxed
DTFT existence condition)
10
Unit impulse response plot of ideal LPF:
Shown for n=-20 to 20 only
11
Summary of ideal impulse response of
standard frequency selective filters
Filter type Ideal unit impulse response h(n)
Low Pass
High Pass
Band Pass
Band Stop
Note: fc, fL and fH are cut-off frequencies: fH > fL
Ideal Unit Impulse Response Plots:
Shown for n=-20 to 20 only: Non-causal but
stable; h(n) symmetrical w.r.t. n=0.
Causal LPF: Unit impulse response and
Frequency Response:
Ideally we can write:
𝜔𝑐 𝜔𝑐 𝑛
ℎ𝑙𝑝 𝑛 = sinc ; −∞ ≤ 𝑛 ≤ ∞
𝜋 𝜋
𝜔 𝜔𝑐 𝑛 −𝑗𝜔𝑛
𝐻𝑙𝑝 𝜔 = 𝑐 ∞
𝑛=−∞ sinc ( )𝑒
𝜋 𝜋
One approach is to provide ∞ delay to hlp(n) and
multiply it with unit step to make it zero for n < 0. But
Practically we can provide only finite delay.
𝜔𝑐 𝜔 𝑛−𝑀
ℎ𝑙𝑝 𝑛 = ( sinc 𝑐 ) u(n); 𝑀 → ∞
𝜋 𝜋
𝜔𝑐 ∞ 𝜔𝑐 (𝑛−𝑀) −𝑗𝜔𝑛
𝐻𝑙𝑝 𝜔 = 𝑛=0 sinc ( )𝑒 ;𝑀 → ∞
𝜋 𝜋
This will deviate from ideal frequency response 𝐻𝑙𝑝 𝜔 .
Write MATLAB script to check it with different M. (Take
finite length of filter unit impulse response)
14
MATLAB Script:
clc;
close all;
clear all;
M=input('Enter the delay value ');
wc=input('Enter the cut-off frequency ');
n=0:2*M;
k=1;
for w=-pi:(pi/255):pi
H(k)=(wc/pi)*sum(sinc((n-M)*wc/pi).*exp(-j*w*n));
k=k+1;
end
magnitude=abs(H);
phase=angle(H);
w=-pi:(pi/255):pi
figure;
subplot(2,1,1);
plot(w, magnitude);
title('magnitude plot');
xlabel('w in radians/sample');
ylabel('|H(w)|');
subplot(2,1,2);
plot(w,phase);
title('phase plot');
xlabel('w in radians/sample');
ylabel('<H(w)');
15
MATLAB Prog Results: Magnitude Responses
for several M are shown in figure.
Designed for cut-off frequency: pi/4
rad/sample.
Length of unit impulse response: 2M+1
Phase response is non-zero (not shown).
16
Important implications in the design of
practical digital filters:
The frequency response cannot be zero over any finite frequency
band, except at a finite set of points in frequency.
The magnitude response cannot be constant in any finite range of
frequencies.
The transition from pass band to stop band cannot be infinitely
sharp There is always a transition band between pass band and
stop band.
Oscillatory behaviour (Ripples) in Practical frequency responses in
pass band and stop band (around cut off) is called Gibbs
Phenomenon.
The phase response is not zero. The magnitude and phase response
can’t be independently specified.
Practically we can design a filter with finite length of unit impulse
response: Finite Impulse Response (FIR) filter: Length of unit
impulse response is finite. Always have Ripples.
Practically it is also possible to design Infinite Impulse Response
(IIR) filter using feedback (recursion) to avoid ripples; but in that
case the unit impulse response will not follow the infinitely delayed
sinc function but some other practical function.
17
Paley Wiener Theorem:
Specifies necessary and sufficient condition for
magnitude response of a filter |H(𝜔)|to become
causal:
For causal unit impulse response h(n), the
magnitude spectrum function |H(𝜔)| must satisfy
following inequality:
𝜋
−𝜋
|ln(
𝐻(𝜔) )|𝑑𝜔 < ∞
Also, if |H( 𝜔)|
𝜋
is square integrable (having finite
energy) i.e. −𝜋 𝐻(𝜔) 2 𝑑𝜔 < ∞ then the system is
stable.
So, if magnitude frequency response satisfies
Paley-Wiener Theorem and square integrable, it
gives causal as well as stable filter.
18
Module II:
FIR and IIR
Digital Filters: Examples
19
FIR Filters:
The unit impulse response of an FIR filter has finite duration and
corresponds to having no denominator in the rational function
H(z):
There is no inherent feedback in the difference Equation
representation. This results in the reduced form:
M
y (n) bk x(n k )
k 0
Unit impulse response of causal FIR filter is given by:
h(n) bn ,0 n M M 1 taps
h(n) 0, otherwise
The FIR systems are always stable. S h n
n
2
0
Example of FIR filter: M-tap Moving
Average Filter
Causal M-tap Moving Average filter is given by difference
equation: 1
y ( n) ( x(n) x(n 1) ..... x(n ( M 1)))
M
1 M 1
M k 0
x(n k )
1
h( n) ;0 n M 1
M
1
H ( z) (1 z 1 z 2 ...... z ( M 1) )
M
H(z) contains only numerator polynomial of –ve power of z.
Have zeros located anywhere in z-plane and poles only at
origin only, no non-zero poles Always stable.
It can be implemented recursively or non-recursively.
Recursive implementation reduces hardware/ computation
required.
21
Non-Recursive implementation:
Const. Multiplier
M-1 -adders 1/
x(n) M
y(n)
Z-1 Z-1 Z-1
M-1 - Unit delay elements
Recursive implementation:
1
y (n) y (n 1) ( x(n) x(n M ))
M
2 -adders y(n)
1/
x(n) M
Const. Multiplier
-1 Z-1
Z-M
1 – M Unit delay element 22
Frequency Response of the Moving-
Average System
𝑀−1 −𝑗𝜔𝑛1
𝐻 𝜔 = 𝑒
𝑀 𝑛=0
MATLAB Plot for M=2, M=3 and M=20:
Basically a LPF; Magnitude response is not flat and contain sidelobes
that increase with M, Linear Phase response in pass band.
As M increases: BW reduces; more precise in detecting average.
magnitude plot
1 magnitude plot
1
|H(w)|
|H(w)|
0.5
0.5
0
-4 -3 -2 -1 0 1 2 3 4 0
w in radians/sample -4 -3 -2 -1 0 1 2 3 4
phase plot w in radians/sample
2 phase plot
4
<H(w)
<H(w)
1 2
0 0
-1 -2
-2 -4
-4 -3 -2 -1 0 1 2 3 4 -4 -3 -2 -1 0 1 2 3 4
w in radians/sample w in radians/sample
23
Infinite-duration impulse response (IIR)
Filter:
N M
y (n) ak y (n k ) bk x(n k )
k 1 k 0
M
Y ( z) k
b z k
H ( z) k 0
N
1 ak z k
X ( z)
k 1
The unit impulse response of the system is infinite in duration.
There is inherent feedback and it is implemented by using recursive
structures only.
IIR filters include the denominator term in H(z).
So it has non-origin poles in addition to zeros and poles at origin.
Stability needs to be investigated as they are not always stable.
However, IIR filters are implemented using recursive structures only
and resulted in less hardware/computation compared to FIR filters
with same specifications.
Also, with an IIR filter the magnitude frequency response can be
made more close to ideal.
The phase response is non linear.
The highest negative power of z in denominator polynomial (N)
specifies order of the filter and also number of non
24 – origin poles.
Example of IIR Filter:
x(n) y(n)
3/4 Z-1
-1/8
Z-1
Obtain governing difference equation, system transfer function, pole-zeros, stability, unit
impulse response and frequency response functions.
3 1
𝑦 𝑛 =𝑥 𝑛 + 𝑦 𝑛−1 − 𝑦(𝑛 − 2)
4 8
1 𝑧2 𝑧2
𝐻 𝑧 = 3 1 = 3 1 = 1 1
1− 𝑧 −1 + 𝑧 −2 𝑧2− 𝑧 + (𝑧− )(𝑧− )
2 4
4 8 4 8
Stable as poles inside unit circle in z-plane.
1 1
ℎ 𝑛 = (2( )𝑛 − ( )𝑛 )𝑢(𝑛) IIR
2 4
1
𝐻 𝜔 = 3 1
1− 𝑒 −𝑗𝜔 + 𝑒 −2𝑗𝜔
4 8
25
MATLAB Plot of unit impulse response
and frequency response:
26
Comparison of FIR and IIR filters:
Parameter FIR Filter IIR Filter
Length of h(n) Finite Infinite
Stability Always Stable Stable or Unstable,
Stability needs to be
investigated
Pole-zero Contains zeros located Contains zeros and poles
anywhere in z-plane, poles located anywhere in z-
only at origin plane
Implementation Recursive or Non-recursive Recursive only
Feedback Not inherent Inherent
Magnitude Contains ripples in passband Possible to have ripple
Response and stopband less passband and
stopband
Phase response Possible to have linear phase Non linear phase
response response only
Order of the filter More Less
and components
reqd. for same
27
specifications