Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Digital Filter Design Using

Spreadsheets
KARIM Y. KABALAN, ALI EL-HAJJ
Department of Electrical and Computer Engineering, American University of Beirut, P.O. Box 11-0236, Beirut,
Lebanon

Received 30 June 1998; accepted 13 November 1998

ABSTRACT: This article presents a spreadsheet approach to the design of analog and
digital Butterworth and Chebyshev filters. Corresponding analog filters are designed; then,
bilinear transformation is used to map from the s plane into the z plane. Plots of magnitude
and pole locations in the s and z planes of each filter are obtained. Although software
packages are available to solve this problem, the spreadsheet solution makes an excellent
and effective way of achieving the task in a manner that can be interpreted and thoroughly
understood. This approach is only an introduction to the subject, but the topic chosen forms
strong links with the rest of the design problems. © 1999 John Wiley & Sons, Inc. Comput Appl Eng
Educ 7: 9 –15, 1999

Keywords: filter design; spreadsheets; Excel program

INTRODUCTION 1. The data necessary for the design, i.e., the


stop-band and the pass-band frequencies, the
The use of spreadsheet programs has been extended to desired attenuation, and the sampling fre-
treat some science and engineering problems [1,2] quency are first entered.
with specialization in control [3], logic design [4], 2. The input data are used and necessary calcu-
microprocessor systems [5], and many others that can lations are performed to obtain the response of
be found in the literature. the filter and the poles and zeros in the s plane
In this article, the Excel program is used to design and z plane.
digital Butterworth and Chebyshev filters. Corre- 3. The plots of the response of the filter as well as
sponding analog filters are first designed, and then the plots corresponding to the poles and zeros
bilinear transformation is used to map from the s in the different planes are obtained using the
plane into the z plane. This spreadsheet design ap- spreadsheet available facility.
proach has been used owing to its simplicity and
availability, and the usability of their powerful In this article, the basic design steps have been re-
graphic packages. In this design, the following steps peated in a reasonably mathematically precise manner
are done: whenever possible, avoiding long and deep discussions
as the subject is usually introduced in many textbooks
[6–8]. Moreover, our intention is not to cover all topics
Correspondence to K. Y. Kabalan, Department of Electrical and in filter design, but rather to show students how to apply
Computer Engineering, American University of Beirut, New York
Office, 850 3rd Avenue, 18th floor, New York, NY 10022-6297
this spreadsheet tool in solving practical design prob-
(kabalan@aub.edu.lb). lems. It is also to be noted that although only two filter
© 1999 John Wiley & Sons, Inc. CCC 1061-3773/99/010009-07 types are considered, the exercise is intended to provide
9
10 KABALAN AND EL-HAJJ

Figure 1 Spreadsheet design of the Butterworth filter.

the students with examples and new ideas on how to use 2d 1 , 20 log10uH~jV!u , 2d 2 (2)
spreadsheets in filter design.
This article is divided into five sections. The next In addition, the bilinear transformation yields
section treats the Butterworth filter; the Chebyshev is
considered in the third section. A general conclusion
and concluding remarks are given in the final section. Vp 5
2
T S D
tan
vp
2
(3)

BUTTERWORTH FILTER Vs 5
2
T SD
tan
vs
2
(4)

Butterworth filters are defined by the property that


magnitude response is maximally flat in pass-band. Combining Equations (2– 4), the following two equa-
Another property is that the magnitude response is tions are obtained:
monotonic in the pass-band and stop-band. The mag-
nitude squared function for a continuous time Butter-
worth filter is of the form
11
2
T
1
tan
vp
2 S D2 2N

5 10 d1/10 (5)
Vc
1

S D
uH~ v !u 2 5
S D2
(1)
v 2N

1
11 j
2 vs 2N

vc tan
T 2
11 5 10 d2/10 (6)
Vc
In Equation (1), v c is the cutoff frequency in rads per
second, and N is the filter order.
Equations (5) and (6) can be used to obtain the ex-
In designing a Butterworth digital filter, the pass-
pression of N. This expression is given by
band ripple d1 in decibels, the attenuation in the
stop-band d2 in decibels, the pass-band frequency v p ,
log10 @10d 2/10 2 1# 2 log10 @10d 1/10 2 1#
the stop-band frequency v s , and the sampling period
F S DG F S DG
1
N52 z (7)
T in seconds must be given. These values are stored, 2 vs 2 vp
log10 tan 2 log10 tan
respectively, in cells B4, C4, D4, E4, and F4, as T 2 T 2
shown in Figure 1. To design the filter, the following
equation must be satisfied: The corresponding spreadsheet formula is
DIGITAL FILTER DESIGN 11

1 1 22
2N
2
tan~ v p/2!
T
d 1 5 10 z log10 11 (11)
Vc

The corresponding spreadsheet formula is

d1 5 10*LOG10(1 1 ((2/$F4*TAN(D4/2))
(12)
/C7)ˆ(2*C6))

The result of Equation (12) is stored in cell C8. The


next step in the procedure is to compute the poles and
zeros locations of the filter in both the s plane and z
plane. To do that, the s plane is first considered and
the real and imaginary parts are then obtained using
the following formula:

Real s 5 V ccos
S p ~2k 1 1!
2N 1 12 D (13)

Figure 2 Pole locations of the Butterworth filter in the s


Im s 5 V csin
S p ~2k 1 1!
2N 1 12 D
plane.
In Equation (13), k takes the values from 0 to (N 2 1).
The corresponding spreadsheet formulas are
N 5 CEILING(LOG10((10ˆ(C4/10)
5 $C$& 1 COS(PI*(2*A12 1 1)/(2*$C$6) 1 0.5))
2 1)/(10ˆ(B4/10) 2 1))/
(2*LOG10((2/F4*TAN(E4/2))/
5 $C$& 1 SIN(PI*(2*A12 1 1)/(2*$C$6) 1 0.5))
(2/F4*TAN(D4/2)))),1) (8)
(14)
The result of Equation (8) is stored in cell C6, as
In Figure 1, a new table of five columns has been
shown in Figure 1. On the other hand, the value of N
constructed. Column 1 (Column A) indicates the val-
is substituted in Equation (6) and used to calculate V c
ues of k, where the real parts and the imaginary parts
so that the specifications are met exactly at the stop-
are placed in Column 2 (Column B) and Column 3
band and exceeded at the pass-band. V c is obtained
(Column C), respectively. A similar approach has
using the following formula:
been used to compute the poles and zeros locations in
the z plane. The results of that are placed in Columns
2 D and E as shown in Figure 1. The formulas used in
tan~ v s/2!
T this case are
Vc 5 (9)
@10 d2/10 2 1# 1/2N

The corresponding spreadsheet formula is


Real z 5
S12
~Real s z T!2 ~Im s z T!2
4
2
4 D
~real s z T!2
~Im s z T!2
V c 5 2/F4*TAN(E4/2)/ (10) 1 2 ~real s z T! 1 1
4 4
((10ˆ(C4/10) 2 1)ˆ(1/(2*C6)))
Im s
Real z 5
The result of Equation (10) is stored in cell C7, as ~real s z T!2 ~Im s z T!2
shown in Figure 1. Also, the ripple d1 is again calcu- 1 2 ~real s z T! 1 1
4 4
lated: (15)
12 KABALAN AND EL-HAJJ

CHEBYSHEV FILTER

The analog Chebyshev filter is either equiripple in the


pass-band and monotonic in the stop-band, or mono-
tonic in the pass-band and equiripple in the stop-band
[9]. The squared magnitude function is

S D
uH~V!u 2 5 (16)
V
11« V2 2
N
Vc

In Equation (16), « is a function of the ripples in the


pass-band, and V N ( x) is the Nth-order Chebyshev
polynomial. The digital filter specifications are en-
tered in the same cells as in the previous section as
shown in Figure 5, and the values for V N are given
using the following recursive formulas:

V N11~x! 5 2xV N~x! 2 V N21~x!

V 0~x! 5 1 (17)

V 1~x! 5 x
Figure 3 Pole locations of the Butterworth filter in the z
plane. It should be noted that V c 5 V p in case of Chebyshev
filter. « and the order of the filter must be chosen so
the specifications are met exactly at the pass-band and
This program has been tested for a filter having v p the stop-band frequencies. That is,
5 0.2 p , v s 5 0.3 p , d1 5 1 dB, and d2 5 15 dB. The
order of this filter and the cutoff frequency are found 2d 1 , 20 log10uH~jV!u
to be 6 and 0.76622, respectively. The plots of the (18)
pole locations in the s plane and z plane of this filter 20 log10uH~jV!u , 2d 2
are shown in Figures 2 and 3, respectively. Figure 4
shows the magnitude of this filter as it is normalized Using the first part of Equation (18), the value of « is
to a maximum amplitude of unity. obtained using the following formula:

Figure 4 Magnitude response of the Butterworth filter.


DIGITAL FILTER DESIGN 13

Figure 5 Spreadsheet design of the Chebyshev filter.

« 5 ~10 d1/10 2 1! 1/2 (19) the second equation of (18) must be satisfied. To
achieve this task, a table of five columns is con-
The value of « is computed and stored in Cell D7 structed. In the first column (Column H), the value of
using the following spreadsheet formula: N is introduced from 0 until a maximum value defined
usually by the user. In our case, a maximum value of
5 (10ˆ)(C4/10) 2 1)ˆ0.5 (20) 12 is considered. In the next column (Column I), the
value of V N ( x) is computed using Equation (17), and
The next step is to determine the order N of the filter the magnitude of the filter of the corresponding value
so specifications are met at the stop-band. In this case,

Figure 6 Pole locations of the Chebyshev filter in the s Figure 7 Pole locations of the Chebyshev filter in the z
plane. plane.
14 KABALAN AND EL-HAJJ

Figure 8 Magnitude response of the Chebyshev filter.

of these polynomials is obtained in Column J. Column These values are obtained and stored in Cells C8, C9,
K contains the results of the right-hand side of the and C10, respectively. The next step is to determine
second part of Equation (18) which is obtained by the location of the poles of the filter in the s plane.
replacing V with V c . This formula is found to be These locations are given by the following formula:

VNS D F
Vs
Vp
1
$ 2 @10 d2/10# 2 1
« G
1/2
(21) s 5 aV pcos$ p @~2k 1 1!/2N 1 2 #%
1
(25)
1 jbV psin$ p @~2k 1 1!/2N 1 1
2
#%
Column L is a comparative column where an IF
function is introduced. This statement compares the
elements of Columns J and K and returns an empty As for the previous case, the pole locations in the
cell if J is less than K; otherwise, it will return the z plane are obtained and placed in the table, as shown
value of N. in Figure 5.
The example used for Butterworth filter is used in
5IF(J6 . K6, H6,9999) (22) this section. The resulting filter is of order 4 with a
cutoff frequency of 0.6498. The pole locations of the
Finally, the order of the filter is obtained by sim- filter in the s plane and the z plane are shown in
plify taking the minimum value in the L column. The Figures 6 and 7, respectively. The magnitude of the
value of N is computed and stored in Cell D6 using filter is plotted in Figure 8 normalized to a maximum
the following spreadsheet formula: amplitude of unity.

5MIN(L3.L15) (23)
CONCLUSION
The poles in the s domain lie on an ellipse with minor
axis radius a*V c and major axis radius b*V c , where
Designing digital filters using spreadsheets has proved
all the advantages listed in the introduction of this
a 5 12 * ~ a 1/N 2 a 21/N! article. It is flexible in changing the specifications and
modifying the layouts, programming the formulas,
b 5 12 * ~ a 1/N 1 a 21/N! (24) and plotting output. On the other hand, the approach
followed here in designing filters can be altered and
a 5 « 21 1 ~1 1 « 22! 1/2 used to design other types of filters.
DIGITAL FILTER DESIGN 15

REFERENCES [4] A. El-Hajj, K. Y. Kabalan, A spreadsheet simulation


of logic networks, IEEE Trans Educ 34 (1991), 43– 46.
[1] N. D. Rao, Typical applications of microcomputer [5] A. El-Hajj, K. Y. Kabalan, H. Diab, A spreadsheet
spreadsheets to electrical engineering problems, IEEE educational tool for microprocessor system, Comput
Trans Educ E-27 (1984), 237–242. Appl Eng Educ 3 (1995), 205–211.
[2] L. R. Hulsman, Electrical engineering applications of [6] A. V. Oppenheim, R. W. Schafer, Digital signal pro-
microcomputer spreadsheets analysis programs, IEEE cessing, Prentice-Hall, Englewood Cliffs, NJ, 1975.
Trans Educ E-27 (1984), 86 –92. [7] S. D. Stearns, Digital signal analysis, Hayden Book
[3] A. El-Hajj, K. Y. Kabalan, The use of spreadsheets to Company, NJ, 1975.
study the stability of linear control systems, Int J Appl [8] B. Gold and C. M. Rader, Digital processing of sig-
Eng Educ 6 (1990), 437– 442. nals, McGraw-Hill, New York, 1969.

BIOGRAPHIES

Karim Y. Kabalan was born in Jbeil, Leb- Ali El-Hajj was born in Aramta, Lebanon, in
anon. He received the BS degree in physics 1959. He received the lisense degree in Physics
from the Lebanese University in 1979, and from the Lebanese University, Lebanon, in
the MS and PhD degrees in electrical engi- 1979; the degree of “Ingenieur” from L’Ecole
neering from Syracuse University, in 1983 Superieure d’Electricite, France, in 1981; and
and 1985, respectively. During the 1986 fall the “Docteur Ingenieur” degree from the Uni-
semester, he was a visiting assistant profes- versity of Rennes I, France, in 1983. From
sor of electrical engineering at Syracuse Uni- 1983 to 1987, he was with the Department of
versity. Currently, he is a professor of elec- Electrical Engineering at the Lebanese Univer-
trical engineering with the Department of Electrical and Computer sity. In 1987 he joined the American University of Beirut, where he is
Engineering Faculty of Engineering and Architecture, American currently a professor of electrical and computer engineering. His
University of Beirut. His research interests are numerical solution research interests are numerical solution of electromagnetic field prob-
of electromagnetic field problems and software development. lems and engineering education.

You might also like