Adding new components to LTSPICE

Adding a new model to the LTSPICE library (example: BCX70K)
First you need to get a suitable model. Models are supplied by many manufacturers, we will use the one from NXP. Save the model as text file somewhere, it doesn't matter where as long as you can remember the place

Next insert the model into the fitting LTSPICE library (Note that the NXP model description is "QBCX70K", not BCX70K). Since the BCX70k is a Bipolar Junction Transistor, the correct library is the "standard.BJT" (capitals by me to emphasize the correlation between library and type of component). This library is usually located in LTSPICE_home\lib\cmp where LTSPICE_home 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). Just double-click on "standard.bjt" and open with LTSPICE (you may need to select from the open-with list in case the document type is not already associated with LTSPICE or open from within LTSPICE's file menu.

In the editor, go to the end of the list and insert the model description that you saved in the first step. Don't worry if the format looks different from what you already find in the library. If it makes you feel better, you can manually correct the formatting so that your new model looks exactly as the old models.
Don't forget to save the library "standard.bjt" (the text file from step 1 may be discarded since it is no longer needed).

You are now ready to use the model.

In the schematic editor, place an NPN transistor and pick a new model. You will (in this case) notice that the information about manufacturer, Vceo and Ic is missing for the QBCX70K. This information is not crucial for simulation. However, if that troubles you, you can easily add this information. Just open the library again ("standard.bjt") and go to the model of the BCX70K. Append the following line to the model:

Vceo=45 Icrating=100m mfg=NXP
​

When in doubt about the correct format, look at the other models and copy from them.

Important note:
The LTSPICE standard libraries may be deleted and replaced by new libraries every time you update LTSPICE. Therefore it is a good idea to keep a copy of your modified libraries in a separate directory and copy them back to the standard installation directory after an update of LTSPICE (of course, unless you like to practice the above method of adding models your libraries).

Addendum:
Instead of modifying the standard library, as described above, another technique is to save your own model(s) in a separate library. All you have to do is create your own library file (e.g. "Mylib.lib") with the text editor of your choice. Put the model information into that file. It is always a good idea to add a header to the library file, using SPICE comments ("*") to remind you in future what this file is.
Here is sample file for the BCX70K:

Note the use of the “+” sign at the start of a line is the marker for a continuation line.

There is one drawback, however: Since your model is no longer in the standard library, you will not be able to right-click and pick a new component (here: transistor) from the drop down list. You have to change the component type manually (here: from "NPN" to "BCX70K") plus you have to tell SPICE to use your own library by adding the following SPICE directive to your schematic:

.LIB path\Mylib.lib
​

where path is the folder path to your library (may be omitted if the library is put in the standard library path LTSPICE_home\lib\cmp, see above).

Adding a new component (subcircuit) to the LTSPICE library (example: SIOV varistor)
Several ways of adding a new component are documented in the LTSPICE help. I will demonstrate one method here:

The model:
First you need a model of the component in the form of a SPICE subcircuit with fitting parameters. Many manufacturers supply that information for free on the Internet. For this example I will use the SIOV SPICE library from EPCOS (http://www.epcos.com/blob/523076/download/1/siov.zip).
Put this library in the LTSPICE library directory, e.g. LTSPICE_home\lib\sub\SIOV.lib where LTSPICE_home is the root directory of your LTSPICE installation (e.g. C:\program files\LTC\LTspiceIV, depending on your setup).

The symbol:The hard way:
Next we need a schematic symbol for the varistor. A symbol is edited within LTSPICE using the menu command File -> new symbol. However, creating a symbol from scratch can be a pain in the ass. It is much easier to modify an available symbol, if one can be found in LTSPICE's library. In our case we will use the "xvaristor" from the Misc library.

Add a new xvaristor on a blank sheet. Right-click on the symbol (you may have to press and hold the CTRL or STRG key for this to work) to open the attribute editor. Click on "Open Symbol" within the attribute editor. Change the attribute from "varistor" to "S20K275" (for an S20K275 type of varistor. Change that type according to your needs). Save the symbol with a new name in LTSPICE's symbol library: save as -> LTSPICE_home\libsym\SIOV\S20K275.asy (you will have to create the subdirectory \SIOV the first time you create a SIOV varistor).

The easy way:
From within LTSPICE open the netlist (.asc or .mod file) of the subcircuit. Select the line where the subcircuit is defined, e.g.

.SUBCKT B32K130 1 2 PARAMS: TOL=0
​

Right click and from the pop-up menu select "create symbol". LTSPICE will automatically create a symbol (a yellow rectangle) with all the necessary pins and an association of that symbol to the netlist. You may then rename the pins to give them meaningful names. You can even redraw the symbol to your needs (e.g. to create a triangle for an OpAmp).

Important note:
Within the attribute editor of the new symbol set the prefix to "X". Only then will SPICE use the subcircuit. If you use any other prefix, SPICE will try to use a built-in model and will fail.

The schematic:
Now we are ready to add the varistor to a schematic. Open your schematic or open a new blank schematic. Use the "add component" dialog, select the SIOV library and place the new S20K275 varistor on your schematic. You're almost there. You now have to tell LTSPICE to use the SIOV library which you saved in the first step. Therefore add a spice directive (Edit -> add Spice directive, see "Adding SPICE directives") ".include SIOV.lib" to your schematic.

Figure 1 Test circuit with SIOV varistor

Note: depending on your installation of LTSPICE you may need admin rights to create a symbol in LTSPICE's symbol library. If you receive an error message to this end, restart TSPICE as admin (once and for the purpose of adding the symbol to the library only - recommended) or make the LTSPICE libraries write-accessible by users without admin rights (not recommended).