-I
CALIFORNIA STATE UNIVERSITY.
NORTHRIDGE
Digita1 Fi1ter Ana1ysis Using IBM PC's
A Graduate project submitted in partial satisfaction of the
requirements for the degree of Master of Science in
Electrical Engineering
by
Donald Joseph Brunnett
January 1987
The Graduate Project of Donald Joseph Brunnett is approved:
P:r>of. G. Melara
Prof. ' ay Pettit
P~f.
John Adams
Ca~ifornia
(Chair)
State University,
ii
Northridge
Acknowledgments
The
to
Pro~.
author wishes to express his gratitude and thanks
John Adams
this paper,
~or
his contributions to the writing
and for his insight into the theory
signal processing.
during
digital
The author also wishes to express a very
special thanks to his wife,
patience
o~
o~
Lori,
for her understanding and
the author's pursuit of
Science degree.
iii
this
Master
o~
Table of Contents
Page
List of Figures
v
Abstract .
vi
Chapter·
1.0
Historical Perspective .
1
2.0
Introduction .
2
3.0
Computer Implementation
4
4.0
Functional Description .
6
5.0
Filter Analysis Examples
10
6.0
Summary
22
A
Numerical Example of system solutions
23
B
Numerical Example of Gaussian Elimination
27
c
Graphical Demo of Gr·oup Delay Equation
29
D
Listing of Read. me File
30
E
Listing of Main Program Source Code
33
F
Listing of Gaussian Elimination Procedure
48
G
Listing of DrawGrid Procedure
52
Appendices
iv
List of Figures
Figure
Page
1
Schematic of Third Order Elliptic Filter
13
2a
Full Magnitude Response of Elliptic Filter
14
2b
Passband Magnitude Response of Elliptic Filter
14
3a
Phase Response of Elliptic Filter .
15
3b
Group
15
4
Time Domain Responses of Elliptic Filter
16
5
Schematic of Parallel Form Digital Filter
17
6a
Full Magnitude Response of Parallel Filter
18
6b
Passband Magnitude Response of Parallel Filter
18
7a
Full Phase Response of Parallel Form Filter
19
7b
PassBand Phase Response of Parallel Filter
19
8a
Full Group
20
8b
Passband Group
9a
Impulse Response of Parallel Form Filter
21
9b
Step Response of Parallel Form Filter .
21
Dela~
Response of Elliptic- Filter
Del~
Response of Parallel Filter
Dela~
Response of Parallel Filter
v
20
Abstract
Di~ital
Filter Analysis
IBM PC's
Usin~
by
Donald Joseph Brunnett
Master of Science in Electrical Engineering
A
computer program is presented for analyzing digital
filters with arbitrary topology.
to
that
of
analysis.
to
be
graphics
the
The
used
SPICE program
[1]
for
analog
circuit
digital filter analysis program is designed
on IBM
capability.
educational purposes.
an
The input data is similar
instruction
compatible
It
is
personal
computers
especially well
with
suited
for
The program prompts the user so that
manual is
not
required.
analysis examples are also included.
Several
filter
A portion of this work
was presented at the IEEE conference described in [2].
[1]
Nagel,
L.W.
"SPICE2:
A computer program to simulate
semi
conductor
circuits,"
Electronics
Research
Laboratory,
Report ERL-M520, University of California,
Berkely, 1975.
[2]
D.J.
Brunnett and J.W. Adams, "Digital Filter Analysis
Using
IBM
PC
Compatible
Computers,"
IEEE Midwest
Symposium on Circuits and Systems,
Lincoln, NE, August
1986.
vi
Chapter .1.
~.o
Historical Perspective
Signal flow graphs have emerged as a popular means
representing
As
the
the topological structure of digital filters.
complexity
of
digital
filters
analysis becomes more difficult.
the
area
of
increases,
the
This is especially true in
of component sensitivity.
For
this
reason,
computer algorithm is developed which uses the notation
a
of
signal flow graphs and the equivalent matrix representation
to
provide
characteristics
program
system
the
of
consists
transfer
digital
of
filters.
numeric
data
frequency response characteristics:
group
delay.
In addition,
and
time
The output
or
plots
magnitude,
of
domain
of
the
three
phase,
and
the impulse and step responses
can be analyzed and plotted.
1
.z
Chapter
2.0 Introduction
The DINAP II computer program [3]
for
filter
digital
several
analysis.
is an excellent tool
However,
it
consists
of
thousand lines of FORTRAN code and is intended for
mainframe
computers.
described
in
popular
this
The digital filter analysis
report was developed for
IBM PC (or compatible)
computers.
program
use
on
It can
the
analyze
digital filters with arbitrary topologies.
The program is very short and easy to use.
reasons,
the
educational
program
purposes.
should be especially
and plottig can be performed with the program,
efficiency
simple,
were
sacrificed
and easy to use (i.e.
these
valuable
All schematic inputting,
the use of an instruction manual.
For
editting,
and without
In some cases speed
to keep
the
for
program
and
short,
Gaussian Elimination was used
instead of sparse matrix methods).
Schematics of up to 60 nodes,
and 400 branches can be
analyzed.
Possible
schematic
elements
branches,
multiplier
branches,
feed through
adder nodes.
include
nodes,
delay
and
Any node can be specified as the input and any
[3] S.E.
Belter and
S.C.
Bass,
"Computer-aided analysis
and
design of digital filters with arbitrary topology,
"IEEEE Transactions Qn circuits an.Q. Systems,
vol. CAS22, pp. 810-819, Oct. 1975.
2
3
node
or difference between two nodes can be
the
output.
Possible
in decibels
magnitude
delay in samples.
eliminates
the
frequency
(dB),
The method
domain
specified
plots
phase in degrees,
and
group
used to compute group
delay
difference of the phase as i t moves around the +180
and
step responses.
monitor
CRT.
include
discontinuity that occurs when taking
to -180 degree point.
as
the
degree
Other possible plots include impulse
All plots are directly viewed on
Schematics
can
be
deleted from a floppy or hard disk.
stored,
retrived,
the
and
Chapter .3
3.0 Computer Implementation
The program is written in turbo pascal using the turbo
graphix
360
toolbox.
The executable code resides on a
single
floppy disk along with supporting software
KByte
documentation.
A
separate disk contains the source
and
code.
The source code of the main program is listed in Appendix E
and
the
Gaussian
elimination
procedure
listed
is
in
Appendix F.
The program will operate on the IBM PC,
PC-AT,
256K
IBM PC-Junior,
of
memory,
Hercules
an
monochrome
or compatible.
IBM color,
Enhanced
color
for
program
will
filters
with large numbers
automatically
or
An optional math
processor will significantly reduce the computational
required
IBM
It requires at least
IBM
graphics card.
IBM PC-XT,
determine
of
what
cotime
nodes.
hardware
The
is
present and respond accordingly.
The
output
program is intended to provide hardcopy
the plots for Epson (or
of
Although
built in graphics dump routines are
much faster,
larger
by
compatible)
graphics
printers.
included,
and in the case of the IBM color cards,
a
a much
and more readable graphics printout can be obtained
using
the PrintScreen option in conjunction
with
the
and
the
cards.
The
hardcopy
command for the Hercules graphics card,
graphics
command
for the IBM color
graphics
5
hardcopy
command
can
compatible printers.
with any printer.
even be made to support
listing)
All sample plots presented were generated
Read.me file
contains
Epson
Note That numeric output is available
using the Hercules graphics card,
The
non
and the hardcopy command.
on the disk (see Appendix D
enough information to start
program as well as other useful information.
for
using
a
the
Chapter
11:.
4.0 Functional Decription
information
Shematic
branches,
ending
each branch containing a
with
node,
entered in the
is
and multiplier
value.
form
starting
of
node,
A multiplier value of
zero is used to denote a delay branch.
The frequency domain characteristics are calculated by
using
the
list to derive a set
branch
linear equations in
the
matrix form of A x
is the nodal transmittance matrix,
vector,
nodal
and
b
First,
the
matrix
A
is
simultaneous
b,
x is the node
is the source vector.
transmittance
of
variable
The complex
generated
A matrix is defined to be a
as
follows:
square
identity
matrix
of
rank equal to the number of nodes.
branch
is
inserted
matrix
element,
whose
node,
and whose
row is equal to the ending node,
to
the
branch
sum
and
(where
column is equal to
previous matrix
element
is zero (meaning a delay branch)
represents
j
multiplier
nodes.
setting
value.
The
b
equal
for
then
the
e~(-jw)
is
the
is substituted
for
source vector b is defined
as
a
number of
vector has all zero values except for
6
that
If
value.
with the number of elements equal to the
The
the
starting
the
the square root of -1 and w
frequency sample in radians per sample)
vector
by
each
Then
the negative of the multiplier
of
the
multiplier
into the A matrix
valued
the
7
element whose position is equal to the input node.
A contains a detailed example of how the A
generated
are
lowpass
set
a.
ensure
simulta.nious equations
of'
frequency
elimination
to
of'
b matrices
that
method.
that
premature
Partial
zero valued
the
do
rows
the
column
that
Gaussian
not
Partial
remaining
the
element of the largest magnitude
is to be eliminated,
cause
solution.
pivoting consists of' searching
f'or
the
in
and using that
reduce the rank of the remaining rows b;y one.
the
scaling.
largest
than 1e-10.
in the row
element
to
The pivot row
greater
sets the magnitude
to
one.
If'
after·
the pivot element has a magnitude less then 1e-30
a singularity is indicated.
example
Scaling
the
row
is scaled if' the magnitude of' the pivot element is
than 1e10 or less
for·
horizontal pivoting is used
elements
of'
termination
solved
is
to plotted using
is
horizontal
of'
order
third
elliptic filter.
This
each
the branch list
from
and
Appendix
of'
Appendix B contains a
numeric
using this Gaussian elimination procedure
to
solve a. set of' three simultaneous linear equations.
The
group
dela;y is obtained as a
finite
between the phases at adjacent plot frequencies,
the frequency difference.
to
However,
divided by
a novel approach is used
obtain the difference in phases;
susceptible
difference
this approach is
to the usual discontinuities which occur
not
when
the phase at adjacent frequencies steps between value close
to
-180
and
+180
degrees.
The
phase
difference
is
~
.
8
as the arc tangent of the complex conjugate
calculated
the
of
frequency response at one plot point multiplied bY the
response at the adjacent plot point.
This is indicated
in
the following.
ATan2
Im H2 Hl
*
Re H2 Hl
*)
Group Delay
w2 -
wl
where
jw2
jwl
=
Hl
*
H(
e
H2
)
represent conjugate
wl,
c
Appendix
=
w2
H(
=
j
e
)
square root of -1
frequency samples in radians per sample
contains a graphical proof of
this
equation
using vector notation to represent the complex numbers.
impulse response and step response
The
using
the
branches
equations,
node
are
not
=
A X
b,
computed
are
except
the
represented in the A matrix and
vector is updated on each filter iteration.
delay
the
The modified A
matrix shall be denoted as Am and the modified b vector
bm.
node variables are computed for the first
The
iteration
Am x
to
=
determining
in
the
step
by
r·esponse
as
filter
using
where the element of the b vector corresponding
bm,
the input node is set to unity.
nonzero
b
Solving for
x
yields
values only for those nodes which are connected to
the input through delay free paths.
conditions,
the
Assuming zero
initial
delays are treated as open circuits since
their outputs are all zero for the first iteration.
For
the
second filter iteration,
updated as follow:
the bm
vector
is
Delay branches cause the previous value
9
the "from" node of the delay branch to be added to
of
value in the bm vector corresponding to the
existing
node
of the delay branch.
this
way,
the
By modifying the bm
delay outputs are effectively
nodes for the second filter iteration,
system of equations,
Successive
Am x
vector
in
treated
as
=
bm,
the modified
is solved.
filter iterations proceed in the same way,
with the x and bm vectors being updated on each
The
"to"
To determine the values of the
sources of delayed signals.
other
the
iteration.
step response output is taken as the element of the
vector
response
output
is
The
impulse
taken as the difference between
the
current
value
response.
discrete
node.
corresponding
and
to
the
output
x
the previous output value of
the
step
Since the time domain information corresponds to
samples in time and not
impulses
whose magnitude corresponds to the plotted value.
Appendix
A
and step response plots consist
information,
of
the
impulse
continuous
also contains a detailed example of how the time
matrices
are formed from the third order lowpass
filter example.
domain
elliptic
Chapter .5.
s.o
Filter AnalYsis Examples
first
The
example
analysis
is the
third
lowpass elliptic filter listed in Appendix A.
is
order
The schematic
redrawn in Figure 1 with its related frequency and time
Figure
domain plots listed next.
magnitude
response,
and Figure
magnitude
response.
Notice
2a
contains the entire
2b contains the passband
how the tic spacing for
frequency and magnitude axis is always
2,
a multiple
or 5 regardless of' the minimum and
selected.
spacing
also
If' a
would
second y
of'
1,
maximum axis value
axis had been selected,
be dependent on the magnitude
automatic date stamp and
the
the
user
i t ' s tic
Note
axis.
specified
title
included on every plot.
Figure
delay
axis
is
plots
respectively.
In order to have the second y
the magnitude axis
contain even numbered tics,
given
a
and 3b contain the entire phase and group
3a.
the same limits as
magnitude
plot
was
the
second
not requested.
not a discontinuity in the group
phase
passed
however,
phase
a
from
delay
is
axis even though
Note
that
delay plot
+180
deg.
discontinuity
an instantaneous
makes
+130 deg (this
-180 deg to
group
y
jump
was
there
as
the
There
is,
were
the
from -60
deg
to
possible since the magnitude is zero at
this point).
10
11
The
time domain plots for the third order
located in Figure U.
filter
are
domain
case
delay,
and group
magnitude
magnitude
the
where
Unlike
phase,
and
step
on
having
it's
the
"*"
with
impulse
each
step
The
and
response
response
"O".
and the impulse response bY an
on
two time responses falls
is
If
the
same
pixel then a horizontal zero reference line
will
zero
vertical
graph
same
own set of limits.
indicated by an
or
can optionally be plotted on
the program always plots the
the
frequency
the
the same graph,
response
elliptic
the
of
be drawn.
The
digital filter example is a
next
bandpass filter,
with
it's
6a contains
schematic
the entire
parallel
listed in
magnitude
5.
Figure
and
Figure 6b
was
generated with the optional variable
Figure 5a
frequency
but rolls off
little too quickly as the magnitude exits the
The auto
with
step
a very good
Note that i t does
job of catching all the transmission zeroes,
a
Figure
response,
contains the passband response.
size algorithm set to 1dB.
form
passband.
frequency step size algorithm does not work
filters
that
have
very
abrupt
changes
in
well
the
magnitude response.
Figures
passband
7a.
and 7b contain the entire
phase respectively,
contain the entire group delay,
phase,
while figures 8a,
and
In order
to
8b
and passband group delay.
The time domain plots can be found in figures 9a,
9b.
and
keep the step and impulse responses
and
from
12
obstructing
were
set
each
so large
impulse response,
when
other,
the step response
axis
limits
in Figure 9a so as to obtain only
and vice versa in
the number of samples is
size is cut in half.
large,
Figure 9b.
the
the
Note that
sample
marker
.13
1
.05634
2
1
4
1
7
.683
Thircl orcler elliptic filter
Input node = 1
Output node = 7
'
r-
1.4
G~
Elliptic Filter, n=3.
in (dE:)
0
I
0
I
0
I
0
1
I
I
0
0
I
~---~--~--~·-•·-~--~---~--~·-r·-~--~--~---~--~··r•••••1•·~---~-'
I
0
0
I
I
I
I
I
0
I
0
I
0
I
0
I
0
0
0
0
I
I
I
0
I
I
o
o
o
o
I
o
0
I
0
I
I
I
o
I
I
1
I
0
I
I
I
0
I
.
I
0
0
0
o
I
I
I
I
0
I
..
1
I
I
I
I
-~--~·-•·••••1··~---~--~··r•••"'•1•·~------~--r••••••·-~-----'
. .
I
I
0
. .
I
--~·-•·•••••·-~--o
0
I
I
I
0
I
0
o
I
I
·IS .0
--~·-•··•··•-------
I
I
I
I
0
0
I
0
I
I
0
I
I
0
I
o
I
0
•
•
I
I
.
1
0
I
.
I
0
o
•
0
.
I
•
I
I
I
I
I
I
I
0
I
J
I
0
I
Figure 2a
I
I
0
0
l
0
I
0
0
I
I
I
I
I
I
I
0
t
-~·-••••··•-------·•r••r••••·•·-~------~·-r•••••••·~------
. .
--:- -- -- -:---:---r
. . .
I
I
I
I
I
0
I
I
·3&.0
0
I
.
~
I
I
I
~--
I
0
0
-~-- ~ --~--
Full magnitude plot
of Elliptic filter·.
.
.... .
. . . . ..
.
--~--+--t--~---:---:---~-.
..
'
'
..
.. ..
'
I
I
1
I
0
I
'
I
'
I
'
I
'
I
I
0
I
0
I
I
I
I
0
0.0
0.0\
D>~t:
3· 9·1386
G~
in (dE:)
..
O.i -~--~--:--
'
o.u
0.0$
~.
-~--~--:--
0.2
.3E·OI>
,
::::r~~~~;~:;..
~0.5
-1--~--:-
·G.i
-1--~·-:-·
·1.0
-~--~--:--
·1.2
-~--~--~--
....................
·I.\
·1.6 ... ~ ...
-
~-
-~--~--:--
--t--~- . .:--u~-~--~--:-
·2.,
.ir- . . . -:- .
~
~
-3.0r-~--~--:--
-l.2
-~--~--:--
·3.,
-~--~--:-
0.0
0.015
3· 9·198i
0
I
0
I
I
I
-~-- ~--
o
I
0
-j.-
.
0
I
I
0
I
0
I
-r- .. ; --,---:---:---
I
I
I
I
I
0
I
I
I
I
I
I
I
I
I
0
1
I
I
I
I
0
I
I
0
I
I
0
I
I
I
I
; ......:.... -:-- -r .... ;. --; -- ~-- -\---:-- -r- .. ,.
0
I
1
0
I
I
I
1
1
I
0
I
I
I
I
I
.; .... ; ---:---:---
I
I
I
I
I
I
I
0
I
0
0
I
I
0
I
I
I
I
I
I
I
I
I
•
'
• • • • • • • • •
1
• • •
I
0
0
I
I
I
I
1
1
I
0
0
0
0
I
I
I
0
I
0
0
I
I
I
I
I
0
0
I
I
I
I
I
0
0
0
I
I
I
0
I
0
I
I
I
0
0
I
0
0
0
I
0
I
I
I
0
I
I
I
'
~---~-0
0
I
I
I
..
I
I
o.l>
0
0
o.2
Frequency
I
I
0
0
.
I
I
1
0
I
t
o.n
o.2s
o.32
o.>G
(cycles;s~Hple)
0,,,
0 ·'
I
I
I
I
0
I
I
o
I
0
--:---:-.. -:--
- -~- --:-- t- .. -:- -~-- ~- -:--f--~- -:-
0
0
o
I
1
0
--:-:--:--:--:--:--:-- t --~--:--: --:-
~--:--
- - &. - - · - -
1
I
1
t
1
I
I
I
I
o
I
I
0
0
0
I
1
I
0
I
0
I
I
I
-~-
--~-i--+--~-~--~-~--i--~-~--i--~-~--t--~1
I
0
1
I
0
I
I
I
I
0
I
0
. .
- -~- --:- -t- -:--
.
'
'
'
'
'
--~-~--t--~-1--~-~--i--~
~--~1
I
I
I
I
I
I
I
'
.
--:--
I
I
0
•
I .. •
~'"
I
0
I
--:--
--:---:---:--
--:--
--~--:-- .. &. __ ._-
0.03
~
.. -;--
--~--:--
--!-- -:--
:·-:--:--:--:--:-- :--:--:--
.... L .... •....
--~--:--
i .. -~ • '"•t'" -:- •
.... L .. .,.•.. ..
--~--:--
.... &. .... •.. ..
--~--:--
•:••
I
~ --~
- - : - ..
l
I
0
l
I
0
0
I
--:-:--:--:--:--:--:--:--:--:- -t--~ -~ -+- -:--
--!---:-- ·-!---:--
--:-:--t--~-~--:-~--:--r-i--:--:-~-
--~--:--
--!---!--
--~-~--+--~-~--~-~--~--~-~--~--~-~+--~•
0
1
0
I
I
1
I
I
0
0
1
I
--!----~-
--~--:--
--~-~--t--~-~--~-~--t--~-~--t--~-~+--~'
I
0
0
I
0
I
- .. L ... •....
--~--:--
--~-~--t--~-~--~-~--i--~-~--~--~-~---~'
0
0
I
I
1
0
I
I
0
I
I
I
I
.... L .... '.. ...
--~--:--
--&.--•--
--~--:--
--~I
-:-- t--:- .. ~- -~--:-- f --~ --:-- f- -~- --:-I
I
1
0
I
I
I
I
--~--:--
--:--
I
I
--~-~--+--~-~--~-~--t--~-~--~--~---:---~•
1
I
0
0
0
I
I
I
I
I
l
0
I
I
--~---:--t·-~-~--~-~--t·-~-~--~--~-~--1
-~-
- -·--
--~---:--t--~-~--~-~--t--~-~--t--~---:--t
-~-
--'---'--
-:--
--~--:--
--:--:-- :--:- .. :--:--:--:--:--:--:--: .. :--:
•
I
I
I
0
I
I
0
I
0
0
I
I
I
-'--
1
I
0
I
I
I
I
0
I
I
--~--:---~--:--
.. - --:-~
--!-·-:--
--:--~--t--~-i--~-~--1--~-~--~--~-~--t
-~'
t
o
--:--
--
--~--:--
0
--~-i--t--~-1--~-~--t--~-~--t--~-~
-t--~0
I
I
I
I
0
I
I
1
I
I
0
--: ... --:--
--"--'--
.... L ..... I.,. ..
--:--:--:--:--:--:--:--:•
---:--t·-:--:--~-
--~--:--
-:--
- .. ~--:--
--:-:--:--:-:--:--:-- :·-:--:--:--: :--:--:-
•3.6 -~--~--:-
-~--~--:·-
I
I
I
-i--1--~---~--~--~--t--~--~---~--~--~--t--~--~•
0
0
I
I
I
I
0
I
1
0
I
1
·).1
1
:--t- -:-- -..
--~-~--t--~-~--~-~--t--~-~--t--~-~--t--~--~-~--+--~-~--~-~--t--~-~--t--~-~--t--~- -
--:--
-:--
.......................
·2.2
-~
I
I
I
I
EII i pt i c F i Iter, n=3.
·1.8 -~--~--:--
·2.0
I
~--
•
I
0.5 ......... &. ....• ....
0 ... _., __ __•__
-:---:-- .
. .
,_ --:---:-..
0
I
'
I
0
... :--- - ~--~--~---~--~--~--~--~--~---~--~--~--~--~
1
t
.,5.0
I
I
·::::::::.ml\::::::
··t -- t·- t· -:---:---:---:--:--~--f--t--~---!---;--
·ltO.O
I
I
I
--r--~--,--,--~---~·--r-
.or
I
I
I
I
--~
·25 .0
I
I
0
I
OUt:
I
o
--:- --~·-~ ..... ; .... ...; ..... -!-- .. -- ~ ..... ~ -- .; ..... -:---:---;..- ... ;. ...... T..... ; ..... -\-- . . ;...... ;.. .. -i- ..... .; ..... .; .... -:---:- ... -
-~11.0
·2
0
I
--~·-••••••••·~---~·-r••r••••••··~----·-r••r••••••··~-----I
I
I
I
I
I
I
I
I
I
0
I
I
0
0
0
I
I
I
I
0
I
I
0
0
0
I
0
I
0
0
I
I
I
0
0
I
I
0
1
0
·35
I
I
o
I
·10.0
f
I
I
--~-~--t--~-~--~-~--~--~-~--~--r-~--t- ~-
- -!-- -:--
--~-~--t--~-~--~-~--t--~-~--~--~-~--+~•
I
0
0
I
I
I
I
I
-- !-- -:-0.12
0.135
Passband_magnitude
plot of tllJDtlc
f i 1ter.
·
Q
'
15
Elliptic Filter, n=3.
uoo
.
·•
'
.
--~--~---~·-110.0
•
0
0
I
0
0
0
0
I
-------~-- --~--~---------~--·--~--~--------I
I
I
I
I
I
I
0
I
1,0.0~--~-
uo.o~-+--
..
uo.o~--~-
---:-
IOO.ot--~-
I
I
I
0
I
0
0
I
--~--~--
--~--~---~--~--r--•--~--~---~--~-0
I
0
I
0
I
I
0
I
I
-.-- --*--
--~--~---~--~--~--~--~--~---~--~--
-:---~--~
0
I
I
1
I
I
I
t
1
•
I
0
I
I
I
I
I
I
I
I
0
I
I
I
I
0
I
0
0
I
0
0
I
0
0
I
I
I
I
I
0
I
I
0
I
I
1
I
0
--..:--..:---:-·-1\0.0
- -- ~ ---:---:-- -~-- :-- .. t- .. -!- ... -:---:---:-- ..
-------· -
---!--~---:---120.0
--~--~---~--100.0
,
I
0
I
I
0
--4--~---------k·-·--~--~---------
~0.0 --~-
I
I
I
I
I
I
I
......... _ ...... ~ .... p
- .... , ....
so.o .... ,. .......
1
--~--~--+·-1,0.0
0
I
I
0
0
I
I
I
I
I
I
I
~---.--·r·-r·-~--,
I
I
I
I
I
I
I
I
0
I
. . . . p . . . . . . . . . . ~--~---~--~--
0
0
I
0
1
I
I
I
I
I
I
I
I
I
20.0
-~--~--·
-
.. --:-
-:---~--
I
I
I
I
I
I
I
1
I
I
I
<
I
I
I
0
I
I
0
I
I
I
I
I
I
.0
--,--~---r--r--r·-~--,--~---r--r--
.... , .... ., ...... r-
·2.0.0
t - -- ~ ---:---:-- -~- -:--- ~- .. ~- --:- .. -:-- -~--
--~--~---;--
-lO.O
I
'
1
•
I
I
0
1
I
•
I
0
0
• • •
'
I
0
I
•
I
I
I
0
I
0
I
• •
I
I
I
I
I
I
I
I
•
•
1
I
I
I
0
0
I
I
I
I
.
'
I
1
0
I
I
I
0
.
'
--~--~--·--·--~--~---~--~--~--~-I
I
\
t
I
I
1
0
I
:~~H-_
--·--·---~-
-to.o
--~--~---.--
·$0,1)
0
I
I
0
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
0
1
I
0
I
I
0
I
I
I
I
I
I
I
I
0
I
I
t
I
I
I
I
I
0
I
I
I
I
I
I
0
I
I
I
I
I
I
I
I
I
t
I
I
I
I
0
I
I
I
I
I
0
0
of Elli~'tic
filter-.
I
--:---:---;..-- ~- -.; ---:---:-- -r-- i---T--; .. --\---:-- -r-- i- -- .r -- ~- --\---:--- -too.o
--:-- -~-- ~-·~- --!- --:---:---:- .. -~- -~ -- ~-- -:---:---:-- -~-- ~ --~-- -:---:--- ·120 .0
I
--~- -~- -~-- ~--~-- ~-- -~- -~-- ~
I
0
I
I
0
I
0
I
0
-- ~--~- -~-- -~- -~-- ~ -- ~ -- ~ -- ~-- +--
-1,0 .0
--~ -- ~ --~- -~-- ~- -~-- ~-- ~-- -~- -~-- ~- -~- -~-- ~-- -~- -~-- ~- -~ --~ --~-- -~-- ·1'0 .0
I
I
I
I
I
I
1
I
I
I
I
0
I
I
I
I
I
I
I
I
0
I
I
1
I
I
o.28
o.n
I
1
0
I
I
I
0
I
I
.... ~ ---:---:---:- .... ~ .... t .. -~ . --:---:- . -~-- ~ .. -~ . - ~-- ~-- -:-- -r--~-- ~ --~- -oo\-- -:--- -1SO .0
-uo.J--r-0.0
I
Full phase plot
I
I
~--~---~-----·--~--~------~--~-'
I
0
I
I
I
I
·!0.0 --~--
0.0
o.o
--~--~---~--~--~·-•·-~--~---~·-r••
I
0
I
I
I
I
-60.0
D>~t:
I
I
I
I
·r--r--r •
·\0.0
I
I
Figur·e . .\a
--~--~---~--~--~--~--4--~---~--~-•
I
I
I
I
0
I
I
I
0
.
0.0
I
I
.,._
o.o
--.1--.J---'---
.. -- ~-- -:... - -:---:---:- ... - t .... ~-- -:---:-- -~ ....
I
--~--~---~-- .0.0
--,--~---.---
.... , .......,- ..... ,. ....
0
0.0,
0.12
0.08
3· 9-Uii
,J_L_L_
!.Or--·--·-•. sr--~--t--
O.li
o.n
0.2
o.36
FreQIJency (cycles;s;.Hple)
O.H
0 ·'
0.\8
Elliptic Fi Iter, n=3.
GroiJp Del;.y
o
I
t
I
I
I
I
o
I
I
---:.- ... -- __ ,__ -~- ·~ -- ~-- .... --:---:-I
1
I
-~
0
I
I
I
-- ~- -~ ---: .. --:- ... -:-- -~-- ~ -0
t
I
I
I
~---:
t
I
I
-- .... --:--- .5
I
I
- -~- .. ~--!.-- ~-- ~-- ~-- -:-- -~-- ~- .. ~- . . ~-- ~· .. -~- -~-- ~--:-- ~-- ~-- -~-- .0
.
I
·-~--
1
·-
0
0
I
0
1
I
I
t
I
I
I
I
I
o
-:---~--~--~--~---:---:---~--~--~--~--~---:---~--~--~--~--~---:---
.s
--~- ~: r:t::~::~::rrrr:~::;::~::rr:~::~::;::~::~:::;:: .:
:·:l~::~:::::
. .
1
1
I
I
t
I
I
I
I
0
0
I
I
I
0
I
I
I
1
0
0
0
I
I
I
I
0
0
0
I
I
0
0
0
I
I
I
'
0
1
I
I
I
I
I
I
0
I
0
I
I
I
I
I
0
I
I
I
0
I
I
0
I
I
I
I
I
I
0
0
I
I
I
0
0
I
I
I
I
I
0
I
I
I
I
I
0
'
7.0 --~--:--
I
-~- ·:-·: --:- -·--:-- ·:- ·:-- ·--: --:-- :·- ·:- ·:--:--: -- ·- ·:·- ·:-- .0
:-- -r- -~-- T-- ; .... -:---:-- -r- -i- -- ~- -~-- -\-· -:-- -r.- -i---T- .. ;---\---:--- .s
6.5 --r--~--
-- , .. -.--
:1::::::::
., ..
.. -.. --:-- :- --:-·-t- -~-- ~ -- -;---:-- -:-- ·~ .. - t-- ~-- -:-- -:---:-·- ~ -- ~ --~-- -:---:---
I
I
I
t
I
I
--~ --; --~ --~--~-- +--~-- r--: --~--~---~--~ --:-- ~ --~-- ~-- -~-I
I
I
I
I
I
I
I
I
I
I
t
I
I
I
s.ot--~--~-\.5 --~--~-- -- ---:- .... : - -~- -~- -~- -~---:- --:-- -~ -- ~ . - ~ -- ~-- ~-- ·:-- -~-- ~-- ~ --i-- ~-- -:--..
•. 0
~r~~ r~~1~~ 1~~J~ ~~t~ ~t~~ t~~1 ~~1~~J~~~t~~t ~ ~ ~ ~~ 1~~1 ~ ~ J~ ~ ~t~ ~
--~--i-1
--·---:---: 0
--:---~--
u,
I
0
I
o
I
I
I
I
I
t
I
I
I
I
I
I
I
0
I
I
I
I
I
I
0
I
:
:
:
:
:
I
I
I
I
I
I
:
:
:
:
:
:
:
:
:
:
0
I
0
0
I
I
I
I
I
I
I
I
I
I
I
I
I
0
I
I
I
I
I
I
I
I
0
I
I
t
0
--~--~--~---:---!---:--·~--~--~--~---:---:---~--~--~---:---:---
-- ~- -~-- -~- -~-
0
I
I
I
0
I
~-- ~-- ~--~-- -~ --~
I
I
-;-- ~I
3- 3-13&>
I
I
~--~--~--~--~---~--:---~--~--;---\---~--r--~--~--;--~---~-I
~.,.,
0
I
I
1
0.0,
I
I
:
--:---fo-- ---!---:---:---.
0.0
I
.o
.s
·0
.s
·--~--:--·------~--·--·--·--·------~--·--~--·--·------~-- .0
'
'
--:---~--
0.5 .... ,. .... t ' - ..
t
I
I
t.S
1.0 --·--·--
I
:
2.0
I.S
.0
--~--~--~--~--~---~--~--~·-i---:--~---:---~--~--i·--:--~---:--.5
o
I
0
t
I
I
I
I
I
0
0
t
t
I
I
I
I
I
I
.s
.0
I
-- ~ · -~- ·~-- ~--+- -~- +-~- -~- -~-- -~ -- I.S
I
I
I
I
I
I
-~-- -~- -~- -; --:-- ~-- ~-- -~- -~-- ~--:-- ~--~-- -~-- 1.0
I
1
0
I
I
I
I
o
I
I
I
o
I
I
0
I
I
0
I
I
I
t
0
--·-- -r -- i--- ~- .. .; .... ~-- -:-- .. r-- ~ -- ~ --.;- -~-- -:-- .. .s
0.2,
0.28
0.3!
0.3£
(cycles;s;.Hple)
Q.I
O.H
0
·'*
Figur·e 3b
Full gr-oup delay
plot of Elliptic
filter •
16
Step Re p n e
Elliptic Fi
~
--
: I
I
0
.
--~----------
--~
---
IHPUise Response D
. . .
I
-- --
. ...
....
• _, -- •__ ·--'
I
I
I
0
I
I
I
0
0
0
I
0
I
I
I
--.;---:---~--~--~------~---:---1.1
I
'
.....
0
-- -- -- --
--~.9
,
__ __
--
lf - -
·0.1
.o
-- .7
:rr --0.0
0
--- -- --
--
0.7
'·'
I
-~· -~
--1--i-' '
... -
0.1 --~--
n=3.
--,--~---r--r--
1.0
0.!
I
lt~r,
l
__ j__
.5
--~-·
-- .3
--
.2
I
. . . ..
'
............. . .
--~--~--------~--·--~--------0
1
0
I
I
I
I
0
I
I
t
I
I
I
I
I
I
0
0
0
I
I
I
I
I
I
I
I
I
0
0
I
I
I
0
I
,:o ' ,:o ' ,:o
1
I
I
0
--4--~----0
1
I
I
I
I
0
0
I
I
I
I
I
I
I
1o'.o ' u'.o ' n'.o
16.. o
SiHP I e NtJHber
................ . .
I
0
I
I
I
0
0
I
'
'
u'.o ' to'.o
----------1:.
u'.o ' n'.o
Figure 4
Impulse and step
r·esponse of
Elliptic filter.
17
.07ec1
'
.1
2
1
3
.2035
23
4
1
1
1
1
1'
Po.roJ.lel. ForM Digi"to.l Fil.ter.
Input node = 1
Dutp~t node = 23
Flg~re
5
1.8
............................
0.0
0
-5.0 --·--
-~--
·IO.L-L.
-~-•
I
0
I
I
0
I
I
I
1
I
I
~--~--~--~--
•
I
I
I
I
~--~--~--~-0
I
I
---:---:---r-- ..... .; ....
::!::t:
-25.L-L.
-lO.J._L_
--~---:---i---
---:---:---~--
--"--
---·---
--."---:---~--
--~---:-·-~--
---·- --·-- ..... --
--~--
.... j
--~--~--~--
--~---:---:---
......
. .
.
............................
--~--
__ _, ___ ._ __ Figur·e 6a
__ j___i___j Full mag;1itude plot
: :
... ........... ..............
.. ..................
.. ..
...
--~---
..
...
·lS.J) __
_,0
0
~
__ _,:_____ _
of Parallel Form
ti 1ter.
'
~--~---
.0~--~--
I
I
I
0
o
I
I
I
I
1
--
~-
- -~ - -- ~-~--::.;.::.:~:.;.:.::--:.:;~"-"--~-""'"-=1"
- . .; -- -:---r- - r-I
o.o
~>tt:
0.01
0.01
0.12
3- S·U$>
0.16
o
I
0
0.21
I
I
I
I
>
o
I
0.28
0.32
I
C.3G
(cycles;s~Hple)
lei ForK
P~r~l
G:ain (d8)
o
0.2
Freq~ency
I
'
o
0. I
I
--
0
o.a: --:--- r-- -- ~-- -:---:---:--- ~-- ~-- ~- --:---:---:--- r-- ~ -- -!-- -:---:- .. 0 .G - -:-·- ~--
--:---:---:---:--:--:--:---:---:---:--:--! --:--:---:---
0 .•
--:---:---:---:---:--:--:---:---:---:--:--:--;-- -:---:---
o
I
~- -~-- f--
I
I
f
1
I
I
I
I
I
I
l
I
I
•
.3E-OI5r··:---~--o.2.f- -~--
~..
-t-o.~l--- -~-- t-
-o.•r --:--o.st- -~ -- t
-1.0
•
''
, '
--: .. - -;-- -;-- -;-- ..
'
----~--~---:---,
-:---:- .. -
•
,
-:- .. -:- ....
~--
;--!- -;- . -:- --;-- -;-- -;--!--:- :---:---
- .. '!--~---:---I
--:---:---:- .. -: .. -:--: .... :---:---:- .. -:--:- .. :--:- .. :·- -:-- ..
- - .J - - J .. - - · - - -
--;- --;-- -:---:--:- -; -- ;---:-- -;-- -:--; --;--:-- ---·---
- --!.-- ~-- -:---
- --; -- -;-- -:---;- .. -:- .. ;-- ;- --:-- -;- .. -;- .. _:--: .. -: ............. _..
--~---:---;---
--:---t -
.tt
'
~--
-- ~-- -:---:---
&.2.~ .. -:---- t-- -- ~ .. - -;---:-- -~-- ~-- ~- .. ~---:-- -:---:--- .. ~ --~ __ , .. - --:---:--1
0.11
Fi Iter.
Di~it~l
I
0
' ..' ' ..' ' ' .' '
---·---
--~---:---:---~--~--~--~---:---:---~--~--~--~--
--"!:--~---:---
-1.2 --:---~ - --:---:---:---:--;--:--:---:---:---:---:--:--:--' --:---1 '
--~-I
.&.
-
I
-
-~-
--:---:--
I
I
I
-~-- ~-- ~-- ~-I
I
0
-:-- -:-·
t
I
I
--~---:---:---
-!-' -- ~-- ~- -~-- ~ --·--I
0
t
0
0
-1.€ --:-- -~ - --:---:---:---:- .. :--:--:---:---:---:--:--:--:---: .. -·--- --~-·1.8
--~---:---:---:---t--~--~---:---:---:---~--~--~--.;; --·--'
'
·2.0 --~ -- ~ - - .. :---:---:---:--:--:-- "': ---:---:---:--:--:--:--: --:-- ..
............
--:----t -
-2.2.~ --~--:-- --:---:-- -;-- -:- .. : .. -: --:---:---:---:--:--:--:--: --:---2.\ --:----I-- -- ~-- -:-- -:·- -r- -t-- ~-- ~---:-- -:---:-- -~-- ~- -~- -~- -:---2 il-- --~-.. - ~-- -:---:-- -~-- ~-- ~-- ~-- -:---:-- -~-- ~-- ~ --~-- ~- -·---
•t :
I
-2
I
a - -~--
-3:0 --~--3.1 --~ --
-3.\t- --~--s.if- -:---
-l.S.. --~--. -0.2
0.201
;;;.te: 3- 3-n;;
I
I
o
t
I
I
I
I
t
I
I
I
0
I
0
I
0
I
0
I
I
I
I
0
I
I
0
l
--~----:---:---
-- ~- --!-- -:---
- --~
--1---~---i---~--~--~--~---~---~---~--~--~--~--~- -~--
0.201
t
0.212
0
t
O.Hi
I
I
0.22
Frequency
I
J
0.221
I
I
0.2U
I
0
0.232
~-
--:---
--~--~---;---
--: ---:---:---
..... :---:-- .. :---:- -;--: --:---:---:---:--:- .. !--:--:- -:----:· --:---:---:--:--: . -:---:---:---:--:--:--: . -:- -·---- ~-- -:---:---:--- +-- -t- -~-- -:---:---:--- ~- -~ -- ~-- ~- -:----~---:---:---~--t--i--~---:---:---~--~--~--~--~- -·--I
~:rrr:,
--~--~---;---
-- ~-- -:- --:--·~ .. - ~-- ~ --~- --:---:-- -:--- -~ --~ --~--~- -:---
•
·--!.---:---:---
--~--~---:---
--
~--
-:---:- .. -
--~---':---;---
1
0.23G
(cycles;s~Hple)
0.21
0.~\1\
0.2:\S
F1gur-~
6b
Passband magnitude
plot of Parallel
Form filter.
19
P;r;lle.l ForH
110.0
Filte.r.
Di~it;l
uo.o --r--
::~:::t-::~:: t$-r~~~~t-~~~:~~~~~: ~
120.0
---:-·-:--·~--
100.0
...........................
I
I
I
0
0
--t-
I
.__
80.0
I
I
........................ .. __ .. ___ ._ _____ _
_.
I
I
I
I
I
I
- :--
--~---~--~--.--~
0.0
.,o.o
0
I
I
I
I
I
•
0
I
I
0
I
0
I
I
o
o
o
1
I
I
I
I
0
I
I
I
0
-~0.0
._
-:----~--~-
::~::~:::~: t::
---\---:---}--
.. -
~--
...
-:- ... -~ ... -
. .
. ,.... ,.... ,.....
.. .
I
0
I
I
--:
I
I
I
1
I
•
•
I
-~--~--~---~--~--~-1
I
I
I
I
'
o
r
·100 .0 --~--;--~--~--~---~--}--} .... ;
0
I
I
0
0
I
I
I
0
I
..
.... ,
:-
·120.0 --:---t-·t--~-··:·--:-··~·-t--t--~·--:1
0
I
I
I
I
I
I
I
0
I
1
••
I
I
I
I
I
0
.
o
I
I
0
I
o.o,
o.ot
o.u
-~--~--~---~--~--~--
--~--~---:---
.
.
-120.0
--~--~---~-- -t•o.o
·-~~ -~--~--~---:..--~--r- ·--:----:-··;--- -tGO.O
o.1'
0
uo.o
I
0
.
I
t
I
o.ze
o.z~
0.2
0.32
o.3,
0.,
Fre.que.ncy (cycles;s;Hple)
lei ForH
P;r~l
.
0
0
I
.
I
Fi Iter.
Di~it~l
I
0
I
I
•
0
t
I
I
0
I
I
0
t
0
I
I
I
t
I
I
I
I
-----·--~--~------~-----·--·--~------~-----·--~--~--·---------·-t
I
I
I
o
I
I
t
I
'
I
I
0
I
I
I
I
I
t
I
I
I
t
0
I
I
0
0
I
1'0 .0
--~--~·-•··~--~---~··r•-~·-•--~------~--~-·r••••·~--
.0
--r-- ;. .... ~- ·-- -:---:- .... ;. .. - T-r --r-. ... ;.--.:---:---:-.
. ~-- 4-.
o
o
I
0
0
0
0
. . .
110.0
I
0
t
I
I
0
0
0
0
I
I
I
0
I
I
I
I
0
t
0
0
I
I
1
0
I
I
I
I
0
I
1
I
I
0
. . .
I
0
'
I
I
•
I
•
0
•
I
•
0
0
I
1
I
t
I
0
---~·-r••r••
• • • • •
I
0
I
t
0
~--~--~--
1::-:r:::::::::- . ---::::::::Ej::~::~+ri::~:: ;: : : : :;:
~0.0
-·:---~--t
-~-·-:---:---~•
0
I
I
--~--~---~-- 180 0
--~--~---~-- 1,0.0
--.- --r- -r-- .... .;--~---:--- 1\0.1)
--
~---~--~--t--t·-~--~---~--~--~--t--~-0
..... ~--
~--
-:--- 120.0
• - ~-- ~-- -~-. 100.0
--~--~---:---ku
-~--;.- -:---ko. o
""--t--~---:---:---~--~--t--~-- .---:---~--~-I
0
I
I
0
I
0
I
I
0
I
I
I
I
I
t
0
0
I
I
I
I
...:::::.:::::::::::
I
I
I
I
%0 0 --~--:--: -~---:---:---:---:-
0 0
--~·-••••
--~--~--~
-20:0
t
·IJO.O --~ ·-t- -t
·--~---:---:-·-:---:--·:--:-- .-·-:--·:---:··
.. .., .... ..., ...... ~--~-- ........
:
•
•
1
•
•
:
~---o•••.-••r-••r•• ... --~--
:
I
:
I
L--~--~--~--~-- :--·:---~--L-
,"\,
I
0
I
0
.. :- .. ·:- .. -:---: .. -:·· :·-:- .. -:- ~-- ·:- -:- .. :--:-
I
~-
0
I
--~•
~--~---:---:--·~--t--t--~---:---:---:---!-·-
0
I
I
I
I
--~
•
0
0
.... ..
~
I
0
0
I
I
~
0
0
0
I
t
I
I
1
I
I
I
I
0
I
0
0
I
I
0
I
I
0
0
I
~---- --~1
I
0
I
I
I
I
I
t
I
t
I
0
0
0
I
1
0
0
--~-
0
o
I
0
I
I
I
I
0
I
I
I
0
0
I
0
0
I
0
I
I
0.%
0.20'
3·li·Uii
0.%08
o 212
0
o.u,
t
o.a
Fre.que.ncy
0
--·--·-·-~-
-!0.0
--.,--'"1---.--
-100.0
~---:---~--~--
I
0
I
0
I
t
0
I
0
o
I
~---~·-r·-~-I
I
0
0
--~--~--+-- ·1\0.0
--~--~---~·· ·t'O.O
I
--~--~---~--~--;--i--~--~---~--~--~--t--i--~---~--~--~-1
Par a11 e1 Form
filtH•
0
-~-
-~---.-·-~--~·-•·-~---.--•.-••r•-r••••·~
1
0
Passbar:d ?hase
plot of
I
--:-- -~ -·~ ....
o~--: .... r--1 -1·--~- . -~-- -r --r . -1""""1""- -i-- -~- --r--: ·t --1- ~-- -:- . -i-- -r-t- ..
............. .. -- ...............
-- --·- .................. -·--
-120.0
Fi g:ne 7b
---~·-~--,. .....
:::.: . : ::~~:~~~~~::~:~t~l:1:~~~~~N:~~::~: ::::~::~::~::
D~t<:
--~--~--+-- -10 0
I
.e~ --~- -~ ·-~--~-- ..;......:.... -~- -i -- i-- ~-- ..:.. :-- .. ;. - -~-- ~-- ~-- . : .. --:-- -~ --~-i ~ : : : : : : : : : : . : : : :
~
:
o.o
-tOO
·tO.O
--4--~---:--- ·100.0
.
•liO.O --~--~--~--~--~---~--~--~·-!·-~--~-
-lO.O
--~--~---~--
-~--~--~---~--~--~--
'
I
I
I
0
I
- ~--: -·--~--·---~-----·--
·1'0.0 --:--:--:--:--:---;--;--·--:--:--:-
--~---:---:---
I
.. ---------·--
--~··r•••··~--~---~--r'""•r•••••
I
I
I
o
I
I
I
'
For-m filter-.
I
I
I
0
Full phase plot
of Parallel
I
-t--i--~---~--~--~--
I
Figure 7a
-~·-r--~--
--~--t-·t-·i·-~---~--~--t-·t··\ -~
'
.0
-·--1·-~---.---r---~--
-·--~-1
'
1~0
-+-~--+··100 0
- -~-- ~-- -~- -~0 .0
--~--~---~·-po.o
--~--t--t--~--~---~--~--t--t1
I
I
I
0
0
0
I
0
·60 .0
--:--:---:---!20.0
. .
.........................
-------.---r-.. -~-- ~- .. ~--~-- ..:......;.~ ~- -~-
-10.0
--:---:---~--
. :--1~--~--~-·~--
, •. 0
te.O
--~--~---~-- no.o
I
~--1!- --~-+-~--
--·-
....
I
--~--~--+·-160.0
-:---:---:--:--:--
•
·180
--~--~---~--180.0
•
1
I
I
I
I
I
0
I
0
I
------~-----·--~--~------------~--·-I
I
I
I
1
I
I
I
0
I
1
liO.O
0
o.u, o.zu o.n2 o.n,
(cycl~s;s;Hple.)
I
--4--~---:---
0
o.z,
o.n~
o.n1
-180.0
20
lei ForH
P~r~l
I
?S.O ...........
I
0
I
I
I
. .
70.0
I
I
60.0
I
I
I
o
I
I
.
I
.
I
::::t~+:
0
'I
I
I
I
I
I
I
------~-o
0
I
0
0
I
I
I
I
I
I
I
I
•s.o --:---
--~---~--~--t--t--~
~-
---:---:---:.---;.--~--..:
-.- -- .. ;.. --
35.0
------------·--·--·
.. . .. '
30.0 --"--
--~---~--~·-t--~--~
I
I
I
I
I
2~.0
--------. ... --·--·-.
. .
0
I
.
I
I
I
0
I
I
I
I
I
I
I
..
..
..... ,.....
20.0 --"-ts.or--~-
--~---~--~--T
.
..
'
to .o~- -~--
I
I
.
0
I
I
I
I
I
I
I
.
I
I
.
I
o
o
I
I
I
I
0
I
I
I
I
I
0
I
---:---~--~--t--~--~---:--I
0
I
I
I
0
I
I
I
I
I
I
I
I
I
0
I
I
I
I
1
I
I
I
---:---~--~--~--~--~---:---
---~--~--t--
--
0.0
5.0:
I
------~-----·--·--~------
1
•
•
•
•
I
I
I
0
I
•
t
0.0
s.o
---:-- .;.. __ ,. --; -- ~-- -\---:--- 0.0
-v--
--~--~--~--
---:---:----~--~--~---:---:---
I
~ •
-.~ •
I
I
t
I
I
I
0
I
0
I
I
I
I
I
0
0
---.---.---r---~--
--:---~--{---
'
s.o
I
---~--~--~--:--~--~---~-- -s.o
I
'
--~---~--~--t--t-1
t
I
I
1
---~--~-----~--~--~---~--
t
I
~-- ~
I
I
I
t
0
I
---:- --~-- ~- -~- -i-- ~-- -:--- -s .o
I
--~--·--~
I
I
---:---:---- .. ·-·--~---:---:--- 0.0
.
~-- ~--~--~--~--
\o.o --r--
--~--
0
~--·--
I
I
'
I
'
------~-----·--·--~------
I
I
I
I
I
I
I
--J---~--~--~--~--J
'
I
(S~Hples)
......
I
.. ---. .............. . .
....
. -...
I
I
I
1
0
t
------~--'-·-·--·--~
I
I
-~---~·-r--r·-,--
--~---~·-r--T--,--,
•
I
--~--~--~--
t
--~------~--~--·--~
--r--
'S.O
..
I
. ..... _.....-......-- ·-..
. -____
g-q~~~~-mp••p--~--~--~--I
F Iter.
roup Del~y
Oi~it~l
I
"'I
-
I
I
-,.--,. --
o
---:-- -~-I
I
0
I
I
I
Full group
delay plot
of Parallel
Form filter.
0.0
5.0
I
~-- ~- -~--
I
'
0
I
I
.. -- .. ------
Figur·e Sa
t
-:---:--- 0.0
I
I
o
o
t
o
---:-- -r-- ~ --; -- ~- --:---:--- 15 .o
'T-I
-- -~-
I
-~-- ~--:- -~-- ~-- -~--
o
I
0
0
I
I
I
I
I
I
I
I
---:---:---i---T--.;---:---:---
s.o --:---
10.0
.o
... 0
0.0
O>te:
0.0,
0.08
0.12
3·U-US6
O.li
O.H
0.28
0.32
Fi Iter.
Group Del;y (s;Hples)
: : : : : : :J
Di~it~l
-- ~--..:- --~--:..- -~-- ~ --~ -- ~- --:-- -~- -~-- ~-- ~-'
•
• • • •
'
•
• •
'
'
•
•
I
•
'
I
I
•
I
-~- -~-- ~-- ~-- ~-- ~-- -~ ,- ~ .0
•
•
--~--·---~--~--·--·--J--·---~--~--~--·--J- ~-
70.0
O.H
0.3!
(cycles;s~Hple>
lei ForH
P~r~l
-
0.2
Frequency
I
• • •
'
'
I
'
I
I
'
I
•
I
I
-~--~-~~--·--J--~---~1-
+-+--:-- -~--~--;- +--;- -\- --~-+-~ --1- ~-- :-- +-- ~ --; -- ~-- ~-- -1-r
c0
·s o
-r-~---~--~--:--:--~--~---:--~--~--:--~ -~-- ~--~--~--!--~--~--+<- ,o o
" 0
~. ()
0.0
s .0
-+-+-+-+-- ~-- t·- ~-- +- +-+-- ~-- f-- ~ --~-- +--· -- ~-- f-- ~ -- ~- -+ i-
0.0
--~--~---~--~--+--t--~--~---~--~--~--t--~~-~---~-o
o
0.0
I
0
1
1
I
I
I
o
1
I
0
I
I
I
I
I
I
I
I
I
t
I
I
..
t
I
0
I
.
J
I
I
0
I
I
t
t
0
I
I
I
..
0
--,--~---~·-r·-~--'T"'"',--~---~·-r•"'r"'"''T"'"',
.
.
•
o
I
I
I
'
'
I
I
I
t
......
'
1
I
s .0
I
I
,---~-I
o
1
0
I
0
I
1
o
0
I
I
I
--~--·------~--·--·--J-------~-~--~--·--~--~-----I
I
I
I
I
0
0
I
I
I
I
--~--~---~--~--~--;--~--~---~--~--i---i·-~---:---~-I
0.0
I
0
0.2
Da'c:
0
I
1
I
I
I
1
t
0
1
--i---
I
---~--
---.--~------~--~--~---.--~------~--p·-~---.--~-----1
I
0
I
I
I
I
t
I
0
I
I
I
0.20'
3-n-ue.s
0.208
J
I
I
I
0.212
I
0
0.216
I
I
I
I
0
I
0
I
0.22
0.22'
0.228
0.232
Frequency
0.236
(cycles;s~Hple>
0.2,
o.2n
o.2's
.0
Fi<jUTe 3b
Passband
~r·oup
delay plot of
Paraliel Form
filter·.
21.
'oo.J-~--~--:-too.t··--·---- -700.
lei ForH
P~r~l
*
...
Step Respo s
I
0
0
Digit~
Filter.
R sponse D
...IHpulse
'
'
I
•
0
0
0
I
0
I
I
I
I
-~--·--~-~--·--~-4--~-~--·--~-~--~-•
I
0
I
t
0
I
I
I
0
I
I
I
I
I
I
I
I
I
I
I
0
0
I
0
I
I
I
0
I
I
I
0
I
I
0
0
I
0
I
I
I
I
I
0
0
I
1
I
I
0
I
0
I
I
0
I
I
I
I
0
1
SOO.Ot·~--~--:--
0
I
I
0
I
0
-
0
0
I
I
I
0
I
I
0
0
0
I
0
I
t
I
0
I
I
0
I
!00.0~-~--~- :-
I
0
. ,. . .
I
I
'
I
I
I
I
0
I
I
I
0
I
t
0
I
I
I
I
I
0
I
I
0
I
I
I
.u
.. .ot
0
o
~--~-,--r·-~I
0
I
I
..
I
.07
- ... , ... - '? - -
: :
I
--:- -t . . - .ot
-~--~--~-~--~--~1
0
I
I
I
I
I
I
0
I
I
I
I
I
0
I
I
I
0
I
t
I
I
0
I
I
I
I
0
J
0
0
I
1
I
I
I
I
I
I
I
.OS
I
I
I
-~--·--~-~--~--~
•
I
I
I
I
0
--~-~·-r·-·••••r·---·-t
I
I
0
0
1
I
......
I
-· - - --~-~--~-~--~--~-~--f--
lto.o . . ; ...... ;. . . -: . .
I
0
----·--~-~--·--~•
I
I
I
I
0
0
I
I
I
I
I
-~--·--~-~--~--~•
I
0
l
I
0
I
I
I
I
•
I
I
o
I
-·--·----~--~-·--·--~-~--·--
..
•oo.o -~--r·~--
I
I
I
I
--!--~--~-i--t·-~-i--~-~--t--~-i--~---: -t--. --:--t--:--~--~--:--t--~--:--t--
600.0 -~--~--:-
I
I
•
I
I
0
I
0
-·--·----·--~----
I
-~·-•·-~-~--•·-~-~·-r-~·-•••r•-.•••••
... .; --:- .. -:-- .....
0
--\-~- -:--..:-- ~- -:-I
0
0
I
0
t
I
I
I
I
-~--:---:--
.................... .n
.....,...... " ...... .03
Figur-e 9a
--'--"--
Impulse
.02
.OS
0.~~~~~~~~~~~~~~~~~~~~~~~~~~
::: :Etjl :f:
:::::t~l~~f~j~:i:: ~ :{ ~ ~ ~ -~--; --!-- ~--~- -!--; --~- -:-- --~-~--~--~-~--~ --:--~--~
f
--:--; --
r·esponse plot
of Par·allel
For-m filter·.
-o .0.
·700.0~-~-- ~- ~- • ~- -~ • ~- • ~- -~- ~-- ~--~ • ~ • -~ • ~-- ~ •• ~ • ~- -~- -~ • ~--~ • -~ -~ • -~--~ • ~ --~- ~- • ~- • ·O .07
I
I
I
I
-•oo .o -~- -~- ~-- ~-
-r -~-- t- -r-~- -r- -~- ~--r-~- -~- -r- ~- -t- -~ -~- -t--~ -~-- r- -~- ~--r-~- -7-- -o.os
1
I
. -:·-
·iOO.O -~--r -~-- ~- ~0
I
0.0
B>te:
I
I
0
1
1
~ --~ -~I
I
I
I
0
0
0
I
0
0
I
I
I
I
I
0
I
I
I
I
I
I
I
60.0
75.0
I
90.0
!OS .0
S;.Hp I e tiiJHber
3·1•·USo
0
I
1!0.0
ISO .0
-- ·ZOO.O
·0 .03
-- ·300.0
I
I
0
o
I
I
I
0
I
0
0
I
I
0
I
I
I
I
I
1
I
--~-~--·--~-~--~-~--+--~-~--f--~-
=-=~~~~:~:~::~::~:~::
--~-~--t--~-~--~-~--~--~-~--t--~1
I
I
I
0
~
: : : : : :
-o .ot~- ~-- ~- ~--:-- ~- ~-I
I
1
I
I
0
-0.09 -;--~--:--; .... ;. .....:-0.0
IS .0
3·1i·IS!i
30.0
I
I
I
I
1
I
I
I
0
t
I
I
t
I
I
-- ·100.0
I
I
·~--~--:--;--~--:-
D>te:
0
I
llS .0
--!---:--
·0.02
-o .o•
-o.os
I
-t- -:-- ~-- ~ --:-- ~-- ~--:-- ~ --~- ~- ·t- -:- -~-- f --:- -~-- ~- ~-- ~ -- ·O .09
0
15.0
30.0
15.0
I
I
I
I
o
I
0
I
I
-- ·SOO.O
I
--:---:--
• • ·iOO .0
I
--·700.0
--~-~--·--~-~--~----~--~----~--~•
I
I
I
I
I
0
I
I
I
I
I
I
I
I
I
I
I
I
I
1
I
I
I
0
I
I
I
I
I
I
I
I
-- ·800.0
--~-~--·--~-~--~----~--·-~--~--~1
I
I
I
o
I
I
I
I
--r--.·
•
I
•
I
o
0
I
T--,-- .,--r .....,.... ,
I
~
I
0
I
I
I
I
-·r --.--, --r-
I
0
I
I
I
I
I
I
0
I
0
I
I
0
I
0
I
t
I
I
I
I
I
I
f
I
iO.O
75.0
!0.0
S;.Hp I e N'JHber
-- ·!00.0
1
105.0
120.0
135.0
150.0
Step response
plot of
Par·allel For·m
filter.
Q
'
Chapter
.6.
6.0 Summar:v
program
A
developed
for IBM PC compatible computers
analyzing digital
for
filters
has
been
arbitrary
with
topologies.
It
incorporates some novel features,
such as
the
of
group
complex
method
conjugation
subtraction,
with
a
computation
multiplication
and
using
instead
phase
of
the use of nodal analysis in conjunction
and
source
delay
vector which is modified
at
each
filter
iteration for computing the impulse and step responses.
The
easy
to
filter
valuable
program prompts the user for inputs and
use,
providing highly presentable graphs of
responses.
for
very
is
For
this
reason,
educational purposes
it
where
is
especially
the
instructor
wishes
to have the students concentrate on digital
theory
rather
than
the
details of
program.
22
using
the
a
filter
particular
24
each
branch
is added.
The negative
of
the
Then
branch
being added
multiplier
for
the
is
summed
existing element in the
with
the
A matrix whose
equal to the to node of
column
is
the branch
being
and whose row is equal
node of
added,
to
the from
delay
If the branch
the branch being added.
is
a
e~(-jw)
branch,
then
substituted
for
the
is
multiplier.
is
the A matrix after
the
first
This
branch has been added.
A
1
-.05634
0
0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
0
After
the second branch has been added,
will be as follows.
A
1
-.05634
0
0
0
0
0
0
1
-e~(-jw)
0
0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
A
1
-.05634
0
0
0
0
0
0
1
-e~(-jw)
-1
0
0
0
0
-.683
1
-1
0
0
0
0
0
0
1
-e~(-jw)
0
1
the A matrix
0
0
0
0
1
0
0
After all the branches have been added,
will be as follows.
0
0
0
0
0
0
1
0
0
0
0
0
0
1
0
0
0
0
0
1
0
the A
0
0
0
-1.4461
1
-e~(-jw)
1.0166
matrix
0
0
0
.7951
0
1
-1
0
0
0
0
0
0
1
Generating the b vector for Frequency Domain Analysis:
The
b vector has the number of elements equal to
the
number of nodes. The vector is zero valued except
for
the element corresponding to the input node.
In
this
case the input node is node one.
Appendix A
Numerical Example
~
sYstem solutions
Schematic:
1
.05634
2
1
4
1
7
Third order elliptic filter
Input node = 1
Output node
7
=
Branch List:
Branches
From Node
To Node
Number
1.
2
3
4
5
6
7
8
9
10
11.
1.2
Multiplier
1.
2
3
2
3
4
5
2
3
2
4
4
5
.05634
6
z~-1.
5
6
4
4
-.7957
4
7
7
7
1.
-1..01.66
1.
5
6
z~-1.
.683
1.
1.
z~-1
1. 4461.
Generating the A Matrix f'or Frequency Domain Analysis:
by making A an identity matrix whose
Start
equal to the number of' nodes.
A
1.
0
0
0
0
0
0
0
1.
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
23
0
0
0
0
1.
0
0
rank
0
0
0
0
0
1
0
is
0
0
0
0
0
0
1
25
1.
0
0
0
0
0
0
b
The
matrix
equation
Ax=b
is now
ready
to
be
solved
for
discrete
values of w.
See Appendix
B
for
an
explanation
of
the Gaussian
elimination
procedure.
Generating the Am Matrix for Time Domain Analysis:
The Am matrix for the time domain analysis is the same
domain
analysis
as for frequency
except the
delay
branches
are omitted.
Am
1.
-.05634
0
0
0
0
0
0
-.683
1.
-1.
0
0
0
0
1.
0
-1.
0
0
0
0
0
0
1.
0
0
1.
0
0
0
-1.. 4461.
1.
0
1..01.66
0
0
0
.7951.
0
1.
-1.
0
0
0
0
0
0
1.
Generating the bm Vector for Time Domain Analysis:
The
bm
vector,
initially starts out the same
as
for
the
frequency
domain
case.
Then
the
delay
branches
cause
the
previous
output
value
corresponding
to the from node of
the delay
branch
to
be
added
to
the
value
in
the
bm
vector
corresponding
to
the
to
node
of
the
delay
branch.
The initial condition of all nodes is
zero.
Shown below are the first four sample times,
and
the
related
bm vector values
and
node
values.
The
last
element
in
the
x
vector
corresponds to the
step response output.
bm
1.
0
0
0
0
0
0
node values of first sample
X
1.
.0563
0
.0563
0
0
.0563
26
bm
1
0
.05634
0
.05634
0
0
bm
1
0
.09482
0
.23263
0
0
bm
1
0
.1211
0
.5075
.23263
0
node values of second sample
X
1
.0948 .0563 .2326 .0563
0
.1753
node values of third sample
X
1
.1211 .0948 .5075 .2326 .0563 .3274
node values of fourth sample
X
1
.1391 .1211 .8090 .5075 .2326 .5267
Appendix 13.
Numevical Example QL Gaussian Elimination
Using
the Gaussian elimination procedure to solve a
three simultaneous linear equations.
5 x1
-2 X1
0 X1
Equations:
Matrix Equation:
Matrices:
A
Solution:
20 x2 3 x3
0 X2 +
l X3
6 X2 - 10 X3
+
+
+
=
set of
1
0
0
Ax=b
5
20
-3
-2
0
1
0
6
-10
1
X
0
0
b
=
X1 X2 X3
A
lower
right
triangle is to be generated,
so
partial
horizontal
pivoting
will take the
row
which
has
the largest
magnitude
element
in
the
first
column,
and exchange i t
with
the
bottom row.
In this case rows one and three are
exchanged.
0
-2
A
5
6
0
20
-10
1
-3
b
0
0
1
magnitude
the
pivot
element,
first
The
of
element
in the last row, is check to see if i t ' s
magnitude
is
<1e-10
or
>1e10.
Since
it
is
not,
required.
no scaling
will
be
Next,
the rank of the remaining rows is
reduced
by one. This requires making the first element in
the
first two rows
equal
to zero.
Since
the
first element
in
the first row is already zero,
only
the second row needs to be
done.
First,
each
element in the second
row
is
multiplied
by
the first element in the last
row
and then
divided by the first element in the second row.
0
5
5
A
6
-10
0 -2.5
20
-3
b
0
0
1
Then
the second row is subtracted from the third
row, and the result is placed in the second row.
A
=
0
0
5
6
20
20
-10
-.5
b
-3
27
0
1
1
28
Now
the
same procedure is carried out on
the
first two rows,
using
the second column as the
pivot
column.
Partial
horizontal pivoting is
not
required
this
time
since
the
largest
magnitude element
in
the
remaining rows
is
already
in the pivot position.
After
reducing
the
rank
of the remaining rows by one
the
following results are obtained.
Again no scaling
is required.
0 32.8
20
-.5
20
-3
0
0
A
5
1
1
b
1
The
A matrix is now in the lower right
triangle
form, and back substitution can be used to obtain
solution.
0 x1
+
o x1
+
5 x1
+
0 x2 + 32.8 x3
20 x2 0.5 x3
20 x2 3.0 x3
1
1
1
so
so
so
X3
x2
X1
.030
.051
.015
9
•
Appendix .5:
Graphical Demonstration
~
Group Delay Eauation
Graphical
demonstration
of formula used to
derive
group
delay.
so as
to avoid the glitch that occurs as the phase
switches
around the -180 and +180 deg point.
H1
represents
the
magnitude and phase
of
the
pr·evious
point.
H2 represents the magnitude and phase of the present point.
Normally the group delay is defined as follows:
phase H2 -
phase H1
Group Delay
freq H1 The phase of H1
phase H2 -
=
freq H2
135 Deg
The phase of H2
phase H1 = -301 Deg
= -166 Deg
when i t should be 59 Deg.
Now let the group delay be defined as follows:
ATan2
( Im H2 H1
*
Re H2 H1
*
Group Delay
delta w
Multiplication
of
vectors.
just causes the phases
to
be added.
and taking the conjugate of a vector
causes
the
phase to
be
inverted.
Thus taking the phase of the
vector
that results when H2 is multiplied by the conjugate
of H1
yields the
phase
H2
minus the phase
of
H1. See
graphical representation below.
H2 Hl•
29
Appendix
Listing
~
Read.me
~
D
supplied
30
~
program
~
...._,.
____
._.,..
Digital Filter Plotting Program.
Version 3.02
Byr Don Brunnett.
Date: Sept. 9, 1985.
Date: Nov. 9, 1986.
The program is written in Turbo Pascal. In order to compile the program,
both Turbo Pascal and the Turbo Graphix Toolbox will be required.
Equipment required:
Computer: IBM PC, IBM PC-XT, IBM PC-AT, IBM PC-junior, or true compatables.
Memory: At least 256K.
Graphics adapter: IBM color graphics,
IBM enhanced color graphics (high resltion mode not used),
Hercules monochrome graphics,
(the IBM PC-junior has built in graphics ability).
Printer (optional): IBM, Epson, or IBM graphics compatable.
Co-processor (optional): 8037, or 80287 (will greatly reduce computational
time and increase numeric accuracy).
Fi !es on Disk:
AU TOE XEC. BAT
COMMAND.COM
DIGITAL.BAT
;Batch file used when computer is turned on
:Necessarr file for DOS to run
;Batch fi e for auto installation and execution
DIGIBM.COM
DIGHGC.COM
DIG37IBM.COM
DIG87HGC.COM
DIG.BAT
DIGSTALL.COM
;Digital program for IBM graphics
;Digital program for Hercules graphics
;Digital program for IBM graph1cs and co-processor
;Digital program for Hercules and co-processor
;Installed version of Digital
;Installation program.
4X6. FON
ERROR.MSG
GRAPHICS.COM
HARDCOPY.COM
PRINTER.DEF
HFIX.COM
;Font for graphics routines
;Error messages for graphics routines
;IBM graphics fast printing option
;Hercules graphics fast printing option
;Printer definition for HARDCOPY.COM
;Takes hercules card out of graphics mode
TEST .NET
TEST87. NET
;Sample network for use without co-processor
;Sample network for use with co-processor
Installation:
Installation is dane automatically each time DIGITAL.BAT is loaded (by
typing digital then CR) or by turning the computer on with the program
disk installed in drive a:. There are four versions of the program, one
of which will be automatically copied to DIG·BAT and then executed.
The four versions are as follows:
1)
2)
3)
4)
DJGIBM
DIGHGC
DIG87IBM
DIG87HGC
;IBM graphics, no co-processor
;Here graphics, no co-processor
;IBM graphics, with co-pr·ocessor
;Here graphics, with co-processor
If it is desired to bypass the auto load feature, just type the version
31
~-----·
of the program that is to be run instead of 'digital'. Once the
digital.bat program has been run, the file 'dig' will contain the
version that was last run and may be used for faster subsequent loadings.
Oper-ation:
The program disk is a system disk, and contains an autoexecution file.
Program operation is intitiated by typing 'digital' or by turning the
computer on with the program disk in drive a:. All necessary
instruction are included in the program. The program allows 400 branches
and 60 nodes. Two sample networks are include, test.net for none
co-processor versions, and test87.net for co-processor versions. The
program disk contains very little room for storage of additional
networks, a seperate data disk should be used.
Notes:
1)
For consistancy sake, it is a good idea to store schematics on disk with
the extension .net.
2) Since it may be possible (i.e· ask1ng for a pr1ntout when no pr1nter is
online) for the program to crash dur1ng plotting, 1t IS ad~1sable to save
your schematic before attempting to plot 1t.
3) If you get an error during plotting while using the Hercules 'f'raphics
card the computer will remain in the graphics mode and DOS w1 1 not be
visable. To exit the graphics mode just type 'hfix' and press Retrn.
4) The program has provisions for making a hard copy, but it is rather slow.
To get a faster printout use the standard graphics command for the
IBM color card and the hardcopy command for the Hercules graph1cs card.
Both are included on the program disk.
32
~----
---
Appendix .E
Listin~ ~
~
Program Source
~
The source disk supplied with the report contains
the necessary code to compile.
all
except for those procedures
copyrighted by Borland International.
Turbo Pascal and the
Turbo Graphix Toolbox are required if the source code is to
be modified and recompiled.
The main program is contained in the Digital.pas file.
The
CGauss.pas
elimination
file
procedure
contains
and
complex
the
i t ' s associated
Gaussian
complex
math
procedures (see Appendix F).
All
high level graphing routines are contained in the
ExtrGrph.pas file.
needed.
it
is
If any graph routine modifications
recommended
definitions
constant
in
that they be limited
the
DrawGrid
to
procedure
are
the
(see
Appendix G).
Schematic
procedures
inputs
are
storage
and retrieval is
in the File.pas file.
And finallY.
handled by the procedures
file.
33
handled
in
the
bY
the
user option
Option.pas
,
I
•·
program digital_tilter_plotter;
w
P
{program to plot digital filters from a schematic}
{programmed by: Don Brunnett}
{programmed on: June 26, 1985}
{version 3.02}
{$1
{$1
{$1
{$1
{$1
{$1
typedef.sys}
graphix.sys}
kernel.sys}
extrgrph.pas}
files.pas}
options}
{include tile routines}
{include command option routines}
{$1
cgauss.pas}
{include gaussian elimination routine}
{include all graphics packages}
const
max_num_branches = 400;
{defines the maximum number of branches allowed}
max num nodes = 60;
{defines the maximum number of nodes allowed}
nul r = fl;
freq max: real = 1·0; {cycles/sample}
{default values tor plot}
treq-min: real = o.o; {cycles/sample}
gain=max: real = 10;
{dB}
gain_min: real = -30; {dB}
phase_max: real = 2~0i {deg}
phase_m1n: real = -LOu; {deg}
delay max: real = 1;
{sec}
delay)in: r·eal = 0;
{sec}
num_po1nts_trans: real = -1;
output_node_plus: integer = 2;
output node m1nus: integer = 0;
input ~ode:-integer = 1;
second type: stnng(2] = 'm';
{m-mag, p-phase, g-delay, 111p-mag and phase, mg-mag and delay}
gr·aphJitle: string[40J = 'Dig1tal Filter-.';
step_min: r·eal = -0.5;
step max: real = 1.5;
impufse_min: real = -0.25:
impulse_max: real = 0.75;
num_points_time: integer = 20;
type
name = string[40];
AMatrix = array[l .. max_num_no<1es,1 .. ma>:_num_nodes,1 .. 2] of real;
Bt1atr·il: = ar·r·ay[1· .ma>:_ntJIT,_nodes, 1· .2} of real i
branch data = record
nfrom: ar·r·ay[l .• ma>:_nu«t_t<ranches} ot integer·;
nto: anity[l .. mai:_num_brarrc~tes} of integer;
nmdt: anay[l .. ma}:_num_r,rancttes] of r·eal;
end;
1
l
go toxy (15 1wherey); f r·om: =input _integer( 1 From node 1 1 01 max _num_node s, 0," , 0);
1f from( >o then
begin
nfrom[i) :=tr-om;
gotoxy(35,wherey-1); nto[i):=input_integer('To node',l,Max_num nodes,0 1 11 1 0);
gotoxy(55,wherey-1); nmult[i):=input_real('Multiplier 1 10,0 1 0,'T,o);
end·
until h=max_num_branches) or (from=O);
if (i<max_num_branches) and (i<>l) then nfrom[i):=O;
end;
end;
(...)
"'
procedure read_schematic;
{used to retrieve a shematic from disk}
var
circuit_name: name;
begin
clrscr·
circuii name:=null•
gotoxy(f,9); write!' (return for main menu)');
gotoxy(l,B); write('Include drive designation and paths if needed.');
gotoxy(1 17); write( 1 Input name of file to retrieve ? '); readln(circuit_name);
1f circu1t name<>null then
begin
if file_exist(circuit name) then
begin
gotoxy(30,20); write('Reading file from disk');
assign(branch file,circuit name);
reset(branch file);
read(branch lile,branch info);
close(br·anch_fi le);
end
else
begin
gotoxy(20,13); write('File does not exist 11 ' ) ;
gotoxy(20 1 14); write( 1 Press return for ma1n menu'); readln(circuit_name);
end;
end;
end;
procedure save_schematic;
var
circuit name: name;
Degin
clrscr;
circuit ~ame:=null;
gatoxy(f 1 9); write['
{used to save a schematic on disk}
(return for main menu)');
,'
Val'
cmd: integer;
branch info: branch data;
br·anch)ile: file of branch_data;
choices: choice_names;
graph_in: string[dO];
title: strin980;
version: str1nglO;
{*****************************************************************************}
{*** function definitions ****************************************************}
VJ
VI
function num_branches: integer;
{returns the number of branches}
var
i: integer;
begin
with branch info do
begin
i: =0;
repeat i:=!+l until (i=max_num b!'anches-1) or (nfrom[!+l]=O);
1f (!=max num branches-!) and Tnfrom[!+l]=O) then num branches:=max num branches
else numJr·anches:=i;
- end;
end;
{*****************************************************************************}
{*** procedure definitions ***************************************************}
procedure input_schematic;
{used to input a new schematic}
vat
i, from: integer;
begin
clrscr;
writeln('INPUT NEW SCHEMATIC');
writeln('To quite before erasing current schematic, enter a 0 for the first from node.');
writeln('When finished, enter a 0 for the from node.');
writeln( 1To get a delay branch, enter a 0 for the multiplier.');
write In;
i:=O;
with branch info do
begin
repeat
1: =i +1 i
write('ltem ',i);
,
gotoxy(1 18); write('Include drive designation and paths if needed.');
name of file to save schematic under·? '); readln(cinuit_name);
1f circu1t name\)null then
begin
qotoxy(30,20); writeln('Saving file to disk');
assi gn(br·and_fi 1e, ci r-cui t_name);
~otoxy(1 1 7); wr~te('Input
{$!-}
rewrite(br-anch file);
if IOResult=O fhen
begin
write(branch file,branch info)·
if IORESULT<)O then wr·ite('ERROR IN WRITING DATA TO DISK 1 ! 1 'l;
end
else write('ERROR IN WRITING DATA TO DISK ! ! 1 ' ) ;
close(branch file);
{$I+}
-
end;
end;
Ul
--J
procedure delete_schematic;
{used to delete a shematic from disk}
var
circuit_name: name;
begin
clrscr;
circuit name:=null·
qotoxy(f,9); write!• (return for main menu)');
gotoxy(! 18); write('Include drive designation and paths if needed.');
~otoxy(1 1 7); write('lnput name of file to delete? '); readln(circuit_name);
1f c1rcu1t namet>null then
begin
if tile exist(circuit name) then
begin gotoxy(30 120); write('Erasing file from disk');
assign(branch file,circuit name);
erase(branch_file);
close(branch_file);
end
else
begin
gotoxy(20,13l; write('File does not exist 11 ' ) ;
gotoxy(20,14); write('Press return for main menu'); readln(circuit_name);
end;
end;
end;
procedure list_schematic;
var
{used to list schematic on crt or pr1nter}
Ul
():l
i: integH'
answ, answl: char;
printer: text;
begin
clrscr·
answ:=l '·
gotoxy(1,1); write('
(Press return for ma1n menu)');
gotoxy(1,2); write('Do you w1sh a listing on the printer (P), or crt (C) ? '); readln(answ);
with branch info do
begin
if (upcase(answ) in ['P' 1 1 C1 ]) and (nfrom[l]OO) then
begin
if upcase(answ)= 1 P' then assign(printer,'lst:') else assign(printer,'con:');
reset(printn);
clrscr;
for i:=t to num branches do
begin
wr·ite(pr·inter,'ltem ' 1 i:3,'
From node 'tnfrom[i]:4 1 '
To node ',nto[i]:4);
if nmult[i]=O then wr1teln(printer,'
Mu tiplier t"-1')
else writeln(printert'
Multiplier ' 1nmult[i]:10);
if (upcase(answ)='C'J and (frac(i/22)=0) then
begin
writeln; write(' Press return for more listing'); readln(answl);
clrscr·;
end;
end;
if upcase(answ)='C' then
begin
writeln; write(' Press return tor main menu'); readln(answl);
end;
end;
end;
end;
procedure change_schematic;
{procedure used to change schamtic}
var
i, j: integer;
begin
with branch info do
begin
clrscr;
writeln('Change current schematic.');
writeln('Deleted items are not removed till exit of change routine.');
~riteln;
repeat
gotoxy(l,wherey+l); write('(O or return to e•it, -1 to add)' l;
gotoxy(l,wherey-1); i:=input_integer('ltem number you wish to change',-l,num_branches,O,'',O);
1
(..)
\Q
if iOO then
begin
if i=-1 then
begin
i:=num branches+!;
if iOiiiax_num_bl'anches then nfrom[i+l) :=0;
end;
gotoxy(l,wherey); write('
(0 to delete)
');
gotoxy(l,wherey-1);
write('
');
gotoxy(l wherey); write('ltem ' 1 i);
gotoxy(1~1 w~erey); nfrom[i):=input_integer('From node 1 1 01 max_num_nodes 1 0,'',0);
1f ntrom[l]\)0 then
begin
gotoxy(35,wherey-1); nto[i]:=input_integer('To node',l,max_num nodes,O,'',O);
gotoxy(55,wherey-1); nmult[i):=input_real('Multiplier•,o,o,o,•T,O);
end
else nfrom[i]:=-2;
end·
until l=o;
j :=0;
for i:=t to num branches do
begin
if ntrom[i)=-2 then j:=j+l;
it i+j(=max num branches then
begin
- nfrom[i):=ntrom[i+j]; nto[i]:=nto[i+Jl; nmult[i]:=nmult[i+j];
end
else nfrom[i] :=0;
end;
end;
end;
procedure input_trans_plot_spec;
{used to input or modidiy the transfer function plotting specifications}
var answ: name;
i: integer;
begin
repeat
clrscr;
for i:=-1 to 0 do
begin
gotoxy(1 1 1); writeln('Editting transfer function plot specifications.');
gotoxy(l,3);
freq_mln:=input_real('Frequency minimum
(cycles/sample) 1 1 0 10 1 fr·eq_min,lablr·(fr·eq_min,8,5), i);
freq_max:=input_real('Frequency maximum
(cycles/sample) ',O,O,freq_max,lablr(freq_max 1 815),i);
writeln;
gain_min:=input_real('Gain minimum
(dB)
',O,O,gain_mln,lablr(gain_min,B,l),i);
.j::-
0
1 0 0 gain_max,lablr(gain_max,8,1) i);
ga~n_max:=input_real('Gain maximum
(dB)
1 1 1
1
wnteln;
phase m1n:=input real('Phase minimum
(degrees)
',O,O,phase_min,lablr(phase_min,S,O),i);
phase-max:=input-real( 1 Phase maximum
(degrees)
',O,O,phase_max,lablr(phase_max,8 1 0) 1 i);
write rn j
delay_mlfl:=input_real('Group delay minimum (samples)
',O,O,delay min,lablr(delay_min,8,3),i);
delay max:=1nput real('Group delay max1mum (samples)
',O,O,delay~max 1 lablr(delay_max,8 1 3) 1 i);
writefn;
input node:=input_integer('lnput node
' 1 01 0 1 input _node ,1 ab 1i (input_node , 8) , i) ;
output node plus:=
1nput_infeger( 1 0utput Node +
',0,0, output_node_plus, labl i ( output_node_plus, 8), i);
output_node m1nus:=
input integer( 1 0utput Node - {0 to skip)
',0, 0, output_node_minus,labl i (output_node_minus ,8) 1 i);
num points trans:=
lnput_real('Numb points in plot (neg for· auto in dB) 1 1 01 01 num_points_trans,lablr(num_points_trans,7,2) 1 i);
write In·
? I) j
write( 1 Curve(s) type (m,p,g,mp,mg) ',second type, 1
if i=O then
begin
readln(graph in);
if (graph_in;'m') or (graph_in='p') or (graph_in='g') or (graph_in='mp') or (graph_in='mg') then
second_type:=graph_ln;
end else writeln·
write('Graph title (40 char max) ',graph_title,' ? ');
if i=O then
begin
readln(graph in);
if graph)n<)" then gr·aph_title:=graph_in;
end else wr1teln;
end;
gotoxy(1,25); write('(press enter for yes, n for noJ'l;
gotoxy(ll24); write('Are these changes correct ? '); readln(answ);
1f answ= ' then answ:='y';
until (upcase(answ)='Y');
end;
procedure plot_transfer_function;
var·
fr-eq 1 freq_w, freq delta, treq_test, freq_last, freq_w_last, mag, mag_last, mag_db, mag_dt_last: real;
temp mag, templ_pfiase: real;
phase~ phase w, phase_last, ~·hase_w_last, delay, delay_last, mag_mult, phase_mult, pi2: real;
i, j, w_count, node_ma>:, branch_ma>:: integer;
A: AMatrix;
B, X: BMatrix;
answ: char"
enor·: booleani
NumbPrint: strlng[3J;
+=
1-'
GTitle: string[30];
label err ret;
begin
clrscr;
writeln; writeln( 1 Plot transfer function, if no schematic present then only a grid will be shown.');
writeln; writeln('lf a singularity occurs then plotting will stop and two beeps will be heard.');
writeln; writeln('When plotting is finished, a single beep will be heard·');
writeln; writeln('The following keys can be used while in the graphics mode:');
writeln;
writeln( 1 any key - exit to main menu even if graph not complete.');
writeln('
P -printout a hard copy of the graph·');
gotoxy(1 1 wherey+2); writeln('
(y or n, defaults to no)');
gotoxy(1 1wherey-2); write( 1Would you like the numeric data printed out?'); readln(NumbPrint);
1f NumbPrint='y' then
begin
writeln(lst,1raph_title); writeln(lst);
Fr·equency
Magnitude
Phase
Gr·oup Dela(l;
writeln(lst,
writeln(lst,'(cycles/sample)
(d/B)
(degrees)
(samples) );
writeln(lst,'--------------------------------------------------------------------------- 1 );
end;
.
entergraph1c;
.
if second type[l]='m' then GTitle:='Gain (dB)' else GTitle:= 11 ;
if (seconii_type='p') or (second_type='mp 1 ) then
begin
setscale(freq min,tr·eq_max,'n',gain_min gain_ma>:, 'n' phase_min,phase_max 'n');
drawgr-id(0 1 01,.Frequency (cycles/sample) I 1 01 01 GTi tle,IPhase (deg)~ ,gr·aphJitle, 'd' );
end;
1f (second_type='g') or (second_type='mg') then
begin
setscale(freq min,treq_max,'n' ,gain_min gain_max 'n' delay_min,delay_max,'n');
drawgrid(O,O,,.Frequency (cycles/sample)l,o,O,GTille,IGroup Delay (samples)' ,graph_title,'ct');
end;
if second_type='m' then
begin
setsca!e(freq min,treq_max, 1 n1 1 gain_min gain_max 'n',O 0, 'o');
drawgrid(O,O,,.Frequency (cycles/sample)l,o,O,GTille,' I 1 graph_title 1 1 d'l;
end;
with branch info do
if nfromilJ<>O then
begin
node_max:=O; branch_max:=O;
while (nfrom[branch max+ll<>O) and (branch max<max num branches) do
tegin
- branch_max:=branch_max+t;
if nfrom[branch_max)>node_max then node_max:=nfrom[tranch max];
if nto[branch max))node max then node max:=nto[branch maxr;
end;
-
.j::'
N
tr-eq:=tr-eq_min•
if num_points hans>O then fr·eq_delta:=(freq_max-freq min)/num_points)r·ar!s
else fr·eq_delta:=(fr-eq max-freq_min)/200; fr·eq test:=Hreq_rnax-freq_mln)/:.:5;
mag_rnult:=20/ln(10); pnase_mult:=180/pi; pi2:=7fpi;
repeat
freq~w:=freqtpi2-pi;
{determin freq in rad/sec}
for 1:=1 to node max do
{zero A and B matricies}
begin
for j:=t to node max do begin A[i 1 j 1 1]:=0; A[i,j,2]:=0; end;
B[i 1 1] :=0; B[i ,2T:=O;
end;
for i:=t to node_max do A[i 1 i 1 1]:=1;
{create identity matrix in A}
for i:=t to branch max do
{load branches into A matrix}
if nmult[i]=O tlien
{if mult zero then branch is a delay branch}
CAdd(A[nto[i],nfrom[i],1],A[nto[i],nfrom[i],2],1,-freq_w 1A[nto[i],nfrom[i] 1 1],A[nto[i],nfrorn[i],2])
telse branch is a scaler branch}
else
CAdd(A[nto[i] ,nfrom[i] ,1] ,A[nto[i] ,ntr-om[i] ,2] ,nmult[i],-fi ,A[nto[i] ,nfr·om[i] 1 1] ,A[nto[i] ,nfrom[i] 12]);
B[input_node 1 1):=1;
{ oad B matrix with input node}
c gauss elim(A,B,X,node max,error);
{solve matrix solution for this freq}
if erroF then
{if error found then beep and abort rest of plot}
begin
sound(440); for j :=1 to 15000 do; nosound;
go to err _r·et;
end;
if output_node_minus=O then
{find output mag and phase, tor single ended output
beg1n
mag:=X[outeut node_plus,l]);
phase w:=X[oufput node plus,2];
end
else
{find output mag and phase for double ended output}
csub(X[output node_plus,l],X[output_node plus 1 2],X[output node_minus,1] 1 X[output_node_minus,2],mag 1phase_w);
if mag>l.Oe-3u tfien mag db:=ln(mag)fmag_mulf else mag_db:=-59"9.0; {calc ma~ in db and check for undertlow}
phase:=phase wtphase muTt;
{calc phase 1n deg}
wh!le phase>f8~,do pfiase:=phase-3~0t
{scale -1SO<=phase<=180}
wh1le phase(-ldU do phase:=phase+JbU;
if freq>freq min then
{calc delay in samples}
begin
cmult(mag 1 £ha~e.w,mag_last,:phase_w_last,templ_mag,templ_phase)·
. . . ..
.
delay:=ArclanL((templ_magtsln(templ_phaseJ),(temp!_magtcos(templ_phase))J/(freq_w_last-freq_wJ;
end·
if lreq<>treq min then
{if nut on first point then plot results}
begin
-
if second type[l]='m' then
sdrawlTne(freq_last,mag_db_last,freq,mag db);
if (second_type='p') or (second_tYi'e='mp 1 ) fhen
s2drawline(treq last,phase_last,freq 1 phase);
if (second_type='gTl or (second_type='mg') then
{plct mag in db if required}
{plot phase if req}
{plot delay in samples if required}
begin
if freq>treq_mi n+freq_de 1ta then s2dr·awl ine ( heq_las t, de lay _last, freq, de 1ay);
end;
end;
{print data to line printer if required}
if NumbPrint='y' then
begin
1
write(lst,freq:ts:tl,'
',mag db:15:9,'
');
1 phase:15:10 1 '
if freq>freq_min then writeln(lsf,delay:15:9) else writeln(lst);
end·
{det next freq inc if auto num samples selected}
if (num_points_trans<O) and (freqOfr·eq_min) then
be•Jin
if (mag_db<gain_min) or (mag_db>gain_ma};) then freq_delta:=treq_delta*1·5
else
if abs(mag db-mag db_last)<(-num_points_transf0.75) then freq delta:=treq_deltafl.25
e1se f reqJe 1ta: =r r·eq de 1tafabs (num_po i nts _trans/ (mag_db-magJb _last));
if freq_delta>freq_test fhen freq_delta:=freq_test;
end;
{save all parameters}
freq_last:=freq;
freq w_last:=freq_w;
mag_Iast:=mag;
mag_db_last:=mag_db;
phase _w_las t: =phase_w;
phase_last:=phase;
delay_last:=delay;
{calc new frequency}
.
freq:=freq+freq_delta;
{determine if plotting is done or cancelled}
ur1til (fr·eq_last>freq_max) or (keypressed=true);
end;
~
w
err _ret:
{proceede immediatly to here if an error occurrs}
if not keypressed then
begin
sound(1000); for j:=l to 7500 do; nosound;
end·
read(Kbd,answ);
if upcase(answ)='P' then hardcopy(false 1 6);
leavegraphic;
end;
procedure input_time_plot_spec;
var answ: name;
i: integer;
begin
Hpeat
clr·scr;
for i:=-1 to 0 do
heglfl
{used to input or modid1y the time domain plotting specifications}
~
~
gotoxy(l,l)j writeln('Editting time domain plot specifications.');
gotoxy(1,3);
1 0 0,step_min,lablr·(step_min,8,5),i);
step_min:=input_real( 1Step amplitude minimum
1 1
1
step_max:=input_real('Step amplitude maximum
1 0,0,step_max, lablr(step_ma):,8,5) 1 i);
writeln;
impulse_min:=input real('Impulse amplitude minimum ',O,O,impulse_min,lablr(impulse min,8,5) 1 i);
impulse_max:=input)eal( 1 lmpulse amplitude maximum 1 ,O,O,impulse_max,lablr(impulse)ax,B,S),i);
writeln;
input node:=input_integer-('lnput node
' 10,0 1 input_node,labli(input_node,B),i);
output_node plus:=
1nput_i nfeger( 'Output Node +
', 01 01 output_node _p 1us, labl i (output_node_pl us 1 8) 1 i);
output_node m1nus:=
input infeger( 1 0utput Node - (0 to skip) 1 101 01 output_node_minus 1 labli(output_node_minus,8),i);
num po1n£s t1me:=
input_integer( 1 Numb samples in plot
',O,O,num_points_time,labli(num_points_time,8) 1 i);
writeln·
write(•draph title (40 char max) ',graph_title,' ? ');
if i=O then
begin
readln(graph in);
if graph.)n<>"" then graph_title:=graph_in;
end else wr1teln;
end;
gotoxy(1,25); write('(press enter for yes, n for no)');
gotoxy(1 24); write('Are these changes cor·r·ect ~ '); r·eadln(answ);
1 then answ:='y';
1f answ='
until (upcase(answ)='Y 1 );
end;
procedure plot_time_domain;
var·
i, J, node_max, branch_max: integer;
A: AMatn x;
B, x: BMatrix;
sample: integer·;
step, step_last, imp: real;
answ: char·
err-oi': boolean;
NumbPrint: strlng[3];
scale: integeq
label er-r ret·
beq1r1
clrscr-;
- '
write!~; writeln('Plot time domain, if no schematic pr~sent then only a grid will be shown.');
writeln; writeln('If a singularity occurs then plotting will stop and two beeps will he heard.');
writeln; writeln('When plotting is fln1shed, a single beep will be hear-d.');
writeln; writeln('The following keys can be used while in the graphics mode:');
f
+=
writeln·
writelnl• any key- exit to main menu even if graph not complete.');
writeln('
P -printout a hard copy of the grarh·'l;
gotoxy(l,wherey+2); writeln('
(y or n, defau ts to no)');
9otoxy(1 1wherey-2); write('Would you like the numeric data printed out?'); readln(NumbPrint);
1f NumbPrint='y' then
begin
writeln(lst,,raph title); writeln(lst}l·
writeln(lst,
Sample
mpulse
Step 1 );
writeln(lst 1 '-------------------------------------------------------');
end·I
h.
entHgrap
1 c;
setscale(0 1 num points time 1 1 n1 1 step min step_max,'n' impulse min 1 impulse_max 1 1 n1 )·
drawqr·id(O,O~ •Sample fiumbH',OlO,'Step Resf•OTISe *'I 1 lmpulse ~esponse 0',gr·aph_title,'d 1 );
if YAct(O)=Y;:Act(O) then sdraw ine(0 1 01 num_points_time 1 0);
with branch info do
if ntrom!1l<>O then
t•egin
node_max:=O; branch_max:=O·
while (ntrom[branch max+1]~)0} and (branch max<max num branches} do
begin
- branch max:=branch max+1;
if nfr-om[br·anch_max]>node_max then node_max:=nfr·om[branch max];
if nto[branch_max])node_max then node_max:=nto[branch_maxT;
end;
\.11
sample:=O·
for i:=1 lo node_max do begin X[i 1 !]:=0; X[i 12]:=0; end;
1f num_polnts_tlme<50 then scale:=~ else scate:=1;
while (sample<=num points time) and (keypressed=false) do
begin
for i:=1 to node max do
begin
for· j:=1 to node max do begin A[i 1 j 1 l]:=O; A[i 1 i 1 2]:=0j end;
B[i,1]:=0; B[i,2J:=O;
end;
for i:=l to node max do A[i 1 i 1 1):=1;
B[input TiOde,1]:;:;1;
for i:=[ to branch max do
if nmult[i]=O tten
CAdd(B[nto[i] 1 1) 1 B[nto[i] 1 2] ,X[nfrom[i] 1 1] ,X[nfrom[i] ,2] ,B[r,to[i] ,1] ,B[nto[i] 1 2])
els~
CAdd(A[nto[i] ,ntrom[i], 1] ,A[nto[i] ,nfr·om[i] 1 2) 1 -nmul t[i],O,A[nto[lj ,nfrom[1] 1 1] 1 A[nto[i] ,nfrom[i] 1 2])j
c gauss_elim(A 181 X1 node_max 1 error);
if ~ rror then
beg1r1
sound(440); for j:=l to 15000 do; nosound;
go to err _ret;
end;
if output_node_minus=O then step:=X[output_node_plus 1]tcos(X[output_node_plus,2])
e1se 5t ep: =X [output _node _p 1us 1 1] *coS( X[output _node p\ u51 2] )-X [output _node_ min u51 1] • cos (X [out ~·u t _node _minus 1 2] ) ;
1f samp1e=O then imp:=step else imp:=step-step 1a5f;
sdrawline(sample 101 5amp1e 1 5tep)•
DrawTextSOrg(sample,step 1 scale 1 lt 1 18);
52drawline(sample 101 5ample 1 imp)•
DrawTextS20rg(sample 1 imp 1 5cale,l0',8);
step la5t:=step·
sampTe:=samp1e+!;
if NumbPrint= 1 y1 then
begin
1
1
1 imp:15:10);
writeln(lst,sample:B,'
1 step:t5:9,
1
end;
end;
endj
err_r·et:
P
~
{proceede imrnediatly to here if an error occurrs}
if not keypressed then
begin
sound(lOOO); for j:=l to 7500 do; nosound;
end•
read(Kbd,answ);
if upcase(answ)= 1 P1 then hardcopy(false 1 6);
1eavegraphi c;
end;
{*************•**************************************************************•}
{*** main program *******•**•*•****•**•***************************************}
begin
with branch_info do nfrom[l]:=O;
initgraphic;
{get graphics mode ready}
leavegraphic;
{put 1n text mode}
title:='Di~ital Filter Plotting Program.
By: Don Brunnett, Copyright: June 26 1 1985';
version:='0·02';
choices[l]:='Input new schematic.';
choices[2]:='Read old schematic from disk·'i
choices[3]:='Save new schematic to diSk·';
choices[4]:='Delete old schemat1c fro1 disk·';
choices[5]:='List cu~~ent schematic.';
choices[6]:='Change current sche~atic. ';
choices[7]:='Edit transfer function plotting specifications.';
chcJces[S]:='Plot transfer function of current schematic.';
choices[9]:='Edit time domain plotting specifications.•;
choices[10]:= 1 Plot impulse and step response of current schematic.';
choices[11]:='Exit program·';
repeat
cmd:=Enter option(title,version,choices 1 11);
case cmd or
1: input schematic;
2: read_schemat~c;
3: save schemat1c;
4: delete schemat1c;
5: list_schematiq
6: change schematlcj
7: input frans_plot_spec;
8: plot transfer function;
9: 1npuf time plot spec;
10: plot:time:domain;
end;
until cmd=11;
end.
+=="
~
Aopendix
Listing
~
z
Gaussian Elimination Procedure
48
{Complex Gaussian elimination procedure.
by: Don Brunnett,
Date: 8/12/85}
{All numbers are complex, stored as mag, and phase (in radians)}
{AX=B
Hatricies A, and B must be supplied. They will be destroyed.}
{Var types AHatrix 1 and BHatrix must be defined by the calling prograa.}
function Sgn(var x: real): integer;
begin
if x>O then Sgn:=!
else it x<O then Sgn:=-1
else Sgn:=O;
end;
function ArcTan2(y 1 x: real): real;
begin
if x>O then ArcTan2:=ArcTan(y/x)
else if x<O then
if y=O then ArcTan2:=-pi else ArcTan2:=ArcTan(y/x)+sgn(y)*pi
else ArcTan2:=sgn(y)*pi/2;
end;
CHult(mag1 1 phase!, •ag2 1 phase2: real; var mag3 1 phase3: real);
beg1n
mag3:=mag!fmag2;
phase3:=phasel+phase2;
end;
pro~edure
-~=="
""
CDiv(mag1 1 phase!, mag2 1 phase2: real; var mag3, phase3: real);
beg1n
mag3:=magl/mag2;
phase3:=phase1-phase2;
end;
pro~edure
procedure CAdd(mag1 1 phase!, mag2, phase2: real; var mag3, phase3: real);
vu
x3 1 y3: real;
begin
x3:=maglfcos(phasel)+mag2*cos(phase2);
y3:=maglfsin(phase1)+mag2fsin(phase2);
mag3:=sqrt(x3fx3+y3ty3);
phase3:=ArcTan2(y3 1 x3);
end;
procedure CSub{magl, phase!, mag2, phase2: real; var mag3 1 phase3: real);
var
x3 1 y3: real;
begin
x3:=mag1fcos(phase1)-mag2*cos(phase2);
y3:=mag1fsin(phase1)-mag2*sin(phase2);
mag3:=sqrt(x3fx3+y3*y3);
phase3:=ArcTan2(y3 1 x3);
end;
~
o
procedure C_Gauss_elim(var A: AHatrix; var B,
var
i 1 j 1 k1 ipivot, nm1, n11i 1 nmipt: integer;
pivot: real;
temp\ tempt: array[t •• 2] of real;
labe err ret;
begin
error:=false;
nmt:=N-1;
for i:=t to nm1 do
begin
nmipt:=N-i+1• nmi:=N-i•
ipivot:=nmipf; pivot:=A[ipivot 1 i 1 1];
for j:=t to nmi do
it A[j 1 i 1 1])pivot then
beg~n.
· t == A['·
IPlVO t l=Jj· plVO
J,l, 1] i
end;
if ipivot<>nmip1 then
begin
tor j:=i toN do
begi~mp[1]:=A[i~ivot,j 1 1];
x: BHatrix; N: integer; var error: boolean);
{set error indicator off}
{find pivot row}
{exchange pivot row if needed}
temp[2]:=A[ipivot j,2];
A[ipivot 1j 1 1]:=A[nmlp1 1 j 1 1l; A[ipivot,j,2~:=A[nmip1 1 j 1 2];
A[nmip1,J 1 l]:=temp[1]; Atnmlp1,j 1 2]:=temp[2];
end;
teap[1]:=B[ipivot 11]; temp[2]:=B[ipivot 2]j
B[ipivotlt):=B[nmlpl,t); B[ipivot 12):=Btnm!p1 1 2];
B[nmip1 1 ]:=temp[1]; B[nmip1 12):=temp[2J;
end·
it lA[nmip1,i,1))1.0e10) or (A[nmip1 1 i 1 1](1.0e-10) then
begin
{scale it multiplier to small or to big}
pivot:=B[nmip1 1];
tor j:=i toN do
{find largest mag in row, to use as scale factor}
if A[nmip1 1 j 1 1]>pivot then pivot:=A[nmipl,j 1 1l;
if ~ivot<>O then
{scale by pivot if pivot <>O}
begn
tor j:=i toN do A[nmip1 1 j 1 1]:=A[nmip1 1 j 1 1]/pivot;
B[nmip1 1 1]:=B[nmip1 1 1]/plvot;
end·
it Arnmip1 1 i 1 1]<1·0e-30 then
{indicate singularity if multiplier to small}
~
~
begin
error:=true;
goto err_ret;
end;
end;
for j:=t to n1i do
{reduce equations}
begin
if A[j 1 i 1 1l<>O then
begin
cdiv(A[nmip1 1 i 1 1] 1A[nmip1 1 i 12] 1A[j 1 i 1 1] 1A[j 1 i 12] 1 temp[1] 1 temp[2])j
for k:=i+1 to N do
begin
c•ult(A[j 1k 1],A[j k 1 2~ 1 temp[1] temp[2],temp1[~],te~p1[2])· .
csub(A[nmlpl,k,1],A[nmlp1 1k12],temp1[1] 1 temp1[,] 1A[J 1k1 1],A[J 1 k12])j
end·
cmult(B[j 1 1] 1 B[j 2],temp[1] temp[2] 1 temp1[1],temp1[2])j
csub(B[nmlp1 1 1] 1B[nmip1 12] 1 temp1[1],temp1[2] 1B[j 1 1] 1B[J 12]);
end;
end;
end;
cdiv(B[1 1 1] 1B[1 12] 1A[1 1N1 1] 1A[1 1N12] 1 X[N,1) 1X[N 12])j {back substitution}
for i:=2 to N do
begin
nmipt:=n-i+l•
X[nmip1,t):=~[i 1 1J; X[nmip1 12]:=B[i 12];
for j:=nmipl+l toN do
begin
cmult(A[i 1 j 1) A[i 1 j 12] 1 X[j 1] 1 X[j 2] 1temp1[1) temp1[2))•
csub(X[nmlpl,1~ 1 X[nmip1 1 2] 1 temp1[t},temp1[2] 1 Xlnmip1 1 1),X[nmip1 1 2])j
end;
cdiv(X[nmip1 1 1] 1 X[nmip1 1 2] 1 A[i,nmip1 1 1) 1A[i,nmip1 1 2] 1 X[nmip1 1 1] 1 X[nmip1,2])j
end•
err 'ret: {return if an error is detected}
end; -
Appendix .G
Listing
~
DrawGrid procedure
52
Procedure DrawGrid(Xlnter,XTic: real; Xlabel: StrBO;
Ylnter,YTic: real; Ylabel: Str80;
Y2Label: StrBO; Graphlabel: StrBO; GraphlineType: char);
canst
NumScale = 1;
{scale for all grid numbering}
LblScale = 2·
{scale for all grid labeling}
DateScale = l;
{scale for date label}
NumSigFig = 3;
{min num of sig figs for axis labeling}
{specifies the number of char to use when labeling an axis}
NumDig = 7;
{>=4+NumSigFig}
AutoTargTicX = 25; {target number of tics in linear auto tic mode, x axis}
AutoTargTicY = 15; {target number of tics in linear auto tic mode, y axis}
XAxisTiclngth = 6; {if tics used and not grid, then this determines tic size in pixils}
YAxisTicLngth = 9;
{GraphlineType parameter g - dashed lines heavy, d - dashed lines light, t - tics only, no lines}
V1
c...>
{Labels an axis, called by DrawGrid}
Procedure LabelGrid(Ualue: real; Axis: char);
var LogVal: r·eal; Lab!: str·BO; Dcm: integer;
begin
if Value=O then Labl:='O·O'
else
begin
LogVal:=ln(abs(Value))/ln(10);
if (LogVal(-(NumDig-NumSigfig)) or (LogVal>NumDig-1) then str(Value:NumDig,Labl)
else if LogVal>=NumSigFig then str(Value:numDig:O,Labl)
else
begin
it LogVal)=O then
begin
Ocm: =NumDi g-tr·unc (logVa l) -3;
str(Ualue:NumDig:Dcm,Labl);
end
else begin Dcm:=NumDig-2; str(Value:NumDig:Dcm,Labl); end;
while (Labl(length(Labl)]='O') and (Labl[length(Labl)-1J<>'·'l do delete(Labl,length(Labl),l);
end;
end;
while Labl[1)= 1 1 do delete(Labl,1 1 1);
it Ax~s='x~ then DrawTextSOrg(V~lu!JYMin,NumScaleJLabl,2)_ .
else 1f Ax1s= 1 y1 then DrawTextSUrglXMln,Value,Numticale,Labl,Ol
else if Axis='z' then DrawTextS2Drg(XMax,Value,NumScale,Labl,4)
end;
var
X, Y, Y2, Last, i: real;
month, day, year: integer;
month_label, day_label: string(2]; year_label: string(4];
begin
~t (XTic~O!
1f
if
if
if
if
tXT1c<OJ
(YTic=O)
(YTic<O)
(XTic=O)
(YTic=O)
and
and
and
and
and
and
(XType='n')
(XType='n')
(YType='n')
(YType='n')
(XType='g 1 )
(YType='g'}
then
then
then
then
then
then
XTir:=AutoT~c(XM~n,XMax,AutoTargTicX);
XTlc:=AutoTlc(XMln,XMa~,trunc(-XTlc))j
YTic:=AutoTic(YMin,YMax,AutoTargTicY);
YTic:=AutoTic(VHin,YMax,trunc(-YTic));
XTic:=Autolog(XMin,XMax,3·2,5·2,7.2};
YTic:=Autolog(YMin,YMax,2.2,4.2,6·2);
XGraphHin:=&•NumScale*(NumDig)•
XGraphMax:=XScreenMaxGlb-6•NumScale*(NumDig)-2*NumScal~;
YGraphMin:=14*LblScale;
YGraphHax:=YMaxGlb-7*LblScale-7*NumScale;
SetW1ndowModeOff;
SetlineStyle(O};
if MaxForeGround)=i4 then SetForegroundColor(14);
Drawline(XGraphMin,YGraphHin,XGraphMin,YGraphMax);
Drawline(XGraphMin,YGraphMax,XGraphMax,YGraphMax);
Drawline(XGraphMax,YGraphMax,XGraphHax,YGraphMin};
Drawline(XGraphHax,VGraphHin,XGraphHin,YGraphMin);
DrawText~rg(ro~nd(XScreenMaxGlb/2) 1 0 1 LblScale,Graphlabel 1 2);
IJJ
P"
DrawTexturqtO,YGrafhMin,lb!Scale,Ylanel,5J;
if upcase(92Type)(, 101 then DrawlextOrg(XScreenMaxGlb,YGraphMin,Lb!Scale,Y2Label,7);
DrawTextDrg(round(XScreenHaxGlb/2) 1 VMaxGlb,LblScale,Xlabel,6);
Date(month, day year)•
Str(montb:2,monlb_label);
Str(day:2,day_label)•
Str(year:4,year label)·
DrawTextOrg(l,Y~xGlb,dateScale 1 1 Date: 1 +month_label+'-'+day_label+'-'+year_label,5);
if GraphlineType='d' then SetLineStyle(51);
if GrapblineType='p' then SetlineStyle($33);
if XType='n' then
begin
X:=XInter-int((XInter-XMin}/ITic+l)*XTic;
Last:=32767;
while X<=XMax do
beqin
"it X>=XMin then
begin
if GraphlineType='t' then
begin
Drawline(IAct(X),YAct(YMin),XAct(I),YAct(YMin)-IAxisTiclngth)j
Drawline(IAct(I),YAct(YMax),IAct(X),YAct(YMax)+XAxisTiclngth);
{Draw Fr·ame}
{label Graph and Axises}
end
else SDrawline(X,YMax,X,YMin);
if abs(Last-XAct(x)))6f(NumDig+1)*NumScale then
begin
LabelGrid(X,'x'); Last:=XAct(X);
end;
end;
X:=X+XTic
end;
IJI
IJI
end
else
begin
x:=Pow10(trunc(LogXMin/ln(10)));
if XMin(l then X:=X/10;
Last:=32767·
while X/lO<XMax do
begin
if (X>=XMin) and (X<=XMax) then
begin
if GraphlineType='t' then
begin
Drawline(XAct(X),YAct(YMin),XAct(X),YAct(YMin)-XAxisTiclngth);
Drawline(XAct(X),YAct(YMaxl,XAct(X},YAct(YMax)+XAxisTiclngth);
end
~lse SDrawline(X 1 YM~x 1 X,YMin/; .
.
. .
.
.
1f abstlast-XAct\x)))b+(NumDlg+l)+NumScale then beglf, LabelGnd{X, 'x' >; Last:=XActlX); end;
end·
i:=hic;
while i<10 do
begin
if (lti)lmin) and (Xti<XMax) then SDrawline(X+i,YMax,X*i,YMin);
i:=i+Hiq
end;
x:=X+to;
end;
end;
if GraphlineType='d' then SetlineStyle(15l;
if GraphlineType='p' then SetlineStyle($10);
if VType='n' then
begin
Y:=Vlnter-trunc((Ylnter-YMin)/VTic}*YTic;
Last:=32767;
while Y<YMax do
beqin
-if Y>VMin then
begin
if GraphlineType='t' then
begin
Drawline(XAct(IMin),YAct(Y),XAct(lMin)+YAxisTitlnqth,YAct(Y));
Drawline(XAct(IMax),YAct(Y),XAct(XMax)-YAxisTiclngth,YAct(Y));
end
else SDrawline(IMin,Y XMax,Y);
if abs(last-YAct(Y))>S*NumScale then
begin
LabelGrid(Y,'y'};
if Y2Type='n' then LabelGrid(Y2Min+YPerci(Y2Max-Y2Hin), 1 z1 )
else if Y2Type='g' then LabelGrid(exp(logY2Min+YPerc*(LogY2Max-LogY2Min)),'z');
Last:=YAct(Y);
end;
end;
Y:=Y+YTic
end;
\}1
o-.
end
else
begin
Y:=Pow10(trunc(logYMin/ln(10)));
if YHin(l then Y:=Y/10;
last:=32767;
while Y/lO<YMax do
begin
if (Y>YMin) and (Y<YHax) then
begin
if GraphlineType='t' then
begin
Drawline(IAct(lMin),YAct(Y),XAct(XHin)+YAxisTiclngth,YAct(Y));
Drawline(XAct(XMax),YAct(Y),IAct(XHax)-YAxisTiclngth,YAct(Y));
end
else SDrawline(XMin,Y XMax Y)·
if abs(Last-YAct(Y))>S*Num~cale then
begin
LabelGrid(Y,'y');
if Y2Type='n' then labelGrid(Y2Min+YPerc*(Y2Hax-Y2Min), 1 z1 )
else it Y2Type= 1 g1 then LabelGrid(exp(logY2Hin+YPerct(logY2Max-LogY2Hin)) 1 'z');
Last:=YAct(Y);
end;
end;
i:=YTic;
while i<lO do
begin
if (Yii)Ymin) and (Y*i<YMax) then SDrawline(IMax,Y*i,IMin,Y*i);
i:=i+YTic;
end;
-.·-..
0
>II
>- ...,.
.... ...,.
=
·0::
""
57
© Copyright 2026 Paperzz