LTspice Lesson 1: Generating IV curves

Kashif Javaid

“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. [1]

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:

  1. Resistor
  2. Diode
  3. NPN and PNP BJT
  4. NMOS and PMOS MOSFET
  5. 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.

RESISTOR

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.

Step 1:

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:

Screen Shot 2019-02-03 at 10.58.28 AM

*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.

Screen Shot 2019-02-03 at 1.25.21 PM

Step 2:

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:

Screen Shot 2019-02-03 at 1.29.29 PM.png

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Ω.

Step 3: 

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.

Step 4:

Run the simulation with clicking on the running man in the tool bar: Screen Shot 2019-02-03 at 1.37.17 PM.png. 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:

Screen Shot 2019-02-03 at 1.40.54 PM.png

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.

Step 5:

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

Screen Shot 2019-02-03 at 1.55.52 PM.png

DIODE

Step 1 and 2:

Screen Shot 2019-02-03 at 7.48.09 PM.png

Step 3:

Lets add a .dc command to simulate diode IV. Notice, 1N4148 is real diode, but it should follow diode equation:

Screen Shot 2019-02-18 at 3.48.09 PM.png

We expect to see an exponential curve as we vary VD. Click on the diode when cursor become a current probe to following plot:

Step 4:

Screen Shot 2019-02-18 at 3.51.42 PM.png

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:

Screen Shot 2019-02-18 at 4.02.09 PM.png

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.

Step 5:

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

Screen Shot 2019-02-18 at 4.15.02 PM.png

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.

NPN

Screen Shot 2019-02-25 at 9.18.10 AM.png

PNP

Screen Shot 2019-02-25 at 9.18.58 AM

Screen Shot 2019-02-25 at 9.21.56 AM.png

bipolar.asc

Metal Oxide Semiconductor Field Effect Transistor (MOSFET)

Screen Shot 2019-02-25 at 9.46.19 AM.png

Note the convention used above where PMOS is source is tied to highest positive rail.

Screen Shot 2019-02-25 at 9.45.46 AM.png

Screen Shot 2019-02-25 at 9.47.58 AM.png

mosfet.asc

ami_c5n_corner_bsim3.txt

SOLAR CELL

An excellent paper that discusses the solar cell simulation using datasheet parameters is given below.

Simulation of Single-Diode

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.

Screen Shot 2019-02-25 at 10.48.17 AM.png

Screen Shot 2019-02-25 at 10.48.27 AM.png

solar_iv.asc

Conclusion.

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.

 

 

 

 

 

Advertisements
This entry was posted in LTspice for EE students. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s