The first thing to do with any spice simulation problem is check your netlist, which is the easiest way to debug with graphical spice packages. If you don't have a .lib and the name of your downloaded package then you have a problem. (you can do this in view->spice netlist)
The second thing is you need to get your paths straight. If you do have a .lib statement, then the path of your .subckt file needs to follow the .lib statement. Example: if your .subckt file was named NCP1217.cir (or whatever its extension is, they are all text files anyway) was located in C:\LTC\libraries then the spice command that needs to show in the spice netlist is:
.lib c:\LTC\libraries\NCP1217.cir
If you put your file in the LTspice\lib\sub folder you don't need to provide the entire path.
There are ways through the attributes list (in your symbol files, .asy to be more specific) to include the .lib statement.
The last thing is you need your X line in the netlist to have the appropriate nodes, double check each node of the lt spice netlist and make sure it matches up with the netlist in your 3rd party model. Then if you have multiple devices, the last thing should be the name of the subcircuit.
Here is an example:
XU1 posrail negrail posterminal negterminal output DEV1376
Keep in mind that no spice model will even come close to the real world, most all models are simplified in spice to model selected parameters in the datasheet by the manufacturer and only approximate the real world. (after all if they really did a transistor model of each device, all you would have to do to create a copy of the device is download the spice file) Some models will give some kind of disclaimer as to what the model can and can't do.
Best Answer
I downloaded your linked ZIP file. The one described this way on the page you linked in your question:
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":
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:
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:
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:
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:
If you scroll down a bit, you'll find these lines:
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:
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.
Related Posts