Impulse Response and Convolution

advertisement
Linear Time Invariant Systems
Definitions
A linear system may be defined as one which obeys the Principle of Superposition, which may be stated as
follows:
If an input consisting the sum of a number of signals is applied to a linear system, then the output is the sum, or
superposition, of the system’s responses to each signal considered separately.
A time-invariant system is one whose properties do not vary with time. The only effect of a time-shift on an input
signal to the system is a corresponding time-shift in its output.
A causal system is one if the output signal depends only on present and/or previous values of the input. In other
words all real time systems must be causal; but if data were stored and subsequently processed at a later date, it
need not be causal.
Steps, Impulses and Ramps
The unit step function u[n] is defined as:
u[n] = 0,
u[n] = 1,
n < 0
n ≥ 0
This signal plays a valuable role in the analysis and testing of digital signals and processors.
Another basic signal which is even more important than the unit step, is the unit impulse function δ[n], and is
defined as:
δ[n] = 0, n ≠ 0
δ[n] = 1, n = 0
Figure 1 (a) the unit step function, and (b) the unit impulse function
1
One further signal is the digital ramp which rises or falls linearly with the variable n. The unit ramp function r[n]
is defined as:
r[n] = n u[n]
Figure 2. The unit ramp function
Since u[n] is zero for n<0, so is the ramp function
The Unit Impulse Response
The unit impulse was described above as:
δ[n] = 0, n ≠ 0
δ[n] = 1, n = 0
This is also sometimes known as the Kronecker delta function
This can be tabulated
n
δ[n]
δ[n-2]
Table 1
0
0
-2
0
0
-1
0
0
0
1
0
1
0
0
2
0
1
3
0
0
4
0
0
5
0
0
6
0
0
0
0
Figure 3 Shifted impulse sequence, δ[n – 2]
A shifted impulse such as δ[n – 2] is non-zero when its argument is zero, i.e. n – 2 = 0, or equivalently n = 2.
2
The third row of table 1 gives the values of the shifted impulse δ[n – 2] and Figure 3 shows a plot of the sequence.
Now consider the following signal:
x[n] = 2δ[n ] + 4δ[n – 1] + 6δ[n – 2] + 4δ[n – 3] + 2δ[n – 4]
Table 2 shows the individual sequences and their sum.
n
2δ[n]
4δ[n-1]
6δ[n-2]
4δ[n-3]
2δ[n-4]
x[n]
0
0
0
0
0
0
-2
0
0
0
0
0
0
-1
0
0
0
0
0
0
0
2
0
0
0
0
2
1
0
4
0
0
4
2
0
0
6
0
0
6
3
0
0
0
4
0
4
4
0
0
0
0
2
2
5
0
0
0
0
0
0
6
0
0
0
0
0
0
0
0
0
0
0
0
Table 2
Hence any sequence can be represented by the equation:
x[n] = ∑ x[k ]δ [n − k ]
k
= + x[-1]δ[n + 1] + x[0]δ[n] + x[1]δ[n - 1] + x[2]δ[n - 2] +…….
When the input to an FIR filter is a unit impulse sequence, x[n] = δ[n], the output is known as the unit impulse
response, which is normally donated as h[n].
This is shown in Figure 4.
Figure 4
Substituting x[n] = δ[n] gives the output y[n] = h[n].
3
FIR Filters
The block diagram of a finite impulse filter (FIR) is shown in Figure 1. The input signal x(n) is a series of discrete
values obtained by sampling an analogue waveform. In this series x(0) corresponds to the value at t=0, x(1) is the
value at t = ts, x(2) is the value at t = 2ts etc.
The value ts is the sampling period, where:
ts = 1/fs
The z in Figure 1 is the ‘Z transform’ which can be thought of a time delay of one sampling period (ts) also known
as the unit delay. The value shown as x(n-1) is actually the value of x(n) one time period before now i.e. the
previous input. The output signal y(n) is therefore always the combination of the last three input samples. In the
diagram each of the samples is multiplied by a coefficient aR, to give
y(n) = a0x(n) + a1x(n-1) + a2x(n-2)
Figure 1
Now the following share prices were obtained from a weeks trading
Day
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
Period
0
1
2
3
4
5
6
x(n)
x(0)
x(1)
x(2)
x(3)
x(4)
x(5)
x(6)
Price
20
20
20
12
40
20
20
Table 1
4
Plotting a histogram of the Table 1 gives
Figure 2
Using the FIR filter used in Figure 1 with the following values for the coefficients.
aR
a0
a1
a2
Value
0.25
0.5
0.25
Figure 2
The filter now looks like Figure 2. When n = 0 the first value of x(n), i.e. x(0) is applied as the input to the circuit.
Assuming there have been no share prices for the two previous days, the values of
x(n), x(n-1) and x(n-2) are:
5
x(0) =
x(-1) =
x(-2) =
20
0
0
Performing the multiplications and additions gives:
y(0) = 0.25 x 20 + 0.5 x 0 + 0.25 x 0 = 5
Moving on to the next sampling period, Tuesday’s share price is the input value and Monday’s share price is
displaced to x(n-1), i.e. it has become the old value, one sampling period behind. So:
x(1) =
x(0) =
x(-1) =
20
20
0
It follows that:
y(1) = 0.25 x 20 + 0.5 x 20 + 0.25 x 0 = 15
Moving on to Wednesday gives:
x(2)
x(1)
x(0)
=
=
=
20
20
20
Giving:
y(2) = 0.25 x 20 + 0.5 x 20 + 0.25 x 20 = 20
For Thursday
x(3)
x(2)
x(1)
=
=
=
12
20
20
Giving
y(3) = 0.25 x 12 + 0.5 x 20 + 0.25 x 20 = 18
Repeating the calculation gives:
Day
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
y(n)
5
15
20
18
21
28
25
6
Plotting these output values gives:
Figure 3
It can be seen that the filter is performing a moving average calculation.
This filter is known as a finite impulse response filter (FIR) because the output depends upon a finite number of
inputs.
The inputs in the example above could have been described as a series if weighted impulses as shown in Figure 4
and is written mathematically as:
+∞
∫ 20δ (t ) = 20
−∞
Figure 4 The input pulse train.
We can also use weighted impulse functions to describe the filter itself. The definition of a filter’s impulse
response is the output waveform when a single unity weighted impulse function is applied to the filter input at t =
0.. If the analysis is repeated a pulse train as shown in Figure 5 will be obtained.
7
Figure 5 The impulse response of the FIR filter
It is now possible to calculate the output signal at any point in time simply by multiplying the impulse response of
the filter by the input pulse train present at the desired time. However the pulse train must be reversed so that for
y(5) – we simply multiply the values of x(t) with the values of aR in the same position, giving:
y(5) = 0.25 x 20 + 0.5 x 40 + 0.25 x 12 = 28
Figure 6 The input sequence reversed.
This was the value calculated for Saturday’s output and this method is known as convolution. Moving on to
Sunday, the input response is shifted along one stage to the right to allow Sunday’s value to take u
Convolution
The simplest example of convolution is the multiplication of two polynomials. e.g.
y = (4 x 2 − 3x + 9)(3x 2 + 4 x + 4 )
8
This is calculated by:
(
)(
)(
)
y = (4 x 2 × 3x 2 ) + (4 x 2 × 4 x )+ (4 x 2 × 4 ) + (−3x × 3x 2 )+ (−3x × 4 x ) + (−3x × 4 ) + (9 × 3x 2 )+ (9 × 4 x ) + (9 × 4 )
y = 12x 4 + 16x 3 + 16x 2 − 9x 3 −12x 2 −12x + 27x 2 + 36x + 36
y = 12x 4 + 7x 3 + 31x 2 + 24 x + 36
This can be proved using Matlab as follows:
a=[4 -3 9];
b=[3 4 4];
y=conv(a,b)
Convolution is a weighted moving average with one signal flipped back to front:
The general expression for an FIR filter’s output is:M
y[n] = ∑ h[k ]x[n − k ]
k =0
A tabulated version of convolution
n
x[n]
h[n]
h[0]x[n]
h[1]x[n-1]
h[2]x[n-2]
h[3]x[n-3]
y[n]
n<0
0
0
0
0
0
0
0
0
2
3
6
0
0
0
6
1
4
-1
12
-2
0
0
10
2
6
2
18
-4
4
0
18
3
4
1
12
-6
8
2
16
4
2
5
0
6
0
7
0
n<7
0
6
-4
12
4
18
0
-2
8
6
12
0
0
4
4
8
0
0
0
2
2
0
0
0
0
0
h[0]x[n] = x[0] * h[0] + x[1] * h[0] + x[2] * h[0] + x[3] * h[0] + x[4] * h[0]
h[0]x[n] =
2*3
+
4*3
h[0]x[n] =
6
+
12
+
+
6*3
+
4 * 3
18
+
12
+
2 * 3
+
6
h[1]x[n-1] = x[0] * h[1] + x[1] * h[1] + x[2] * h[1] + x[3] * h[1] + x[4] * h[1]
h[1]x[n-1] = 2 * -1 +
h[1]x[n-1] =
-2
+
4 * -1
-4
+
+
6 * -1
-6
+
+
4 * -1
-4 +
+
2 * -1
-2
9
The diagrams below show how convolution works.
Figure 5 A single impulse input yields the system’s impulse response
Figure 6 A scaled impulse input yields a scaled response, due to the scaling property of the system's linearity.
Figure 7:
This demonstrates the use the time-invariance property of the system to show that a delayed input results in an
output of the same shape, only delayed by the same amount as the input
10
Figure 8: This now demonstrates the additivity portion of the linearity property of the system to complete the
picture. Since any discrete-time signal is just a sum of scaled and shifted discrete-time impulses, we can find the
output from knowing the input and the impulse response
No if we convolve x(n) with h(n) as shown in Figure 9 we will get the output y(n)
Figure 9: This is the end result that we are looking to find
The following diagrams are a breakdown of how the y(n) output is achieved.
Figure 10: The impulse response, h , is reversed and begin its traverse at time 0.
Figure 11: Continuing the traverse. At time 1 , the two elements of the input signal are multiplied by two elements
of the impulse response.
11
Figure 12
Figure 13
What happens in the above demonstration is that the impulse response is reversed in time and "walks across" the
input signal. This is the same result as scaling, shifting and summing impulse responses.
This approach of time-reversing, and sliding across is a common approach to presenting convolution, since it
demonstrates how convolution builds up an output through time.
12
Download