Micro-Cap v7.1.6 / RM
.PDFVariables
In the variable definitions that follow, the symbols A and B represent node names. A node name is one of the following:
1.A node number assigned by MC7.
2.A text node name (a piece of grid text placed on the node).
Text node names consist of a number, letter, special character (+,-,*,/,$,%), or an underscore followed by at most 50 alphanumeric characters.
Node names may consist of numbers only, but this is not recommended due to the likely confusion between node numbers assigned by the program and integer node names assigned by the user. In case of conflict, MC7 gives priority to the node number. So if you place the text "1" on node number 2 and try to plot V(1) you'll get the voltage on node number 1, not the voltage on the node labeled "1".
Reserved variable names and some mathematical operator names may not be used. Spaces are not allowed in text node names. For example, T, S, F, TEMP, VT, GMIN, J, E, and PI are all invalid because they use reserved variable names. Function names that use parentheses such as SIN, COS, and TAN are legal, whereas function names that do not use parentheses such as MOD, DIV, and RND areillegal.
A1, Out, _721, +, -, and Reset are valid node names. B&&4 is invalid because it uses the non-alphanumeric character &. T1 is valid but T is not because T is a reserved variable name.
Global nodes are nodes whose names are globally available to all parts of the circuit, including the top level circuit and all macros and subckts used by it. Global nodes are always prefaced by $G_. For example if a circuit uses a subckt that has a node named $G_ABC, then you can plot its voltage with V($G_ABC). As another example, if a digital part that uses the $G_DPWR is present in the circuit, plotting V($G_DPWR) plots the default TTL power supply node voltage waveform (a flat line at 5.0 volts)
277
The general list of variables is as follows:
|
D(A) |
Digital state of node A |
|
|
|
||
|
V(A) |
Voltage at node A |
|
|
V(A,B) |
Voltage at node A minus voltage at node B |
|
|
V(D1) |
Voltage across the device D1 |
|
|
I(D1) |
Current through the device D1 |
|
|
I(A,B) |
Current through the device using nodes A and B |
|
|
IR(Q1) |
Current into the R lead of the device Q1 |
|
|
VRS(Q1) |
Voltage across the leads R and S of the device Q1 |
|
|
CRS(Q1) |
Capacitance between leads R and S of the device Q1 |
|
|
QRS(Q1) |
Capacitor charge between leads R and S of device Q1 |
|
|
R(R1) |
Resistance of the resistor R1 |
|
|
C(X1) |
Capacitance (in farads) of the capacitor or diode X1 |
|
|
Q(X1) |
Charge (in coulombs) stored in the capacitor or diode X1 |
|
|
L(L1) |
Inductance (in henrys) of the inductor L1 |
|
|
X(L1) |
Flux (in webers) in the inductor L1 |
|
|
B(L1) |
B field (in gauss) of the core material of inductor L1 |
|
|
H(L1) |
H field (in oersteds) of the core material of inductor L1 |
|
|
T |
Time |
|
|
F |
Frequency |
|
|
S |
Complex frequency = 2*π *F*j |
|
|
RND |
Random number generator (0 - rnd -1) |
|
|
ONOISE |
Noise voltage at the output node |
|
|
INOISE |
Noise voltage referred to the input = ONOISE / gain |
|
|
EG(V1) |
Energy generated by source V1 |
|
|
ES(Q1) |
Energy stored in device Q1 |
|
|
ED(D1) |
Energy dissipated in device D1 |
|
|
PG(V1) |
Power generated by source V1 |
|
|
PS(Q1) |
Power stored in device Q1 |
|
|
PD(D1) |
Power dissipated in device D1 |
|
|
|
|
|
|
|
|
|
D1 represents any two-terminal device or controlled source. Q1 represents all active devices and transmission lines. The lead name abbreviations, R and S, are chosen from the following table.
|
Device |
Abbreviations Lead name |
|
|
MOSFET |
D,G,S,B |
Drain, Gate, Source, Bulk |
|
JFET |
D,G,S |
Drain, Gate, Source |
|
GaAsFET |
D,G,S |
Drain, Gate, Source |
|
BJT |
B,E,C,S |
Base, Emitter, Collector, Substrate |
278 |
Chapter 19: Expressions |
|
|
Component variables
The variables available for each component are shown in the following tables.
Compo nent Variables
C om po nent |
Vol tage |
C urrent |
|
C apa cit anc e/ |
C harge / F lux |
P owe r/E nergy |
P owe r/E nergy |
P owe r/E nergy |
|
|
Induct anc e |
G enera te d |
S tored |
D issipated |
|||||
|
|
|
|
|
|||||
|
|
|
|
|
|
|
|
|
|
S ources |
V |
I |
|
N A |
N A |
P G / EG |
N A |
N A |
|
R esisto r |
V |
I |
|
N A |
N A |
N A |
N A |
P D / ED |
|
|
|
|
|
|
|
|
|
|
|
C apa citor |
V |
I |
|
C |
Q |
N A |
P S / ES |
N A |
|
|
|
|
|
|
|
|
|
|
|
Inductor |
V |
I |
|
L |
X |
N A |
P S / ES |
N A |
|
|
|
|
|
|
|
|
|
|
|
D iode |
V |
I |
|
C |
Q |
N A |
P S / ES |
P D / ED |
|
|
|
|
|
|
|
|
|
||
Transmission Line |
VA P, VAM , V B P |
IA P, IA M |
N A |
N A |
N A |
N A |
N A |
||
V B M |
IB P, IB M |
||||||||
|
|
|
|
|
|
||||
|
|
|
|
|
|
|
|
|
|
|
V B , VC , VE , |
|
|
|
|
|
|
|
|
B JT |
V B E, V B C , V EB |
IB , IE, IC |
C B E, C B C |
Q B E, Q B C |
N A |
P S / ES |
P D / ED |
||
|
V EC , V C B , V C E |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
V B , VC , VE , VS , |
|
|
|
|
|
|
|
|
|
V B E, V B C , V B S |
IB , IE, IC |
C B E, C B C |
Q B E, Q B C |
|
|
|
||
B JT4 |
V EB V EC , V ES |
N A |
P S / ES |
P D / ED |
|||||
IS |
|
C C S |
Q C S |
||||||
|
V C B , V C E, V C S |
|
|
|
|
||||
|
|
|
|
|
|
|
|
||
|
V SB , V S E, V S C |
|
|
|
|
|
|
|
|
|
V G, V S , V D, V B , |
|
|
|
|
|
|
|
|
|
V GS , V G D, V G B |
IG , IS, |
ID |
C G S, C GD |
Q GS , Q G D |
|
|
|
|
M OS F ET: L EV 1-3 |
V DS , V D G, V D B |
C G B , C B D |
Q GB , Q B D |
N A |
P S / ES |
P D / ED |
|||
IB |
|
||||||||
|
V SG , V S D, V S B |
|
C B S |
Q B S |
|
|
|
||
|
|
|
|
|
|
||||
|
V B G, V B D , V B S |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
V G, V S , V D, V B , |
|
|
|
|
|
|
|
|
|
V GS , V G D, V G B |
IG , IS, |
ID |
|
|
|
|
|
|
M OS F ET:L EV 4,5,8 |
V DS , V D G, V D B |
N A |
N A |
N A |
N A |
P D / ED |
|||
IB |
|
||||||||
|
V SG , V S D, V S B |
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
||
|
V B G, V B D , V B S |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
O PA M P |
V P, V M , VO U T, |
N A |
|
N A |
N A |
N A |
N A |
N A |
|
V PM , V C C , V EE |
|
||||||||
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
V G, V D , V S, |
|
|
|
|
|
|
|
|
JFE T |
V GS , V G D, V S G |
IG , ID, IS |
C G S, C GD |
Q GS , Q G D |
N A |
P S / ES |
P D / ED |
||
|
V SD , V D G, V D S |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
V G, V D , V S, |
|
|
|
|
|
|
|
|
G aA sF E T |
V GS , V G D, V S G |
IG , ID, IS |
C G S, C GD |
Q GS , Q G D |
N A |
P S / ES |
P D / ED |
||
|
V SD , V D G, V D S |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Va riables tha t are me re perm utations of the lea ds are not show n. F or exa mple C G S a nd C S G produc e th e same plot a s do QG S and Q S G.
Table 19-1 Syntax for common variables
Com po nent Variables
Com po nent |
Resistance |
Flu x |
Ind uctance |
B field |
H field |
|
|
|
|
|
|
Resisto r |
R |
NA |
NA |
NA |
NA |
|
|
|
|
|
|
Ind uctor |
NA |
X |
L |
B |
H |
|
|
|
|
|
|
The com plete variable nam e includes the appropriate dev ice nam e. For exam ple, th e B field of a device L1 is referenced as B(L1).
Table 19-2 Syntax for resistance, flux, inductance, and B / H field variables
279
Subcircuit and macro variables
To reference a node name or a part name of an object within a macro or subcircuit, use the following dot notation:
Subcircuit part name + "." + node name or part name
For example, to reference node 10 in subcircuit X41, use the expression:
X41.10
To reference the node voltage on that node you would use:
V(X41.10)
To reference the current in the diode DSTUB in subcircuit CHOPPER4, you would use the expression:
I(CHOPPER4.DSTUB)
To reference the charge in the base-emitter junction of an NPN N3 in subcircuit AMP1, you would use the expression:
QBE(AMP1.N3)
If the node or part is nested inside more than one macro or subcircuit, simply concatenate the macro or subcircuit names. For example:
V(X1.X2.X3.10)
This specifies the voltage on node 10 in macro X3, in macro X2, in macro X1.
To see more examples, load the circuit SUBCKT1, run transient analysis, and click the right mouse button in the Y Expression field. This pops up a variable menu which shows all of the circuit variables available in the entire circuit. It nicely demonstrates many examples of subcircuit variables.
280 Chapter 19: Expressions
Model parameter variables
You can print or plot a part's model parameter by using the following syntax:
PART_NAME.MODEL_PARAMETER_NAME
Here are some examples:
Q1.BF |
Forward beta of BJT Q1 |
M1.GAMMA |
GAMMA parameter of MOSFET M1 |
J1.VTO |
VTO of JFET J1 |
Since model parameters do not vary during an analysis, plots of these variables will produce straight lines. Why bother plotting them? If you are stepping a parameter, or running a Monte Carlo analysis, and you want to check the value of a parameter of a particular part for a particular run, plotting its model parameter value is a quick way to be sure it is being stepped through the values you want.
281
Sample variables
Here are some sample variables.
|
T |
Time in seconds. |
|
F |
Frequency in Hz. |
|
D(A) |
Digital state of node A. |
|
HEX(A1,A2,A3,A4) |
Hex value of the nodes A1, A2, A3, and A4. |
|
BIN(A1,A2,A3,A4) |
Binary value of the nodes A1, A2, A3, and A4. |
|
OCT(A1,A2,A3) |
Octal value of the nodes A1, A2, and A3. |
|
DEC(A1,A2,A3,A4) |
Decimal value of the nodes A1, A2, A3, and A4. |
|
V(16,4) |
Voltage at node 16 minus the voltage at node 4. |
|
V(A,B) |
Voltage at node A minus the voltage at node B. |
|
I(R1) |
Current flowing through the resistor R1. |
|
I(2,3) |
Current flowing through the resistor, capacitor, |
|
|
source, or inductor between nodes 2 and 3. |
|
B(L1) |
B field in the inductor L1. |
|
H(L1) |
H field in the inductor L1. |
|
X(L2) |
Flux in the inductor L2. |
|
IB(Q1) |
Base current into the device Q1. |
|
VBE(Q1) |
Base-emitter voltage for the device Q1. |
|
IG(M1) |
Gate current into the device M1. |
|
VGS(M1) |
Gate-source voltage for the device M1. |
|
QBE(Q1) |
Charge stored in Q1's base-emitter capacitance. |
|
VAP(T1) |
Voltage at the positive pin of the input port of |
|
|
transmission line T1. |
|
ID(J1) |
Drain current into the device J1. |
|
I(D1) |
Current into the diode D1. |
|
L(L1) |
Inductance of the inductor L1. |
|
C(C2) |
Capacitance of the capacitor C2. |
|
R(R7) |
Resistance of the resistor R7. |
|
I(R1) |
Current through the resistor R1. |
|
I(Lap1) |
Current through the Laplace source Lap1. |
|
I(V1) |
Current through the waveform source V1. |
|
V(F1) |
Voltage across the Function source F1. |
|
V(X1.MID) |
Voltage on node MID in subcircuit X1. |
|
IB(G3.Q1) |
Base current of Q1 NPN in macro circuit G3. |
|
V(G1.G2.N) |
Voltage on node N in macro G2, in macro G1. |
|
ES(C1) |
Power stored in capacitor C1 |
|
PS(D1) |
Power stored in diode D1 |
|
PG(V1) |
Power generated by source V1 |
|
PD(Q1) |
Power dissipated in transistor Q1 |
282 |
Chapter 19: Expressions |
|
Mathematical operators and functions
In the definitions, the following symbol conventions are used:
Symbol |
Represents |
|
n, m |
Integers |
|
dt |
The DSP timestep. |
|
x, y, u |
Real expression. For example 26.5, T in transient, V(10) in DC. |
|
z |
Complex quantity. z= x + i • y. For example, V(1) in AC. |
|
S |
Spectrum generated by one of the signal processing operators. |
|
D1, D2 |
Digital node states. For example D(1), D(QB). |
|
Arithmetic |
|
|
+ |
|
Addition |
- |
|
Subtraction |
* |
|
Multiplication |
/ |
|
Division |
MOD |
|
Modulus (remainder after integer division) |
DIV |
|
Integerdivision |
Transcendental (x and y are real, z is complex, z = x + i • y ) |
||
SIN(z) |
|
Sine function |
COS(z) |
|
Cosine function |
TAN(z) |
|
Tangent function |
COT(z) |
|
Cotangent function |
SEC(z) |
|
Secant function |
CSC(z) |
|
Cosecant function |
ASIN(z) |
|
Inverse sine function |
ACOS(z) |
|
Inverse cosine function |
ATAN(z) |
|
Inverse tangent function |
ATN(z) |
|
Inverse tangent function |
ARCTAN(z) |
Inverse tangent function |
|
ATAN2(y,x) |
Inverse tangent function = ATN(y/x) |
|
ACOT(z) |
|
Inverse cotangent function |
ASEC(z) |
|
Inverse secant function |
ACSC(z) |
|
Inverse cosecant function |
SINH(z) |
|
Hyperbolic sine |
COSH(z) |
|
Hyperbolic cosine |
TANH(z) |
|
Hyperbolic tangent |
283
COTH(z) |
Hyperboliccotangent |
|
|
SECH(z) |
Hyperbolic secant |
|
|
CSCH(z) |
Hyperboliccosecant |
|
|
ASINH(z) |
Inverse hyperbolic sine |
|
|
ACOSH(z) |
Inverse hyperbolic cosine |
|
|
ATANH(z) |
Inverse hyperbolic tangent |
|
|
ACOTH(z) |
Inverse hyperbolic cotangent |
|
|
ASECH(z) |
Inverse hyperbolic secant |
|
|
ACSCH(z) |
Inverse hyperbolic cosecant |
|
|
LN(z) |
Natural log: log (|x + i • y|) + i• tan-1(y / x) |
|
|
LOG(z) |
e |
10(|x + i • y|) + i• tan-1(y / x) / log e |
(10) |
Common log: log |
|||
LOG10(z) |
Common log: log |
10(|x + i • y|) + i• tan-1(y / x) / log e |
(10) |
EXP(z) |
Exponential: ex• (cos(y)+i• sin(y)) |
|
|
POW(z,x) |
Complex exponentiation function= zx = ex ln(z) |
|
|
|
For example, POW(-1+j,2) = -2j, POW(2,2) = 4 |
|
|
^, or ** |
Same as PWW(z,x). z^x = z**x = POW(z,x) |
|
|
|
For example, (-1+j,2)**2 = -2j, j^2 = -1 |
|
|
PWR(y,x) |
Real power function = yx. |
|
|
|
For example PWR(-2,3) = -8, PWR(-2,2) = 4 |
|
|
PWRS(y,x) |
Real signed power function: |
|
|
|
if y<0 PWRS(y,x) = -|y|x |
|
|
|
if y>0 PWRS(y,x) = |y|x |
|
|
|
For example PWRS(-2,2) = -4, PWRS(2,2) = 4 |
|
|
DB(z) |
20 * LOG(|z|) |
|
|
RE(z) |
Real part of z |
|
|
IM(z) |
Imaginary part of z. IMAG() and IMG() also work. |
|
|
MAG(z) |
Magnitude of z. M() also works. |
|
|
PH(z) |
Phase of z in degrees. PHASE() and P() also work. |
|
|
GD(z) |
Group delay=∂ (Phase(z in radians))/∂ (radian frequency) |
Digital
A is the MSB. D is the LSB. These operators are designed for use in plotting and printing logic expression waveforms.
|
D(A) |
Digital state on node A. |
|
HEX(A,B,C,D) |
Hex value of the digital states of nodes A, B, C, D. |
|
BIN(A,B,C,D) |
Binary value of the digital states of nodes A, B, C, D. |
284 |
Chapter 19: Expressions |
|
DEC(A,B,C,D) |
Decimal value of the digital states of nodes A, B, C, D. |
OCT(A,B,C,D) |
Octal value of the digital states of nodes A, B, C, D. |
+ |
Sum of two binary, octal, hex, decimal values. |
- |
Difference of two binary, octal, hex, decimal values. |
MOD |
Modulus operator (integer division remainder) of two |
|
binary, octal, hex, decimal values. |
DIV |
Integer division of two binary, octal, hex, decimal values. |
& |
Bitwise AND of two digital node states. |
| |
Bitwise OR of two digital node states. |
^ |
Bitwise XOR of two digital node states. |
~ |
Bitwise NOT of a digital node state. |
Analog Boolean and Relational |
|
AND |
And operator |
NAND |
Nand operator |
OR |
Or operator |
NOR |
Nor operator |
XOR |
Exclusive-Or operator |
NOT |
Negation operator |
< |
Less than operator |
> |
Greater than operator |
<= |
Less than or equal operator |
>= |
Greater than or equal operator |
!= |
Not equal to operator |
<> |
Not equal to operator |
== |
Equal to operator |
MIN(z1,z2) |
Minimum of real and imaginary parts of z1 and z2 |
MAX(z1,z2) |
Maximum of real and imaginary parts of z1 and z2 |
LIMIT(z,z1,z2) |
Returns z, with its real part limited to the range of RE(z1) |
|
to RE(z2) and the imaginary part limited to the range |
|
IM(z1) to IM(z2) |
IF(b,z1,z2) |
If b is true, the function returns z1, else it returns z2. |
Signal processing |
|
HARM(u) |
Harmonics of waveform u |
THD(S[,F]) |
Total harmonic distortion of spectrum S as a percent of |
|
the value at the reference frequency F. If F is missing, it |
|
is set to the first harmonic (1/tmax in transient analysis) |
285
IHD(S[,F]) |
Individual harmonic distortion of spectrum S as a percent |
|
of the value at F. Similar to THD but not cumulative. |
FFT(u) |
Forward Fourier transform of waveform u |
IFT(S) |
Inverse Fourier transform of spectrum S |
CONJ(S) |
Conjugate of spectrum S |
CS(u,v) |
Cross spectrum = CONJ(FFT(v))*FFT(u)*dt*dt |
AS(u) |
Auto spectrum of waveform u = CS(u,u) |
CC(u,v) |
Cross correlation of u and v = IFT(CS(u,v))/dt |
AC(u) |
Auto correlation of waveform u is = IFT(AS(u))/dt |
COH(u,v) |
Coherence of u and v =CC(u,v)/sqr(AC(u(0))*AC(v(0))) |
REAL(S) |
Real part of spectrum S produced by FFT |
IMAG(S) |
Imaginary part of spectrum S produced by FFT |
MAG(S) |
Magnitude of spectrum S produced by FFT |
PHASE(S) |
Phase of spectrum S produced by FFT |
Numeric integration and differentiation: These are for analysis plots only.
With respect to any variable
DER(u,x) |
Calculates the derivative of u W.R.T x. |
SUM(y,x[,start]) |
Running integral of y with respect to x, with optional start |
|
parameter. Integral begins at x=start. Start defaults to |
|
the analysis variable minimum (tmin, fmin, or dcmin), |
|
or 0, depending upon the integration variable, x. |
With respect to the analysis variable (T, F, or DCINPUT1)
SD(y[,start]) Running integral of y with respect to T in transient, F in AC, or DCINPUT1 in DC, with an optional start parameter. Integral begins at start. Start defaults to tmin, fmin, dcmin, according to the analysis type
|
DD(y) |
Numerical derivative of y with respect to T in transient, F |
|
|
in AC, or DCINPUT1 in DC |
|
RMS(y[,start]) |
Running root-mean-square of y with respect to F in AC, |
|
|
T in transient, or DCINPUT1 in DC, with an optional |
|
|
start parameter. The integral begins at start. Start defaults |
|
|
to tmin, fmin, or dcmin, according to the analysis type. |
|
AVG(y[,start]) |
Running average of y with respect to T in transient, F in |
|
|
AC, or DCINPUT1 in DC. The optional start parameter |
|
|
defaults to tmin, fmin, dcmin. |
286 |
Chapter 19: Expressions |
|