LTspice v17.1.x - How to add custom library? - Page 1
Forum section: electronics / general

author: Faranight
author_rank: Unknown
timestamp: October 17, 2023, 11:34:09 am
content: Hello! What is the proper way to add new libraries to LTspice? I recently installed the new LTspice version 17.1.x (for all users), and the official libs seem to be missing a lot of components. I thought I'd add a 3-rd party library with stuff that I need, but I think I'm gonna need some help doing this because I found a lot of conflicting and outdated information on the web.I found this component collection, which seems to have the .model directives present inside standard.bjt for some required components:Website:http://bordodynov.ltwiki.org/Library link:http://bordodynov.ltwiki.org/lib.zipI downloaded the zip and extrcted it to a custom folder in: C:\Users\User\Documents\LTspice. Then I started LTspice and added custom library paths in the control panel (see pics below). Finally I restarted it and opened a new schematic. Added a "npn" transistor symbol, right-clicked it and chose "Pick New Transistor". Unfortunately, the transistor "2SC3357", which is present in the new lib's "standard.bjt" file as a ".model" directive (yes, I checked with a text editor), does not appear in the list of NPN transistors in LTspice. I tried changing the paths to various subfolders, but it doesn't seem to be working.Code:.model 2SC3357 NPN (IS=684.2e-18 BF=161.1 VAF=51 IKF=574.6m BR=10.71 VAR=2.1 IKR=28.05m ISE=1.0e-18 NE=1.193 ISC=6.211e-18 NC=1.1 RB=3 IRB=75.9e-5 RBM=1 RE=2.67 RC=3.5 CJE=1.847p VJE=1.014 MJE=464.8m CJC=1.086p VJC=617.4m MJC=353.8m XCJC=0.1 FC=0.5 TF=23p XTF=0.39 VTF=0.668 ITF=0.06 TR=100p PTF=20 EG=1.11 XTI=3 XTB=0 Vceo=12 Icrating=100m mfg=NEC)Any ideas how to solve this?EDIT: I followed the recommended paths:https://ez.analog.com/design-tools-and-calculators/ltspice/w/faqs-docs/18474/ltspice-17-1-default-file-locations-windows

author: Ian.M
author_rank: Super Contributor
timestamp: October 17, 2023, 01:01:37 pm
content: The Bordodynov library was originally intended to replace and extend the LTspice VII standard library, overwriting it.Try manually editing the transistor's part number (its 'value' field - NPN) by right clicking it and entering the exact part number 2SC3357, as I *think* LTspice only looks at the default library's standard.* files when building the picklist dialogs. If that doesn't work, you'll also need to extract the model(s) you need from the Bordodynov standard.bjt and either add them directly to your schematic or put them in an include file and .lib it.

author: Faranight
author_rank: Unknown
timestamp: October 19, 2023, 08:01:02 am
content: Hmm, I didn't know you could rename elements like that. Yes, right-clicking the NPN text and naming it "2SC3357" worked, but I also had to manually add the SPICE directive text and copy/paste the .model line in there for the 2SC3357 transistor. This seems to be working for now. Still, is there a way to add/import these components so that they appear in the component list? I don't want to overwrite the original LTspice libraries with Bordodynov's since an update might overwrite them back.Regards, fn

author: Ian.M
author_rank: Super Contributor
timestamp: October 19, 2023, 08:28:59 am
content: LTspice Update parses the standard.* files and preserves 3rd party single line models for devices not in the update, however its a sucky way of doing things even if you edit the model's mfg parameter to prepend the library name (so they sort together).

author: SiliconWizard
author_rank: Super Contributor
timestamp: October 20, 2023, 02:24:10 am
content: For transistors and diodes that are not in the standard file, I usually create dedicated symbols and attach the spice model to them, rather than modify the standard files themselves.A bit more work, but this way you can actually use a full spice model from manufacturers (which often contain more tha just a .model line) rather than only a .model spice directive.

author: Faranight
author_rank: Unknown
timestamp: October 20, 2023, 03:45:33 pm
content: I've not used LTspice a lot so my knowledge is lacking. Could you shine some light on how to do that and what exactly to do? What parameters besides .model are of interest?The transistor I'd like to do next is:https://www.nxp.com/part/BFU590Q#/

author: SiliconWizard
author_rank: Super Contributor
timestamp: October 20, 2023, 08:03:00 pm
content: Quote from: Faranight on October 20, 2023, 03:45:33 pmOK, that gives you a typical example to work with. First, locate the Spice model if the vendor provides it. You can find it here:https://www.nxp.com/products/radio-frequency/rf-discrete-components-low-power/rf-wideband-transistors/2-ghz-rf-wideband-transistors/npn-wideband-silicon-rf-transistor:BFU590Q?fpsp=1#documentationDownload the archive "BFU5xx family SPICE GP model v2", it contains all Spice models for their BFU5xx family. Inside you'll find the one for the BFU590Q which is the file: BFU590Q_SPICE_GP.PRM. You can open it in a text editor, it's just a Spice model. What you'll typically see here is that on top of the model for the transistor (".MODEL BFU590D NPN ...") they implement parasitics (capacitance and inductance) for the particular package it comes in SOT89), so that the actual Spice model to use is BFU590Q (".SUBCKT BFU590Q 1 2 3"). The Spice pin order (netlist order) is commented just above ("* 1: COLLECTOR; 2: BASE; 3: EMITTER").So to answer you question about the additional parameters, here they model the parasitics due to the package itself. Of course this will potentially matter for high-frequency designs, a lot less so for lower frequencies.Another thing typically modeled in vendor Spice models are any additional diodes that the transistor may embed (such as explicit diodes between source and drain, for instance, for MOSFETs.)AD has a tutorial for adding third-party models:https://www.analog.com/en/education/education-library/videos/5579239882001.htmlNow, first, you'll need to edit the BFU590Q_SPICE_GP.PRM Spice model file - turns out that LTspice doesn't recognize the IMAX parameter, so just delete the "+IMAX 2.00" line in the file and save.In this case, what you'll typically do is:- Copy the Spice model file to the: C:\users\xxx\AppData\Local\LTspice\lib\sub directory- Open the generic NPN transistor symbol: C:\users\xxx\AppData\Local\LTspice\lib\sym\npn.asy in LTspice (filter symbols in the open dialog)- Save it as a new symbol in the same directory (for instance BFU590Q.asy)- Edit the attributes of the symbol: menu Edit/Attributes/Edit Attributes: set BFU590Q_SPICE_GP.PRM for the ModelFile attribute, and BFU590Q for the SpiceModel attribute (it's the subckt name), and change the prefix to "X" (instead of QN, this is a quirk of LTspice, or of Spice itself actually, if the prefix is not X - or, I think U should also work - you can't use a Spice subckt)- Check that the pin numbering matches the Spice model (in this case, it does): right-click on each pin of the symbol to see the pin parameters (Label, Netlist Order) - the "Netlist Order" number corresponds to the Spice netlist order for the subckt- Save the symbol- Restart LTspice (yes you need to restart it for it to reload all symbols...)You can also manually edit the symbol file (.asy) in a text editor, I find it easier than the quirky symbol editor, unless you actually need to create new graphics for a symbol.Yes, that's not exactly a picnic but once you get the hang of it, that's ok. I suggest creating a shortcut for the "C:\users\xxx\AppData\Local\LTspice\lib" directory so that next time you don't waste a few minutes wondering where the heck this LTspice library directory is.The BFU590Q symbol should appear in the Component Symbol list, you can select it and add it to your schematics.

author: Faranight
author_rank: Unknown
timestamp: October 24, 2023, 10:20:10 am
content: Finally had some time to test this.I managed to follow your instructions, and ended up with a working symbol. I didn't save the files in the AppData folder but rather in a custom folder in my Documents folder. The trick seems to be to add a new library path to the list - the symbol search path should end in a \sym folder while the library search path seems to have to end in the /sub folder where the PRM file is located, not the parent folder (assuming both /sym and /sub are located in the same folder). Also, you were right... setting "SYMATTR Prefix Q" in the .asy file makes LTspice complain that the model cannot be found while setting it to "SYMATTR Prefix X" works fine. Weird. My guess is this prefix dictates where the program looks for the SPICE model.Cheers!