Electronic – Embed Component into LTSpice

ltspice

I have downloaded the Spice file for the TLV9062 here. I have now created a custom symbol LTV9062 that lives in my AutoGenerated folder and links to the TLV9062.cir file for the Spice model.

When I make a schematic it runs fine on the original machine but won't work on any other computer because the folder path is different for the symbol and the circuit. Is there some way I can include this symbol and circuit such that it takes it from the same directory as my schematic?

What I want to do is to be able to zip my schematic and all custom circuits that it uses into a single folder. When I email it to someone I want them to be able to run the schematic without having to relink all these parts.

I tried looking at libraries but am still confused.

Best Answer

Simplest Approach

That .CIR file looks like what could also be .LIB or .MOD (or whatever, really.) It's just a text file with SUBCKTs and MODELs. And like any other part of a Spice deck, you can insert this directly into the schematic. Doing so may be distracting because there will be a LOT of text now appearing in your schematic. But doing it this way guarantees that the MODELs and SUBCKTs follow the schematic since the entire text is included in the schematic. That means it is really easy -- just copy and send the schematic.

You may complain at this point that you also built a custom schematic symbol, as well. If so, my response would be to point out that there was no need to do so for an opamp like this. There already is a customizable symbol located in every LTspice installation. Just hit F2, select the [Opamps] folder there and scroll over until you see the symbol name, "opamp2", located towards the end. Use that symbol and paste it into your schematic. Now, just right-click carefully over the word "opamp2" that appears near the symbol and edit it so that it says "TLV9062".

If you follow the above process, then your schematic will completely contain all of the spice deck required to run the schematic. It will be built into the schematic. So you won't even need to transfer a folder of files. You can simply hand out the single schematic file. It will run in any plain vanilla installation of LTspice.

If you have more such models to include, that just means lots more text on your schematic. But you can re-arrange things so that it is still readable for anyone.

Of course, if it turns out that you really do need to create custom symbols (and there is a need for that), then this is no longer workable. Symbols require a symbol file (extension is .ASY) and so now it would be appropriate to take the next step.

Schematics with Custom Symbols

If you need to use custom symbols (which can apply to an hierarchical schematic in a .ASC file of the same name or can apply to any SUBCKT you write), then you will need to save these symbols as files so that LTspice can find them and apply them.

Any symbol you create can also include the file name containing the model. There is a special attribute called "ModelFile" which you can include and modify, specifying the name of the file containing one or more models and subcircuit definitions. If you do NOT use this method, then you probably will need to include a ".INCLUDE" Spice statement on your schematic that includes some specific file containing these models and subcircuits.

In your case, you are provided with a .CIR file. So just save it inside the same folder where you keep your schematic. Then just use .INCLUDE and give that file name. No need to add a directory. LTspice will find it if the file is in the same folder with the schematic it is working on.

If you use the ModelFile attribute, again do not include a directory. Just the file name for the .CIR file. (Include the extension, .CIR, though.) LTspice will find the model file, as well.

This way, you can just transfer the folder and all needed, related files. Anyone should be able to run the schematic.

Related Topic