Ltspice Add Library
Correcting shortcomings and adding new models. Additional library for LTspice, file is lib.zip 18M. Additional examples for LTspice, file is example.zip 25M. Transistors and diodes, file is cmp.zip 260K. VDMOS for LTspiceIV, file is standard.mos.IV.txt 322K. VDMOS for LTspiceXVII, file is standard.mos.XVII.txt 322K. After adding RL=1kΩ load resistance you should have the following circuit. This transformer won’t work properly because LTSpice does not know this is a transformer. This looks like two inductors are in the circuit. We need to tell LTSpice these are transformer. We will use a Spice directive to add a K-Statement (“K Lp Ls 1 “) to this. This library is usually located in LTSPICEhome lib cmp where LTSPICEhome is the root directory of your LTSPICE installation (e.g. C: program files LTC LTspiceIV, depending on your setup). Inserting the model can be done using a standard text editor or by using LTSPICE's built-in editor (my preferred method since it supports syntax highlighting).
- Ltspice Import Library
- Add Library To Ltspice
- Ltspice Add Library File
- Ltspice Add Component To Library
LTspice comes with a wide range of symbols. You can create new symbols, both as functional or non-function parts or even editthe existing symbols. New symbols are often contributed to the yahoo LTspice user group so it is worth checking first to see if there is already a suitable symbol.
LTSpice Library Files
If you are running Microsoft windows then the library files in LTSpice are stored at C:Program FilesLTCLTspiceIVlib
The 'lib' folder, (screenshot below) contains 3 sub-folders called sym, lib, and sub. You can bookmark this location for futureuse. Click Favorites and add a suitable name.Folder Details
cmp Contains standard model data for passive components, diodes, transistors, FET's etc
sub Contains subcircuit data. Files are ASCII text and end in .mod .sub or .lib
sym Contains circuit symbols ending in extension .asy
Creating a New (Non-Functioning) Schematic Symbol
Please note, all subsequent screenshots are taken from LTspice running on Linux. Appearence may look slightly different, but allsteps are the same, independent of the platform used.
The example below shows how to create a non-functional 'meter symbol. Begin by starting LTspice and click on File, New Symbol:
In Figure 1 the circle with the cross is the symbol origin. When inserting the symbol into a schematic the symbol will be rotated about the origin.Note If the first pin is fixed to the origin, then the symbol will be rotated around this point, this is useful for any component that is drawn at 45 °, as they can be rotated to form a bridge.
The symbol is now complete. As the symbol is not included with LTspice it is advisable to make a backup of your work.I just create an LTspice folder, with sub-folders called my_symbols, my_ccts. To save the symbol, go to the file menuand choose 'Save As' (figure 15). Use a descriptive name, and all symbols in LTspice must end with the extension .asy
Adding your symbol into LTspice
To include your symbol in LTspice, save it in the LTspice library. For windows users the location will be
C:Program FilesLTCLTspiceIVlibsym The image above shows location C:Program FilesLTCLTspiceIVlib, clicking sym folder contains all the schematicsymbols.
Warning Each symbol MUST have a unique name, otherwise the existing symbol will be replaced.
Also note: If you create a schematic using a custom symbol and send it to someone else, thenyou MUST also include the new symbol with the schematic. If you forget, then the missing symbol will show as empty space.
Closing LTspice, (if open) and restarting will cause the program to read the new symbols. Pressing F2 brings up the componentbrowser, and your new symbol should now be available for use.
A note about Drawing Scale
After designing a new symbol, you may find that it is disproportionate large or smaller than other components. There is no way to scale components, so it will need to be redrawn. However, if you copy an existing symbol from the LTspice symbol directory,and rename it, you can use the symbol elements, (circles, lines, rectangles etc) as a guide, to create your new component.
Creating New Symbols with Spice Prefix Data in LTspice
In this example I have drawn a new symbol for an electrolytic capacitor. First the edit attributes menu is accessed, either viathe edit menu (screenshot below) or by pressing Ctrl+AThe edit attributes table is then displayed with the symbol (figure 16). The spice prefix (prefix) determines the type ofcircuit element.
Entering 'C' in the prefix field, associates the symbol with a capacitor, entering L associaties the symbol with an inductor.The value field sets the default value. A list of spice prefix characters is shown in the table below :
Spice Prefix TableA | XSpice Model |
B | Nonlinear Dependent Voltage Sources |
C | Capacitors |
D | Junction Diodes |
D | Zener Diodes |
E | Linear Voltage-Controlled Voltage Sources |
F | Linear Current-Controlled Current Sources |
G | Linear Voltage-Controlled Current Sources |
H | Linear Current-Controlled Voltage Sources |
I | Independent Current Sources |
J | JFETs |
K | Coupled (Mutual) Inductors |
L | Inductors |
M | MOSFETs |
O | Lossy Transmission Lines |
Q | Bipolar Junction Transistors |
R | Resistors |
S | Voltage Controlled Switches |
T | Lossless Transmission Lines |
U | Uniform Distributed RC Lines (Lossy) |
V | Independent Voltage Sources |
W | Current Controlled Switches |
X | Subcircuits |
Z | MESFETs (GaAs FETs) |
Setting a default value. If not changed, the capacitor will be assigned the value 'C'. Each component will have to be changedon the schematic. However you can assign a default value which will appear on the schematic. Choosing a popular value such as100uF, will set every new capacitor symbol to 100uF. This may save time drawing a schematic, as you only have to alter non 100uFcapacitors. To set a default value, either right the value on the symbol (see figure 17), or bring up the edit attributes window,by pressing ctrl+A and change the value field.Save the component. If you choose a name like cap2.asy, you can have the choice of using existing symbols in LTspice or yournew symbols. Once again the component needs to be saved in LTspice library files under symbols. The location is:
C:Program FilesLTCLTspiceIVlibsym ()for windows users).
/home/username/.wine/drive_c/Program Files/LTC/LTspiceIV/lib/sym
Windows explorer, nautilus or dolphin (linux) allow all the symbols to be browsed. Figure 18 shows the components displayedby konqueror file manager.Using your symbol in new schematics
Closing LTspice, (if open) and restarting will cause the program to read the new symbols. Pressing F2 brings up the componentbrowser, and your new symbol should now be available for use. If you assigned a default value, then the component will be displayed with this value. It can be changed of course, with a right click.
New Symbols for LTSpice
I have created a range of new symbols, that I use in Circuit Exchange, shown in the image below:
The top two lines, are schematic only symbols and non-functional. Starting on the third line, all capacitors havespice prefix character C and are therefore functional, as this the 45° diode symbol. F1 is a non-functional fusesymbol. The bottom line is a Norton current generator, followed by a European symbol for a resistive preset.The last 4 symbols are SPST switch, SPDT switch, NO push button, and NC closed push button.
Download My New Symbols
You may use my new symbols, in your own work. They are free to use for both commercial and non-commercial use. If you havea website, you may want to link back to this page, as I often create new components.
Click hereto download my symbols.
As stated previously, if you plan to share any schematics that use new symbols, then you must also include them with theschematic. The recommended method by the LTSpice User group is to create separate directories for every circuit. The symbols, subcircuit data, and new models can then be stored with the schematic.
Shell Script for linux Users
The following bash script is designed to make life easier when adding newcomponents to LTspice. It is a simple shell script that can be modifiedand places all component, library, model and subcircuit files into therelevant directory in LTspice. My download location is/media/share/electronics/ltspice Just replace this with yourdownload location for your system.
Transfer shell script
Just download the script and execute it with ./transfer.sh
LTspice Tutorial: Part 4
This LTspice Tutorial explains how to import third party models into LTspice®.
LTspice is not limited to simulating Linear Technology parts. Third party models can be imported into LTspice too. There are 2 types of model that can be imported into LTspice:
.MODEL parts - these are simple components such as transistors and diodes
.SUBCKT parts - these are more complex parts made up of simpler Spice parts (diodes, transistors, resistors etc)
It is important to note that LTspice looks at the first line of the SPICE model to determine how the model should be handled. If the part is defined with a .MODEL statement, importing the model is handled one way; if the part is defined with a .SUBCKT statement, importing the model is handled in a slightly different way. Thus we could import 2 identical diodes, one defined with a .MODEL statement and one defined with a .SUBCKT statement and they are actually handled differently. LTspice looks at the model definition, NOT the component to determine how to import the part.
.MODEL parts:
To import a simple third party SPICE model into LTspice using the .MODEL directive , follow these steps:
Add a generic component to the schematic that represents the symbol of the SPICE model
Download the SPICE model into the same directory as the circuit you are simulating.
Make a note of the filename of the SPICE model, including the file extension.
Add a .include SPICE directive to the schematic that will use the model
Open the SPICE model and note the name of the model - this is the text immediately after the .MODEL directive and before the part designator (in the case below this is the text DI_SBG1030L). The SPICE model can be viewed from within LTspice.
Press <CTRL> then right click over the generic component and change the 'Value' field to the SPICE model name
Ensure the .include SPICE directive contains the exact filename of the SPICE model
Ensure the name of the generic component exactly matches the SPICE model name
Here is an example of how to import a Schottky diode into a circuit. FIG 1 shows a simple circuit to measure the forward voltage drop across a diode. This can be downloaded here: Diode Test Circuit
FIG 1
Running the simulation shows the diode has a forward voltage drop of 653.2mV
Remove diode D1 and replace it with the standard Schottky diode from the LTspice library.
Download the SPICE model of the BAT 54 Schottky diode: BAT 54 SPICE model and save it in the same directory as the circuit in FIG 1.
Add the following SPICE directive to your schematic using the symbol:
.include DI_BAT54.txt
To avoid spelling mistakes, use Windows Explorer to highlight and copy the filename including the filename extension (.txt). Paste the text after the include statement.
Open the SPICE model file (using, say, Notepad) and note the name of the model (in this case it is DI_BAT54). Again, to avoid spelling mistakes, it is easier to highlight the model name and copy it.
Press <CTRL> Right click over the Schottky diode symbol and paste the text DI_BAT54 into the Value field as shown in FIG 2. Do not put any comments in the Spice Model field.
FIG 2
The final circuit should look like FIG 3
FIG 3
Run the simulation. The forward voltage drop should now be 290mV.
If you encounter errors, check the following:
Has the SPICE file been loaded into the same directory as the simulation file?
Is the part name the same as that specified in the SPICE model?
Ltspice Import Library
Does the filename in the .include statement exactly match the SPICE model filename?
It is also worth opening the SPICE model file from within LTspice and checking its contents. Some text editors can add formatting characters that confuse LTspice.
.SUBCKT parts
A similar procedure can be used to import more complex models. Follow the steps above, except when modifying the Component Attribute Editor (see FIG 2), ensure the Prefix attribute is marked as X (and not D as in FIG 2).
We are now going to compare the performance of the LT6231, (215MHz low noise op amp) with the LM324 (low cost op amp).
Download the circuit in FIG 4: Op Amp Test Circuit
FIG 4
Running this circuit shows the output falls from 1V at dc to 0.707V at about 2.77MHz.
Now remove the LT6231 and replace it with a standard 5 terminal op amp. This is the 'opamp2' model in the Op Amps folder in LTspice.
Download the LM324 model: LM324 model and save it in the same directory as the circuit in FIG 4.
Make a note of the SPICE model filename (in this case it is LM324.txt). Add a .include SPICE directive in your schematic as follows:
.include LM324.txt
Open the SPICE model and make a note of the SPICE model name (immediately after the .SUBCKT command). In this case it is LM324.
Press <CTRL> Right click over the op amp symbol in the schematic and insert the model name into the Value field as shown in FIG 5
FIG 5
Ensure that the Prefix attribute is filled in with X.
NOTE: The SPICE model of some simple components (e.g. Zener diodes) are defined as a SUBCKT. In this case, the Prefix attribute has to be 'X' and not 'D' to correspond with the .SUBCKT SPICE definition (and not a .MODEL definition).
Creating a Quick Part Outline for 3rd Party SPICE models
Once the SPICE model has been imported, an outline can be created for the part. Open the SPICE model in LTspice, move the mouse over the .SUBCKT line, right click and select 'Create Symbol'. A square symbol will appear showing the nodes of the SPICE model.
FIG 5a
Then select a new component (using the AND gate symbol) and in the dialogue box, the new component is stored under the [AutoGenerated] directory.
Running the simulation shows the output falls to 0.707V at about 10kHz, showing the inferior frequency response of the LM324 over the LT6231.
Add Library To Ltspice
The final circuit is shown in FIG 6
FIG 6
SPICE models for many components that are needed with LTC devices can be downloaded here:
Want to know more?
Ltspice Add Library File
Please see LTspice Tutorial: Part 5
Ltspice Add Component To Library
LTspice is a registered trademark of Linear Technology Corporation