“Never perform a measurement or simulation without first anticipating the results you expect to see.” ~Eric Bogatin’s Rule # 9
Learn these spice commands: .dc .param
In these 10 lesson series, we will explore LTspice circuit simulator. Assumption is that you’re a beginner or someone who already plays around with it a bit and feel it has potential to solve circuit problems, and perhaps provide intuition and insight how electronic circuits works. Ultimately, it will help solve a real world EE problem and continue to provide a quick go to tool for a quick circuit simulation of some proof of concept.
The approach we will take is that we will never simulate a circuit unless we know what output we expect to see. This is beautifully captured by world-renowned signal integrity expert Eric Bogatin rule # 9. 
First of all, why start with IV curves? Voltage-Currrent (aka IV) relationship of a component can tell us a lot about behavior of that component. In a nutshell, by applying a voltage across its terminal and measuring the resulted current, one can figure out the resistance or more generally impedance of the component. Later this knowledge can lead to electrical models which can help design and predict the behavior of a circuit. This is a good starting point as we will get to know immediately two of most important LTspice simulation commands: .dc and .param
We will look at IV curves of following components:
- NPN and PNP BJT
- NMOS and PMOS MOSFET
- Solar cell
We will be using following 5 steps approach for each of the circuit in these tutorials:
Step 1: Draw a circuit.
Step 2: Add proper dot simulation command.
Step 3. Predict its behavior.
Step 4: Simulate and verify behavior with your prediction.
Step 5: (Optional) Repeat step 3 if result doesn’t match prediction and extend the example for some other use case or different parameters.
Let’s start things with a lonely resistor and it’s IV curve. True to rule # 9, a resistor is related with voltage and current through ohm law: V=I*R or I = V / R. This is in the form of y = m*x form where m = 1/R is the slope. So if we vary a voltage from 1V to 2V we expect to see a current proportional to 1/R. This means if resistor is huge (i.e ~MΩ range), current would be small compared to if resistor is small (i.e ten’s of ohm). Let’s see if we can verify it using LTspice.
I am not going to layout exact steps for how to find these components. Just mess around and find them yourself and wire it up like this. Tip, you can find most of generic component in this toolbar link:
*If you want to take a short cut, you will find all the .asc files at the end.
Here is a simple schematic where resistor and voltage source are wired as below. Note the variable X in curly bracket. We will use it to vary the value of R1.
We will start with following two simulation commands: .dc and.param
.dc V1 Lin -10 10 .1
The syntax is almost readable and follow the format of .dc <Voltage or Current source> <Start value> <Stop Value> <increment>. In this case we want to sweep voltage source V2 linearly from -10V to +10V with increment of 100mV. Ltspice provide a useful dialog box which can also be used enter these values:
Now let’s a take a look at this command
.step param X list 100 1k
Again the syntax is readable and allow a source or parameter to vary by a list of values or some increment. In this case, we want to step our X variable which correspond to R1 value in the schematic for two values 100Ω and 1kΩ.
As mentioned earlier, low value resistor will be able to pass lot more current and curve will be close to current axis in accord with the ohm law. A high value resistor will pass low current thus its curve should be close to voltage axis.
Run the simulation with clicking on the running man in the tool bar: . After simulation run without an error, point the cursor on the resistor until a current probe appears and click it. This will plot voltage vs current plots on the plot window with two defined resistor values:
Notice as expected R1=10Ω is close to current axis when compared with R1=100Ω as we have predicted from the ohm law. Granted this is a extremely simple example, but it will help with more complicated circuit in which reasoning remain the same but formula gets more complex.
Let’s go one step further and create IV curves by varying R1 from 1Ω to 100Ω with increment of 1Ω. How does the .param command will change? How long it takes for simulation to plots these curves? I will leave this as an exercise, but prediction remain the same and curves are shown below: Actual simulation file .asc attached if you want to play along. R_IV_2.asc
Step 1 and 2:
Lets add a .dc command to simulate diode IV. Notice, 1N4148 is real diode, but it should follow diode equation:
We expect to see an exponential curve as we vary VD. Click on the diode when cursor become a current probe to following plot:
Notice, VD can be varied at any arbitrary voltage, but since this is a real diode it adheres to absolute maximum rating as per its datasheet:
Simulation gives a false sense of putting any voltage across diode, but in-fact if power dissipation gets exceeded, expect to see smoke in a real circuit build. LTspice won’t gives any warning. It is your job as a circuit designer to adhere to any datahseet limits.
Let’s extend the above example to simulate the effect of temperature. As diode equation predict and both VT and Is are function of temperature, we expect to see at higher temperature current rise earlier than room temperature. In order word diode will switch faster. As an example add following command to effect of temperature on this real world diode.
.step temp list -40 25 85
BIPOLAR JUNCTION TRANSISTOR (BJT)
From this point on, I will combine all the steps here. Since a transistor is 3-terminal device, you have to make the one terminal constant current or voltage value while varying the other one. For typical IV curves, we make the base current constant while varying the VCE of the transistor. Then we can do it for multiple value of base current. The .dc command shown below the circuit. We expect to see a triode region and saturation region.
Metal Oxide Semiconductor Field Effect Transistor (MOSFET)
Note the convention used above where PMOS is source is tied to highest positive rail.
An excellent paper that discusses the solar cell simulation using datasheet parameters is given below.
A simplified Rseries and Rshunt model of solar cell is given below. Just click on the V1 while cursor in current probe mode to run the simulation.
This just scratches the surface of LTspice capability and a good starting point to get familiarize with some basic commands. Next tutorial will focus on DC circuit analysis.