You are on page 1of 35

FIR is a finite impulse response.

FIR system has an impulse response that is zero


outside of same finite time interval.
FIR system has a finite memory of length M
samples.

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)

The FIR filter can be characterized by its system function


N 1
H( z) = h (n )z n
n =0
The frequency response is given by,
N 1
H(e j ) = H() = h (n )e jn
n =0

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

Procedure for designing FIR filters using


windows:
1. For the desired frequency response Hd(ej), find the
impulse response hd(n) using, 1

2
h d (n) = H d (e j )d

2. Multiply the infinite impulse response with a


chosen window sequence w(n) of length N to obtain
filter coefficients h(n), i.e.,
h (n ) w (n ), for 0 n N - 1
h (n ) = d
0, otherwise

3. Find the transfer function of the realizable filter.

5
( N 1) 2
n
h (0) + h (n )(z + z )
( N 1) 2 n
H (z ) = z
n =0

Ex 3.2(NK): Design a LPF using rectangular 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 LPF the desired frequency response is,
e j ; - c c
H d () =
0 ; otherwise
Take inverse Fourier transform of Hd() to obtain hd(n),

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 )

When n = , sin c (n ) will become 0


indeterminate
( n ) 0
form .
For n = ; using LHospital rule, sin A
Lim 0
=A

sin c (n ) c
h d (n ) = Lim =
n ( n )

The impulse response of FIR filter is obtained by


multiplying hd(n) by window sequence,
h(n) = hd(n) WR(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)

The magnitude function of FIR filter when the


impulse response is symmetric & N is odd is given
N 1
below, 2

H () = h ( N21 ) + 2(h ( N21 n )) cos n


n =1

The transfer function of the filter is given by,


N 1
H(z ) = h (n ) z n
n =0
8
= h (n ) z n
n =0
3 8
= h ( n ) z n + h ( 4) z 4 + h ( n ) z n
n =0 n =5

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

X(Z) Z-1X(Z) Z-2X(Z) Z-3X(Z) Z-4X(Z)


Z-1 Z-1 Z-1 Z-1

+ + + +

Z-1 Z-1 Z-1 Z-1


Z-8X(Z) Z-7X(Z) Z-6X(Z) Z-5X(Z)
h(0) h(1) h(2)
h(3) h(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 )

When n = , hd(n) will become 0 indeterminate form .


0
For n = ; using LHospital rule, sin A
1 sin(n ) sin(n )c
Lim
0
=A
h d (n ) = Lim
n ( n ) (n )
1
= [ c ]

c
When n = , h d (n ) = 1

The window sequence for hamming window is given by,


WH (n ) = 0.54 0.46 cos( 2Nn1 ); for n = 0 to 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

Since both n and are integers,

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

Design an ideal band pass filter with a frequency


response,

Find the values of h(n) for N = 7.

From the desired frequency response, we can find that


the given response is symmetric N odd

15
For symmetry response,

For n = 0,

For n = -3, -2, -1, 1, 2, 3:

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

Homework (RB second Ed.)


1. Example 4.2
2. Example 4.4
3. Example 4.2(NK)
4. Example 5.6 (Use both transformations)
5. Example 5.29
6. Exercise 5.7
7. Example 6.6
8. Example 3.4(NK)
9. Example 3.5(NK)
10. Example 7.15

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

Input quantization error:


In DSP, the continuous time I/P signals are
converted into digital using a b-bit ADC.
The representation of continuous signal amplitude
by a fixed digit produces an error, which is known
as Input quantization error.

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.

Coefficient quantization error


In digital computation the filter coefficients are
represented in binary & are stored in registers.
If b bit register is used, the filter coefficients must be
rounded or truncated to b bits, which produce an
error.
Due to quantization of coefficients, the frequency
response of the filter may differ appreciably from the
desired response & sometimes the filter may actually
fail to meet the desired specifications.
If the poles of desired filter are close to the unit circle,
then those of the filter with quantized coefficients may
lie just outside the unit circle, leading to unstability.

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

If 8-bit register is available, then step size varies with


respect to range of the signal.
For the range between 0V to 5V,
5 5
step size = 8
= = 19.53mV
2 256

For the range between -5V to 5V,


10 10
step size = = = 39.0625mV
28 256

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.

What is rounding effect?


Rounding is the process of reducing size of a binary number to
finite size of b bits such that the rounded b-bit number is
closest to the original unquantized number.
The rounding process consists of truncation and addition.
In rounding of a number to b-bits, first the unquantized number is
truncated to b-bits by retaining the most significant b-bits.
Then zero or one is added to the least significant bit of the
truncated number depending on the bit that is next to the least
significant bit that is retained.
For Example:
0.101010 rounded to four bits is either 0.1010 or 0.1011 (Here
adding one is called rounding up).

24
Error due to rounding: The quantization error is fixed point
number due to rounding is defined as

In fixed point representation the range of error made by rounding


a number to b bits is
Error due to Truncation:
et = N t N
In fixed point representation the range of error made by
truncating a number to b bits is
2b < e 0

Quantization of input data:


e(n)
Quantization error, e(n ) = x q (n ) x (n )
xq(n) y(n)
x(n) h(n)
Mean of the error signal = 0
Variance of the error signal, 2
q
e2 =
12
Steady state noise power
2 2 2 b
due to For the range of 2V, = ;
12 e

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

Steady state output noise power:


( n ) = e( n ) h ( n )
n
e(n)
= h ( k )e( n k )
k =0 x(n) xq(n) y(n)
h(n)
Steady state variance,

2 (n ) = e2 h 2 (n ) e(n)
h(n)
(n)
n =0
Using Parsevals theorem, the steady state output noise variance
due to the quantization error is given by,

e2
2 (n ) = e2 h 2 ( n ) = H(z) H(z 1 )z 1dz
n =0 2j c
where the closed contour of integration is around the unit circle z = 1
in which case only the poles that lies in the unit circle are
evaluated using residue theorem.

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

The steady state noise power for a1 = 0.5, a2 = 0.6 is


given by,
02 = e2 [5.4315]

Limit cycle oscillations:


For an IIR filter, implemented with infinite precision
arithmetic, the output should approach zero in the
steady state if the input is zero & it should approach a
constant value, if the input is a constant.
However, with a implementation using finite length
register an output can occur even with zero input if
there is a non-zero initial condition on one of the
registers.
The output may be a fixed value (or) it may oscillate
between finite positive & negative values.

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.

Consider first order IIR filter with difference equation,


y(n) = y(n-1) + x(n)

Dead band for the first order filter is given by,

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

Because of finite length register the product 0.95 y(n-


1) in the difference equation must be rounded to 4-
bits before adding to x(n).
The output y(n) with rounding is given by,
y(n) = x(n) + Q[0.95y(n-1)]
where Q[.] stands for quantization.
For n = 0, y(0) = x(0) + Q[0.95y(-1)]
= 0.875 [y(-1) = 0]
For n = 1, y(1) = Q[0.95y(0)] + x(1)
= Q[0.95(0.875)] +0
= Q[0.83125]
(0.83125)10 = (0.1101010)2

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

For n = 3, y(3) = Q[0.95(0.75)]


= Q[0.7125]
(0.7125)10 = (0.101101)2
(0.1011)2 = (0.6875)10
y(3) = 0.6875
Similarly, y(4) = 0.625
y(5) = 0.625
y(6) = 0.625
From the above calculations it can be observed that for
n 5, the output remains constant at 0.625 causing
limit cycle behaviour.

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

You might also like