EEVblog Electronics Community Forum
Electronics => Projects, Designs, and Technical Stuff => Topic started by: 741 on September 02, 2022, 10:43:40 am
-
Diodes Inc provide a file (diodes-spice-models.txt) with lots of subcircuit models (http://www.diodes.com/spice/downloadall (http://www.diodes.com/spice/downloadall)). Although it is possible to copy sections into LTSpice, I tried using this file via ".include diodes-spice-models.txt", then specifying the desired model using "CTRL+right-click" on a Zener symbol, entering a 'Value' of DI_BZX84C2V7.
The simulation stops immediately with a message Fatal Error: Could not open library file "B540C"
Inside diodes-spice-models.txt appears this:
.LIB B540C
*
.MODEL B540C D (
+LEVEL = 1 IS = 1.5672e-06 RS = 0.0209949
+N = 1.01362 IBV = 0.0001 CJO = 8.98694e-10
+VJ = 0.396195 MJ = 0.457747 FC = 0.5
+XTI = 0.000352915 EG = 0.750278 TRS1 = 0.00406277
+TRS2 = 2.17553e-07 BV = 50 TT = 0 )
*
.ENDL B540C
That looks like a self-contained definition (?). If it is self contained then why the error message? (Or, do I have to find a separate library file?)
-
Try commenting out the .LIB 540C by putting a * in front e.g. *.LIB 540C, it does appear to be self referencing, also comment out the .ENDL B540C
-
Try commenting out the .LIB 540C by putting a * in front e.g. *.LIB 540C, it does appear to be self referencing, also comment out the .ENDL B540C
Well, in ngspice, .LIB/.ENDL statements are handled correctly for libraries. But then the library needs to be included with a '.lib' statement where you want to include the library, and not '.include'.
Not sure LTSpice handles Spice libraries at all though.
-
Out of interest, I tried using .lib (instead of .include). The error message from LTSpice is the same though.
-
The problem seems to be SPICEs use of the .LIB statement:
1. Used to include an external library e.g. .LIB 540C.lib
or
2. Used inside a library at the start:
.LIB 540C
statements
.ENDL 540C
The second seems to have fallen out of use and that is what you seem to have encountered. They just copied a .lib file's text into this one large file but left the start and end statements, which are being misinterpreted as (1) not (2).
This is from the NGSPICE user manual:
2.8 .LIB
General form:
.LIB filename libname
Examples:
.LIB /users/spice/common/mosfets.lib mos1
The .LIB statement allows including library descriptions into the input file. Inside the
*.lib file a library libname will be selected. The statements of each library inside the
*.lib file are enclosed in .LIB libname <...> .ENDL statements.
If the compatibility mode (16.14) is set to ’ps’ by set ngbehavior=ps (17.7) in spinit
(16.5) or .spiceinit (16.6), then a simplified syntax .LIB filename is available: a warning
is issued and filename is simply included as described in Chapt. 2.7.
-
That file is unfortunately full of small syntax errors, that prevent importing cleanly into ltspice. I spent a couple of hours with sed, trying to clean it up, before giving up. It's easier to just copy the desired components across to a new file, rather than import it in full.
-
Except that you have to change the prefix attribute in the standard diode to "x" such it recognizes the new model.
The .inc and .lib should work then fine (try to create a file, like "MyLib.lib" with the BZX diode model only and do .inc or .lib).
PS: I've also spent an hour with that file, there are some encrypted models inside, not sure ltspice can read it..
-
Hi,
I prefer to include the models on the LTspice schematic like this:
(https://www.eevblog.com/forum/projects/spice-model-file-includes-lib-definition-ltspice-looking-externally-()/?action=dlattach;attach=1583788;image)
I have put the diode in a test circuit to measure forward voltage versus current.
By including the model on the schematic I can share a single file. If you use .lib the link to the file will be break if you try and share the .asc file with a friend.
In this case the model is a diode, we can use the Diode, D, prefix. CTRL_RIGHT CLICK on a component to access the attribute editor.
(https://www.eevblog.com/forum/projects/spice-model-file-includes-lib-definition-ltspice-looking-externally-()/?action=dlattach;attach=1583794;image)
If the model is a subckt then use the 'X' prefix.
I have attached the LTspice file.
Regards,
Jay_Diddy_B
[attachurl=3]