External reference in LTspice

Thread Starter

cmartinez

Joined Jan 17, 2007
8,252
Here's a question that I'm sure has been asked many times... but I'm posting it here anyway as a last resource.

I'm trying to include a reference to an external file in LTspice, and I keep getting this bunch of errors. From duplicate "Flag" to other strange stuff. I've already tried to use the ".inc" and ".lib" directives and I just can't make them work.

My problem is simple, I'm trying to point my circuit to another circuit (a power supply) that I've already drawn.
So I drew the power supply in a file named "pwrspply.asc" (it works perfectly), and in it I named a node "120". Then I drew the other circuit in another file, named another node "120" and used the directive ".inc pwrspply.asc" ... and it just DOESN'T WORK...

What am I doing wrong?
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,252
I finally made it work!
Something to do with saving the circuit's defaults, and the <InstName> in the .asy file has to be left blank. And in the attributes table of the same file, the prefix also has to be left blank, also the symbol type has to be set to "Block".
But on the other hand, the sym's running incredibly slowwwwwwww....
 

Attachments

ronv

Joined Nov 12, 2008
3,770
I finally made it work!
Something to do with saving the circuit's defaults, and the <InstName> in the .asy file has to be left blank. And in the attributes table of the same file, the prefix also has to be left blank, also the symbol type has to be set to "Block".
But on the other hand, the sym's running incredibly slowwwwwwww....
@cmartinez , Could you detail the way you had to do it? I haven't been able to get it to work. :(
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,252
@cmartinez , Could you detail the way you had to do it? I haven't been able to get it to work. :(
Well... the key was in what @Alec_t suggested... that I looked up "Rules of hierarchy" in LTspice's help.
But I didn't like the end result much anyway.... besides being slow, it also lost accuracy.

Basically what you do is:
  • Draw a symbol, or assembly file (an .asy file) that represents the simplified version of the .asc file that you're trying to include as a subcircuit.
  • That assembly file must include the labels from the original .asy file drawn as pins (Edit -> Add Pin/Port) using the same name as in the original subcircuit
  • Make sure that for both subcircuit.asy and subcircuit.asc files in Control Panel -> Save Defaults, Save Subcircuit Node Voltages, Save Subcircuit Device Currents, and Save Internal Device Voltages are checked.
  • Then you go to Edit -> Attributes -> Edit Attributes and a Symbol Attribute Editor dialog box appears
  • Leave everything blank, except the two bottom rows, in the Description Row you can write anything you want, and in the ModelFile row write the complete name of the file being referenced. Also, make sure that the pull down on top of this dialog has "Block" selected.
  • Go to Edit -> Attributes -> Attribute Window and select the first option "InstName", then insert it anywhere you want in the .asy file
  • The .asy file must be located either in LTspice's library path, or in the same directory as your end circuit
  • Finally, in your end circuit, insert your new component, and you're done
  • One last thing, both subcircuit.asy and subcircuit.asc (the name subcircuit is just a suggestion) files must have the exact same name, and must not contain any spaces in their names.
But as I said, it's very slow and inaccurate... don't know if I'm doing something wrong or not, or if this could be improved...
Just download and check the three files that I attached in post #4. The draft4.asc file is the end circuit... run it, and you'll see what I mean.
 
Top