Analog Insydes

Analog Insydes,is a Mathematica toolbox for symbolic modeling, analysis and design of analog electronic circuits.With Analog Insydes and Mathematica you can model and analyze circuits, manipulate analysis results mathematically, produce graphical visualizations of circuit characteristics,and document your solutions all in one integrated environment.

A Very Short Introduction

What Is Spice?

SPICE stands for Simulation Program Integrated Circuits Especially! The program originates from the University of California, Berkeley. SPICE is used to provide a reasonably detailed analysis of circuits containing active components such as bipolar transistors, field effect transistors, diodes, and lumped components such as resistors, capacitors, and inductors. Note that SPICE is a circuit simulation program, not a logic simulation program. Thus SPICE considers the voltages and currents in a circuit to be continuous quantities, not quantized into high/low values. The original SPICE program has given rise to a variety of commercial implementations. Variations of Spice include PSPICE, HSPICE, etc.  

The one thing to keep in mind is that everybody uses SPICE.

Some Simple Demos

<< AnalogInsydes`

Getting more examples

Analysis of a voltage divider

A simple voltage divider

\(VoltageDivider = 
	
      Netlist[
		{V0, {1, 0}, 10}, 
		{R1, {1, 2}, 
          R1}, 
		{R2, {2, 0}, R2}
	]\)

vdeqs = CircuitEquations[VoltageDivider]

MatrixForm /@ %

SolveCircuitEquations[vdeqs] // TableForm

Smallsignal transistor model (hierarchical netlists)

To analyze the common-emitter transistor amplifier below, one has to find an appropriate analog model for the transistor Q1.

Let's take a look at two standard transistor models to replace the transistor by either one of the following two small-signal equivalent circuits.

In the following nestlist, you can see the referenceto the models in the top level and the two alternative formulations of the two transistor models.Not that the top level definition only includes the external connections. This is called a black box: the top level does not have know anything about the inner workings of the sub circuits, just where they connect to the top level.The Selector option lets the user easily switch between the two formulations.

CommonEmitterAmplifier=
	Circuit[
		Netlist[
			{V1, {1,  0},  inputVoltage},
			{VCC, {2,  0}, Type  ->  VoltageSource,  
                  Value  ->  supplyVoltage},
			{R1, {2,  1},  R1},
			{R2, {2,  0},  R2},
			{RC, {2,  3},  RC},
			{RE, {4,  0},  RE},
			{Q1,{1  ->  B,  3  ->  C,  
                        4  ->  E}, 
				Model  ->  NPNTransistor, Selector  ->  BJTModel}
		],
		
		Model[
			Name -> NPNTransistor,
			Selector -> ACsimple,
			Ports -> {B,  C,  E},
			\(Definition -> 
				Netlist[
					{RB, \ {X, \ E}, \ RB}, 
					{CC, \ {B, \ X, \ C, \ 
                          E}, β}
				]\)
		],
		
		Model[
			Name -> NPNTransistor,
			Selector -> ACdynamic,
			Ports -> {B,  C,  E},
			\(Definition -> 
				Netlist[
					{RB, \ {X, \ E}, \ RB}, 
					{CM, \ {B, \ C}, \ 
                        CM}, 
					{CC, \ {B, \ X, \ C, \ 
                          E}, \ β}, 
					{RO, \ {C, \ E}, \ 
                        RO}
				]\)
		]
	];

Now we can expand the sub-circuits:

flatAmpSimple = 
	ExpandSubcircuits[ CommonEmitterAmplifier /.{supplyVoltage  ->  0,inputVoltage  ->  1,BJTModel  ->  ACsimple}]

flatAmpDyn=
	ExpandSubcircuits[
		CommonEmitterAmplifier /.{supplyVoltage  ->  0, inputVoltage  ->  1,BJTModel  ->  ACdynamic}]

and analyze the resulting nestlists.

eqAmpSimple = CircuitEquations[flatAmpSimple];
MatrixForm  /@  eqAmpSimple

{(({{(1/R1), -(1/R1), 0, 0, 0, 1, 0, 1}, {-(1/R1), (1/R1) + (1/R2) + (1/RC), -(1/RC), 0, 0, 0, 1, 0}, {0, -(1/RC), (1/RC), 0, 0, 0, 0, β}, {0, 0, 0, (1/4) + (1/RE), -(1/RB), 0, 0, -β}, {0, 0, 0, -(1/RB), (1/RB), 0, 0, -1}, {1, 0, 0, 0, 0, 0, 0, 0}, {0, 1, 0, 0, 0, 0, 0, 0}, {1, 0, 0, 0, -1, 0, 0, 0}})),(({{V$1}, {V$2}, {V$3}, {V$4}, {V$X$Q1}, {I$V1}, {I$VCC}, {IC$CC$Q1}})),(({{0}, {0}, {0}, {0}, {0}, {1}, {0}, {0}}))}

eqAmpDyn = CircuitEquations[flatAmpDyn];
MatrixForm  /@  eqAmpDyn

We can now solve the circuit equations for the voltage gain at the collector [3], for example.

v3simple  =  
      V$3  /.  SolveCircuitEquations[eqAmpSimple,  
            V$3][[1]]

v3dyn  =  
      V$3  /.  SolveCircuitEquations[eqAmpDyn,  
            V$3] [[1]]

Now let's see what happens when we make the (usually realistic) assumption that the transistor current gain is very large;

Limit[vtfsimple,  β  ->  ∞]

Limit[vtfdyn,  β  ->  ∞]

This result actually agrees with the approximations found in the textbooks.

What Functionality Is Built In?

General functionality

Analog Insydes can set up and analyze analog circuits. It can also model elements like transistors, diodes and MOSFETs using standard models also used in SPICE and PSPICE symbolically and numerically. AI allows users to create hierarchical models using object-oriented definitions of circuits and sub-circuits. AI can automatically simplify and approximate complex models by discharging higher order terms and taking symbolic limits. AI can read ,interpret, and analyze SPICE and PSPICE models.

Basic circuit elements

TableForm[Partition[ElementTypes, 3]]

Model libraries

Also, Analog Insydes contains model libraries for

Diodes

BJTs

BJTs, or bipolar junction transistors, are your basic PNP and NPN transistors. Analog Insydes provides the following analysis models.

({{Nonlinear Analog Behavioral Model, Small - 
              Signal Model (PSpice,  Spice2),  }, {Simplified BJT Small - Signal Model, Nullor Model, Fixator}})

MOSFETs

MOSFETs are Metal-Oxide-Semiconductor Field-Effect-Transistors. For MOSFETs, Analog Insydes provides:

• piecewise and continous nonlinear analog behavioral model based on the SPICE1.
• MOS Small-Signal Model (SPICE2, PSpice)
• Small-Signal Model without ohmic resistances and gate bulk capacitance
• Small-Signal Model for Low Frequencies
• Small-Signal Model without ohmic resistances and bulk effects
•  Nullor Model
• Fixator Model

To show how “simple” these models are ,here is a MOSFET modeled with the Small-Signals Model.

Analysis functions

({{CircuitEquations, MatrixToEquations, SolveCircuitEquations}, {NDAESolveDC, NDAESolve,  }, {NyquistPlot, NicholPlot, RootLocusPlot}, {TransientPlot, BodePlot,  }})

Plotting

To show the plotting functions in Analog Insydes, let's define a transfer function. This describes what comes out of a circuit if you put ins

H1[s_] := 1000./(1. + 10.1*s + s^2)

Bode plot

The Bode plot is perhaps the most commonly used graphing scheme for visualizing frequency responses of linear analog systems. It consists of two separate charts which display magnitude and phase of a transfer function on a logarithmic and a linear scale vs. frequency, the latter being scaled logarithmically. The magnitude values are usually given in decibels (dB) and the phase values in degrees.

BodePlot[
        H1[I ω],  {ω,  0.001,  1000. }];

Nyquist plot

The Nyquist plot is a parametric plot of the real and imaginary part of a transfer function in the complex plane as the frequency parameter sweeps through a given interval. Nyquist plots are particularly useful for stability analysis in control system design because one can immediately check whether a negative feedback loop meets Nyquist's stability criterion: If the Nyquist curve of the open loop system wraps around the point-1 on the real axis,  then the corresponding closed-loop system is unstable.

\(NyquistPlot[\ 
      H1[I\ ω], \ {ω, \ 0.001, \ 
        1000. }, 
\ \ PlotStyle\  -> \ RGBColor[1, 0, 0], \ 
      PlotPoints\  -> \ 100]\)

We determine whether the corresponding closed-loop system is stable or unstable by taking a closer look at the region around the point (-1, 0) using the PlotRange option.

\(NyquistPlot[\ H1[I\ ω], \ {ω, \ 0.1, \ 1000. }, 
	
      PlotStyle\  -> \ RGBColor[1, 0, 0], \ PlotPoints\  -> \ 100, 
      PlotRange\  -> \ {{\(-3\), \ 1}, \ {\(-1\), \ 1}}\ ]\)

(-1,0) is left of the curve, so the system is stable.

Nichols plot

A Nichol plot is similar to a Nyquist plot, but it shows gain on a logarithmic scale (dB) vs. phase on a linear scale (degrees), with an axis origin at the point (0dB, -180°). The advantage of Nichol's chart is the ease by which gain and phase margins can be determined graphically. The gain margin is simply the negative value of the gain axis intersect. The phase margin is equal to the distance between the axis origin and the phase axis intersect.

H3[s_]  :=  
      20*(3  +  
              s) / (s * (5  +  s) * (20  +  5*s  +  
                  2*s^2))

\(NicholPlot[\ H3[I\ ω], {ω, \ 0.1, \ 5. }, 
	
      PlotStyle\  -> \ RGBColor[1, 0, 0], \ PlotPoints\  -> \ 100, 
      PlotRange\  -> \ {{\(-200\), \ \(-80\)}, \ {\(-15\), \ 
            2}}]\)

The gain margin is 12.5dB, and the phase margin is about 80 degrees.

The root locusplot

Root locus can be plotted for normal transfer functions.

RootLocusPlot[ H3[s] ]

But usually root locus plot shows the locus of the poles and zeros of H(s,k) in the complex plane as k varies within an interval {k\_0..k\_1}. By default, polesare red and zeros are green.

H4[s_, 
        a_] := (a + 2*s + s^2)/(10 + 3*a*s + 4*s^2 + s^3)

RootLocusPlot[H4[s,  a],  {a,  3,  5}]

Simplification functions

({{ApproximateMatrixEquation, ApproximateTransferFunction}})

Utilities

({{DXFGraphics, CSDFRead, CSDFInterpolatingFunctionList}, { , SpiceToAI,  }})

What Should I Say About Analog Insydes?

SPICE Compatibility

AI can read and interpret SPICE2G6 and PSPICEe netlists.

Exact Symbolic Calculation of Element and circuit behavior

ABMs

The short blurb

Mathematica and Analog Insydes can combine analog models and symbolic equations for the behavior of nonlinear devices.

The long blurb

Models which are based on sets of mathematical equations describing the behavior of a circuit element or an analog building block are frequently called (analog) behavioral models or ABMs. A behavioral model is similar to a sub-circuit object in that it constitutes a box which is connected to a circuit through electrical ports. As indicated above, the difference is that the interior of a behavioral model box is implemented in terms of symbolic equations rather than as a netlist. With Analog Insydes'  behavioral modeling capabilities you can model a large variety of nonlinear elements characteristics. You can then use the function Circuit Equations, with which you are already familiar; to set up symbolic systems of nonlinear modified nodal or sparse tableau equations.

So what does all that mean?

It  means that you can model nonlinear devices by simply putting in the equations for the behavior of the nonlinear device (like a transistor or a diode) instead of simulating it more or less accurately with linear devices.

Can you show me an example?

Sure, let's calculate the bias point of a transistor circuit.

In an earlier section, we had to model the transistor with a rather elaborate sub-circuit.

Using a simplified Ebers-Moll model, we can define the transistor by

({{(Subscript[I, C]) == (Subscript[I, S]) (e^((Subscript[V, BE])/(Subscript[V, t])))}, {(Subscript[I, E]) == -((Subscript[I, S])/(Subscript[α, f])) (e^((Subscript[V, BE])/(Subscript[V, t])))}})

Circuit[
	Model[
		Name  ->  NPNBJT, Selector  ->  EbersMoll, Scope  ->  Global,
		Ports  ->  {C,  B,  E},
		Parameters  ->  {βf,  βr,  Js,  
                  Area,  Temperature},
		\(Translation\  -> \ {αf\  -> \ βf/\((1 + βf)\), \ αr\  -> \ βr/\((1 + βr)\), Is\  -> \ Js*Area, 
\ \ \ \ \ \ Vt\  :> \ 
                    ThermalVoltage[Temperature]}\),
		Variables  ->  {Current[B,  C],  
                  Voltage[B,  C], Current[B,  E],  Voltage[B,  E]},
		Definition ->
			{Current[B,  C]==-Is*(Exp[Voltage[B, E]/Vt] - 1)+((Is ((E^(((Voltage(B, C))/Vt))) - 1))/α)r,
				Current[B,  E] == 
                      Is/αf*(Exp[Voltage[B,  E]/Vt]  -  1) - 
                        Is*(Exp[Voltage[B,  C]/Vt]  -  1)}
  ]
] // ExpandSubcircuits;

This leads to the following for the complete circuit:

\(\(BJTbias = 
	
        Circuit[
		Netlist[
			{VCC, \ {1, \ 0}, \ 
              Type\  -> \ VoltageSource, \ 
              Value\  -> \ VCC}, 
			{RB, \ {1, \ 2}, \ 
              Value\  -> \ RB, \ 
              Pattern\  -> \ Impedance}, 
			{RC, \ {1, \ 3}, \ 
              RC}, 
			{Q1, \ {3\  -> \ C, \ 2\  -> \ B, \ 
                0\  -> \ E}, Model\  -> \ NPNBJT, \ 
              Selector\  -> \ BJTModel, βf\  -> \ 
                100. , \ βr\  -> \  .2, \ 
              Js\  -> \ 6. *10^\(-16\), Area\  -> \ 4. , \ 
              Temperature\  -> \ 300. }
		]
	];\)\)

\(mnaeqssat = 
	
      CircuitEquations[BJTbias\  /. \ BJTModel\  -> \ EbersMoll, \ 
        MatrixEquation\  -> \ False]\)

Solving these enhanced equations will now deliver a proper result, provided we increase the maximum number of iterations a bit.

startvals  =  Map[{#,  0. } &,  Last[mnaeqsfa]]

\(FindRoot[
	
      Evaluate[First[mnaeqssat]\  /. \ {RC\  -> \ 4000. , \ 
            VCC\  -> \ 12. , \ 
            RB\  -> \ 100. *10^3}], \ 
\ \ Evaluate[
        Sequence\  @@ \ startvals], 
\ \ MaxIterations\  -> \ 
        20\ 
]\)

From the result we can immediately read off the operating-point. We have

VBE==V$2==0.713 V
VCE==V$3==2.970 V
IB==I$RB==22.6 μA
IC==-I$BC$Q1 == 2.26 mA

Calculating the bias point of a nonlinear circuit is something we could have done with virtually any elecrical circuit simulation program.  Withe Mathematica, however, we can go beyond the limits of circuit analysis and easily tackle circuit design problems as well. It does not make a difference to Mathematica whether we assign values to design parameters and then solve a system of circuit equations for the voltages and currents, of if we impose constraints on some voltages and currents and solve for design parameters instead.  To give you an idea how Mathematica can be applied to circuit sizing, we modify our initial analysis task: For the above circuit, determine the value of (Subscript[R, B]) such that calculations like the following are impossible in other tools, in which engineer would have to simulate the circuit with a number of test parameters.

We evaluate the equations with the constraint on V$3 and solve for (Subscript[R, B]) ,using approximate results of our previous DC analysis for  (Subscript[R, B]) = 500kΩ as initial guess.

\(\(\(\ \)\(FindRoot[
	
      Evaluate[First[mnaeqssat]\  /. {RC\  -> \ 4000. , \ 
            VCC\  -> \ 12. , \ V$3\  -> \ 1.0}], 
	{V$1, \ 
        12. }, \ {V$2, \ 0.71}, \ {I$VCC, \ \(-0.0023\)}, \ {I$RB, \ 
        0.000023}, \ 
\ \ {I$BC$Q1, \ \(-0.0023\)}, {I$BE$Q1, \ 
        0.0023}, \ {RB, \ 500. *10^3}, 
	
      MaxIterations\  -> \ 20
]\)\)\)

It follows from the output of FindRoot that we have to choose RB=410kΩ  for V$3=1.0V.

Complexity reduction for complex circuits

Analog Insydes can simplify circuit equations for small to midsize circuits. Symbolic circuit analysis is known to yield extremely large expressions even for small circuits. To cope with expression complexity Analog Insydes provides special functionality for calculating simplified symbolic formulas which are small and easy to understand. Approximated symbolic expressions are computed by dropping numerically insignificant terms from circuit equations or transfer functions. This leads to:

(make into bulleted list)
Faster numeric modelling.Exact understanding of the obmitted terms.
Easier qualitative understanding of new circuits.
Automatic building of simplified models.

What Can Analog Insydes Do That SPICE Can't?

Symbolic analysis, and direct modeling of transfer functions

Direct modeling of nonlinear components using their characteristic equations

Direct solutions of matching problems

Symbolic simplification of circuit equations

Accurate discharge of higher order terms

Can calculate arbitrary large gains (many products are limited to about 70dB)

Arbitrary precision means no loss of significant digits, even when computing numbers differing by several dB)

Who Is Analog Insydes For?

Engineers working on new analog circuits or circuit simulation tools

Engineers working on "unusual circuits" with high gains (over 100dB), strong non-linearities, or non-standard devices

Engineering educators (EE)

Anybody who wants to look beyond SPICE-like modelers