External reference in LTspice

Discussion in 'General Electronics Chat' started by cmartinez, May 5, 2015.

  1. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,574
    2,543
    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?
     
  2. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,801
    1,105
    Look at 'Rules of hierarchy' in the Help. Did you create a symbol as stated there?
     
    cmartinez likes this.
  3. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,574
    2,543
    So that's how you do it!
    Thank you so much. I'm going to try it and then get back here if I run into trouble again.
     
  4. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,574
    2,543
    Almost there... but still not working.
    The circuit Draft4.asc reports no errors, but it doesn't output the voltage produced by 120PwrSply.asc. I wonder what I'm missing.
     
  5. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,574
    2,543
    @MikeML this sort of thing seems to be right up your alley. Your opinion would be thoroughly appreciated.
     
  6. hajivitra

    New Member

    Apr 7, 2015
    13
    0
    nice information
    thanks all
    [​IMG]
     
  7. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,574
    2,543
    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....
     
  8. crutschow

    Expert

    Mar 14, 2008
    13,028
    3,237
    Please do not respond to the information in these threads unless you have something additional to contribute to the subject being discussed or are the original poster. :rolleyes:
    Thanks.
     
    cmartinez likes this.
  9. ronv

    AAC Fanatic!

    Nov 12, 2008
    3,292
    1,255
    @cmartinez , Could you detail the way you had to do it? I haven't been able to get it to work. :(
     
  10. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,574
    2,543
    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.
     
Loading...