Sei sulla pagina 1di 54

PEMP

ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Session 3:Time-Domain Filtering
Session delivered by:
Chandan N.

1
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Session Objectives
To discuss several noise reduction examples and experiments to
introduce important time-domain techniques for processing digital
signals and analyzing simple DSP systems.
To understand the fundamental time-domain DSP concepts which is
helpful and more interesting to examine real-world DSP applications
with the help of interactive MATLAB tools
To understand the concepts of FIR and IIR filter
2
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Introduction to Digital systems
Moving-Average Filters
Digital Filters
Realization of FIR Filters
Nonlinear Filters
Examples
Introduction to FIR and IIR
Structures for FIR Systems
Structures for IIR Systems
Session Topics
3
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Introduction
A DSP system (or algorithm) performs operations on digital
signals to achieve predetermined objectives.
In some applications, the single-input, single-output DSP
system processes an input signal x(n) to produce an output
signal y(n).
The general relationship between x(n) and y(n) is described as
y(n) =F [x(n)],
where F denotes the function of the digital system.


Figure : General block diagram of digital system
4
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Introduction
DSP system consists of the interconnection of adders, multipliers, and
delay units.
A digital filter alters the spectral content of input signals in a specified
manner.
Common filtering objectives include removing noises, improving signal
quality, extracting information from signals, and separating signal
components that have been previously combined.
A digital filter is a mathematical algorithm that can be implemented in
digital hardware and software and operates on a digital input signal for
achieving filtering objectives.
A digital filter can be classified as being linear or nonlinear, time invariant
or time varying.
5
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
To process signals, we have to design and implement systems called filters.
The filter design issue is influenced by such factors as
The type of the filter: IIR or FIR
The form of its implementation: structures
Different filter structures dictate different design strategies.
Introduction
6
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Since our filters are LTI systems, we need the following three
elements to describe digital filter structures.
Adder
Multiplier (Gain)
Delay element (shift or memory)
x1(n)
x2(n)
x1(n)+x2(n)
x(n) ax(n)
a
x(n) x(n-1)
1/z
Introduction
7
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
1 ;
1 ) (
) (
) (
0
1
1
1
1 0
0
0
=
+ + +
+ + +
= = =


=

a
z a z a
z b z b b
z a
z b
z A
z B
z H
N
N
M
M
N
n
n
n
M
n
n
n

The system function of an IIR filter is given by


The difference equation representation of an IIR filter is expressed
as

= =
=
M
m
N
m
m m
m n y a m n x b n y
0 1
) ( ) ( ) (
Structures for IIR Systems
8
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Three different structures can be used to implement an IIR filter:
Direct Form:
In this form, there are two parts to this filter, the moving average part and the recursive
part (or the numerator and denominator parts)
Two version: direct form I and direct form II
Cascade Form:
The system function H(z) is factored into smaller second-order sections, called
biquads. H(z) is then represented as a product of these biquads.
Each biquad is implemented in a direct form, and the entire system function is
implemented as a cascade of biquad sections.
Parallel Form:
H(z) is represented as a sum of smaller second-order sections.
Each section is again implemented in a direct form.
The entire system function is implemented as a parallel network of sections.
Structures for IIR Systems

9
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Direct Form I Structure:
Consists of the zeros of H(z)
Consists of the poles of H(z)

= =
=
M
k
N
k
k k
k n y a k n x b n y
0 1
) ( ) ( ) (
Structures for IIR Systems

10
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Direct Form I Structure:
Structures for IIR Systems

11
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
) 2 ( ) 1 ( ) 2 ( ) 1 ( ) ( ) (
2 1 2 1 0
+ + = n y a n y a n x b n x b n x b n y
Direct Form I Structure:
As the name suggests, the difference equation is implemented as given using
delays, multipliers, and adders.
For the purpose of illustration, Let M =N =2,
x( n) y( n) b0
b1
b2
- a1
- a2
1/ z
1/ z
1/ z
1/ z
H1( z) H2( z)
Direct Form I structure
Structures for IIR Systems

12
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
) 1 ( ) ( ) 1 ( ) (
1 0 1
+ + = n x b n x b n y a n y
Given a LTI system with a rational transfer function H(z)
1
1
1
1 0
1
) (

+
=
z a
z b b
z H
Direct Form
I structure
Structures for IIR Systems

13
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
We can implement the system with
the following pair of coupled
difference equations: ) 1 ( ) ( ) (
) ( ) 1 ( ) (
1 0
1
+ =
+ =
n w b n w b n y
n x n w a n w
The
commutative
law of the
convolution
Structures for IIR Systems

14
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Direct Form II Structure:
Structures for IIR Systems

15
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Direct Form II Structure:
x( n) y( n)
H1( z)
- a1
- a2
1/ z
1/ z
H2( z)
b0
b1
b2
1/ z
1/ z
x( n) y( n)
H( z)
- a1
- a2
1/ z
1/ z
b0
b1
b2
The
commutative
law of the
convolution
Structures for IIR Systems

16
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Cascade Form:
In this form the system function H(z) is written as a product
of second-order section with real coefficients.
This is done by factoring the numerator and denominator
polynomials into their respective roots and then combining
either a complex conjugate root pair or any two real roots
into second-order polynomials.
Structures for IIR Systems

17
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
We assume that N is an even integer. Then
Cascade Form:
2
2 ,
1
1 ,
2
2 ,
1
1 ,
1
0
1
1
1
0
1
1
1
1 0
1
1
1
1
1
) (
0 0
1


=




+ +
+ +
=
+ + +
+ + +
=
+ + +
+ + +
=
z A z A
z B z B
b
z a z a
z z
b
z a z a
z b z b b
z H
k k
k k
K
k
N
N
N
b
b
b
b
N
N
N
N
N

Where, K is equal to
N/2, and B
k,1,
B
k,2,
A
k,1,
A
k,2
are real numbers
representing the
coefficients of
second-order section.

Structures for IIR Systems

18
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
) ( ) ( ); ( ) (
, , 2 , 1 ,
1
1
) (
) (
) (
1 0 1
2
2 ,
1
1 ,
2
2 ,
1
1 ,
1
z Y z Y z X b z Y with
K k
z A z A
z B z B
z Y
z Y
z H
K
k k
k k
k
k
k
= =
=
+ +
+ +
= =
+


+

Biquad Section:
Is called the k-th biquad section. The input to the k-th biquad section is the
output from the (k-1)-th section, while the output from the k-th biquad is the
input to the (k+1)-th biquad. Each biquad section can be implemented in direct
form II.
Y
k
(n)=X
K+1
(n)
Y
k+1
(n)
-A
k,1
-A
k,2
1/z
1/z
B
k,1
B
k,2
Structures for IIR Systems

19
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Example:
x(n)
y(n)
-A
1,1
-A
1,2
1/z
1/z
B
1,1
B
1,2
-A
2,1
-A
2,2
1/z
1/z
B
2,1
B
2,2
b
0
Cascade form structure for N=4
Structures for IIR Systems

20
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Example:
Determine the cascade
structure the following
transfer function:
Structures for IIR Systems

21
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
( )
( )( )
( )( )
( )
( )
( )
( )
1
1
1
1
1 1
1 1
2 1
2 1
z 25 . 0 1
z 1
z 5 . 0 1
z 1

z 25 . 0 1 z 5 . 0 1
z 1 z 1
z 125 . 0 z 75 . 0 1
z z 2 1
z H

+
=

+ +
=
+
+ +
=
Example:
Cascade of Direct Form I
Cascade of Direct Form II
Determine the cascade
structure the following
transfer function:
Structures for IIR Systems

22
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Parallel Form:
In this form the system function H(z) is written as a sum of second-
order section using partial fraction expansion.

N M if only
N M
k
k
k
K
k
k k
k k
N M if only
N M
k
k
k
N
N
N
M
N
N
M
M
z C
z A z A
z B B
z C
z a z a
z b z b b
z a z a
z b z b b
z A
z B
z H

+
+ +
+
=
+
+ + +
+ + +
=
+ + +
+ + +
= =
0 1
2
2 ,
1
1 ,
1
1 , 0 ,
0
1
1
1
1 0
1
1
1
1 0
1
1

1 ) (
) (
) (
K=N/2, and
B,A are real
numbers
Structures for IIR Systems

23
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
The second-order Section:

< = =
=
+ +
+
= =

+
N M z Y z Y z X z H z Y with
K k
z A z A
z B B
z Y
z Y
z H
k k k
k k
k k
k
k
k
), ( ) ( ), ( ) ( ) (
, , 2 , 1 ,
1 ) (
) (
) (
2
2 ,
1
1 ,
1
1 , 0 ,
1

Is the k-th proper rational biquad section.


The filter input is available to all biquad section as well as to the polynomial
section if M>=N (which is an FIR part)
The output from these sections is summed to form the filter output.
Each biquad section can be implemented in direct form II.
Structures for IIR Systems

24
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Structures for IIR Systems
Parallel form structure for N=4 (M=N=4)
C
0
B
1,0
-A
1,1
-A
1,2
B
1,1
B
2,0
-A
2,1
-A
2,2
B
2,1
x(n) y(n)
1/z
1/z
1/z
1/z
25
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Example:
Determine the parallel
structure the following
transfer function:
H(z) must be expanded in partial fractions:
Structures for IIR Systems

26
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Structures for IIR Systems
Example: (Cont.)
27
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Three different structures can be used to implement an FIR filter:
Direct Form.
Cascade Form.
Linear Phase Form.
Frequency Sampling Form.
Lattice Form.
Structures for FIR Systems
28
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Direct Form :
The difference equation is implemented as a tapped delay line
since there are no feedback paths.
Note that since the denominator is equal to unity, there is
only one direct form structure.
Structures for FIR Systems
29
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Example :
Determine the Direct form structure for the following
FIR Filter:
Structures for FIR Systems
30
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru

2 / ); 1 (
1
) (
2
2 ,
1
1 ,
1
0
1
0
1
1
0
1
0
1
1
1
1 0
M K z B z B b
z
b
b
z
b
b
b
z b z b b z H
k k
K
k
M
M
M
M
= + + =
|
|
.
|

\
|
+ + + =
+ + + =

=

Cascade Form :
Cascade form FIR structure for
6-order FIR filter
Structures for FIR Systems
31
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Linear Phase System :
A LTI system is said to have Linear Phase if the frequency
response has the form
where real is a real number
A system is said to have Generalized Linear Phase if the
frequency response has the form
where A(e
jw
) is a
real-valued function
of , and is a
constant
Often the term linear phase is used to denote a system that
has either linear or generalized linear phase.
2
0 , , ) (

= < = or w w e H
jw
Structures for FIR Systems
32
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
For an FIR filter with a real-valued impulse response of length M, a
sufficient condition for this filter to have generalized linear phase is that
the h(n) be whether symmetric or anti symmetric.
For a causal FIR filter with M Length and impulse over
[0,M-1] interval, the linear-phase conditions
1
0
( ) ( )
M
j j k
k
H e h k e

=
=

1
0
( ) ( ) ( )
M
k
y n h k x n k

=
=

1 0 , 2 / ); 1 ( ) (
1 0 , 0 ); 1 ( ) (
= =
= =
M n n M h n h
M n n M h n h

The length of the impulse response of the FIR filter (M) can be even or odd.
Linear Phase System :
Structures for FIR Systems
33
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Linear phase filters may be classified into 4 types,
depending upon whether h(n) is symmetric or anti symmetric
and whether M is even or odd.
Linear Phase System :
1. Type I Linear Phase: Symmetrical and M even
2. Type II Linear Phase: Symmetrical and M odd
3. Type III Linear Phase: Anti-symmetrical and M even
4. Type IV Linear Phase: Anti-symmetrical and M odd
Structures for FIR Systems
34
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
16 M =
h(1)=h(14)
( ) h n
n
h(0)=h(15)
h(2)=h(13)
h(7)=h(8)
Type I Linear Phase:
Symmetric and M even
1
1
2
2
0
1
( ) 2 ( )cos
2
M
M
j
j
k
M
H e e h k k

| |
=
|
\ .

Symmetrical Impulse Response, M: Even


Structures for FIR Systems
35
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Symmetrical Impulse Response, M: Odd
( ) h n
n
15 M =
h(0)=h(14)
h(7)=h(7)

h(1)=h(13)
h(6)=h(8)
Type II Linear Phase:
Symmetric and M odd
H(e
jw
)
Structures for FIR Systems
36
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Antisymmetrical Impulse Response, M: Even 16 M =
( ) h n
n
h(0)=-h(15)
h(7)=-h(8)
h(1)=-h(14)
Type III Linear Phase:
Anti Symmetric and M even
H(e
jw
)
Structures for FIR Systems
37
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Antisymmetrical Impulse Response, M: Odd
n
( ) h n
17 M =
h(0)=-h(16)
h(1)=-h(15)
h(8)=-h(8)=0
h(7)=-h(9)
!
Type IV Linear Phase:
Anti Symmetric and M odd
H(e
jw
)
Structures for FIR Systems
38
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Structures for FIR Systems
39
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru

+ + + + + + =
+ + + + + + =
)] 2 ( ) 1 ( [ )] 1 ( ) ( [
) 1 ( ) 2 ( ) 1 ( ) ( ) (
1 0
0 1 1 0
M n x n x b M n x n x b
M n x b M n x b n x b n x b n y
Linear Phase Form :
Consider the difference equation with a symmetric impulse response.
The linear-phase structure is essentially a direct
form draw differently to save on multiplications.
For
M
odd
Structures for FIR Systems
40
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Example:
Determine the Linear phase structure for the
following FIR Filter:
The length of the filter is 7
Structures for FIR Systems
41
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Example:
7 6 5 4 3 2 1
) 0 ( ) 1 ( ) 2 ( ) 3 ( ) 3 ( ) 2 ( ) 1 ( ) 0 ( ) (

+ + + + + + + = z h z h z h z h z h z h z h h z H
Determine the Linear phase structure for the
following FIR Filter:
The length of the filter is 8
Structures for FIR Systems
42
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Moving-Average Filters:
Structures And Equations
As shown in Figure below, the effect of noise causes signal
samples to fluctuate from the original values; thus the noise
may be removed by averaging several adjacent samples.
The moving (running)-average filter is a simple example of a
digital filter.
An L-point moving-average filter is defined by the following
input/output (I/O) equation


where each output signal y(n) is the average of L consecutive
input signal samples.

43
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Example
Figure : Original (open circles) and corrupted (x) signals
44
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Moving-Average Filters
Implementation of above Equation requires L 1 additions and L memory
locations for storing signal sequence x(n), x(n 1), . . . , x(n L +1) in a
memory buffer.
As illustrated in Figure below, the signal samples used to compute the output
signal y(n) at time n are L samples included in the window at time n. These
samples are almost the same as the samples used in the previous window at
time n 1 to compute y(n 1), except that the oldest sample x(n L) in the
window at time n 1 is replaced by the newest sample x(n) of the window at
time n.


45
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Moving-Average Filters
Thus previous equation can be computed as


Therefore, the averaged signal, y(n), can be computed recursively based on
the previous result y(n 1). This recursive equation can be realized by
using only two additions.
However, we need L +1 memory locations for keeping L +1 signal
samples {x(n), x(n 1) . . . x(n L)} and another memory location for
storing y(n 1).
The recursive equation given in above equation is often used in DSP
algorithms, which involves the output feedback term y(n 1) for computing
current output signal y(n).
46
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Example
To remove the noise that corrupts the sine wave as shown in Figure we
implement the moving-average filter with L =5, 10, and 20, using the
MATLAB code example.m.
The original sine wave, noisy sine wave, and filter output for L =5 are
shown in Figure in next slide
This figure shows that the moving-average filter with L =5 is able to reduce
the noise, but the output signal is different from the original sine wave in
terms of amplitude and phase.
In addition, the output waveform is not as smooth as the original sine wave,
which indicates that the moving-average filter has failed to completely
remove all the noise components.
In addition, we plot the filter outputs for L =5, 10, and 20 in Figure for
comparison. This figure shows that the filter with L =10 can remove more
noise than the filter with L =5 because the filter output is smoother for L =
10; however, the amplitude of the filter output is further attenuated. When
the filter length L is increased to 20, the sine wave component is attenuated
completely.
47
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Moving-Average Filters
Figure : Performance of moving-average filter, L = 5
48
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Moving-Average Filters
Figure : Moving-average filter outputs, L = 5, 10, and 20
49
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Digital Filters
The I/O equation given below can be generalized as a difference equation
with L parameters, expressed as



where bl are the filter coefficients.
The moving-average filter coefficients are all equal as bl =1/L.
We can use filter design techniques to determine different sets of
coefficients for a given specification to achieve better performance.
Define a unit impulse function as


FIR Filter Equation
Substituting x(n) = (n), the output is called the impulse response
of the filter, h(n), and can be expressed as

50
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Example
The moving-average filter defined above is an FIR filter of length L (order
L 1) with the same coefficients b
l
=1/L.
Consider an FIR Hanning filter of length L =5 with the coefficient set {0.1
0.2 0.4 0.2 0.1}.
Similar to Example , we can implement this filter with MATLAB script
example2_4.m and compare the performance with the moving-average
filter of the same length.
The outputs of both filters are shown in Figure . The results show that the
five-point Hanning filter has less attenuation than the moving-average
filter. Therefore, we show that better performance can be achieved by
using different filter coefficients derived from filter design techniques.

51
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Example
Figure :Comparison of moving-average and Hanning filters, L = 5
52
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Nonlinear Filters
An efficient technique for reducing impulse noise is the use of a
nonlinear filter, median filter.
An L-point running median filter can be implemented as a first-in
first-out buffer of length L to store input signals x(n), x(n 1), . . . ,
x(n L +1).
These samples are moved to a new sorting buffer, where the
elements are ordered by magnitude.
The output of the running median filter y(n) is simply the median of
the L numbers in the sorting buffer.
Medians will not smear out discontinuities in the signal if the signal
has no other discontinuities within L/2 samples and will
approximately follow low-order trends in the signal.
53
PEMP
ESD2521
M.S. Ramaiah School of Advanced Studies, Bengaluru
Session Summary
Signals represent a message or information and are represented
mathematically as a function of one or more independent variables, e.g.
time.
A system is an operation that transforms input signal x into output signal y.
The signals encountered in the real world such as speech, music, and noise
are random signals.
The moving (running)-average filter is a simple example of a digital filter
An efficient technique for reducing impulse noise is the use of a nonlinear
filter, median filter.
Realisation of a digital filter amounts to constructing a block diagram of
the internal structure of the filter.
Realisation of LTI filters need only three blocks.

54

Potrebbero piacerti anche