Professional Documents
Culture Documents
Fir Filters
Fir Filters
Fir Filters
1
IIR Filter FIR Filter
All the infinite samples of impulse Only N samples of impulse response
response are considered. are considered.
The impulse response cannot be The impulse response can be directly
directly converted to digital filter converted to digital filter transfer
transfer function. function.
The design involves analog filter The digital filter can be directly
design and then transforming analog designed to achieve the desired
filter to digital filter. specifications.
The specifications include the desired The specifications include the desired
characteristics for magnitude characteristics for both magnitude
response only. and phase response .
IIR filter can become unstable (if the FIR filter is always stable
poles of the IIR filter are outside the
unit circle)
2
Symmetric condition:
If the unit impulse for a FIR filter has the property that,
h(n) = h(N-1-n), then its phase is linear.
Gibbs phenomenon
3
Features of a good window for FIR filters:
1. Side lobe level should be small.
2. Broaden middle section.
3. Attenuation should be more.
4. Smoother magnitude response.
5. The trade off between main lobe widths and side lobe
level can be adjusted.
6. Smoother ends.
7. If cosine term is used then side lobes are reduced further.
Windowing
Based on Truncated Fourier series
4
Windowing
h (n ) = 0 n N 1
Rectangular: w(n) = 1
Hanning: 2n
w h (n ) = 0.51 cos
N 1
Hamming: 2n
w H (n ) = 0.54 0.46 cos
N 1
2
h d (n) = H d (e j )d
5
( N 1) 2
n
h (0) + h (n )(z + z )
( N 1) 2 n
H (z ) = z
n =0
6
1 1 c j jn
2 2 c
jn
h d (n ) = H d ()e d = e e d
c
1 c j ( n ) 1 e j ( n )
2 c
= e d =
2 j(n )
c
1 e jc ( n ) e jc ( n )
=
2 2j
1
h d (n ) = sin c (n )
(n )
sin c (n ) c
h d (n ) = Lim =
n ( n )
7
Rectangular window sequence is given by,
1; for n = 0 to N - 1
WR (n ) =
0; otherwise
h(n) = h d (n ); n = 0 to N - 1
N 1
Here, c = 1.2 radians/sec and N = 9; = =4
2
sin c (n )
h d (n ) = ; n
( n )
sin(1.2 x (4))
When n = 0; h (0) = = 0.0793
(4)
sin(1.2 x (3))
When n = 1; h (1) = = 0.0470
(3)
sin(1.2 x (2))
n = 2; h (2) = = 0.1075
( 2)
sin(1.2 x (1))
n = 3; h (3) = = 0.2967
(1)
c
h d (n ) = ; n=
1 .2
When n = 4(n = ); h (4) = = 0.3820
8
sin(1.2 x (1))
When n = 5; h (5) = = 0.2967
(1)
sin(1.2 x (2))
n = 6; h (6) = = 0.1075
(2)
sin(1.2 x (3))
n = 7; h (7) = = 0.0470
(3)
sin(1.2 x (4))
n = 8; h (8) = = 0.0793
(4)
The impulse response is satisfying the symmetry
condition h(N-1-n) = h(n)
9
3
H ( z ) = h ( n ) z n + z ( 8 n ) + h ( 4) z 4
[ ]
n =0
Y (z )
X (z )
[ ] [
= h (0) z 0 + z 8 + h (1) z 1 + z 7 + h (2) z 2 + z 6] [ ]
+ h (3)[z 3
+ z 5 ] + h ( 4) z 4
+ + + +
+ + + +
Y(Z)
10
Ex 3.3(NK): Design a HPF using hamming window
by taking 9 samples of w(n) and with a cutoff frequency
of 1.2 radians/sec.
Solution:
c = 1.2 radians/sec and N = 9
For a HPF the desired frequency response is,
e j ; - c & c
H d () =
0 ; otherwise
Take inverse Fourier transform of Hd() to obtain hd(n),
1 1
h d (n ) =
2
H d ()e jn d =
2
e j e jn d
1 c j ( n )
= e d + e j( n ) d
2 c
1 e j ( n ) e j ( n )
c
= +
2 j(n ) j(n )
c
1 e jc ( n ) e j ( n ) + e j ( n ) e jc ( n )
=
2 j(n )
11
1 e j ( n ) e j ( n ) e j c ( n ) e j c ( n )
h d (n ) =
( n ) 2j 2j
1
h d (n ) = [sin(n ) sin(n )c ]; for n
( n )
c
When n = , h d (n ) = 1
h(n) = h d (n ) WH (n ); n = 0 to N - 1
1
h (n ) = [sin(n ) sin(n )c ]
( n )
[0.54 0.46 cos( 2Nn1 )]; for n
= 1 c [0.54 0.46 cos( 2Nn1 )]; for n =
12
N 1
Here, c = 1.2 radians/sec and N = 9; = =4
2
sin(n )c
h (n ) = [0.54 0.46 cos( 2Nn1 )]; for n
( n )
= 1 c [0.54 0.46 cos( 2Nn1 )]; for n =
sin(4)(1.2)
When n = 0; h (0) = [0.54 0.46 cos(0)] = 0.0063
( 4)
sin(3)(1.2) 2
When n = 1; h (1) = 0.54 0.46 cos 8 = 0.0101
(3)
n = 2; h ( 2) = 0.0581
n = 3; h (3) = 0.2567
1.2
When n = 4; h (4) = 1 [0.54 0.46 cos( )] = 0.6180
n = 5; h (5) = 0.2567
n = 6; h (6) = 0.0581
n = 7; h (7) = 0.0101
n = 8; h (8) = 0.0063
13
Design a low pass filter with Hd()
H d ()
e j2 ; 4
H d () =
0; 4
using Hann window, with N = 5.
1
Solution: H d ()e d
jn
h d (n ) =
2 4 4
1 4 j2 jn 1 4 j( n 2 )
2 4 2 4
h d (n ) = e e d = e d
=
1
2j(n 2)
e [
j( n 2 ) 4
e
j( n 2 ) 4
]
2j
= [sin(n 2) 4 ]
2j(n 2)
sin(n 2) 4 1
h d (n ) = ; n2 h d ( 2) = ; n = 2
(n 2) 4
1 1 1
h d ( 0) = sin = h d (3) = = h d (1)
2 2 2
2
1 1
h d (1) = sin = 1
4 2 h d (4) = = h d ( 0)
2
14
From the Hanning window function,
1
Wh (n ) = (1 cos N2n1 ) = 1 (1 cos 2 4n )
2 2
1
Now , Wh (0) = 0 = Wh (4); Wh (1) = = Wh (3) and
2
Wh ( 2) = 1
h ( 0) = 0 = h ( 4)
1
h (n ) = h d (n ) Wh (n ) h (1) = = h (3)
2 2
1
h ( 2) =
4
15
For symmetry response,
For n = 0,
16
Design a high pass filter with Hd()
0 ; 4
H d () = j2
e ; 4
using Rectangular window given by,
1 ; 0 n 4
W (n ) =
0 ; otherwise
17
The fundamental operation in digital filters are
multiplication and addition.
When these operations are performed in a digital system
the input data and output data (product & sum) have to
be represented in finite word length, which depends on
the size(length of the register) used to store the data.
In digital computation the I/P & O/P data (sum &
product) are quantized by Rounding or Truncation to
convert them to a finite word size.
18
This creates error (noise) in the input or creates
oscillations (limit cycles) in the output.
These effects due to finite precision representation of
numbers in a digital system are called finite word
length effects.
19
The following are some of the finite word length effects in
digital filters:
1. Errors due to quantization of input data by A/D converter.
2. Errors due to quantization of filter co-efficient.
3. Errors due to rounding the products in multiplication.
4. Errors due to overflow in addition.
5. Limit cycles
20
Types:
1. Input quantization error
Errors due to rounding of I/P data
2. Product quantization error
Errors due to rounding the product in multiplication
3. Coefficient quantization error
Errors due to quantization of filter coefficients
Limit cycles:
Due to product quantization & overflow in addition
21
Product quantization error
Arises at the output of a multiplier.
Multiplication of a b bit data with a b bit
coefficient results a product having 2b bits. Since a
b bit register is used, the multiplier output must
be rounded or truncated to b bits, which produces
an error.
22
Quantization step size:
Let us assume a sinusoidal signal varying between +1 & -1
having a dynamic range 2.
If ADC used to convert the sinusoidal signal employs b+1
bits including sign bit, the number levels available for
quantizing x(n) is 2b+1.
Thus the interval between successive levels represents the
step size.
Quantization step size is given by,
2
q = b +1 = 2 b
2
23
1. Truncation
Process of discarding all bits less significant than LSB
that is retained.
2. Rounding
Rounded to the closest of the original number.
24
Error due to rounding: The quantization error is fixed point
number due to rounding is defined as
input quantization 2
Qq =
2 b +1
25
Quantization of filter coefficients:
Consider a second order IIR filter with
1.0
H ( z) =
(1 0.5z 1 )(1 0.45z 1 )
find the effect on quantization on pole locations of the
given system function in direct form-I & in cascade
form. Take b = 3 bits.
Solution:
Direct Form-I:
1.0
H( z) =
1 0.95z + 0.225z 2
1
(0.95)10 = (0.11110011.)2
(-0.95)10 = (1.11110011.)2
After Truncation, (1.111)2 = (- 0.875)10
(0.225)10 = (0.0011100)2
After Truncation, (0.001)2 = (0.125)10
So, 1. 0
H ( z) =
1 0.875z 1 + 0.125z 2
26
Cascade Form:
1.0
H ( z) =
(1 0.5z )(1 0.45z 1 )
1
(-0.5)10 = (1.100.)2
(-0.45)10 = (1.011100.)2
After Truncation, (1.100)2 = (- 0.5)10
After Truncation, (1.011)2 = (- 0.375)10
1. 0
H (z) =
(1 0.5z )(1 0.375z 1 )
1
27
Example 7.5 (NK): Consider the transfer function
H(z) = H1(z)H2(z) where H (z) = 1 and H (z) = 1 1 1 2 1
1 a z 1 a z 1 2
(i). Find out output roundoff noise power. (ii). Assume,
a1 = 0.5 and a2 = 0.6 and find out output roundoff
noise power.
x(n) y(n)
e1(n) e2(n)
Z-1 Z-1
a1 a2
1
H( z) = [as seen by e1 (n )]
(1 a1z )(1 a 2 z 1 )
1
1
H 2 (z ) = [as seen by e 2 (n )]
(1 a 2 z 1 )
2 2 2
Total steady state noise variance is given by 0 = 01 + 02
e2
2j c
2
01 = H(z )H(z 1 )z 1dz
2 1 1
2
01 = e 1 1
z 1dz
2j c (1 a 1z )(1 a 2 z ) (1 a 1z)(1 a 2 z)
[
= e2 sum of residues of H(z)H(z -1 )z -1
1 1
at poles z = a 1 , z = a 2 , z = ,z =
a1 a2
28
1 1
If a 1 and a 2 are less than 1, poles z = ,z =
a1 a2
lies outside the unit circle, so the residues of
1 1
H(z)H(z -1 )z -1 at z = ,z= are zero.
a1 a2
2
01 [
= e2 sum of residues of H(z)H(z -1 )z -1
at poles z = a1 , z = a 2 ]
z 1
= e2 (z a 1 )
(1 a1z 1 )(1 a 2 z 1 )(1 a1z)(1 a 2 z) z =a
1
z 1
+ (z a 2 ) 1 1
(1 a 1z )(1 a 2 z )(1 a 1z)(1 a 2 z ) z =a 2
2 a 1 1 a2 1 1
01 = e2 1 2
+ 2
a1 a 2 1 a 1 1 a 1a 2 a 2 a1 1 a 2 1 a 1a 2
Similarly, e2
2j c
2
02 = H 2 ( z)H 2 (z 1 )z 1dz
e2 1 1
2
02 = 1
z 1dz
2j c (1 a 2 z ) (1 a 2 z )
z 1
= e2 ( z a 2 )
(1 a 2 z 1 )(1 a 2 z ) z =a
2
2 1
02 = e2 2
1 a 2
29
1 a1 1 1 a2 1 1
02 = e2 2
+ 2
+ 2
1 a 2 a 1 a 2 1 a 1 1 a 1a 2 a 2 a 1 1 a 2 1 a 1a 2
30
This effect is referred to as (zero-input) limit cycle
oscillations & is due to the non-linear nature of the
arithmetic quantization.
The amplitude of the output during a limit cycle are
confined to a range of values called the dead band of
the filter.
In the case of FIR filters, there are no limit cycle
oscillations, if the filter is realized in direct form or
cascade form since, these structures have no
feedback.
2b
1
2
y(n 1)
1
31
Example 7.18 (RB): Explain the characteristics of
limit cycle oscillation with respect to the system
described by the difference equation,
y(n) = 0.95 y(n-1) + x(n)
Determine the dead band of the filter.
Solution:
Let us assume 4-bit sign magnitude representation
(excluding sign bit)
Let the input,
x(n) = 0.875 for n = 0
= 0, otherwise
32
After rounding to 4-bits, we get,
Q[0.83125] = (0.1101)2 = (0.8125)10
y(1) = 0.8125
For n = 2, y(2) = Q[0.95y(1)] + x(2)
= Q[0.95(0.8125)]
= Q[0.771875]
(0. 771875)10 = (0.110001)2
After rounding to 4-bits, we get,
(0.110001)2 = (0.1100)2 = (0.75)10
y(2) = 0.75
33
The dead band is given by
2 b
1
2
Dead band =
1
1
2 2 4
For, b = 4, = = 0.625
1 0.95
34