DSP - Class Notes
DSP - Class Notes
doc 1
Introduction to DSP:
Text Books : (P) = Proakis , (M) = Mitra (I) = Iffeachor.
(previous reference continues to apply unless change is indicated)
Signals: (p)
speech, biomedical, music, video, radar,
DSP concerned with digital representation of signals, and use of digital processors to
analyse, modify, and extract information.
Advantages:
• Guaranteed accuracy: no. of bits
• Perfect reproducibility: no equipment dependence, tolerances etc.
• No drift in performance with age, temp,
• With CMOS, reliability, small size, low cost, low power and high speed
• Flexibility: a given system can be reprogrammed, with same hardware
• Superior, near ideal performance: i.e. linearity, adaptive filtering etc
• Storage: digital storage media can be used
Applications:
• Image processing: pattern recognition, enhancement,
• Control and Instrumentation: spectral analysis, noise reduction, and data
compression
• Speech: recognition and synthesis, text to speech, equalisation
• Military: secure communication, radar and sonar, guidance systems.
• Communications: echo suppression, adaptive equalisation, spread spectrum,
• Bio-medical: EEG-ECG analysis, scanners, X-ray storage, and enhancement
Here F can be increased without limit, and can also be 0, and all resulting signals are
distinct. Increasing F results in increase in the rate of oscillation.
k
2πf 0 N = 2kπ , where k is an integer, or f 0 = and must be a rational number.
N
In this case however s k + N (n) = e j 2π n ( k + N ) = e j 2π N s k (n) = s k (n) and there are only N
distinct complex exponentials in the set.
N −1
Hence x(n) = c k e j 2π k n / N is a periodic signal with fundamental period N
k =0
Sampling: (P)
Consider uniform sampling of an analogue signal x(n) = x a (nT ) where T is sampling
1
period, and Fs = the sampling frequency.
T
n
Since t = nT = the analogue sinusoid can be written as
Fs
x a (t ) = A cos(2πFt + θ )
F
thus x a (nT ) = x(n) = A cos(2πFnT + θ ) = A cos 2πn +θ
Fs
Comparing with the discrete time sinusoid expression
DSP2008.doc 4
x(n) = A cos(2πfn + θ )
F
we find f = or ω = ΩT .
Fs
1 1
Since − ≤ f ≤ and − π ≤ ω ≤ π , the frequency of the continuous time sinusoid
2 2
1
when sampled at Fs = must fall in range
T
1 Fs Fs 1
− T =− ≤F≤ ≤ T
2 2 2 2 ,
π π
− = −πFs ≤ Ω ≤ πFs =
T T
F0 + kFs F
x(n) = x a (nT ) = A cos 2π n = A cos 2π 0 n
Fs Fs
which is the same as the first signal.
Thus the process of sampling introduces an ambiguity (Aliasing).
If the signal has a highest freq. Fmax = B then it follows that to avoid aliasing,
Fs
Fmax < or Fs > 2Fmax
2
The sampling theorem states that for Fs > 2 B , x a (t ) can be exactly recovered using
sin(2πBt )
the interpolation function G (t ) =
2πBt
Thus
∞
n n
x a (t ) = xa g t−
n = −∞ Fs Fs
DSP2008.doc 5
Discrete-Time Signals:
Sequences of numbers (samples) represented by x[n] where n is integer with range
−∞ < n < ∞.
The signal is the set {x[n]}.
Infinite:
Right Sided.
Zero values for n < N1, N1 negative or positive.
x[n] = 0 n <-2, and
=n n ≥ -2
If N1 ≥ 0 then CAUSAL.
Left Sided:
zero for n > N2.
If N2 ≤ 0 then ANTI CAUSAL.
x[n] = -(1/n) n ≤ -5
=0 n > -5
Two Sided:
Has -∞ ≤ n ≤ + ∞.
x[n] = 1/n2
DSP2008.doc 6
Even / Odd:
Conjugate symmetric x[n] = x*[-n]
If all x[n] real then EVEN
Conjugate asymmetric x[n] = -x * [-n],
If all x[n] real then ODD
Periodic:
x[n] = x[n + kN] for all n, N is a positive integer, and is the PERIOD of sequence
Nf = fundamental period is the period with smallest N
Bounded:
|x[n]| ≤ Bx < ∞
x[n] = 0 n≤0
= 1/n n > 0
Absolutely Summable:
|x[n]| < ∞
Square Summable:
E = |x[n]|2 < ∞, E is the energy
Exponential:
x[n] = Aα n , where A , α are complex in general and α = e σ 0+ jω 0
, A = A e jΦ .
x re [n] = A e σ 0 n cos(ω 0 n + Φ )
xim [n] = A e σ 0 n sin (ω 0 n + Φ )
For a real sinusoid x[n] = A cos(ω 0 n + Φ ) , ω 0 is angular frequency.
In Phase Sequence:
For a real sinusoid sequence x[n] = xi [n] + x q [n] ,
DSP2008.doc 7
Quadrature Sequence:
x q [n] = − A sin φ sin(ω 0 n) is the quadrature sequence.
Addition:
w2[n] = x[n] + y[n]
Scalar multiplication:
w3[n] = A . x[n]
Time Reversal:
w4[n] = x[-n]
Delay:
w5 [n] = x[n - N] N positive
Advance:
w6[n] = x[n + N]
Sampling Process: ( M)
samples at nT = n F = 2π n Ω
T T
= A cos 2π Ω 0 + kΩ T ) n +Φ
ΩT
= A cos 2πΩ 0 n +Φ
ΩT
= A cos(ω 0 n + Φ )
= x[n]
If Ω T > 2Ω 0 , then − π < ω 0 < π implies no aliasing, otherwise aliasing is observed.
Example:
v(t) = 6 cos (60 π t) + 3 sin (300 π t) + 2 Cos (340 π t) + 4 cos (500 π t)
+ 10 sin (660 π t) is sampled at T =1/200 sec.
Giving
v[n] = 6 cos (0.3πn) + 3 sin (1.5πn) +2 cos (1.7πn) + 4 cos (2.5πn)
+ 10 sin (3.3πn)
= 6 cos (0.3πn) + 3 sin ((2π - 0.5π)n) + 2 cos ((2π - 0.3π)n)+4 cos((2π + 0.5π)n)
- 10 sin ((4π - 0.7π)n)
= 8 cos (0.3πn) + 5 cos (0.5πn + 0.6435) - 10 sin (0.7πn)
example:
y[n] = nx[n] is linear
y1[n[ = nx1[n], y2[n] = nx2[n] thus y3[n] = n([a1x1[n] + a2x2[n])
also a1y1[n] +a2y2[n] = a1nx1[n] + a2nx2[n] .
but
n n
αy1 [n] + βy 2 [n] = αy1 [−1] + α x1 [k ] + β y 2 [−1] + β x2 [k ]
k =0 k =0
which can equal y[n] only if y[-1] = α y1[-1] + β y2[-1] for all α, β, y[-1], y1[-1] and
y2[-1]. This is possible if and only if system starts from rest with initial condition
zero. Otherwise it is Nonlinear
Causality:
y[n0] depends only on x[n] where n ≤ n0
Stability:
Bounded input gives bounded output (BIBO Stability)
if |x[n]| < Bx then |y[n]| < By
Impulse Response:
denoted by {h[n]} is the response to a unit sample sequence {δ[n]}
Step Response:
{S[n]} → response to {µ [n]}
Output is the weighted linear combination of the past M input samples. Has a
memory of M samples. It can be realised by adders, multipliers and finite memory.
∴
n 1
y[n] = y[n − 1] + x[n]
n +1 n +1
The expression is recursive, and calculation requires 2 multiplication, 1 addition and
1 memory location (y[n-1]).
Recursive System:
Systems whose output depends on past output values. In the previous example
y[n0] = (n0/ n0+1)y[n0-1] + (1/ n0+1)x[n0],
y[n0-1] is the initial condition at n = n0. Computation of the output of a recursive
system at a time say n0 requires computation of the previous values of y[k] in correct
order.
Non-Recursive System:
Such systems depend only on the present and past inputs.
DSP2008.doc 12
Causal FIR systems are non-recursive. Their computation can be in any order
For an initially relaxed system y[-1] = 0, and the output is the zero-state response or
the Forced response.
For a non-relaxed system, with x[n] = 0 for all n output is called zero input response
or Natural or Free response.
BIBO:
Bounded Input Bounded Output Stable if and only if for every bounded input, and
every bounded initial condition the total system response is bounded.
Example:
y[n] = ay[n-1] +x[n]
Assume x[n] is bounded i.e. |x[n]| ≤ Mx ≤ ∞ for all n ≥ 0. Then
n
|y[n]| ≤ | an+1y[-1] | + a k x[n − k ]
k =0
n
≤ |a| n+1|y[-1]| + Mx
k
a
k =0
n +1
n+1 1− a
≤ |a| |y[-1]| + Mx = My
1− a
DSP2008.doc 13
examples:
1. x[n] = [1,2,5,7,0,1]
x(z) = 1 + 2z-1 + 5 z-2 + 7z-3 + z-5 ; ROC entire z-plane except z = 0
2. x[n] = [1,2,5,7,0,1]
x(z) = 1z2 + 2z + 5 + 7z-1 + z-3 ; ROC entire z-plane except z = 0, ∞
3. x[n] = [0,0,1,2,5,7,0,1]
x(z) = z -2 + 2z-3 + 5z-4 + 7z-5 + z-7 ; ROC entire z-plane except z = 0
4. x[n] = δ [n]
X(z) = 1; ROC entire z-plane
example:
x[n] = αn u[n] i.e. α n when n ≥ 0 and 0 when n < 0
has
∞ ∞
X ( z) = α n z −n = (αz −1 ) n
0 0
∏ (z − z k )
X ( z ) = Gz N − M 1
N
∏ (z − p
1
k )
where G = b0/a0, then there are M finite zeros, N finite poles and N - M zeros
(if N > M) or poles (if N < M) at the origin. Zeros and poles may also exist at ∞
The ROC of the z-transform does not contain poles, and is bounded by them.
single pole - real signal: pole also must be real. –ve pole causes signal to alternate in
sign.
double real poles in expression of type x[n] = nanu[n]. unbounded increase even on
unit circle.
DSP2008.doc 15
Transfer Function:
The multiple M poles at 0 are trivial, and there are M nontrivial zeros. This is an All-
Zero system, It has a finite duration Impulse response (FIR).
If bk= 0 for 1 ≤ k ≤ n the system is an All-Poles system. Its impulse response is
infinite duration (IIR).
In the general case both poles and zeros exist. Because of the poles the system will be
IIR.
Its magnitude is the magnitude response and its angle is the phase response.
G(w) = 20 log10| H(ejw) | dB is the GAIN function and – G(w) is called Attenuation
or LOSS function.
For a real impulse response h[n] magnitude response is even and phase response is
odd.
The negative of derivative of the angle θ(w) w.r.t. w is called the GROUP DELAY.
DSP2008.doc 16
then
M
p k e − jwk
H (e jw ) = k =0
N
d k e − jwk
k =0
p ∏ (z − ξ k )
H ( z) = 0 z N −M 1
N
d0
∏ (z − λ
1
k )
where ξ1, ξ2, are the finite zeros and λ1, λ2 etc are the finite poles. There are
additional N-M zeros or poles at origin.
• FIR transfer function is always stable, For IIR all poles must be within the unit
circle for stability.
• Poles and zeros determine the filter behaviour, and may be placed to obtain a
particular frequency response.
• Poles near the points (but inside unit circle) emphasise the frequency
corresponding to the point on the circle.
• Zeros may be placed near frequency to be de-emphasised, and need not be
within the unit circle.
DSP2008.doc 17
• Complex zeros and poles must occur in conjugate pairs to make filter
coefficients real
The z-transform of the LTI system may be expressed in terms of its poles and zeros
N
∏ K (z − z ) i
H ( z) = 1
N
∏ (z − p )
1
i
To be lowpass, we must have poles near the unit circle near w = 0 and zeros near or
on unit circle at w = π .
Single pole filter
1− a
H ( z) =
1 − az −1
Constant factor is (1-a),to make the amplitude gain unity at w = 0 and the gain is
small at high frequency.
Addition of a zero at –1 attenuates response at high frequency further.
1 − a 1 + z −1
H ( z) =
2 1 − az −1
with a < 1 for stability
2(1 − a) 2 (1 + cos w)
H (e ) =
jw
2(1 + a 2 − 2a cos w)
Here | H(ejw)|2 = H(z)H(z-1)| z = ejw is given by
This is monotonically decreasing, it is maximum at w = 0 and is 0 at w = π
DSP2008.doc 20
or
Example:
the M-point moving average system
has
M −1
1
y[n] = x[n − k ]
M k =0
h[n] = (1/M) 0 ≤ n ≤ M-1
=0 otherwise
with M = 2 the transfer function is
H(z) = ½(1 + z-1)
Its frequency response is
H(jw) = e-jw/2 cos(w/2)
A higher order moving average filter will be an even better approximation to ideal LP
filter.
Example:
A two pole LP filter is H(z) = b0/(1−pz-1)2
Determine b0 and p such that H(0) = 1 and |H(π/4)|2 = ½
Here when w = 0
H(ej0) = b0/(1-p)2 = 1 at w = 0
so b0 = (1-p)2
At w = π / 4
H(ejπ/4)= (1-p)2 / (1-pe-j π /4)2
= (1-p)2 / (1-p Cos(π /4) + j p sin(π /4))2
= (1-p)2 / (1-p/√2 + jp/√2)2
Then (1-p)4 / [(1-p/√2)2 + p2/2] 2 = ½
Or √2(1-p)2 = 1 + p2 – √(2p)
Solution is p = 0.32 giving H(z) = 0.46 / (1-0.32z-1)2
replacing w by w- π gives
M
(−1) k bk e − jwk
H hp ( w) = k =0
N
1+ (−1) k ak e − jwk
k =1
Example:
The LPF y(n) = 0.9y(n-1) + 0.1x(n) give HPF y(n) = -0.9y(n-1) + 0.1x(n)
with frequency response as Hhp(w) = 0.1/(1− 0.9e –jw)
A Band pass filter should contain one or more pairs of complex conjugate poles near
the unit circle, near the frequency band that is the pass-band.
1− a 1 − z −2
H ( z) =
2 1 − β (1 + a ) z −1 + az − 2
Has centre frequency w0 = cos-1(β) and 3-dB bandwidth = cos-1 (2a/(1+a2))
A band stop filter has zero on the unit circle at the frequency w0, and has a transfer
function of the form
1+ a 1 − 2 βz −1 + z −2
H ( z) =
2 1 − β (1 + a ) z −1 + az − 2
Its notch frequency is w0 = cos-1(β) and 3-dB bandwidth is cos-1 (2a/(1+a2)) like in
the BPF.
Example:
Design a two pole BPF with pass-band centred at w = π/2 zeros at w = 0 and π and
magnitude response is 1/√2 at w = 4 π / 9
Then
( z − 1)( z + 1) z 2 −1
H ( z) = G =G 2 2
( z − jr )( z + jr ) z +r
The frequency response at π/2 is
π 2
H =G =1
2 (
1− r2 )
or G = (1-r2)/2
which gives
1.94(1-r2)2 = 1 − 1.88 r2 + r4
which is having solution
r2 = 0.7,
so the system function is
H(z) = (0.15)(1−z -2)/(1+ 0.7z−2)
Digital Resonator:
This is a two-pole BPF with a pair of complex conjugate poles near the unit circle.
Angular position of the poles determines the resonant frequency. For resonance at
w = w0 we select poles at
p1, 2 = re ± jw
0
0<r<1
we may also select two zeros at the origin or at 1 and –1
choosing zeros at the origin, the system function is
b0 b0
H ( z) = − jw0 −1
=
(1 − re jw0
z )(1 − re z ) 1 − (2r cos w0 ) z −1 + r 2 z − 2
−1
at w = w0
b0 b0
H ( w0 ) = =
(1 − re jw0 e − jw0 )(1 − re − jw0 e − jw0 ) (1 − r )(1 − re − j 2 w0 )
we select b0 such that
b0
H ( w0 ) = =1
(1 − r ) (1 + r 2 − 2rCos 2 w0 )
Thus b0 = (1 − r ) (1 + r 2 − 2rCos 2 w0 )
DSP2008.doc 24
1 − e− j 2w
H ( w) = b0
[ ][
1 − re j ( w0 − w) 1 − re j ( w0 + w) ]
N ( w) = 2(1 − cos 2 w
The amplitude response is |H(w)| = b0N(w)/U1(w)U2(w) where N(w) is defined as
above.
Thus the resonant frequency and bandwidth are altered by the added zeros.
A two pole resonator for which the poles lie on the circle.
b0
H ( z) =
1 − (2r cos w0 ) z −1 + r 2 z −2
± jω
has complex conjugate poles at re 0 and unit sample response
h[n] = [born/(sin wo)]×sin(n+1)wou(n)
If r = 1, bo = A sinwo then h[n] =A sin(n+1)wou(n) giving sinusoidal oscillations.
Used to eliminate specific frequencies. E.g. power line frequency and its harmonics.
To create a notch at w0 introduce a pair of conjugate complex zeros at angle w0 on the
unit circle.
DSP2008.doc 25
z1, 2 = e ± jω0
Thus system function for a FIR notch filter would be
H ( z ) = b0 (1 − e jω0 z −1 )(1 − e − jω0 z −1 ) = (1 − 2 cos ω 0 z −1 + z −2 )
The notch will have a large bandwidth. This can be reduced by adding a pair of
complex poles at p1, 2 = re ± jω 0
1 M −k 1 [1 − z − ( M +1) ]
H ( z) = z =
M + 1 k =0 M + 1 1 − z −1
If the frequency response of the original filter is H(w) then for the above equation it
is
M
H ( w) = h(k )e − jkLw = H ( Lw)
k =0
One way is to process finite data by passing it through a causal real coefficient filter,
reversing the output in time and reprocessing it by the same filter.
Else, we can use a filter having a response H(ejw) = e-jwD, having a group delay D.
Zero Locations:
Using symmetry we can write
N N
h( z ) = h[n]z − n = h[ N − n]z − n
n=o n =o
using m= N-n
N N
H ( z) = h[m]z − N + m = z − N h[m]z m = z − N H ( z −1 )
m =0 0
Thus for a given zero of H(z) its reciprocal is also a zero. Further zeros must be
conjugates for a real coefficient response. Hence any complex zero not on unit circle
is associated with three other zeros
for the zeros on the unit circle, its reciprocal is also the conjugate, so these zeros are a
pair
z = e±j ϕ
z = σ and z = 1/σ
Any zero at +1 or –1 is its own reciprocal and can appear only once.
giving
H(z) = z-7/2{ h[0](z7/2+z-7/2) + h[1](z5/2+z-5/2) + h[2](z3/2+z-3/2) + h[3](z1/2+z-1/2)}
or
H(z) = e-j7w/2{2h[0] cos (7w/2) + 2h[1] cos(5w/2) + 2h[2] cos(3w/2) + 2h[3]cos(w/2)}
N /2
H (e jw ) = e − jNw / 2 e jπ / 2 c[n] sin( wn)
n =0
H(z) = -z-NH(z-1)
Hence the poles are located as in the previous case and there is also a zero at z = -1 as
H(-1) = -H(-1).
Similarly there is a zero at +1 as H(1) = -H(1)
It cannot be used in high-pass, Low-pass or Band-stop filters because of these zeros.
zero placements follow same rules as earlier cases but there is no zero at –1, and
there is a zero at 1
This means it cannot be used as a low-pass filter
group delay is N/2 and frequency response has form
N +1 / 2
H (e jw ) = e − jNw / 2 e jπ / 2 d [n] cos( w(n − 12 ))
n =1
H (e jw ) = e − jNw / 2e jβ h( w) where β = 0 or π / 2
Zero locations for various cases of symmetric and anti-symmetric impulse response
functions.
A( z −1 )
H ( z) = z − N
A( z )
and H(z)H(z-1) = 1= |H(z)|2, If z0 is a pole, then 1/z0 is a zero.
DSP2008.doc 30
Properties:
The All-pass function is a lossless bounded real transfer function.
The magnitude of A(z)< 1 for z >1, = 1 for z = 1, < 1 for z <1
Unwrapped phase is monotonically decreasing so that group delay is positive.
The change in the phase of the Mth order all-pass function as w goes from 0 to π
radians is M π
Application is as a delay equaliser. If G(z) is a filter designed to meet a given
amplitude specification, its phase response will inn general be non-linear, It can then
be cascaded with an all-pass filter A(z) such that the overall function has a linear
phase and constant group delay
Given the same poles in two functions, the zeros influence the phase of the functions.
H1(z) = (z+b)/(z+a) and H2(z) = (bz+1)/(z+a) with a <1, b <1 both have poles
within unit circle and are stable zeros are at –b and –1/b.
Magnitudes are identical as H1(z).H1(z-1) = H2(z).H2(z-1)
Phase of H1(z) varies from 0 at w = 0 to +ve values to 0 at w = π , of H2(z) phase
varies from 0 at w = 0 to – π at w = π
In general, a causal, stable transfer function with all zeros outside the unit circle has
an excess phase (maximum phase function) compared with a function having all
zeros inside (minimum phase function)
DSP2008.doc 31
If the zeros have a mirror image symmetry, the magnitude responses are identical, but
phase responses differ.
When all the zeros are inside the unit circle, net phase change between w = 0 and
w = π is 0. This is called a MINIMUM PHASE system. It has minimum group
delay.
When all zeros are outside the unit circle, the net change is M π
This is called a MAXIMUM PHASE system.
Any non-minimum phase function can be expressed as a product of a minimum phase
function and an all-pass function.
Stability:
d1 ± d12 − 4d 2
λ1, 2 = −
2
Gives d1 < 1 + d2
The poles (roots) will be within unit circle if d1 and d2 lie in the stability triangle.
DSP2008.doc 32
Let DM(z) be the denominator polynomial and let DM be its mirror image
polynomial.
M
DM ( z ) = d i z −i with d 0 = 1
i =0
DM ( z )
AM ( z ) =
DM ( z )
If
M M
DM ( z ) = ∏ (1 − λi z −1 ) then d M = ∏ λi hence dM < 1
i =1 i =1
k2M <1
now form a new AM-1(z) given by
AM ( z ) − k M A ( z) − d M
AM −1 ( z ) = z =z M
1 − k M AM ( z ) 1 − d M AM ( z )
d i − d M d M −i
i =
with d ' i = 1,2,3, M −1
1 − d M2
example:using
DSP2008.doc 33
• FIR can have linear phase response, are always stable if realised non-
recursively, are affected less by quantisation and rounding errors
• IIR require less no. of coefficients. They are derivable using analog filter
design techniques, and are easier to synthesise
• Therefore use IIR when requirement is for a sharp cut-off and high throughput
• Use FIR if no . of coefficients is not too large, and if linear phase is required
where N is the filter length. It is a non-recursive all zero form and is always stable.
This is a straightforward way to calculate the response.
FIR filters can also be made to have an exactly linear phase response, with constant
group and phase delays. Thus the filter is non-distorting.
Finally FIR structures are easier to implement, and typical DSP processor
architectures are suited to FIR filtering, the implementation results in less finite
word-length errors.
Let the ideal filter be HD(w), then its impulse response is hD(n) which is obtained by
inverse Fourier transform.
Ideal impulse responses of the different filters are given below;
LP:
sin( nω c )
hD (n) = 2 f c
nω c
n ≠ 0, with hD(0) = 2fc
HP:
sin( nω c )
hD (n) = −2 f c
nω c
n ≠ 0, with hD(0) =1- 2fc
BP:
sin( nω 2 ) sin( nω1 )
hD (n) = 2 f 2 − 2 f1
nω 2 nω1
n ≠ 0, with hD(0) =2(f2-f1)
BS:
sin( nω1 ) sin( nω 2 )
hD (n) = 2 f1 − 2 f2
nω1 nω 2
n ≠ 0, with hD(0) =1-2(f2-f1)
w(n) = 1 , n = 0,1,…,M-1
= 0 elsewhere.
DSP2008.doc 35
In the frequency domain, this gives convolution of HD(w) and W(w), the latter having
the (sin x)/x shape.
The resulting impulse response of the windowed filter has ripples and overshoots in
the pass and stop bands (Gibbs Phenomena).
The transition width of the filter is greater, and depends on the width of the main lobe
of the window function, and the ripples depend on the sidelobes.
Rectangular:
The frequency response of the rectangular window has a narrow main lobe and much
lower ripples or sidelobes. Main lobe width is 4 π /(2M+1), defined by zero crossings
of the main lobe. As M increases this width decreases., but the area under each lobe
remains constant. The main-lobe width is also the width measured between the
maxima and minima on either side of wc., at wc , H(jw) = 0.5, and pass-band and
stop-band ripples are the same. The transition band is less than lobe width. The ripple
does not depend on the filter length and wc.
w(n) = 1 n ≤ (N-1)/2 = M
Transition width: 0.92 π /M, main lobe width 4 π /(2M+1)
Passband ripple: 0.7416
Main lobe relative to side lobe: 13 dB
DSP2008.doc 37
Stopband attenuation: 21 dB
Hanning: (M,I)
w(n) = 0.5 + 0.5Cos(2πn/N) n ≤ (N-1)/2
Transition width: 3.1 π /M, main lobe width 8π /(2M+1)
Passband ripple: 0.0546
Main lobe relative to side lobe: 31 dB
Stopband attenuation: 44 dB
Hamming: (M,I)
w(n) = 0.54 + 0.46Cos(2πn/N) n ≤ (N-1)/2
Transition width: 3.3 π /M, main lobe width 8 π /(2M+1)
Passband ripple: 0.0194
Main lobe relative to side lobe: 41 dB
Stopband attenuation: 53 dB
Blackman: (M,I)
w(n) = 0.42 + 0.5Cos(2πn/N-1) + 0.08 Cos(4πn/N-1) n ≤ (N-1)/2
Transition width: 5.5 π /M main lobe width 12π /(2M+1)
Passband ripple: 0.0017
Main lobe relative to side lobe: 57 dB
Stopband attenuation: 74 dB
These windows have fixed characteristics, and equal Passband and Stopband ripples.
This is their major disadvantage.
DSP2008.doc 38
if A ≤ 21 dB, β=0
21 < A < 50 dB β = 0.5842(A-21)0.4 + 0.07886(A-21)
A ≥ 50 dB β = 0.1102(A-8.7)
where A = -20 log (δ ) and δ = min(δp, δs).
The number of coefficients N is given by
Example:
FIR filter having specifications:
DSP2008.doc 39
Example:
Passband 150-250 Hz, Transition width 50 Hz, Passband ripple 0.1dB Stopband
attenuation 60 dB, sampling frequency 1kHz.
Here 20 log(1+ δp) = 0.1 giving δp = 0.0115
-20 log δs = 60 giving δs = 0.001
now δ = min(δp, δs) = 0.001
Attenuation requirements can only be met by Kaiser and Blackman.
For Kaiser number of coefficients
N ≥ (60-7.95) / 14.36(50/1000) = 72.49 i.e. 73
The ripple parameter is β = 0.1102(60-8.7) = 5.65
Ideal response cutoffs are at fc1 – δf/2 and fc2 + δf/2, i.e. 125 and 275 Hz
For Blackman window N = 5.5/δf = 5.5/(50/1000) = 110.
DSP2008.doc 40
This method is based on the sampling of the ideal frequency response desired, and
then taking the inverse DFT of the samples to get h(n)
If N samples are taken at intervals kFs/N, k ==0,1,…N-1
Then
N −1
1
h( n) = H (k )e j ( 2π / N ) nk
N k =0
where a = (N-1)/2
N −1
1
h( n) = H (k ) cos[2πk (n − a ) / N ]
N k =0
as h(n) is real. For a linear phase filter h(n) is symmetric leading to:
N / 2 −1
1
h( n) = 2 H (k ) cos[2πk (n − a ) / N ] +H (0)
N k =0
The response is poor in the transition region, and stop band attenuation is insufficient.
Better response can be obtained by including samples in the transition region.
The window and frequency sampling methods produce ripple that is maximum near
band edges, and decreases further away..
The Optimal method distributes ripples evenly (equiripple) over stop and pass bands,
giving a better approximation to the desired frequency response.
Let HD(w) be the ideal and H(w0 the actual and W(w) be a weighting function that
allows the relative error of the approximation to be defined
Then the difference between ideal and practical is E(w) = W(w)[HD(w) –H(w)]
The method finds the h(n) which minimises the maximum weighted error in the pass
and stop bands
It can be shown that when max E(w) is minimised the filter will have an equi-
ripple response, with the ripple alternating between two equal amplitude levels.
(Alteration Theorem) for linear phase filters there are
R+1 or R+2 such extremas, R = (N+1)/2.
The locations of the extremal frequencies are generally not known except at the band
edges fp and fs/2
If the extremal frequencies can be found, then the frequency response is known, and
the impulse coefficients can be obtained.
DSP2008.doc 42
Example:
Linear phase equiripple filter , pb 0.3 –0.5 , sb 0 – 0.25, 0.55-1, desired pb magnitude
= 1 , sb magnitude 0, order 27
» n= 27;
» f = [0,0.25,0.3, 0.5,0.55,1];
» m= [0,0,1,1,0,0];
» b = remez(n,f,m);
» [h,w] = freqz(b,1,256);
» mag = 20*log10(abs(h));
» plot(w/pi, mag,' b'); grid;
»
BPF, passband 8-12kHz, Sbripple 60dB, peak pb ripple: 0.001, fs = 44.14 kHz,
transition width 3 kHz
f =[5,8,12,15];
» m=[0,1,0];
» dev = [0.001, 0.001,0.001];
» fs = 44.14;
» [n,fo,mo,w] = remezord(f,m,dev,fs);
» b= remez(n,fo,mo,w);
» [h,om] = freqz(b,1,256);
» mag = 20*log10(abs(h));
» plot(om/(2*pi),mag,'b'); grid;
DSP2008.doc 43
n = 48
fo = 0, 0.22655188038061, 0.36248300860897, 0.54372451291346,
0.67965564114182
1.00000000000000
mo =0 0 1 1 0 0
w =1 1 1
• Optimum method is the easiest and efficient, with total control over
specifications, but requires the necessary software.
• Window method gives equal pass and Stopband ripples, and is suitable for
direct application. It may result in overdesign in any one band, and does not
give full control over ripples and cut-off frequencies.
• Frequency sampling method can be applied directly or recursively, and integer
coefficients can be used. It is suitable for primitive ALUs and for designing
filters with arbitrary bands. It lacks control over edge frequencies and ripples.
ADC noise:
Quantization error, reduced by using ADC with larger bit length
Roundoff error:
x(n-m) is 12 bit and h(n) is 16 bit. The 24 bit product is rounded off to 16 bits in
memeory, or 12 bit in DAC, may result in more severe effect than ADC quantisation.
Avoided partly by using double length registers and rounding in the final step.
DSP2008.doc 44
Overflow error:
When the sums exceed allowed wordlength. Avoided by scaling down h(n) and
inputs by constants = sum of terms and then rescaling.
IIR selection:
• IIR require less no. of coefficients. They are derivable using analog filter
design techniques, and are easier to synthesise
• Therefore Use IIR when requirement is for a sharp cut-off and high throughput
Ideal filters have brick-wall characteristics, which do not give causal impulse
responses, and are therefore unrealisable.
A realisable filter, say a LPF is generally specified by giving a desired passband gain
of 1 with acceptable error (tolerance) ±δ p (Pass band deviation).
| Ha(j Ω ) | ≤ δs for Ωs ≤ Ω ≤ ∞
Ωp and Ωs are the passband and stopband edge frequencies and δp and δs are the
ripples
1+δ p
1
1-δ p
1/√1+ε2
passband passband
stopband stopband
δs 1/A
Ωp Ωs Ωp Ωs F/2
transition band transition band
1//√ (1+ε2),
The maximum stopband ripple is 1/A.
Placing a zero at given point in z-plane makes frequency response 0 at that point and
a pole produces maximum response.
Poles close to unit circle give large peaks and zeros close to the circle produce
troughs.
For the coefficients to be real poles and zeros must be either real or in conjugate
pairs. Further, poles must be within unit circle for stability
For the pole with r > 0.9, bandwidth is approximately
DSP2008.doc 46
r = 1-(BW/F)π
Example:
Bandpass filter with complete rejection at 0 and 250 Hz, narrow passband centred at
125 Hz, and 3-dB bandwidth 10 Hz. Sampling frequency 500 Hz.
zeros at 0 and 360 x 250/500 = 180 degrees. Pass band at 125 requires poles at
± 360 x 125/500 = ± 90 as conjugate pair.
with BW = 10, F = 500, r = 0.937 for poles 0.937
Example 2
Notch filter, notch frequency 50 Hz, 3 dB BW ± 5Hz, sampling
500 Hz.
To reject 50 Hz, a pair of complex zeros at ± 360 x 50/500
= ± 36 degrees
To get sharp rejection a pair of poles at r < 1, from BW 10 Hz
we get r = 0.938
The H(z) is
H(z) = [z- e - j36][z- e j36]/ [z-0.937e –39.6] [z-0.937e +39.6] giving
1 − 1.6180 z −1 + z −2
H ( z) =
1 − 1.5161z −1 + 0.8780 z − 2
with
y[n] = x[n] − 1.6180 x[n − 1] + x[n − 2] + 1.5161 y[n − 1] − 0.8780 y[n − 2]
jw’ Im z
-1 1 Re z
σ
s-plane z-plane
imaginary axis maps to unit circle, LHP to a point within the unit circle, and RHP to
a point outside.
Making substitution z = ejwT and s = jw’
s-plane w’ = k tan (wT/2), k = 1 or T/2
so +ve imaginary axis in s-plane is the upper half of unit circle. Similarly for the
negative imaginary axis the lower half of the unit circle. This is a non-linear
mapping and introduces a distortion called frequency warping.
We therefore have to pre-warp the critical bandedge frequency to find their analog
equivalents, design the analog prototype, using these pre-warped frequency and the
transform with bilinear transform
w’=k tan(wT/2)
w
π
0 W’
-π
Example:
Normalised transfer function is H(s) = 1 / (s+1). Sampling frequency 150 Hz and cut-
off 30 Hz
Critical frequency is wp = 2 π 30 rad.
analogue frequency after pre-warping wp’ = tan (wpT/2) with T = 1/150 we get
wp’=0.7265
The de-normalised transfer function is H’(s) = 1/[(s / 0.7265) + 1]
then H(z) = H’(s) with bilinear transform substitution
H(z) = 0.4208 (1 + z –1) / (1-0.1584 z –1)
The difference equation is y[n] = 0.1584y[n-1] + 0.4208[x[n] +x[n-1]]
2 1
) =
H ( w'
1 + ( w'/ w'
p)
2N
n=4
0
0 1 3
Butterworth LP
DSP2008.doc 49
The transfer function has zero at ∞ and uniformly spaced poles on a circle of radius
wp’ in the s-plane These poles occur in conjugate pairs and lie on LHS of s-plans
Chebychev: (I,P)
Two types
1. Type 1 with equiripple passband, monotonic stopband
2. Type II with monotonic passband, equiripple stopband
1 1
n=3
n=2 n=4
0 0
0 1 3 0 1 3
Cheby I LP Cheby II LP
n=4
0
0 1 3
Elliptic LP
For given specification, lowest order is required for Elliptic. next Chebychev and
highest order for Butterworth.
For a given order, sharpest transition region in the same order
In Butterworth and Chebychev Linear phase is approximated for up to ¾ pass-band
region
Elliptic has a linear phase response unto about half its passband.
Best phase performance is by Bessel filter of order N. This gives linear phase
response, but amplitude performance has a less sharp roll-off.
s
For LP to LP : s = where w'p is the critical frequency
w'p
w'p
For LP to HP : s =
s
2
s + w0
2
For LP to BP : s = ; w02 = w1 'w1 '
; Ws = w2 '
− w1 '
Ws
Ws
For LP to BS : s = 2 2
s + w0
DSP2008.doc 51
example:
w1T
w1' = tan = tan(200π / 2000) = 0.3249
2
w2T
w2' = tan = tan(300π / 2000) = 0.5095
2
∴ w0 = 0.1655, W = w2 '
− w1 '= 0.1846
ana log LP has 1 / 2 order of BP
1
∴ H (s) =
s +1
Using LP to BP transformation
1 Ws
( s ) = H ( s ) s = ( s 2 + w 2 ) / Ws =
H' 2
= 2 2
0
( s + w0 ) / WS + 1 s + Ws + w0
2
Applying BZT
W ( z − 1) /( z + 1)
H ( z) = H '
( s ) s = ( z −1) /( z +1) = 2
[( z − 1) /( z + 1)]2 + W ( z − 1) /( z + 1) + w0
Substituting value for W and w02
1 − z2
H ( z ) = 0.1367
1 − 1.2362 z −1 + 0.7265 z − 2
If the H(s) is of a high order, we express it in a factored form for cascade realisation
with first and second order factors and then transform each factor separately.