Professional Documents
Culture Documents
HANDOUT 8.
Dr David Corrigan1 .
Electronic and Electrical Engineering Dept.
corrigad@tcd.ie www.mee.tcd.ie/corrigad
This handout is based on the set of notes produced by Prof. Anil Kokaram
www.sigmedia.tv
1 DIFFERENCE EQUATION
400
1100
350
1000
300
900
450
250
200
150
100
700
600
500
400
50
0
0
800
300
10
20
30
40
200
0
50
20
40
60
Days
80
100
120
140
Days
To calculate the average share price over the last 10 days you could do
something like
[
]
1
yn =
xn + xn1 + xn2 + . . . xn9
10
where n is the day, xn is the share price at day n, and yn is the average
price over 10 days.
This is a digital lter called the moving average lter. It can be applied
to every day n to yield a value for the average share price over the last
10 days.
Applying this lter to the Iona signal yields the following.
450
1200
400
1000
350
300
250
200
150
800
600
400
100
200
50
0
0
10
20
30
40
50
Days
0
0
20
40
60
80
100
120
140
Days
www.sigmedia.tv
1 DIFFERENCE EQUATION
Consider what the shape of the output signal looks like compared to the
input. What is the dierence? What has been removed? The signal is
smoothed. The moving average lter is a low pass lter.
What happens if we average over more days?
[
]
1
xn + xn1 + xn2 + . . . xn(N 1)
yn =
N
1200
1200
1000
1000
800
600
400
200
0
0
800
600
400
200
20
40
60
80
100
120
0
0
140
20
40
60
Days
80
100
120
140
Days
1200
1000
800
600
400
200
0
0
20
40
60
80
100
120
140
Days
www.sigmedia.tv
2 DIFFERENCE EQUATION
www.sigmedia.tv
2 DIFFERENCE EQUATION
[
]
1
y0 = x0 + x01 + x02
3
[
]
1
= x0 + x1 + x2
3
[
]
1
= 270.2806 + 0 + 0
3
= 90.09
[
]
1
y1 = x1 + x11 + x12
3
[
]
1
= x1 + x0 + x1
3
[
]
1
= 257.9545 + 270.2806 + 0
3
= 176.08
[
]
1
y2 = x2 + x21 + x22
3
[
]
1
= x2 + x1 + x0
3
]
[
1
= 268.2720 + 257.9545 + 270.2806
3
= 265.50
[
]
1
y3 = x3 + x31 + x32
3
[
]
1
= x3 + x2 + x1
3
[
]
1
= 272.81 + 268.2720 + 257.9545
3
= 266.34
[
]
1
y4 = x4 + x41 + x42
3
[
]
1
= 0 + 272.81 + 268.2720
3
=
3C1 Signals and Systems
www.sigmedia.tv
2.1
2 DIFFERENCE EQUATION
Impulse Response
[
]
1
yn = xn + xn1 + xn2
3
What is the impulse response of this lter? Well, just put an impulse in
and see what comes out!
xn = n = 1, 0, 0, 0, 0, . . .
[
]
1
y0 = x0 + x1 + x2
3
[
]
1
= 1+0+0
3
= 1/3
[
]
1
y1 = x1 + x0 + x1
3
= 1/3
[
]
1
y2 = x2 + x1 + x0
3
= 1/3
[
]
1
y3 = x3 + x2 + x1
3
=0
]
[
1
y4 = x4 + x3 + x2
3
=0
So the impulse response hn = (1/3), (1/3), (1/3), 0, 0, 0, . . ..
Because the impulse response has a nite duration (the non-zero values
do not last forever), this kind of lter is called a Finite Impulse Response
ler. (FIR Filter). Another way to remember this is that the output of
the lter is a function only of past inputs.
www.sigmedia.tv
bk xnk
k=0
yn =
N
1
bk xnk
k=0
N
1
k=0
N
1
k=0
N
1
bk x0k = b0 x0 + b1 x1 + . . . = b0
bk x1k = b0 x1 + b1 x0 + . . . = b1
bk x2k = b0 x2 + b1 x1 + b2 x0 + b3 x1 + . . . = b2
k=0
www.sigmedia.tv
am ynm =
m=0
N
1
bk xnk
k=0
(1)
Thus to calculate the current value yn given the previous value yn1 and
the new input xn , we need to calculate the previous total, and add in the
new input xn , before nding the new average by dividing by 2.
This is a recursive lter. It is an IIR lter.
www.sigmedia.tv
1
1
y0 = y1 + x0
2
2
1
= 4
2
=2
1
1
y1 = y0 + x1
2
2
3
=2+
2
= 2.5
1
1
y2 = y1 + x2
2
2
= 1.25 + 1
= 2.25
1
1
y3 = y2 + x3
2
2
= 1.125 + 0.5
= 1.625
1
1
2
2
= 0.8125 + 0
y4 = y2 + x4
= 0.8125
www.sigmedia.tv
4.1
Calculate the impulse response for the system dened through the dierence equation below.
[
]
1
yn = yn1 + xn
2
Put xn = n and turn the handle.
[
]
1
yn = yn1 + xn
2
1
1
1=
2
2
1
1
+0=
2
4
1
1
+0=
4
8
1
1
+0=
8
16
1
1
+0=
16
32
1
1
=
32 64
h0 = 0 +
h1 =
h2 =
h3 =
h4 =
h5 =
1
2
1
2
1
2
1
2
1
2
hn = n+1
2
So the impulse response is hn = 21 ,
1 1
1
1
1
4 , 8 , 16 , 32 , 64 ,
...
10
www.sigmedia.tv
However...
It is important to note that not all recursively dened lters will be IIR.
Consider the recutsive lter
1
1
yn = yn1 + xn xn2
3
3
It has an impulse response as follows
1
1
10=
3
3
1
1
= +00=
3
3
1
1
= +00=
3
3
1
1
= +0 =0
3
3
=0+00=0
h0 = 0 +
h1
h2
h3
h4
h5 = 0
..
.
It is an FIR lter. In fact it is equivalent to the 3-tap moving average
lter from earlier.
11
www.sigmedia.tv
5 STEP RESPONSE
Step Response
Given a dierence equation, calculating the step response is done using
the same idea as with the impulse response.
Just input a step sequence and turn the handle!
Remember discrete step function un = 1, 1, 1, 1, 1, 1, 1, 1, . . .!
Also similar to the case with analogue signals, the step response is the
running sum of the impulse response.
The discrete step function un is the running sum of the discrete delta
function i.e.
n
un =
n
k=0
hk
k=0
12
www.sigmedia.tv
5.1 Blocks
5.1
5 STEP RESPONSE
In the same way that block diagrams are useful for summarising the operation of analogue systems, block diagrams are useful for digital systems.
The main, new operator needed is a shift in time operator. This we will
denote using a box with T in it. Thus if xn is put into T out comes
xn1 . T is a delay operator and shifts the signal that is input by 1
sample.
[
]
1
yn = xn + xn1 + xn2
3
x[n]
x[n-2]
x[n-1]
T
T
1/3
1/3
1/3
y[n]
1
1
yn yn1 = xn xn3
3
3
x[n]
x[n-1]
T
x[n-2]
x[n-3]
1/3
-1/3
y[n]
+
y[n-1]
13
www.sigmedia.tv
6 DIGITAL CONVOLUTION
Digital Convolution
If we know the impulse response of an LTI system, we can calculate the response to any input using convolution. We showed
this from the principles of LTI systems way back when we were
dealing with analogue signals and systems.
The exact same thing happens for digital lters. But this time
... its alot more straightforward because everything is discrete
anyway.
The idea is the same. We can decompose xn into a sum of n
functions. Each of these then pass through the LTI system to
yield impulse responses delayed in time. The nal output is the
sum of these outputs.
14
www.sigmedia.tv
6 DIGITAL CONVOLUTION
x[n]
h[n]
3.5
3.5
2.5
2.5
1.5
1.5
0.5
0.5
0.5
0.5
1.5
4
1.5
4
10
10
x[0]h [n0]
x[0] [n0]
6
5
2
4
3
2
0
1
1
0
1
2
3
4
3
2
10
10
10
10
10
x[1]h [n1]
x[1] [n1]
6
5
2
4
3
2
0
1
1
0
1
2
3
4
3
2
10
x[2]h [n2]
x[2] [n2]
6
5
2
4
3
2
0
1
1
0
1
2
3
4
3
2
10
x[3]h [n3]
x[3] [n3]
6
5
2
4
3
2
0
1
1
0
1
2
3
4
3
2
10
15
www.sigmedia.tv
6 DIGITAL CONVOLUTION
x[0]h [n0]
x[0] [n0]
6
5
2
4
3
2
0
1
1
0
1
2
3
4
3
2
10
10
10
10
10
10
x[1]h [n1]
x[1] [n1]
6
5
2
4
3
2
0
1
1
0
1
2
3
4
3
2
10
x[2]h [n2]
x[2] [n2]
6
5
2
4
3
2
0
1
1
0
1
2
3
4
3
2
10
x[3]h [n3]
x[3] [n3]
6
5
2
4
3
2
0
1
1
0
1
2
3
4
3
2
10
x[n]
y[n]
3.5
7
3
6
2.5
5
2
4
1.5
3
1
2
0.5
1
0
0
0.5
1
1
2
1.5
4
10
16
www.sigmedia.tv
6.1
6 DIGITAL CONVOLUTION
xk kn
xn =
k=
xk kn
xk hnk
k=
k=
xk hnk
k=
OR
yn =
hk xnk
k=
17
www.sigmedia.tv
6 DIGITAL CONVOLUTION
Looks a lot like the statement for the FIR lter dierence equation: with bk = hk . Hence the impulse response for an FIR lter
is actually its coecients.
yn =
hk xnk
k=
yn =
hk xnk
k=0
Signal causal means that xnk = 0 for n k < 0 i.e. for k > n
so we can change the upper limit to n.
yn =
hk xnk
k=0
yn =
hk xnk
k=0
18
www.sigmedia.tv