Introduction: How to Use a Chip Vendor Op-Amp Model in LTSpice

About: Hands-on CTO educated as a Biophysicist and experienced as an entrepreneur in establishing, supporting, and eventually selling a biotechnology company. Focused on helping labs with electronics, software, video…

Introduction

LTspice is a free SPICE simulation software tool with schematic capture, waveform viewer, and many enhancements that runs on both Windows and Mac OS X. I use it to research circuit behavior and quickly experiment with new circuits for my lab before prototyping a PCB (Printed Circuit Board) design. The learning curve is easy to conquer thanks to support by Analog Devices, Yahoo's LTspice Support Group and its compatibility with most common SPICE models supplied by chip vendors.

This Instructable will demonstrate how to go beyond the component library supplied with LTspice by incorporating an LMV321 op-amp model from three different chip vendors to create a simple amplifier schematic as shown in the drawing. Each of these models highlight different methods available within LTspice for use with the wide variety of component models supplied from various vendor websites. Each of these models present different performance features as well. To highlight these performance issues I reuse these three models in a Current-to-Voltage design as well.

The target audience are those with some experience placing components on a schematic and running a simulation. By the end of this tutorial you will know how to interpret the .SUBCKT command within manufacturer models for use with LTspice's opamp2 Pin Table and Attribute editors to use manufacturer parts within your simulations.

Step 1: Download the SPICE Models Available for LMV321 Op-amp From Chip Vendors and Place in New Directory

Manufacture's SPICE Models

We are going to incorporate three SPICE models based on the LMV321 op-amp in this tutorial. Follow along as I outline the steps.

Create a folder for your upcoming LTspice schematics, symbols, and models. I will refer to this directory as our working directory going forward.

Visit these chip vendor websites to extract the SPICE models for the LMV321 op-amp:

See the three associated diagrams for specific files to download as of the writing of this instructable. In the future you may have to search for the model names if they have been moved by the chip vendors to new web pages.

For TI and STMicro you would copy the model from the downloaded zip files into your working directory. For the Maxim model you would right-click on the LMX321.FAM file at their website and save it to your LTspice working directory.

At the end of this step you should have these three spice model files in your working directory:

  • LMV321.MOD
  • LMX321.FAM
  • LMV3x_macromodel.mod

Each of these files can be opened with a text editor to see a common stucture:

  • documentation at the top,
  • .SUBCKT command,
  • spice commands building out the model.

Step 2: Open the Generic 5-pin LTspice Opamp2.asy Symbol

Opamp2.asy Is Reusable

From the LTspice File menu Open the opamp2.asy symbol from your install directory.

For Windows default installation this would be:

C -> LTC -> LTspiceXVII -> lib -> sym -> Opamps -> opamp2.asy

The opamp2 symbol has no op-amp model assigned to it. So it won't run in a simulation. For this reason it is a good starting block as it does contain the drawing and links for us to create any op-amp that uses the five common pins:

  1. In+
  2. In-
  3. V+
  4. V-
  5. Out

Take care not to open one of these similar symbol files by mistake:

  • opamp.asy (similar to opamp2.asy but without the two power pins)
  • UniversalOpamp2.asy (a fully functional opamp with generic model)

Step 3: Verify the Opamp2.asy Symbol Pin Order Matches the LMV321 .SUBCKT Pin Connection Information

Pin Table Assignment Using .SUBCKT

Open the LMV321 opamp model previously saved as LMV321.MOD in your working directory using your favorite text editor. Near the top we can find the .SUBCKT statement.

A .SUBCKT defines a reusable SPICE netlist - similar to a function with it's name and associated parameters in software languages. The subcircuit syntax for an op-amp supplied by a manufacturer looks like this:

.SUBCKT <Op-amp name> <N1> <N2> <N3> <N4> <N5>
. . . element statements ...
.ENDS

Op-amp name is the external reference to the name of the op-amp and the 5 N's are a list of ordered electrical connections to the op-amp as described directly above the .SUBCKT command. The electrical connections may be in any order but our opamp2 symbol assumes this order:

  1. non-inverting input (In+)
  2. inverting input (In-)
  3. positive power supply (V+, Vss)
  4. negative power supply (V-, Vee)
  5. output (Out)

Open the LMV321.asy symbol in our working directory within LTspice and view the Pin Table to map the connection names in the .SUBCKT to the connection names in our symbol:

View -> Pin Table

All the electrical connections are already in the correct order for our LTspice Pin Table, from 1 to 5 like this:

  • non-inverting input (In+) = 1
  • inverting input (In-) = 2
  • positive power supply (V+) = 3
  • negative power supply (V-) = 4
  • output (Out) = 5

So we won't have to make any changes to the symbol's Pin Table.

Step 4: Create the Attributes for the New LMV321 Symbol and Save the File As LMV321.asy

Opamp Symbol Attribute Assignment

One last step before saving the symbol file is to name the symbol using the Attributes Editor. We will use the same name as shown in the .SUBCKT line:

LMV321.

Open the Attribute Editor from the menu:

Edit -> Attributes -> Edit Attributes

Make the following changes:

  • Change Value to: LMV321 (use the same name as in .SUBCKT command line)
  • Change Description to: Include LMV321.MOD in schematic (more on this later)

Click OK and save the opamp2.asy as LMV321.asy in your working directory.

Notes:

  • Leave the X next to Prefix to indicate that the symbol will display in schematic,
  • Leave the Symbol Type as Cell so the model file will be interpreted correctly,
  • Don't save the modified opamp2.asy symbol back into the LTspice library or other schematics that may rely on this file may be corrupted,
  • If you did make this mistake (like I did once), you can restore the original opamp2.asy file with a re-sync using the command: Tools -> Sync Release.

Your working directory should have these files now:

  • LMV321.asy
  • LMX321.FAM
  • LMV321.MOD
  • LMV3x_macromodel.mod

Step 5: ​Create Test Schematic and Simulate the LMV321 Op-amp's Performance

Test LMV321 Op-amp Model in a Simulation

Open a new schematic from within LTspice: File -> New Schematic

We will create an op-amp test circuit based on a non-inverting amplifier with a gain of 2:

Gain = 1 + Rf / Rin

Add our newly created LMV321.asy component from your working directory using the LTspice ribbon menu component command.

Hint: Many LTspice users are not aware that they have to change the symbol's directory to their working directory. To manage access to the new files, switch the item "Top Directory" to their working directory.

Power the op-amp with a 5 volt supply using the voltage component.

Test the op-amp with repeating pulses ranging between 0.2 and 2.3 volts to the non-inverting input using a second voltage component.

Set up a transient analysis over a 500 microsecond interval using the LTspice ribbon menu .Op SPICE directive command.

Increase the simulation performance with the following options with the .OP command:

.options gmin=1e-10 abstol=1e-10

.options plotwinsize=0

Where:

  • Gmin (prevent nodes from floating by defining a small conductance across non-linear devices)
  • Abstol (limit the tolerance for currents anywhere in the circuit)
  • plotwinsize (compression control where 0 indicates no comporession)

Add a title to our schematic using the Text ribbon menu:

National Semiconductor LMV321 model: Non-Inverting Amplifier

Save the schematic into your working directory as: test_LMV321.asc

Run the simulation for the National Semiconductor LMV321 model downloaded from the TI website:

Click the Run icon on the LTspice ribbon menu

Measure V(out) and V(In+) using your cursor over the associated wires

Note that the gain is shown as 2, as we predicted above.

Your working directory should have these files now:

  • test_LMV321.asc
  • LMV321.asy
  • LMX321.FAM
  • LMV321.MOD
  • LMV3x_macromodel.mod

Step 6: Create the LMX321 Symbol Starting From the LMV321 Symbol

Create LMX321.asy Symbol With Correct Attributes and Pin List / Netlist Order

Go to your working directory and open the LMX321.FAM model with your favorite text editor to view the .SUBCKT information (see diagram). We repeat the last two steps to build a new op-amp component and test circuit.

Open our previously created LMV321.asy symbol from LTspice located in your working directory:

File -> Open -> LMV321.asy

Note: If you did not create the LMV321.asy symbol earlier then you can open the opamp2.asy symbol instead.

Use the Attributes Editor to change the symbol Value and Description (see diagram):

Edit -> Attributes -> Attributes Editor

  • Value: LMX321
  • Description: Include LMX321.FAM in schematic

Click OK

Use the Pin Table to change the order of connections to correctly line up with the .SUBCKT command (see diagram):

View -> Pin Table

The connection list from 1 to 5 is in a different order than the list for our previous LMV321 op-amp so we will have to change the Pin Table for LMX321 symbol as follows:

  • In+ = 1
  • In- = 3
  • V+ (Vcc) = 5
  • V- (Vee) = 2
  • Out = 4

Click OK

Why? In the .SUBCKT description within the model we find that In+ is assigned to "1" so we assign In+ to 1 in our Pin Table. But In- is assigned to "3" in the .SUBCKT description so we assign In- to 3 in our Pin Table. And so on.

Save the new symbol to your working directory as LMX321.asy

Your working directory should have these files now:

  • test_LMV321.asc
  • LMX321.asy
  • LMV321.asy
  • LMX321.FAM
  • LMV321.MOD
  • LMV3x_macromodel.mod

Step 7: Reuse Test Schematic and Simulate the LMX321 Op-amp's Performance

Test LMX321 Op-amp Model in a Simulation

Open our previous test circuit and change the op-amp references to the LMX321:

File -> Open -> test_LMV321.asc

Delete the reference to the LMV321 op-amp in our schematic.

Use the component option on the LTspice ribbon menu to place the LMX321.asy op-amp.

Replace the reference to the model by right clicking on the .INC command in the schematic drawing with:

.INC LMX321.FAM

Replace the title to reflect our new schematic purpose:

Maxim LMX321 model: Non-Inverting Amplifier

All the other elements of the schematic will remain the same.

Save the schematic in your working directory as test_LMX321.asc

Run the simulation for the Maxim LMX321 op-amp model.

Click the Run icon on the LTspice ribbon menu

Measure V(out) and V(In+) using your cursor over the associated wires

Note that the gain is shown as 2, as we predicted above.

Your working directory should have these files now:

  • test_LMX321.asc
  • test_LMV321.asc
  • LMX321.asy
  • LMV321.asy
  • LMX321.FAM
  • LMV321.MOD
  • LMV3x_macromodel.mod

Step 8: Create the LMV3x Symbol Starting From the LMV321 Symbol

Create LMV3x.asy Symbol With Correct Attributes and Pin Table

Go to your working directory and open the LMV3x_macromodel.mod model with your favorite text editor to view the .SUBCKT information (see diagram).

Open our previously created LMV321.asy symbol from LTspice located in your working directory:

File -> Open -> LMV321.asy

Note: If you did not create the LMV321.asy symbol earlier then you can open the opamp2.asy symbol instead.

Use the Attributes Editor to change the symbol Value and Description (see diagram):

Edit -> Attributes -> Attributes Editor

  • Value: LM3x
  • Description: Include LMV3x_macromodel.mod in schematic

Click OK

Use the Pin Table to change the order of connections to correctly line up with the .SUBCKT command (see diagram):

View -> Pin Table

The connection list does not have numbers and the parameters are in yet another different order than the list for our previous two op-amp .SUBCKT's. There is no need for numeric entries in the .SUBCKT command, but we will have to change the Pin Table for LM3x symbol to line up with our original opamp2.asy order as follows:

  • In+ = 2
  • In- = 1
  • V+ (Positive Power Supply) = 4
  • V- (Negative Power Supply) = 5
  • Out = 3

Click OK

Why? The .SUBCKT description of the 5 pins are in a specific order. We take the first entry to be pin 1, which is the Inverting Input (In-) parameter. So we mark the In- entry using the Pin Table as number 1. The second entry will be pin 2, which is labled as the Non-Inverting Input (In+). So we mark the In+ entry using the Pin Table as number 2. And so on.

Save the new symbol to your working directory as LMV3x.asy Your working directory should have these files now:

  • test_LMV321.asc
  • LMV3x1.asy
  • LMX321.asy
  • LMV321.asy
  • LMX321.FAM
  • LMV321.MOD
  • LMV3x_macromodel.mod

Step 9: Reuse Test Schematic and Simulate the LMV3x Op-amp's Performance

Complete LMV3 Op-amp Model and Test in a Simulation

Open our original test circuit and change the op-amp references to the LMV3x:

File -> Open -> test_LMV321.asc

Delete the reference to the LMV321 op-amp in our schematic.

Use the component option on the LTspice ribbon menu to place the LMV3x.asy op-amp

Replace the reference to the model by right clicking on the .INC command in the schematic drawing with:

.INC LMV3x_macromodel.mod

Replace the title to reflect our new schematic purpose:

STMicroelectronics LM3x model: Non-Inverting Amplifier

All the other elements of the schematic will remain the same.

Save the modified schematic as test_LMV3x.asc in your working directory.

Run the simulation for the STMicroelectronics LMV3x op-amp model.

Click the Run icon on the LTspice ribbon menu

Measure V(out) and V(In+) using your cursor over the associated wires

Note that the gain is shown as 2, as we predicted above.

Your working directory should have these files now:

  • test_LMV3x.asc
  • test_LMX321.asc
  • test_LMV321.asc
  • LMX321.asy
  • LMV321.asy
  • LMX321.FAM
  • LMV321.MOD
  • LMV3x_macromodel.mod

Step 10: Compare Model Performance and Concluding Remarks

Review Simulation Models in a Current to Voltage Circuit

The non-inverting amplifier op-amp simulations we have explored so far show consistent results for each of the three models. Namely a voltage gain of 2, as we predicted.

I would like to leave you with one more circuit simulation using each of the three models. A "poorly" designed current to voltage converter. The schematic shows a predicted Vout = Iin * R1.

For minimum error due to bias current the suggested value for R2 should be the same as R1. In my circuit I purposely use a much lower value for R2 in an attempt to expose model differences outside of normal design practices. The simulation should also help us visualize the poor design error predicted through variance in bias because R1 and R2 are not the same.

In the three simulations the Maxim LMX321 performs most differently in that the Vout seems low and no variance in bias or ringing. While the other two models, STMicro's LMV3x and National Semi's LMV321 show the expected Vout results along with some differences in variance in bias or ringing behavior.

In conclusion

I have shown three different methods encountered when importing manufacturer op-amp models using the LMV321 family for LTspice. We reviewed the National Semiconductor LMV321 model from TI's web site, STMicroelectronics LMV3x model, and MAXIM LMX321 model. These three methods should help you to import op-amp models for any other part using the model's .SUBCKT command along with LTspices' Attributes and Pin Table editors.

I have also shown that some models perform better than others as demonstrated with the voltage to current converter schematic. Testing two or more models in your simulation designs may help you get more reliable results for your needs.

References:

LTspice Download and Documentation

www.analog.com/en/design-center/design-tools-and-calculators/ltspice-simulator.html

LTspice group - Yahoo Groups: lots of files shared, active support for questions

groups.yahoo.com/neo/groups/LTspice/info

SPICE Quick Reference Sheet v1.0, Standford EE133 - Winter 2001: reference to .SUBCKT pp7-8

web.stanford.edu/class/ee133/handouts/general/spice_ref.pdf

Op Amp Circuit Collection: National Semiconductor Application Note 31, September 2002: reference to non-inverting amplifier and current to voltage conversion op-amp circuits

www.ti.com/ww/en/bobpease/assets/AN-31.pdf

All files related to this instructable are available for download as a zip file below.

ltspice_lmv321_simulation_files.zip