Monte Carlo is one of the best features in MicroCap. It provides a statistical summary of how a
circuit will perform with component parameter variation. There are times when you may wish to see
a circuit that failed a performance test and what component values were used to produce the failure.
In turns out that this is pretty easy to do but is somewhat obscure and easy to miss.
We're making it easier to do in future versions, but here is how it may be done in MC5 through MC11.
To illustrate, we'll use this sample circuit, rf_amplifier3.cir.
Run AC analysis and the program will do a 400 run Monte Carlo analysis and produce a display that
looks like the next figure.
On one side you have the Bode plots of gain or DB(V(A)) vs. F for the 400 runs. You can get a feel
for the statistical distribution of the Bode plot by just looking at the plot width.
For a more detailed statistical description the program produces a histogram of the distribution of
Y_Level(DB(V(A)),1,1,1e6), the value of DB(V(A)) at F=1E6. The histogram shows that all but
2.4% of the cases (.5+.8+.8+.3) were between 9 and 10 dB.
What controls all of this? The Monte Carlo Options dialog box accessed from the Monte Carlo
menu does. It looks like the next figure.
Notice the Report When field. It contains this boolean expression:
Y_Level(DB(V(A)),1,1,1e6)<9.0
The Monte Carlo histogram plots the frequency distribution of
Y_Level(DB(V(A)),1,1,1e6)
Y_Level(DB(V(A)),1,1,1e6)<9.0 causes a notation to be made in the numeric output file when the
expression is true, i.e. when DB(V(A)) measured at F = 1E6 is less than 9.0.
The list box on the right shows the value of Y_Level(DB(V(A)),1,1,1e6) for each Monte Carlo case.
Note that when the Report When expression is true it shows the case number in red font.
Before we illustrate viewing the circuit that causes one of these exceptions, let's look at what happens
when we use Cursor mode. Click the mouse in the AC plot window and press F8. Now click
the mouse in the list box of the Monte Carlo window. The display should look like this.
Notice that the selected case (in this case when the result was 9.516) is plotted in a contrasting color
amidst the other Bode plots. The original case 1 is plotted in red. Click the mouse in the Monte
Carlo list near the 9.516 case and then press the down arrow cursor key and the next case will be
selected and plotted. Continue pressing the key until you have selected the case printed in red. This
is the first case that triggered the boolean exception (8.981). You can't yet see the circuit, but you can
see the Bode plot it produced together with its value.
Using the Scope Cursor mode you can select and view the plots for any of the Monte Carlo cases,
including those that produced a true Report When expression.
Now press F3 to exit the AC analysis. This returns us to the schematic. From the File menu select
Load MC File. Browse to and open the file rf_amplifier.ano. The display should look like the figure
below.
The program loads the rf_amplifier's numeric output file (rf_amplifier.ano). This file contains the
tolerances used in the circuits that produced the cases for which the boolean exception was true. In
this case there were five exceptions out of 400 cases.
From this dialog you can load one or more of the circuits and see what set of tolerances produced
the exception. To illustrate, load the first circuit, Case 32. It looks like this:
This is a copy of the original circuit with the addition of the text:
Monte Carlo generated file Temperature=27 Case=32
Y_Level(DB(V(A)),1,1,1e6)<9.0 occurred for the following parameters:
.MODEL 2N5179_1 NPN (BF=292.268720930229 BR=1.176 CJC=1.036345736434p
+ CJE=1.55888372093p IKF=22.03m IS=.06928f ISE=.06928f ITF=270m MJC=246.8m
+ MJE=322.3m NE=1.177 RB=10 RC=3.978294573643 TF=130.028837209302p TR=1.588n
+ VAF=100 VTF=10 XTB=1.5 XTF=30)
.MODEL CAP1_1 CAP (C=1.015503875969)
.MODEL CAP1_2 CAP (C=1.027519379845)
.MODEL CAP1_3 CAP (C=978.294573643407m)
.MODEL CAP1_4 CAP (C=993.410852713174m)
.MODEL CAP1_5 CAP (C=1.007364341085)
.MODEL 2N3905_1 PNP (BF=131.195894186046 BR=3.11362 CJC=7.068564844961p
+ CJE=6.11856p IKF=44.9898m IKR=998.408 IS=9.99485f ISC=100p ISE=1.00334p
+ ITF=10m MJC=363.511m MJE=300m NE=1.742 NF=1.0259 RC=833.33175697674m
+ RE=686.684m TF=963.95348837209p TR=129.801432558139n VAF=3.35823 VJC=754.908m
+ VJE=700m VTF=10 XTF=500m)
V1=13.808
R8=3.812
R4=470.182
...
This is a list of the specific parameters toleranced to produce the case. If you run this circuit in
AC analysis, it will produce the same exception value of Y_Level(DB(V(A)),1,1,1e6) = 8.981. You
can see the same toleranced values by scanning the numeric output file. Use the search command
(CTRL+F) and search for the word "occurred". The first instance you'll see is:
Y_Level(DB(V(A)),1,1,1e6)<9.0 occurred for the following parameters:
model for:Q1
.MODEL 2N5179 NPN (BF=292.268720930229 BR=1.176 CJC=1.036345736434p
+ CJE=1.55888372093p IKF=22.03m IS=.06928f ISE=.06928f ITF=270m MJC=246.8m
+ MJE=322.3m NE=1.177 RB=10 RC=3.978294573643 TF=130.028837209302p TR=1.588n
+ VAF=100 VTF=10 XTB=1.5 XTF=30)
model for:C7
.MODEL CAP1 CAP (C=1.015503875969)
C7 Device Capacitance=477.287n
model for:C1
.MODEL CAP1 CAP (C=1.027519379845)
C1 Device Capacitance=1.028n
model for:C6
.MODEL CAP1 CAP (C=978.294573643407m)
C6 Device Capacitance=459.798n
model for:C3
.MODEL CAP1 CAP (C=993.410852713174m)
C3 Device Capacitance=504.002n
model for:C4
.MODEL CAP1 CAP (C=1.007364341085)
C4 Device Capacitance=20.147u
model for:Q2
.MODEL 2N3905 PNP (BF=131.195894186046 BR=3.11362 CJC=7.068564844961p
+ CJE=6.11856p IKF=44.9898m IKR=998.408 IS=9.99485f ISC=100p ISE=1.00334p
+ ITF=10m MJC=363.511m MJE=300m NE=1.742 NF=1.0259 RC=833.33175697674m
+ RE=686.684m TF=963.95348837209p TR=129.801432558139n VAF=3.35823 VJC=754.908m
+ VJE=700m VTF=10 XTF=500m)
Similar results are presented by the other four exception cases. You can view these by pressing F3 to
continue the search.
What if you wanted to see all of the 400 cases? Well there is a way: change the boolean expression
to 1. This always evaluates to true and generates an exception report for every case. This causes the
Load MC command to create a list of the circuits used for every case. You can load any one or all of
them. Be careful though, for the program creates a file for each circuit variant that you select to load.
In this case loading all 400 cases would create 400 circuit files on disk, probably more than you want.
Here is what the Load MC command looks like when the boolean expression is 1.
Notice that all the cases are printed in red. Here is the Load MC dialog for this case:
