Adding model files to QSPICE

A recent update to QSPICE erased all the .model files for bipolar transistors that I had added to the NPN.txt file, as it is replaced by a new file during the upgrade. To avoid this I added new transistors as .model directives to the schematic, which can take a lot of space even with the font size set to the smallest size i.e. 0.65. So next I created a file e.g. BD139.mod and placed it in the same folder as the .qsch schematic file and added a .include directive using the file path, which is less text than the .model text; both these approaches work. I then noticed that the properties for the auto-generated symbol for my BD139 includes an entry for library file in the Basics section and my model text was already here but the text was preceded by the pipe symbol i.e. |.MODEL I then replaced the model text in the file entry with the absolute path to the BD139.mod file and that worked too. So it appears to be unnecessary to add directives to the schematic as models are added to the auto-generated symbol and hopefully embedded in the .qsch file.

Using menu View → Netlist, you can see that a specified Library File attribute simply results in a .lib command.

If you have several files, you can also create a file that only consists of .lib commands and then you need to add that as Library File to anyone symbol only.

I don’t see .lib in the Netlist, shown below, is that where I should see it?

  • E:\Users\Steven\Documents\QSPICE\Transistor switching\Transistor switching.qsch
    V1 N04 0 20
    R1 N04 N03 10
    R2 N01 N02 100
    V2 N01 0 PULSE 0 5 0 0 0 1m 2m 10
    .MODEL Q1•BD139 NPN ( IS=2.3985E-13 BF=244.9 NF=1.0 BR=78.11 NR=1.007 ISE=1.0471E-14 NE=1.2 ISC=1.9314E-11 NC=1.45 VAF=98.5 VAR=7.46 IKF=1.1863 IKR=0.1445 RB=2.14 RBM=0.001 IRB=0.031 RE=0.0832 RC=0.01 CJE=2.92702E-10 VJE=0.67412 MJE=0.3300 FC=0.5 CJC=4.8831E-11 VJC=0.5258 MJC=0.3928 XCJC=0.5287 XTB=1.1398 EG=1.2105 XTI=3 Vceo=80 Icrating=3 mfg=fairchild)
    Q1 N03 N02 0 0 Q1•BD139 NPN
    .tran 50m
    .end

If I use menu File → Open Demo… → DPT.qsch, then menu View → Netlist shows:

* C:\Program Files\QSPICE\Examples\DPT.qsch
M1 N03 N01 N02 ¥ UF3C120040K3S NMOS
M2 N02 N04 0 ¥ UF3C120040K3S NMOS
R1 GATE N04 10
R2 N02 N01 10
L2 N03 N05 120n
I1 0 N02 65
V5 GATE 0 PULSE 0 12 1µ 10n 10n 2µ 4µ
V6 N05 0 800
.tran 5µ
.options ABSTOL=1n
.lib Level2010.txt
.end

OK I can see Level2010.txt in C:\Program Files\QSPICE, it seems to be a number of .model definitions for a range of Qorvo components. This text file is listed in the “library file” section of the properties page for the two FETs used in the schematic. So I think if using a component from Qorvo then a .lib directive will reference a file full of models, whereas if an auto-generated symbol is created from a .model text then the .model directive plus the definition text appears in the Netlist. I guess it just goes to show that there are many ways to do the same thing. Netlist for my auto-generated BD139 below show this:

  • E:\Users\Steven\Documents\QSPICE\Transistor switching\Transistor switching.qsch
    V1 N04 0 20
    R1 N04 N03 10
    R2 N01 N02 100
    V2 N01 0 PULSE 0 5 0 0 0 1m 2m 10
    .MODEL Q1•BD139 NPN ( IS=2.3985E-13 BF=244.9 NF=1.0 BR=78.11 NR=1.007 ISE=1.0471E-14 NE=1.2 ISC=1.9314E-11 NC=1.45 VAF=98.5 VAR=7.46 IKF=1.1863 IKR=0.1445 RB=2.14 RBM=0.001 IRB=0.031 RE=0.0832 RC=0.01 CJE=2.92702E-10 VJE=0.67412 MJE=0.3300 FC=0.5 CJC=4.8831E-11 VJC=0.5258 MJC=0.3928 XCJC=0.5287 XTB=1.1398 EG=1.2105 XTI=3 Vceo=80 Icrating=3 mfg=fairchild)
    Q1 N03 N02 0 0 Q1•BD139 NPN
    .tran 50m
    .end

Hello Steven

You can save your own transistor models in a separate file e.g. “MyNPN.txt”, this file will not be overwritten during the update. In the symbol properties you set this file as library file. Now you can choose from the models of this file.

Tom

1 Like

That’s very helpful thanks. For anyone wanting more detail, this is what worked for me:

1: Create a custom .model containing text file in C:\Program Files\QSPICE e.g. My_NPN.txt

2: Paste in single, or multiple, .model statements e.g. from Standard.bjt - LTwiki-Wiki for LTspice and save.

3: Add an NPN transistor from the “Q” folder in the Symbols & IP folder list in QSPICE.

4: Open the symbol properties for the NPN transistor by double clicking and change the Library File from NPN.txt to My_NPN.txt

5: Right click the NPN symbol and choose Selection Guide, which will now display all the added models.

6: The file My_NPN.txt will survive any of the frequent QSPICE updates.

1 Like

Come on, it is 2023, we shouldn’t be forced to store our data files in the install directory of software. If it was Windows 98 in 1998, then I would expect otherwise, but it isn’t 1998 anymore.

It’s not mandatory to store user data files in the installation directory; they can be stored anywhere as long as the full path is included in the Library File field of the symbols property. One advantage of storing them in the installation directory is that admin permission is required to modify or delete the files and if using an editor such as Notepad++ it will always ask if one wants to complete any edits as an administrator - an extra precaution against making a mistake. A second is that one doesn’t have to remember the full path to a NAS drive on Mars! Also all the other symbol text files are stored in the installation directory, so it doesn’t seem unreasonable to keep user files in the same space?

Hello SteveM

What’s wrong with saving a file in the directory provided?

Stefen uses exactly the space provided for it by Mike Engelhardt. Regardless of the date.

Tom

In general, I never want to store personal data in any “Program Files” directory.

Don’t any of you share libraries between computers, or between you and friends, or you and coworkers?

Don’t any of you ever rename directories or move directories around on your computer? or to different drives? or to dropbox? or to a shared network drive letter? or backup your data directories?

Don’t any of you remember this feature in LTspice? https://i.stack.imgur.com/FegxN.png

Yes I do use the symbol & library search paths in LTSpice, but this feature enables searching folders for individual files, whereas QSPICE stores and searches for data in single text files. Unless I’ve missed something, and I’m always open to learning, I find it easier to add a thousand models to a single text file rather than create a thousand .asy model files. Perhaps future upgrades of QSPICE could include a symbol path option, then users could choose or use both methods?