LTspice error “could not open Library file” when trying to use TL431 model from TI

I downloaded the LTspice model of TL431 from the Texas Instruments website, but I am not able to simulate the circuit given below due to this error:

"could not open Library file"

https://www.ti.com/product/TL431 the second model in the Design and simulations tab

• Welcome. Are you using Word to get a screen capture? Ugh. Anyway, see this article. – Spehro Pefhany Jun 29 at 18:03
• – G36 Jun 29 at 18:11
• @G36 I think the problem may be that the .include the OP has doesn't actually point LTspice correctly to the intended model file. I've no reason to suspect that if the OP failed the first time to realize what the error message is saying, that a new download of another workable set in a ZIP file will result in any improvement. The OP probably will still be flummoxed because the OP probably doesn't know where to unzip the files, or once unzipped, doesn't know how to tell LTspice where to find where they ended up at. ;) – jonk Jun 29 at 18:20
• @SpehroPefhany Hey I used the same procedure doesn't work. also, I am using the LtspiceVII model not the previous one. – SAM1 Jun 29 at 18:33
• Last time I simulated a TL431 I used the TL431_x model from SBORKA. Works fine. – Spehro Pefhany Jun 29 at 19:10

SIMULATION MODELS

TL431 Family Unencrypted PSpice Transient and AC Model (Rev. B)

SLVM071B.ZIP (130 KB) - PSpice Model

Inside that ZIP file, digging into the folders, there is a TL431.LIB file. That's the one you want to grab and place somewhere that is "convenient" to LTspice. In that file, you'll find this "card":

.SUBCKT TL431 7 6 11

That tells you a few things. The first is that the model is called "TL431" and that you need to make sure you use exactly that name when trying to access this model. The second is that there are three pins. The absolute value of the numbers shown don't actually matter that much. They are just "node numbers" that are then used inside the model. They could also be words, not numbers. So it really doesn't matter that much, today. (Old, old versions of Spice might still want numbers. But I haven't seen it forced, myself.) So you have three pins exposed by this model.

Also, it would help a great deal if you would also design a nice symbol for the device. LTspice has a semi-usable symbol editor, but it does take time to learn it well. If you are seriously interested in learning how to start using it, I did write something up a while back. It's located at this link. You can learn a lot from it. But it is also detailed and the concepts may be a struggle, at first. Just FYI.

The Schematic Symbol Drawing

I have this symbol:

Version 4
SymbolType CELL
LINE Normal 0 20 -4 16
LINE Normal 32 20 36 24
LINE Normal 0 20 32 20
LINE Normal 0 44 32 44
LINE Normal 32 44 16 20
LINE Normal 0 44 16 20
LINE Normal 16 64 16 44
LINE Normal 16 20 16 0
LINE Normal -16 32 8 32
WINDOW 0 32 0 Left 2
WINDOW 38 32 58 Left 2
SYMATTR SpiceModel TL431-Macro
SYMATTR Description TL431A 2.5V shunt regulator
SYMATTR ModelFile TL431.LIB
SYMATTR Prefix X
PIN 16 0 NONE 0
PINATTR PinName K
PINATTR SpiceOrder 1
PIN 16 64 NONE 0
PINATTR PinName A
PINATTR SpiceOrder 2
PIN -16 32 NONE 0
PINATTR PinName R
PINATTR SpiceOrder 3


What you need to do to use it is to open up an editor and paste the above text into it. Then save the text file using the extension ".ASY" for the file. So, for example, you should probably use "TL431.ASY" and place that into the LTspiceVII's sym folder. In my case, this is in my Documents folder under ".\LTspiceXVII\lib\sym". The reason you need to do this is so that LTspice can find it.

(As a side note, LTspice will not find it until you close LTspice and then re-open it. Apparently, LTspice caches what it finds, at start-up. So you need to re-start LTspice if you want it to recognize a new symbol you just made. Again, FYI.)

Also, please note that there is a line in the above text I just mentioned:

SYMATTR ModelFile TL431.LIB


That's how LTspice knows where to find the model for the above symbol. Without a model, the symbol is just a symbol and completely useless for simulation. So you must make sure that there is a ModelFile card that names the library file holding a model. The extension doesn't matter. It is, by convention, either ".LIB" or else ".MOD" but it doesn't have to be either of those. But you must get it named right.

Note that I didn't place a directory name? That's because I normally place these files in the default directory that LTspice uses to find models. However, you can place the model file anywhere. But if you do, you must either completely specify the location in the above card or else you must use the settings in LTspice to add a new directory to search. You can do that. And the first link I provided at the outset of this answer discusses how to do that, if you want.

You can also place a .INCLUDE card on your schematic. I get that. But it is a LOT better to bury a ModelFile card into the symbol, itself. Then you don't have to bother with all this extra typing, etc.

It is possible for you to have just one ".ASY" symbol but to have lots of models for it. LTspice will automatically find all the models and make them available in a drop-down list for you. So if you want to try out various models for the TL431, you can do that easily. For some information on this, see here where I talk a little about it. But the basic idea is to just slap in lots of .SUBCKT models into a single ".MOD" or ".LIB" file that is referred to by the symbol's ModelFile card. LTspice will observe all those models for you when it loads up the symbol. Then you can access these using the drop-down menu. However, you will need to give different names in the .SUBCKT card so that LTspice knows which of them you want when you select one. That's kind of important.

The above symbol drawing uses this technique. You can tell because it uses this card:

SYMATTR SpiceModel TL431-Macro


This is a give-away that the named model file might have more than one model in it.

A final note is for you to carefully examine the PINATTR's SpiceOrder and PinName. Please do note the order!! Here, find that K is first, A is second, and the reference R is last. So this is the order for the Spice model's pins in the X card which calls the code. You'll see this, soon enough.

The Spice Model to Match the Symbol Drawing

What you have is this:

* PSpice Model Editor - Version 16.0.0
*$* TL431 ***************************************************************************** * (C) Copyright 2009 Texas Instruments Incorporated. All rights reserved. ***************************************************************************** ** This model is designed as an aid for customers of Texas Instruments. ** TI and its licensors and suppliers make no warranties, either expressed ** or implied, with respect to this model, including the warranties of ** merchantability or fitness for a particular purpose. The model is ** provided solely on an "as is" basis. The entire risk as to its quality ** and performance is with the customer ***************************************************************************** * * This model was developed for Texas Instruments Incorporated by: * AEi Systems, LLC * 5777 W. Century Blvd., Suite 876 * Los Angeles, California 90045 * * This model is subject to change without notice. Neither Texas Instruments Incorporated * nor AEi Systems is responsible for updating this model. * For more information regarding modeling services, model libraries and simulation * products, please call AEi Systems at (310) 216-1144, or contact AEi Systems by email: * info@AENG.com. Or visit AEi Systems on the web at http://www.AENG.com. * ***************************************************************************** * ** Released by: Analog eLab Design Center, Texas Instruments Inc. * Part: TL431 * Date: 29NOV2017 * Model Type: Transient and AC * Simulator: PSPICE * Simulator Version: 16.0.0.p001 * Datasheet: SLVS543J - AUGUST 2004 - REVISED DECEMBER 2005 * ***************************************************************************** * * Updates: * * Final 2.10 * Modified the clamping diode parameters( Rs & N). * Replaced the dc volatage source of 2.495 V with ABM E27. * Modified internal feedback and reference implementation. * Implemented internal resistors using VCVS. * Validated the comparator open loop mode in PSpice 16.2 after model modification. * * Final 2.00 * Changed encrypted model to unencrypted. * * Final 1.00 * Release to Web. * ***************************************************************************** .SUBCKT TL431 7 6 11 * K A FDBK R_R18 0 N16955548 1 TC=0,0 C_C17 N16955362 0 1n C_C18 2 6 0.5u D_D11 N16976181 N16975344 DCLAMP C_C19 3 4 0.08u E_E23 2 N16955404 VALUE { {I(V_V16)*15.6} } C_C22 N16955548 0 1n R_R13 N16955401 N16955404 1 TC=0,0 E_E27 VREF 0 VALUE { IF(V(11,0)<2.495,V(11,0),2.495) } V_V16 N16955401 6 0Vdc R_R14 0 N16955362 1 TC=0,0 X_H8 7 N169559021 IKA 6 TL431_H8 E_E24 4 N16955473 VALUE { {I(V_V17)*10} } E_E28 N16955936 0 11 6 1 V_V7 N16976181 6 2 G_ABM2I2 6 N16975344 VALUE { IF((V(3)-V(6))< 0 , 1.73*(V(3)-V(6)) -1U , + -1U) } R_R15 N16955470 N16955473 1 TC=0,0 V_V17 N16955470 6 0Vdc G_G4 6 2 VREF N16955936 0.11 R_R16 0 N16955493 1 TC=0,0 D_D12 N169559021 N16975344 DCLAMP R_R17 N16955529 N16955532 1 TC=0,0 C_C21 N16955493 0 1n E_E25 3 N16955532 VALUE { {I(V_V18)*100} } V_V18 N16955529 2 0Vdc V_V19 N16985445 0 0Vdc .ENDS *$
.subckt TL431_H8 1 2 3 4
H_H8         3 4 VH_H8 1
VH_H8         1 2 0V
.ends TL431_H8
*$.model DCLAMP d + is=1.35e-011 + rs=0.005 + n=0.001 + cjo=4.5e-011 + vj=0.75 + m=0.302 + tt=5.04e-008 + bv=100 + ibv=0.001 *$


If you scroll down a bit, you'll find these lines:

.SUBCKT TL431 7 6 11
*             K A FDBK


The first is the actual .SUBCKT card. But the second is a comment. The comment is telling you that this model was designed with the idea where the first pin parameter is the cathode, the second pin parameter is the anode, and the last pin parameter is the reference pin for the model. It's very, very important that you double-check this order and compare it against any symbol you create or use. In my symbol case, it is K, then A, then R. This appears to match up with the model comment. So all should be good.

Now, the above model has some problems to it. One of them is the direct reference to a node called 0. This always means "ground" to LTspice (and any other Spice program.) But the device doesn't necessarily have access to ground. So the model is, already, no good to use. It assumes that the anode is tied to ground. But this isn't necessarily the case in any real circuit. So you will need to edit the model to fix that problem. You need to know how to do that.

Also, the model uses "E" cards. This works great in PSpice. But perhaps not so much in LTspice. From the LTSpice help on the E source, find: "It is better to use a G source shunted with a resistance to approximate an E source than to use an E source. A voltage controlled current source shunted with a resistance will compute faster and cause fewer convergence problems than a voltage controlled voltage source. Also, the resultant nonzero output impedance is more representative of a practical circuit."

So, you may wish to follow those instructions. Or not. It's your call. The main problem, though, will be the use of 0 where it should not be used in the model. So you really should fix that much, at least.

So here is my TL431.LIB file:

*============================================================================
*                                   TL431
*============================================================================
*
* Calling convention:
*
*              CATHODE
*              |  ANODE
*              |  |  REFERENCE
*              |  |  |
*.SUBCKT TL431 K  A  R
*
* The above calling convention must match up with the pin order of any symbol
* made for the device. Please double-check this if you decide to create a
* symbol in LTspice for this device.
*
*
*
*----------------------------------------------------------------------------
* TL431-Macro            TI Macromodel for the TL431                     1992
*----------------------------------------------------------------------------
* (Modified ordering of the pins per the above calling convention.)
*
.SUBCKT TL431-Macro 3 2 1
V1  6  7  DC  1.4V
I1  2  4  1E-3
R1  1  2  1.2E6
R2  4  2  RMOD 2.495E3
R3  5  7  .2
D1  3  6  DMOD1
D2  2  3  DMOD1
D3  2  7  DMOD2
E1  5  2  POLY(2)  (4,2)  (1,2)  0  710  -710
.MODEL RMOD RES (TC1=1.4E-5 TC2=-1E-6)
.MODEL DMOD1 D (RS=.3)
.MODEL DMOD2 D (RS=1E-6)
.ENDS
*
*
*----------------------------------------------------------------------------
* TL431-Basso            Chris Basso's model for the TL431               2005
*----------------------------------------------------------------------------
*
.SUBCKT TL431-Basso k a ref
G1 a 2 5 ref -250u
Q1 k 2 1 QN3904
R1 1 7 240
R2 7 a 6.6k
Q2 k 7 a QN3904 50
D1 ref k DN4148
C2 7 a 1n
D2 a k D2_mod
C1 k 2 43p
V1 5 a DC=2.49
D3 a 2 D3_mod
.MODEL QN3904 NPN AF=1.0 BF=300 BR=7.5 CJC=3.5PF CJE=4.5PF
+ IKF=.025 IS=1.4E-14 ISE=3E-13 KF=9E-16 NE=1.5 RC=2.4
+ TF=4E-10 TR=21E-9 VAF=100 XTB=1.5
.MODEL DN4148 D BV=100V CJO=4PF IS=7E-09 M=.45 N=2 RS=.8
+ TT=6E-09 VJ=.6V
.MODEL D2_mod D BV=36 CJO=4PF IS=7E-09 M=.45 N=1.3 RS=.8
+ TT=6E-09 VJ=.6V
.MODEL D3_mod D N=0.01
.ENDS
*
*
*----------------------------------------------------------------------------
* TL431-RevB            TI's PSpice/AC model for the TL431, Rev B.       2009
*----------------------------------------------------------------------------
* (Modified to place sub-models and sub-circuits within the main .SUBCKT.)
* (Also modified to remove references to node 0, changing them to node 6.)
*
.SUBCKT TL431-RevB 7 6 11
R_R18         6 N16955548  1 TC=0,0
C_C17         N16955362 6  1n
C_C18         2 6  0.5u
D_D11         N16976181 N16975344 DCLAMP
C_C19         3 4  0.08u
E_E23         2 N16955404 VALUE={{I(V_V16)*15.6}}
C_C22         N16955548 6  1n
R_R13         N16955401 N16955404  1 TC=0,0
E_E27         VREF 6 VALUE={ IF(V(11,6)<2.495,V(11,6),2.495) }
V_V16         N16955401 6 0Vdc
R_R14         6 N16955362  1 TC=0,0
X_H8          7 N169559021 IKA 6 TL431_H8
E_E24         4 N16955473 VALUE={{I(V_V17)*10}}
E_E28         N16955936 6 11 6 1
V_V7          N16976181 6 2
G_ABM2I2      6 N16975344 VALUE={ IF((V(3,0)-V(6,0))< 0 , 1.73*(V(3,0)-V(6,0)) -1u,-1u) }
R_R15         N16955470 N16955473  1 TC=0,0
V_V17         N16955470 6 0Vdc
G_G4          6 2 VREF N16955936 0.11
R_R16         6 N16955493  1 TC=0,0
D_D12         N169559021 N16975344 DCLAMP
R_R17         N16955529 N16955532  1 TC=0,0
C_C21         N16955493 6  1n
E_E25         3 N16955532 VALUE={{I(V_V18)*100}}
V_V18         N16955529 2 0Vdc
V_V19         N16985445 6 0Vdc
.subckt TL431_H8 1 2 3 4
H_H8         3 4 VH_H8 1
VH_H8         1 2 0V
.ends TL431_H8
.model DCLAMP d(
+ is=1.35e-011
+ rs=0.005
+ n=0.001
+ cjo=4.5e-011
+ vj=0.75
+ m=0.302
+ tt=5.04e-008
+ bv=100
+ ibv=0.001)
.ENDS


Do note that there is more than one model in this file. That is not a problem for the symbol I provided at the outset, above. (As I'd pointed out, if you use the SpiceModel "SYMATTR" card to name the device, then this is just fine to do.) It also isn't a problem if you just use the Value line for the symbol. But then LTspice won't help you with a drop-down list if you have more than one model in the model file.

Anyway, if you snap a copy of that text immediately above here and save it, correctly, then I think you may be able to get things working okay and you can try out a few different models, too.

In the above, I have not corrected the "E" cards per the help suggestions in LTspice. I left them "as is." However, I did fix up the 0 pins where I found them -- so that they refer, instead, to the anode.