Installing and using LTspice IV (now including LTXVII), From beginner to advanced

Administrator
Joined 2007
Paid Member
Adding models to use in a simulation.

In this next section we will look at using and including models into a working simulation. This was one of the big mysteries to me when I first used LT and so I hope that these examples will clarify things a little. We will use our basic one transistor amplifier from the start of this tutorial (and a tidied up version is included at the end of this post).

Why do we need to use different models in our simulations ? The most obvious one is simply that LT's component library is in practice pretty limited. If your designing a power amplifier for example, you will find that there are no really suitable drivers or output devices available... so we have to add our own models that hopefully represent the devices we wish to use.

So how do we include a model into the simulation ? Well there are several ways of doing this and the following examples should show the advantages and disadvantages of the different approaches.

First, you need your model and these are available from various sources. Bob Cordell has a notepad file of devices useful in audio listed on his website. I'm including as an attachment to this post a file that I came across that lists many devices. Its a notepad file but it had to be zipped to attach it to the forum (over forum limit for notepad file size)

So what does a "model" look like and how do we use it. Here is a typical example that I've lifted from the attached file (just copy and paste).

.model 2N4124 NPN(Is=6.734f Xti=3 Eg=1.11 Vaf=74.03 Bf=495 Ne=1.28 Ise=6.734f Ikf=69.35m Xtb=1.5 Br=.7214 Nc=2 Isc=0 Ikr=0 Rc=1 Cjc=3.638p
+ Mjc=.3085 Vjc=.75 Fc=.5 Cje=4.493p Mje=.2593 Vje=.75 Tr=238.3n Tf=301.3p Itf=.4 Vtf=4 Xtf=2 Rb=10 Vceo=25 Icrating=200m mfg=Fairchild)

So how do we use it ?

One method is just "include" the file within the simulation as follows.

1/ Open the simulation file you want to include that device into.
2/ Copy and paste the full model details onto the diagram using the "text" Spice directive.



Don't worry if some of the text seems missing... it will all be there when you drop it onto the diagram.



Now we have to instruct LT to be able to use that model and we do that using a very specific command of .model (dot model)

3/ Using the add spice directive command (top right on the toolbar) enter .model 2N4124 (the model name must match the name of the included model that you copied onto the diagram.



4/ You can now right click the old devices type number (2N3055 in this case) and enter a new value of 2N4124 Remember you are right clicking the text that says 2N3055 and not the transistor itself.

5/ Having done that, the simulation should run using the included model and if you now right click the transistor itself you will see details such as Fairchild and a Vce value, all put in from the model details we included.



So thats one way to include a model and it can be useful for sharing files as all the details are with the simulation file. But its messy isn't it ?

So the next method (and my preferred one) is to simply include the models as notepad files with the simulation file. For this to work, the notepad file of the models must be kept in the same folder or directory as the simulation file you wish to use it on.

Lets try it with the attached notepad file of all those models.

1/ Place the LT simulation file and the notepad file into the same folder on your PC. Hint... you can copy and paste the whole models file and drop it into as many separate folders containing simulations as you wish.

2/ Look carefully at the name of the notepad file. It doesn't matter what you call it but you must now enter that exact name onto the simulation. I called it simply LT Models. So again, using the "add spice directive" command (top right toolbar) we now add the following specific instruction,

.include LT Models.txt



Notice how the name MUST match the name of your file and how it also includes the .txt designator.

Having done that you now right click the devices type number on the diagram and enter a device from the LT Models file. I skimmed through it and picked totally at random the BUX47A. When you run the simulation it should all work using that devices model that it extracts from the whole notepad file of hundreds of models.

That is probably my preferred method of including a model but there is another way. Remember back at the start when we were installing and confiuring LT and how we looked at where on your PC where it resided. Well we could add models directly to the program files used by LT but I'm uneasy doing this because when LT updates there is no guarantee that your added files won't get over written and lost. Whether this actually happens or not I can't confirm but its something I've seen mentioned.

For those that are interested though, navigate to C:\program files on your PC and look in the LTC folder. Click through the folder and you will see one called "lib" or library. Click it and look for the "cmp" or component entry for bipolar devices. If you open it you will see all the models available to LT as standard. These are the ones that appear as available devices when you right click a transistor.



You will see that there is nothing stopping you altering or adding to the lists of parts to make devices available automatically from within LT.



However, I personally DO NOT RECOMMEND you go down that route.

So that covers adding a simple model to use in a simulation.
 

Attachments

  • Copy and Paste.PNG
    Copy and Paste.PNG
    52.3 KB · Views: 343
  • Copy and Paste 2.PNG
    Copy and Paste 2.PNG
    40.1 KB · Views: 301
  • Copy and Paste 3.PNG
    Copy and Paste 3.PNG
    54.4 KB · Views: 285
  • Copy and Paste 4.PNG
    Copy and Paste 4.PNG
    50.7 KB · Views: 284
  • Models 1.PNG
    Models 1.PNG
    50.7 KB · Views: 285
  • Files.PNG
    Files.PNG
    83.2 KB · Views: 277
  • Open File.PNG
    Open File.PNG
    89 KB · Views: 295
  • Models.asc
    1.9 KB · Views: 304
  • LT Models.zip
    81.5 KB · Views: 347
Just curious. Why do not recommend to add models directly to the cmp files? Seems easier and neater not having to add them to the diagram every time you want to use them.
LTSpice has an automatic update function which also updates the component-files. So what happens if you add your component XYZ to such a file, after the next update the component XYZ is lost.
 
Last edited:
Can't add models....

Mooly,

Perhaps I did not understand something right, or LTspice has been changed so aditional spice models cannot be added anymore...

I tried 3 methods:
- include file
- spice directive
- added to the standard.bjt library.

In neither of the three methods I'm able to select the model I've added (2N2955). It is not in the list (standard.bjt), nor can I manually change the reference to the transistor. My LTspice version is 4.21q.

HELP, please!!!
 
Administrator
Joined 2007
Paid Member
When you tried including the file you need to paste the model in using "text" directive which is second one in from the right.

The include model directive seems to need .MODEL 2N2955 NPN for it to work. The NPN seems to be part of the model name.
 
Seems to work OK.

Rename your text file to something shorter. I used Model 1

Then add Spice directive .include Model 1.txt And keep both files in the same folder.
OK... I adjusted the filename, put it in the same dir as the .asc but still LTspice does not do what I want it to... :confused:

Also tried the file in the same dir as the standard.bjt... didn't work either.

didn't use the text directive...
 
Here you go.
OK, your files work.

the problem I encounter is : I can not edit the name of the transistor into 2N2955.

When I right-click on the transistor, the edit-box opens, but I am not able to change the name of the transistor, nor can I select the transistor from the list.

previously (several month ago) I was able to do so. But afterwrds I reinstalled the PC...

Perhaps reinstall ltspice?

NB I do see the model in the NPN list .... strange that it won't work with pnp...
 
Last edited:
Administrator
Joined 2007
Paid Member
You should be right clicking the transistor type (the text of the device), not the transistor itself. If that is what you mean.

If you look at my pictures in my earlier posts, if I right click the 2N3055 text I get this where I can then type the new device number in.
 

Attachments

  • Text.PNG
    Text.PNG
    22.1 KB · Views: 698