Вы находитесь на странице: 1из 7

EE32b Signals, Systems, and Transforms

February 4, 2002

R. J. McEliece
162 Moore

Designing Discrete-Time Filters for Dierentiation and Integration


In these notes I will discuss the design and implementation of discrete-time lters for differentiation and integration. Together with the sample, process in discrete time, and
interpolate paradigm of Chapter 7, these lters will allow us to build systems to dierentiate and integrate continuous time signals using digital signal processing.
1. Discrete-Time Dierentiation.
As discussed in class (see also OW2, Sec. 7.4.1) the ideal digital dierentiator has frequency
response
(1)

H(ej ) = j, for || ,

and repeats with period 2. We wish to nd a class of FIR lters which approximate
this ideal as closely as possible. Since the impulse response corresponding to the ideal
system (1) is real and odd,1 it is reasonable to investigate FIR approximations of the same
form. Thus we will restrict our attention to lters characterized by system functions of
the form
(2)

N

an n
(z z n ),
HN (z) =
2
n=1

and call N the order of the approximation.


Substituting z = ej in (2), we nd that the frequency response of the N th order
approximation is
(3)

HN (e ) = j

N


an sin(n).

n=1

Comparing (1) to (3), we see that the design problem boils down to choosing the lter
coecients (an )N
n=1 so that
(4)

fN () =

N


an sin(n) ,

n=1

In fact, this impulse response is h[0] = 0, h[n] = (1)n /n, for n = 0. (See OW2,
Ex. 7.2.)
1

in some appropriate sense. Although there are several possible criteria by which to interpret
, for example minima; mean squared error, we will investigate lters which are optimal
in the sense of maximal tangency to the ideal (1) at = 0.
If we use the Taylor series for sin x, viz.,
x5
x3
+

3!
5!

x2m+1
(1)m
=
(2m + 1)!

sin x = x

m0

we can develop fN () as dened in (4) as a power series in , viz.,


fN () = S1 + S3 3 + ,
where the Sk s are linear combinations of the an s. Since fN () has N undetermined
coecients, it is reasonable to try to choose these coecients so that
S1 = 1, S3 = = S2N 1 = 0,
so that
(5)

fN () = + O(2N +1 ).

For example, with N = 1, we have


f1 () = a1 sin = a1 (

3
+ ),
3!

soo that if we choose a1 = 1, we get


f1 () = + O(3 ),
which is the closest match to the desired f () = possible with just one degree of freedom.
The system function for the corresponding lter is
H1 (z) =

1
(z z 1 ).
2

In the (discrete) time domain this lter is characterized by the dierence equation
y[n] =

1
(x[n + 1] x[n 1]).
2

which corresponds to the well-known (coninuous-time) approximation


x (t)

x(t + T ) x(t T )
.
2T
2

Similarly, with N = 2, we get


3
83
+ ) + a2 (2
+ )
3!
3!
(a1 + 8a2 ) 3
= (a1 + 2a2 )
+
3!

f1 () = a1 (

Thus if we select a1 andn a2 so that


a1 + 2a2 = 1
a1 + 8a2 = 0,
i.e., a1 = 4/3, a2 = 1/6, we get
f2 () = + O(5 ).
The corresponding system function is
H2 (z) =

2
1
(z z 1 ) (z 2 z 2 ),
3
12

with dierence equation


y[n] =

1
2
2
1
x[n + 2] + x[n + 1] x[n 1] + x[n + 2].
12
3
3
12

This corresponds to the not-so-well known approximation


x (t)

4 x(t + T ) x(t T ) 1 x(t + 2T ) x(t 2T )

.
3
2T
3
4T

Figure 1 shows an implementation of a causal version of this system, viz.,


y[n] =

1
2
2
1
x[n] + x[n 1] x[n 3] + x[n 4].
12
3
3
12

y[n]
-1/12

x[n]

2/3
z-1

1/12

-2/3
z-1

z-1

z-1

Figure 1. A causal FIR lter


implementing a N = 2 dierentiator..
3

In general, we can expand fn () as a power series in as follows:


fN () =

N


an sin(n)

n=1

N


an

n=1

(1)m

m0

(1)m

m0

(n)2m+1
(2m + 1)!

N
2m+1 
an n2m+1
(2m + 1)! n=1

Thus to ensure that (5) holds, we choose the lter coecients (an ) so that

N

1 if m = 0
2m+1
an n
=
0 if m = 1 . . . , N 1.
n=1

This is a set of N linear equations in the N unknowns a1 , . . . , aN , which are easily solved
by computer. Here is a short table of the solutions.

N
N
N
N
N

=1:
=2:
=3:
=4:
=5:

n=1

n=2

n=3

2/2
4/3
6/4
8/5
10/6

1/6
3/10
6/15
10/21

n=4

2/60
8/105 1/140
20/168 5/252

n=5

1/630

Figure 2 shows a plot of the optimiized functions f1 (), . . . , f5 () vs. .


f () 3
N
2

N=5
1

N=1
-p

p
-
2

-1
-2
-3

Figure 2. The rst ve maximally


at discrete-time dierentiators.

2. Discrete-Time Integration.
Motivated by the trapezoid rule and Simpsons rule, perhaps, we consider discrete-time
integrating lters characterized by dierence equations of the form
(6)

y[n] y[n N ] =

N


ak x[n k],

k=0

where the lter coecients (ak ) satisfy the symmetry condition


(7)

ak = aN k , for k = 0, . . . , N ,

and N is called the order of the lter. The system function corresponding to the dierence
equation (6) is
N

(8)
(9)

ak z k
1 z N
N
ak z N/2K
= k=0
.
z N/2 z N/2

HN (z) =

k=0

Our goal is to select the coecients (ak ) so that the corresponding frequency response
HN (ej ) is as close as possible (in a suitable sense) to the ideal frequency response for a
digital integrator, viz.,
(10)

H(ej ) =

1
j

as possible.
For example, with N = 1, the system function in (9) is (recalling that a0 = a1 by (7))
H1 (z) =

a0 (z 1/2 + z 1/2 )
.
z 1/2 z 1/2

The corresponding frequency response is then easily seen to be




1 a0 cos(/2)
j
.
(11)
H1 (e ) =
j
sin(/2)
Comparing (10) to (11), we see that in this case the problem is to choose the coecient
a0 so that
1
a0 cos(/2)
,
sin(/2)

or alternatively
(12)

a0 cos(/2) sin(/2).
5

If we expand both sides of (12) as power series in , using the Taylor series
x5
x3
+

3!
5!
x2
x4
cos x = 1
+

2!
4!
sin x = x

(12) becomes (ignoring terms of order 5 and higher)


a0 (

3
3
+ )
+ .
8
2
48

Thus if we take as our measure of goodness the agreement of the power series at = 0,
the best choice for a0 is a0 = 1/2, in which case the lters system function is
H1 (z) =

(1/2)(1 + z 1 )
,
1 z 1

corresponding to the dierence equation


1
y[n] = y[n 1] + (x[n] + x[n 1]),
2
which, as discussed in class, is the trapezoid rule for integration.
Similarly, for N = 2 the system function is by (9)
H2 (z) =

a1 + a0 (z + z 1 )
.
z z 1

Substituting z = ej , this becomes


1
H2 (e ) =
j
j

a1 /2 + a0 cos
sin


.

Reasoning as in the N = 1 case, we see that the problem is to select the coecients a0
and a1 so that
(13)

(a1 /2 + a0 cos ) sin .

Expanding both sides of (13) in power series in up to and including terms of order 3 ,
we get
1
(a1 /2 + a0 ) (a0 /2)3 + 3 + .
6
Thus we can get equality in (13) up to an including terms of order 4 if a0 and a1 are
chosen so that
1
a0 + a1 = 1
2
1
1
= .
a0
2
6
6

The solution is a0 = 1/3, a1 = 4/3, corresponding to the the system function


H2 (z) =

1
3

+ 43 z 1 + 13 z 2
,
1 z 2

with corresponding dierence equation


1
4
1
y[n] = y[n 2] + x[n] + x[n 1] + x[n 2],
3
3
3
which is, as discussed in class, nothing more or less than Simpsons rule.

Вам также может понравиться