Digital Filters

advertisement
Digital Filters
x(t)
x[n]
A/D
y[n]
Computer
Example:
y[n]  y[n  1]  x[n].
y(t)
D/A
To get the current output y[n], which is sent to the
D/A, we get the previous output y[n-1] (sent the last
time to the D/A) and add to it the current input from
the A/D. In a programming language like C++, the
code would look something like this:
yp = 0;
while (true)
{
x = inp(ad);
y = yp+x;
outp(y, da);
yp = y;
}
// set “previous” y to zero
//
//
//
//
//
get new sample
perform filtering operation
send filtered sample to D/A
set “current” to “previous”
for next iteration
Finding the z-transform transfer function:
y[n]  y[n  1]  x[n].
y[n]  y[n  1]  x[n].


Y ( z ) 1  z 1  X ( z ).
Y ( z)
1
H ( z) 

.
1
X ( z) 1  z
Now what does this operation do to an input signal?
Example: find the impulse and step responses to
the previous filter.
Solution: we could use z-transforms or convolution
to find the output when the input is an impulse or a
step, but instead, let us see how the output
“evolves.” A table will be created with three
columns: n, x[n] and y[n]. Each column will
correspond to an instance in discrete-time. For the
impulse input x[n]=d[n] we have
n
x[n]=d[n]
y[n]
0
1
1
1
0
1
2
0
1
3
0
1
4
0
1
For the step input x[n]=u[n] we have
n
x[n]=u[n]
y[n]
0
1
1
1
1
2
2
1
3
3
1
4
4
1
5
The plots of these outputs are as follows:
y[n] for x[n]=d[n]
n
1
2 3 4
y[n] for x[n]=u[n]
5
4
3
2
1
n
1
2 3 4
Example: Find the impulse response and the step
response for the following transfer function:
H ( z) 
1
1  12 z
1
.
Solution: From the definition of the transfer function
we have
Y ( z)
1

.

1
X ( z ) 1  12 z
Cross-multiplying and converting back to discretetime domain we have

Y ( z) 1  z
1
2
1
  X ( z ).
y[n]  12 y[n  1]  x[n].
y[n]  12 y[n  1]  x[n].
In other words, the current output is equal to onehalf times the previous output plus the current input.
n
x[n]=d[n]
y[n]
0
1
1
1
0
1
2
2
0
1
4
3
0
1
8
4
0
1
16
For the step input x[n]=u[n] we have
n
x[n]=u[n]
y[n]
0
1
1
1
1
2
1
3
1
4
1
1 12
1 34
1 78
15
1 16
The plots of these outputs are as follows:
y[n] for x[n]=d[n]
n
1
2 3 4
y[n] for x[n]=u[n]
2
1
n
1
2 3 4
The step and impulse functions for this transfer
function look like those for an RC low-pass filter.
Suppose that we wished to construct a digital filter
corresponding to an RC low-pass filter?
Can we convert an analog filter to a digital filter?
The Matched z-Transform
In the matched z-transform digital filter design
method we try to “match” the impulse response of
the analog filter with that of the digital filter being
designed.
To match the impulse responses, we take the
inverse Laplace transform of the analog filter
H(s)h(t), then sample the impulse response
h(t)h[n], then take the z-transform of the sampled
impulse response to get the z-transform transfer
function h[n]H(z).
Analog Prototype
Digital Filter
H (s )
H (z )
L-1
Z
h(t )
sample
h[n]
Once we have our z-transform transfer function H(z),
we apply the definition of the transfer function to
write our digital filter equations:
Y ( z)
H ( z) 
.
X ( z)
Example: Use the matched filter design method to
design the digital equivalent of an integrator.
Solution: The analog transfer function is
1
H (s)  .
s
The inverse Laplace transform is
h(t )  u(t ).
We then sample the impulse response to get h[n]:
h[n]  u[n].
Finally, we take the z-transform of the impulse
response to get the digital filter transfer function.
1
H ( z) 
.
1
1 z
Finally, we apply the definition of the z-transform
transfer function to get the relationship between the
input of the digital filter x[n] and the output of the
digital filter y[n].
Y ( z)
1
H ( z) 

.
1
X ( z) 1  z
1
Y ( z)[1  z ]  X ( z).
y[n]  y[n  1]  x[n].
y[n]  y[n  1]  x[n].
Applying this formula to an arbitrary input x[n], we
have
n
x[n]
y[n]
0
x[0]
x[0]
1
x[1]
x[0]+x[1]
2
x[2]
x[0]+x[1]+x[2]
3
x[3]
x[0]+x[1]+x[2]+x[3]
We see that the output is the summation of the input.
Thus the digital filter accurately represents the
analog filter.
The digital filter does not always accurately
represent the analog filter as will be seen in the next
example.
Example: Use the matched filter design method to
design the following transfer function:
1
H ( s)  s
,
c  1
where c = s/4, and s is the sampling frequency.
Solution: First, we find the impulse response
h(t )  c e
 c t
.
Then we sample the impulse response:
h[n]  ce
c nT
 cen / 2 .
Then we take the z-transform of the (discrete-time)
impulse response:
c
H ( z) 
.
 / 2 1
1 e
z
Download