LTspice does come with its own libraries of models. It is quite extensive and unsurprisingly, it contains a great deal of Linear Technologies components (as it is somehow “sponsored” by LT). Fortunately, as a fair SPICE program, it provides the user a possibility to add in his simulations models for any other type of component. The user can either write the component SPICE model himself, or he can use the predefined models available from different semiconductor manufacturers.
The level of detail in which this article is written assumes the reader has already gone through the previous articles referring to LTspice on this website:
LTspice - the free and complete SPICE simulator Performing AC Analysis in LTspice
and that he is familiar with the basics of the user interface detailed there.
We will describe how you get a model for an operational amplifier, how you create a schematic symbol for that particular model and how you use the symbol (together with the associated model) in a simulation. As an example, the circuit that will be simulated will be a simple repeater, based on the LMV321 opamp from National Semiconductor.
The first step which needs to be performed is to get the SPICE model for this particular component. Fortunately, it is available as a text file under:
You should copy the text available at that location and then paste it in an empty text file on your computer. Once you do that, save the new text file under the name of “custom.lib” at the following location:
Of course, this assumes you have installed the LTspice program under the default path, in the C:\Program Files folder.
What you have just done is to create a new library for LTspice, where you have placed the subcircuit description of LMV321 opamp. The start of the description starts with the “.SUBCKT” directive and ends with the “.ENDS” directive. Every line that starts with the “*” character is a comment. As you may see, in the beginning of the model there are a few lines describing the function of each terminal of the opamp. These match to the actual pin count on the physical device, and they will have to be taken into account when designing the symbol of the component.
Once you have successfully created and saved the new library, the next step is to create the symbol for the operational amplifier. Fortunately, LTspice provides the means for doing this, and what you need to do is to choose the correct option: File->New Symbol
A new workspace is open where you may now draw the new symbol. The main tool used to draw a symbol is the “Line” tool, which you can access from the top menu: Draw->Line
After successfully selecting the “Line” tool, you should draw the symbol of an opamp like in the picture below:
Using the drawing tool is pretty intuitive, like in any regular drawing program (for instance “Paint”). Please note that you should always draw a suggestive schematic symbol. In the long run, it pays to do so, even if for one time used components you can simply draw a rectangular circuit like for any integrated circuit.
Once the shape of the symbol is completed, you need to add the pins. You access the “Pin/Port” by pressing the “P” key. This brings up the “Pin/Port Properties” message box, where you can edit the attributes of the pin you will be placing.
First, we will ad a pin corresponding to the non-inverting output of the amplifier. Since this is the first pin described in the comment section of the model of LMV321 you have downloaded from the web, you should choose in the “Netlist order” box a value of 1. And since the number of the first pin described in the “.SUBCKT” directive is 3, you should fill in the same number (3) in the “Label” message box. Once these two boxes are correctly filled in, you should click OK and then place the pin at the upper horizontal line on the left edge of the symbol, like in the drawing below:
In the same manner, the other pins of the opamp should also be added, with the following characteristics:
- the inverting input (netlist order: 2, label: 2, position: lower horizontal line on the left edge of the symbol);
- the positive power supply (netlist order: 3, label: 4, position: vertical line on the top edge of the symbol);
- the negative power supply (netlist order: 4, label: 5, position: vertical line on the bottom edge of the symbol);
- the output (netlist order: 5, label: 6, position: horizontal line on the right side of the symbol).
Once the pins are placed, you should also add some text that will indicate you the function of each pin when you place the symbol on the schematic. You can easily access the “Text” tool by pressing the “T” key. This brings up a dialog box were you should type in the various texts that you need to place on the schematic, and what you want to do is place 5 different text strings, each of them corresponding to each pin, in the following configuration:
At this stage, the symbol is pretty much ready. Everything else you need to do is to edit its other significant attributes and to associate it with the subcircuit description form the custom.lib library file which you have created earlier. To access the attributes of the symbol, you need to choose from the top menu: Edit->Attributes-Edit Attributes
Tis will bring on the screen the “Symbol Attribute Editor” message box, where you should fill in the values of the attributes as below:
Since you fill in the value of “SpiceModel” attribute as “custom.lib” you tell LTspice that the model description of this symbol is to be found in the “custom.lib” library file. And since you fill in the “Value2” attribute as “LMV321” you tell LTspice to look for the LMV321 subcircuit description inside the custom.lib library file, in order to pinpoint the description of this symbol. Note that in time, you can add several different subcircuit descriptions inside the custom.lib file, and the only way LTspice can look for the particular one you want to associate to a given schematic symbol, is through the value of the “Value2” attribute.
Once you have filled in the attributes as explained, all you need to do before the symbol is ready is to indicate LTspice which attributes you want to make visible on the symbol. You can do that by choosing from the top menu: Edit-Attributes->Attribute Window
This will pop up the “Attribute Window to Add”, where you have a list of the attributes of the symbols which may be displayed in the schematic.
You should double click on the attribute you want to display and place it somewhere near the symbol. In this case, the attributes you want to display are “InstName” and “Value”. You should place them on the symbol as indicated below:
That’s it now! The new symbol and the associated model description are ready to be used in a new schematic. You should save it under:
As I said, we will simulate a simple repeater circuit built around the LMV321 symbol which you have just created. Before proceeding, you should close the LTspice application and then open it again, in order to allow it to update and refresh its internal list of symbols and models. Once you have done that, as you have learned from the previous articles, create a new schematic and draw this circuit:
The symbol for the LMV321 may be found under the OPAMPS subfolder of the library folders:
As you may see from the schematic drawn above, I have also indicated the settings for the simulation: the circuit will be simulated for 1000us, with a time step of 10ns. Once you run the simulation you should plot the signals at the output of the opamp and the signal at its non-inverting input:
As you have seen in this article, there are a few necessary steps required in order to integrate a manufacturer defined model in your LTspice simulation. This method, however, only refers to models which are defined by the “.SUBCKT” directive. There is a different way of using a manufacturer defined model for transistors and diodes, for instance. That method, will be detailed in subsequent articles.