Symbolic Simulator for Teaching of Electronic Circuits

advertisement
Symbolic Simulator for Teaching of Electronic Circuits
Zdenek Kolka, Vaclav Pospisil*
Abstract − The paper deals with a symbolic simulator
we have developed. It has been used as a supporting
tool for teaching for several years. The simulator can
perform both classical and approximate analyses. All
device models are stored in a text library which can be
easily extended. Device parameters can be defined as
simple symbols or as formulae in netlist. This allows
simulation of both electronic circuits and block
diagrams.
1
INTRODUCTION
The aim of symbolic analysis is to express the
behavior of a system by means of a symbolic
expression. Nowadays, it is used particularly for
linear circuits in the frequency domain. Symbolic
expressions are considered to provide a better insight
into the circuit behavior than numerical analyses. On
the other hand, the expression size grows
exponentially with the number of nodes and
branches. That is why simplification methods have
been studied since the late 80s. Symbolic expressions
are always simplified at the cost of loss of some
information [3].
Symbolic analysis has found applications in
teaching as a supporting tool for discovering
phenomena in electronic circuits or as a complement
to numerical simulators. There are few tools
available for approximate symbolic analysis. The
only commercial program – Analog Insides – is
rather complicated to be used in undergraduate
courses.
The program presented performs symbolic and
semisymbolic analyses of linearized circuits in the
frequency domain with simplification. It runs under
MS Windows. The program was named SNAP
(Symbolic Network Analysis Program) and its
development started eight years ago. At that time the
authors did not know there had been another
program of the same name of Lin and Alderson [4].
Both programs are totally unrelated.
2
SYMBOLIC SIMULATOR
Because SNAP is primarily used as an educational
tool it has been integrated with the schematic editor
supplied with the PSpiceTM simulator. Figure 1
shows two possible analysis flows. In the first case
the schematic editor library contains lineraized
circuit parts and devices. The user has to supply all
small-signal parameters if desired.
Schematics
linearized
devices
netlist
Schematics
standard
devices
PSpice
operating
point
SNAP
symbolic
analysis
Figure 1: Two possible configurations.
The second mode of operation is based on
utilization of standard devices (including nonlinear
ones) from the (P)Spice library. Small signal
parameters are automatically extracted from the
output of Spice operating-point (.OP) analysis.
Figure 2: Integration with PSpice Schematics
(I1/V1 and I2/V2 denote input and output ports).
2.1 Schematic entry
The symbolic simulator reads netlist as its input. It
can be used with any schematic editor that can
generate appropriate netlist format, Fig. 1.
*
2.2 Simulator
The SNAP netlist is similar to Spice netlist but it
offers more ways of device parameter specification.
Brno University of Technology, Brno (Czech Republic), Department of Radio Electronics, Purkynova 118, 61200 Brno,
Czech Republic. E-mail: kolka@feec.vutbr.cz
1
2
3
4
5
syntax
<symbol>
<symbolic expression>
<numerical value>
<numerical expression>
<symbol> = <value>
example
R1
R1+s*L1
10k
{R1/2+1k}
R2=10k
R2={R1/2+1k}
Table 1: Device parameter specification in netlist.
Symbolic expressions are constrained to rational
functions. The symbolic analysis can always be
performed. Moreover, if all parameters are assigned
a numerical value or expression then it is possible to
run all numeric-based analyses. The combined
parameter definition (case 5) allows using the
symbol for symbolic processing and the numerical
value for numerical processing. It is always used in
the of case automatic small-signal parameter
extraction.
Figure 2 shows an example of circuit diagram
drawn using linearized devices. The circuit is always
considered as a two-port. Input and output ports are
defined by means of special symbols. The actual type
of network function for analysis is chosen in SNAP.
Figure 3 shows the analysis flowchart of SNAP. Its
graphical user interface is shown in Fig. 7.
netlist
equation
simplification
symbolic
analysis
matrix-based
numerical analysis
formula
simplification
further processing. Currently, export to Matlab and
Maple is available.
3
ALGORITHMS
3.1 Matrix-based symbolic analysis
Circuit equations are formulated by means of the
modified nodal method [1] as
Hx = 0 ,
(1)
where x is a vector of nodal voltages and additional
currents for elements without the admittance
description. Each network function can be expressed
by means of the Cramer’s rule as a ratio of two
algebraic cofactors of the hybrid matrix H. Thus, no
explicit sources are necessary.
Parameters of each network element appear in
some positions in the hybrid matrix. They are usually
represented as a pattern called stamp. The
exceptional feature of SNAP is that stamps of all
elements are stored in its library. The user can easily
edit the library to add models of new devices. Figure
4 shows the library entry for one-pole voltage
amplifier.
0⎤
⎡
⎢
0 ⎥⎥
⎢
⎢
1⎥
⎢
⎥
−
1⎥
⎢
⎢⎣ A( s ) − A( s ) − 1 1 0 ⎥⎦
[Ef1]
nodes
params
names
add
=
=
=
=
4
;number of nodes
2
;number of parameters
A0, f1;parameter names
1
;number of additional
variables
mat1= -1 1 0 2 : A0/(1+s/(2*pi*f1))
mat2= -1 3 0 4 :-1
mat3= 3 -1 4 0 : 1
Figure 4: One-pole amplifier model in SNAP library.
polynomial-based
numerical analysis
graphical presentation, export
Figure 3: Analysis flowchart.
If numerical values of all device parameters are
available then it is possible to display frequency
characteristics and to perform pole/zero and
symbolic approximation analyses. In addition to
graphical presentation the results can be exported for
The stamp element mati= a b c d : x appears with
the positive sign in positions (a,b) and (c,d), and
with the negative sign in (a,d) and (c,b). The
coordinates are numbered according to local
numbers of the device nodes. The first additional
row and column is denoted as “-1” and “0” means
“no entry” to the matrix.
The symbolic solution of (1) requires symbolic
calculation of determinants by means of the Laplace
expansion. This form of symbolic analysis is
practically constrained to very small idealized
circuits.
3.2 Symbolic simplification
Symbolic analysis can be performed also for larger
circuits but at the expense of approximation. The
expression generated loses its universality [2].
Simplification Before Generation (SBG) and
Simplification After Generation (SAG) [3] are
implemented in Snap.
Each network function can be expressed as a ratio
of two algebraic cofactors
F = (−1)α
det(H1 )
.
det(H 2 )
(2)
Matrices H1 and H2 are derived from H by means of
adding and deleting some rows and columns. Details
can be found in textbooks of circuit theory. Each
determinant can be expanded by any element hij of
matrix H as
det(H k ) = Δ '+ hij Δ i ': j ' ,
(3)
where Δ ' is the determinant without hij, and Δ i ': j ' is
a cofactor of Hk , k = 1, 2 (hij has different
coordinates in H1 and H2). The network parameters
are considered different for the simplification
process despite the fact that they can be marked with
the same symbol. Then any network function can be
written as
F=
aij hij + bij
cij hij + d ij
.
(4)
It is easy to determine how F is changed if hij is
removed by hij → 0 or hij → ∞ using cofactors of
H1 and H2.
An effective method for algebraic cofactor
computation is based on a single matrix inversion in
the form
H kΔ = det(H k )
( )
T
H −k 1
,
FA (q, f )
,
FN (q, f )
e(q, f ) =
20 log E (q, f )
ΔM ( f )
+
(6)
arg( E (q, f ))
ΔP ( f )
,
(7)
where ΔM ( f ) and ΔP ( f ) are frequency-dependent
weights. It gives e = 0 for FA = FN . For sampled
frequency interval of interest the maximum value is
used
emax = max(e(q, f i )) .
(8)
i =1..n
After the matrix simplification the symbolic
solution of (1) is generated, Fig. 3. The expression
can be further simplified by means of SAG
algorithms. A sensitivity based method is
implemented in Snap [3].
Figure 7 shows graphical interface of the
approximate analysis module. The user can see the
original and the approximated functions. Each
reference frequency can be graphically defined with
different maximum magnitude and phase error.
4
SYMBOLIC ANALYSIS IN TEACHING
The exact symbolic analysis is suitable for small
idealized circuits in order to provide interpretable
results. It includes basic RLC circuits, simple filters
and transistor circuits taught in the “Circuit theory”
courses. Students use symbolic simulator for
exploring circuit properties and for checking hand
calculations.
+
Rc1
15
Rc2
RF
out
-
Q2
(5)
where H kΔ is the matrix of algebraic cofactors of
Hk . Its computation requires approximately
(n − 1) 3 / 3 long operations in case of dense matrices.
The matrix is recomputed after each structural
change. The successive use of Shermann-Morrison
formula [2] for avoiding matrix inversion showed to
be numerically unstable.
The error control algorithm finds a parameter hij
whose removal causes the lowest error. This is
repeated until the user-specified maximum error is
reached [3].
The error criterion is defined as
E (q, f ) =
where FN is the reference value, FA the approximated
one, and network parameters are grouped in a vector
q. The weighted sum of magnitude and phase errors
is
BCW 60B
in
Q1
BCW 60B
Re2
Rb
Re1
Re3
Ce
Figure 5: Two-transistor amplifier example.
The approximate symbolic analysis is taught in the
“CAD in electronics” course. It requires very careful
approach. The approximate analysis is in no way a
“push-a-button” process. Students should fully
understand circuit being designed. Figure 5 shows an
example circuit. First, students compile analytical
design model as MathCAD worksheet using the
exact analysis, hand calculations and textbook
formulae, Fig. 6. In this example, the worksheet is
used to obtain network parameters in order to meet
DC and LF specifications. The second task is to
figure out which phenomenon determines the
amplifier dominant pole by means of the
approximate symbolic analysis.
The approximate analysis starts with drawing the
amplifier in PSpice using standard library devices.
Then DC operating point is computed and the
translation module extracts all small-signal
parameters provided by PSpice.
and discovering phenomena in electronic circuits,
and as a useful tool for designers. It has been used
for several years in various courses at the Faculty of
Electrical Engineering and Communications, Brno
University of Technology.
Known parameters
Ic1 := 0.26⋅ m
Ic2 := 1.28⋅ m
Ucc := 15
Ube := 0.65
Re1 := 100
Re2 := 0
Azv := 100
Ue2 := 2
Kg := 35
fDe := 2
beta := 250
***************** Small-signal parameters ****************
Ib1 :=
Ib2 :=
Ic1
beta
Ic2
beta
gm1 := Kg⋅ Ic1
rpi1 :=
gm2 := Kg⋅ Ic2
rpi2 :=
beta
gm1
beta
gm2
*************** 1st stage ***************
Urc1 := Ucc − ( Ube + Ue2)
Rc1 :=
Urc1 = 12.35
Urc1
Ic1 + Ib2
Rc1 = 46.583k
************** feedback ***************
A ( Rf) :=
gm1⋅ Rc1
rpi2⋅ ( 1 + gm2⋅ Re2)
gm2⋅ Rc2( Rf)
Rf
⋅
⋅
⋅
1 + gm1⋅ Re1 Rc1 + rpi2⋅ ( 1 + gm2⋅ Re2) 1 + gm2⋅ Re2 Rc2( Rf) + Rf
Figure 7: Graphical user interface of Snap – module
for approximate symbolic analysis.
Acknowledgments
This research has been supported by the Grant
Agency of the Czech Republic under contracts No.
102/05/0771 and No. 102/05/0277 and by the
Ministry of Education under contract No.
MSM0021630513.
feedback transfer function
B( Rf) :=
−Re1
Rf + Re1
Figure 6: Fragment of MathCAD worksheet.
The full symbolic expression for voltage transfer
function represents approximately 10 pages. Using
two reference frequencies f1 = 1kHz and f2 = 2MHz
with the maximum allowed error of ΔM = 1dB and
ΔP = 5° a simplified expression shown in Fig. 7 was
obtained. The first-order function shows clearly the
dominant pole is determined by the Cμ capacitance
(multiplied by the Miller effect) of Q2.
5
CONCLUSIONS
The program presented serves as a supporting tool of
teaching electrical engineering and electronics, as a
student’s tool for supporting their individual work
References
[1] J. Vlach, K. Singhal, “Computer Methods for
Circuit Analysis and Design”, New York: Van
Nostrad Reinhold, 1994.
[2] R. Sommer et al., “Equation-Based Symbolic
Approximation by Matrix Reduction with
Qualitative Error Prediction”, Alta-Frequenza
Rivista di Elettronica, Vol.5, No.6, 1993, pp.2937.
[3] W. Daems, P. Wambacq, G. Gielen, W. Sansen,
“Evaluation of Error-Control Stategies for the
Linear Symbolic Analysis of Analog Integrated
Circuits”, IEEE Trans. on Circ. and Syst.-I, vol.
46, no. 5, 1999, pp. 594-606.
[4] P. M. Lin, G. E. Alderson, “SNAP: Symbolicnetwork-analysis Program,” Proc. IEE, vol. 119,
no.2, 1972, pp. 160-163.
Download