Monte Carlo Simulation using LTspice with Step by Step Tutorials

LTspice is a very good circuit simulation tool for electronic circuits. Thanks for Linear Technology for sharing such a nice tool. In this article I will teach Monte Carlo Simulation using LTspice with Step by Step Tutorials. Monte carlo is an analysis method used by design engineer to increase the robustness and reliability of their products. It is all about tolerances.

 

 

 

 

 

Our circuit model in this monte carlo simulation  is a comparator as shown in Figure 1 below. Let all resistor tolerances equal to 3%. We will use 5% as the tolerance of V4.

 

Monte Carlo Simulation using LTspice

 Figure 1

Defining the Circuit Operation

 

The circuit is a comparator. The output will be zero if the value of Vref is higher than Vin+. The output is high or equal Vcc otherwise. In this tutorial we will find out what is the voltage range of Vin wherein the output changes state from low to high. I mentioned voltage range because we are dealing here with tolerances. Initially the output is low because Vcc is already stable before the level of Vin starts to rise. We can simulate this using DC sweep command. We are going to sweep the level of Vin from 0V to 20V and observe the voltage range when the output changes state.

 

Monte Carlo Simulation using LTspice Step by Step Tutorials

 

Step 1. Open LTspice Software

We will start the Monte Carlo Simulation using LTspice by of course opening your LTspice software. If you don’t have one yet, click here to download . Once the program is running, start or open a new schematic.

 

Step 2. Start Placing Components

If you are a 100% naive on LTspice, consider reading this post.

Get the supplies V3 and V4 from

 

Monte Carlo Simulation using LTspice
Figure 2

 

Monte Carlo Simulation using LTspice
Figure 3

 

Another way to display above window is by clicking “F2” in your keyboard.

Get the resistors here

 

LTspice software
Figure 4

 

Or by simply typing letter “R” from your keyboard.

Get the opamp here

 

LTspice software
Figure 5

 

Monte Carlo Method
Figure 6

 

Double click opamps to select specific device.

To put a net name such as Vcc, Vin and Vout, click icon below and type the name.

 

Monte Carlo method
Figure 7

 

Another approach to put a net name is by pressing “F4” in your keyboard.

 

Step 3. Arrange and Wire the Circuit

Click this to draw a wire and start connecting components.

 

Monte Carlo Simulation

Figure 8

 

Another method is to press “F3”. To put a ground, click the symbol on the right of the wire symbol above.

Step 4. Changing Component Label

You can change component label if you want to by right clicking on the default component name and then encode a new name then OK. Do not include space.

 

Step 5. Setting the Component Values

For V4 the value is 5V with 5% tolerance. To put this on the circuit right click on the V4 value which is “V” by default. In LTSpice the component value is always below the label by default. After you right click, type this

{mc(5,tola)} and click OK.

 

Monte Carlo method
Figure 9

 

Do the same method to resistors. At this time use “tolb”. By the way, tola and tolb are just the name we use to represent the tolerances. You can change these if you want, just don’t include space.

R595 : {mc(2.49k,tolb)}

R598 : {mc(13k,tolb)}

R596 : {mc(4.7k,tolb)}

R597 : {mc(1.5k,tolb)}

R594 : {mc(30k,tolb)}

R599 : {mc(4.7k,tolb)}

Step 6. Define Spice Directive

Spice directive is the one making the execution. In order for the variable “tola” to become functional we will make a spice directive for it. To do so press letter “T” on the keyboard and below window will show.

 

Monte Carlo Simulation using LTspice
Figure 10

 

Tick “Spice directive” and type the command

.param tola=0.05

 

Monte Carlo Simulation using LTspice
Figure 11

 

Click OK.

Do the same method for “tolb” and click OK thereafter.

.param tolb=0.03

 

Monte Carlo Simulation using LTspice
Figure 12

 

Then make another spice directive to execute a monte carlo run as below

.step param run 1 100 1

 

Monte Carlo Simulation using LTspice
Figure 13

 

The above syntax means that we are going to run the simulation for 100 times with starting point at 1 and the increment is 1.

We already created three spice directives for the tolerances and the monte carlo run. Next is to setup the DC sweep command.

 

Step 7. Setup the DC Sweep Command

Since we want to know the values when the output turns to high, we are going to run a DC sweep of the value of V3. To setup a DC sweep, go to “Simulate” then “Edit Simulation Command”

 

Monte Carlo Simulation using LTspice
Figure 14

 

Follow below window then click OK right after.

 

Monte Carlo Simulation using LTspice
Figure 15

 

With the above setting, we are about to run a DC sweep from 0V to 20V with a voltage increment of 0.1V. The source we are going to sweep is V3 which is labeled Vin in the schematic.

 

Step 8. Run the Simulation

After all the settings and configurations are done, you are now ready to run the simulation. To do so, go to “Simulate” then “Run”

 

Monte Carlo Simulation using LTspice
Figure 16

 

Or click this

 

Monte Carlo Simulation using LTspice
Figure 17

 

This is the result

 

Monte Carlo Simulation using LTspice
Figure 18

 

Monte Carlo Simulation using LTspice
Figure 19

 

You can run also a transient command. To do so, go to “Simulate” then “Edit Simulation Command” then select “Transient”. Follow below data.

 

Monte Carlo Simulation using LTspice
Figure 20

Leave a Reply

Your email address will not be published. Required fields are marked *