From: "analogspiceman" Date: Mon Dec 26, 2005 1:51 am Subject: Re: New Features? analogspiceman --- In LTspice@yahoogroups.com, Alex Jacobson wrote: > The one continuing thread and difficulty of the members is to > incorporate new models and subcircuits into their designs. The > very high quality of the GUI, the solver, the support you and > many other members have given, and the price of LTspice, have > mushroomed this tool. LT is a relatively small company and many > times the users want to try chips from other vendors, create > their own subcircuits etc. Many vendors have excellent PSpice > models for instance. Well you're in luck because LTspice can probably read 99 percent of Pspice models and subcircuits error free without modification. And, although occationally some topics are not covered in Help or elsewhere, I respectfully submit that most of the inexperienced members who have difficulty incorporating new models into their designs have not really made an effective effort to find the existing links to readily available solutions and topics already provided in this Yahoo group and in the Help chapters of LTspice itself. To wit, from the "FAQ" chapter in LTspice's built-in Help: "Third-party Models: This section explains the basics to adding a third-party model to LTspice/SwitcherCAD III." [... rest of help topic at end of post] > It is simply not possible for a user to follow the online > tutorial, and achieve success routinely. Could you be more specific, please (about what you meant by online tutorial)? Were you referring to something in this Yahoo group, or something in LTspice's Help, or perhaps one of LTspice's example schematic files, or ...? > It is between an 8 and 20 hour struggle to understand the > dependencies and directory structure. ??? Perhaps you might consider familiarizing yourself with the search tools of the "experts". From a Yahoo group message search and LTspice's Help file search (about ten minutes): "The symbol and library search paths are not programmable for you. Someday it might be [...] but for now, you are stuck with the hard- wired search paths documented in the help file." - message 7273 to this Yahoo group posted by Mike Engelhardt on Sep 1, 2005. "LTspice looks first in the directory \lib\sub and then in the directory that contains the calling netlist, where is the directory containing the scad3.exe executable, typically installed as C:\Program Files\LTC\SwCADIII." - ".INCLUDE" topic from the Dot Command chapter in LTspice's Help. > What is needed is a tutorial with every step tried without a > single little thing that the expert does without thinking left > out. For good measure, the procedure should be repeated for a > downloaded model from competitor website, ca. National, Analog, > TI, etc. From the FAQ in this Yahoo group (did you already read these?): http://groups.yahoo.com/group/LTspice/files/%20FAQ/faq_4.txt Q: How can I add subcircuits to LTspice? A: You WILL find many answers when you search the messages for words like library, symbol or FAQ. Please read first the programs help: Help->Schematic Capture->Editing Components->Creating New Symbols Help->Help Topics->FAQs->Third party models Help->Help Topics->FAQs->Mosfet Regards and Happy Holidays -- analogspiceman :) Third-party Models (continued): Basically there are two types of third party SPICE models, those described with a .MODEL statement and those defined with a .SUBCKT. Models given as .MODEL statements are for intrinsic SPICE devices like diodes and transistors. The .MODEL statement gives the para- meters for the specific component. The behavior of the device it already known by SPICE, only the parameters need to be given to finish specifying the component's electrical characteristics. On the other hand, models given by .SUBCKT statements define the modeled component by a collection of circuitry of intrinsic SPICE devices. For example, the SPICE model of an opamp would be given as a subcircuit. The way how to include the model in LTspice depends on whether the model is given as a .MODEL statement or a .SUBCKT. Example for an NPN transistor defined with a .MODEL statement: 1. Add an instance of the symbol NPN to your schematic. 2. Edit the value "NPN" to be "BC547C" to coincide with the name used in the target .MODEL statement. 3. Now either: a) Add the .MODEL BC547C... statement as a SPICE directive on your schematic; or b) If you have a file bipol.lib containing your .MODEL BC547C... (other models may too be in this file), then add the SPICE directive ".INCLUDE bipol.lib" on your schematic. Note that "bipol.lib" must be the complete name with any file extensions and that Windows Explorer defaults to not showing the file exten- sion. So you if you have a file called "bipol.lib.txt", which you can edit/view in notepad, and Windows Explorer shows you the file exits as "bipol.sub". The SPICE directive to include this file is ".inc bipol.sub.txt". If you used, ".inc bipol.sub" you will get an error message that that file can't be found; or c) You can alternatively add the .MODEL BC547C... statement to the file typically installed as C:\Program Files\LTC\SwCADIII\lib\... ...cmp\standard.bjt. If you do that you will automatically see the model as a choice was editing the NPN transistor. If you edit this standard.bjt file outside of LTspice, you will have to restart LTspice for it to notice that the file has changed. Example for a 5-pin opamp. This will be defined with a .SUBCKT statement: 1. Add an instance of symbol opamp2 to your schematic. 2. Edit the value "opamp2" to "TL072" on the schematic to coincide with the name of the .SUBCKT. 3. Either: a) Paste the ".SUBCKT TL072 ..... .ENDS" definition as one multi- line SPICE directive to your schematic; or b) If you have a file called "TI.lib" containing the definition of subcircuit TL072 (it will look like a line that starts out as ".SUBCKT TL072...") add the SPICE directive ".INCLUDE TI.lib" to the schematic. It is possible to create a new symbol and program it to automatic- ally include the necessary model for the simulation. See help section Schematic Capture=>Creating New Symbols. Example for a 3-pin NPN transistor but defined with a .SUBCKT statement: 1. Add an instance of symbol NPN to your schematic. 2. Move the cursor over the body of the newly-placed NPN symbol instance. Press RightMouseButton. A dialog box will appear. Change Prefix: QN to Prefix: X. This causes this instance of the symbol to netlist as a subcircuit instead of an intrinsic bipolar transistor. 3. Edit the value "NPN" to be "BFG135" to coincide with the name given on the .SUBCKT line. 4. Then either: a) Add the .SUBCKT BFG135 lines to your schematic; or b) If you have a file Phil.lib containing your .SUBCKT BFG135 ... (others may be too in this file) then you have to add a command line .INCLUDE Phil.lib One aspect of adding a .SUBCKT model to LTspice is that you need have the symbol used to call the subcircuit and the model agree on the same pin/port netlist order. The above examples assume the 3rd party model you're adding follows popular pin order conventions. Further related information is in the help sections Schematic Capture and LTspice. The basic idea is that the schematic capture program generates a netlist that the simulator, LTspice reads. Any aspect of importing 3rd party models can be resolved by understanding SPICE netlist syntax and how the schematic capture program generates that syntax. There are also tutorials prepared on this topic archived at the independent users' group at http://groups.yahoo.com/group/LTspice. Hello "analogspiceman", Thanks for this great explanation regarding models, subcircuits and symbols. I have updated today my older description which also helps how to make symbols for subcircuits. It's now V1.8. Files > Tut > Symbol Types For Subcircuits > Symbol_types.txt Best regards, Helmut