Electronic – How to create a subcircuit in LTspice which is in a txt file

ltspice

I've used LTspice for a long time but I've never made a subckt. When I google "create a LTspice subckt from a txt file", there are no clear steps showing how to do it.

One post said to first change the .txt extension to .subckt then click on some pull-down menu which is in an old version of LTspice and no longer there.

Is there a simple 1,2,3 steps in how to do this?

What I have is a .txt file of a subckt. It's a 4 pin device with several MODELs and SUBCKTs within.

Best Answer

LTspice doesn't care about extensions. Whether the file is a .sub, or .lib, .cir, .txt, or even without extension, it reads the file and if the syntax inside is correct, it will use that file.

Therefore, if your .txt file is already a subcircuit, all you need to do is to add a relevant .lib line inside your schematic, while making sure that you spell the filename properly, say .lib /path/to/some/subcircuit.txt (as you probably know, Windows has a history of hiding extensions, unless manually set otherwise).

If all you need is one subcircuit out of that .txt file, the .lib command ensures that everything inside the file is available in the schematic (as long as everything obeys the syntax). Then simply use the name of the desired .subckt in a symbol of your choice (or a SPICE directive).