importing a model to LTspice.

Discussion in 'General Electronics Chat' started by strantor, Oct 18, 2011.

  1. strantor

    Thread Starter AAC Fanatic!

    Oct 3, 2010
    4,302
    1,988
    I've already read the thread here. Situation is a little different; I don't have any of the file extensions explained there. I want to import this device into LTSpice but it doesn't seem to have the right files. It has files for TINA TI and PSpice (spice files are at the bottom of the page)
     
  2. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Well, the first thing is to get the OPA4140.LIB file out of the .ZIP download, and save it as OPA4140.SUB in:
    \Program Files\LTC\LTSpiceIV\lib\sub\
    or whatever your particular path is to \lib\sub\
    My general "rule of thumb" for a naming convention is, if a file has just one .subckt in it that I'll be using, I'll give it a .sub suffix; if it has multiple .subckt's in it, I may still give it a .sub suffix but more often give it a .lib suffix.

    Then you need to look at the .subckt line. This one is:
    The netlist portion is: -IN +IN V- V+ Vout
    and there are 5 items in the list - so, you need an opamp symbol with exactly 5 I/O pins.

    Start LTSpice, select File/Open, next to "Files of type:" choose "Symbols (*.asy)".
    Navigate to lib\sym\opamps
    Open opamp2.asy
    Save it as OPA4140.asy (I always save it as the new name 1st, so I don't mess up the original)
    Looking back at the .SUBCKT line at our netlist:
    -IN +IN V- V+ Vout
    This one's pretty easy because the parameters are self-explanatory.
    The order of the netlist is very important:
    1st: -IN
    2nd: +IN
    3rd: V-
    4th: V+
    5th: Vout
    Now you look at your newly-saved OPA4140.ASY and right-click on the box next to the "-" (inverting input pin) to see what the netlist order is. You see that it's 2 - that won't do.
    Change it's netlist order to 1, and click OK.
    Right-click on the box to the left of "+" (noninverting input), and check that one. It's netlist order is "1", so change it to 2; then click OK.
    Do the same with the -, + supply inputs (they're reversed from the standard) and finally make sure the output is netlist order 5.

    Next, you need to tell the symbol where the .subckt is.
    Click on Edit -> Attributes -> Edit Attributes
    On the bottom line is "Model file:" ; enter: OPA4140.SUB
    The next line up is "Description:" - you can leave it as-is, but you will help yourself later if you actually enter a meaningful description here.
    I put: "TI-Prec, LN, RRO, 11MHz JFET OpAmp"
    which indicates to me that it's a TI model, and the rest is an abbreviation of the text from the TI page;
    Prec = precision
    LN = low noise
    RRO = rail-to-rail output
    11MHz = bandwidth
    JFET = JFET input (very high impedance)

    Now you need to tell it the .subckt name.
    Type OPA4140 in the Value field.
    Note that since this is a .subckt, the prefix MUST be X. If the prefix is not X, LTSpice won't be looking for a .subckt, it will be looking for a .model (name) and it won't find that.
    Save the file again, and exit/restart LTSpice. You should now be able to find the OPA4140 in the Opamps subdirectory when you go to place a part.
     
  3. strantor

    Thread Starter AAC Fanatic!

    Oct 3, 2010
    4,302
    1,988
    Thanks SGT. I did all that and it worked great. I replaced all 4 opamps in my circuit with the OPA4140. Now it won't sim. it sits there and shows this in the bottom status bar:
    [​IMG]

    just mulling over random numbers for "Con" and "inter"
    Is it because the opamp model is much more complex for the OPA4140 than the basic model LTC1051 that I was using?
     
  4. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Yes, that model is pretty complex.
    Try going into the control panel (click on Simulate -> Control Panel)
    and under the Compression tab, change Absolute Current Tolerance from 1e-009 to 1e-005.
    Then click the Spice tab.
    Change Gmin to 1e-9, Abstol to 1e-9, Reltol to 0.001, Chgtol to 1e-9, voltol to 1e-5

    See if that helps.
     
  5. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    If it's still taking a long time to start/run, then try editing the .tran line, check the box that says "Start external voltages at 0v", and also the "Skip the initial operating point" box.

    You'll then want to start saving data later than 0, as the starting numbers will be pretty outrageous. Start saving data at perhaps 1mS. Some experimentation with the starting save point will help eliminate seeing some wild numbers.

    [eta]
    Here's a simulation of just an OPA4140 amplifying a sine wave by a gain of 2. You can see I've used the Startup and UIC options along with a 1mS delay.

    I've also changed parameters in the control panel as I mentioned earlier; without all of these mods, I get errors such as floating nodes, etc.
     
    Last edited: Oct 18, 2011
  6. strantor

    Thread Starter AAC Fanatic!

    Oct 3, 2010
    4,302
    1,988
    Ok, sorry, I just got back to my desk (at work). I let the simulation run while I was out on the floor (had not yet made the changes you recommended) and when I got back I had this error:
    [​IMG]

    here is the error log:
    Code ( (Unknown Language)):
    1.  
    2. Circuit: * C:\Program Files\LTC\LTspiceIV\motorcontrol2[1]edit.asc
    3. WARNING: Specified period is not longer than the sum of Trise, Tfall, and Ton for v§fixed99%_20khz_pwm.  Increasing period to 5.15e-005
    4. WARNING: Less than two connections to node -6V.  This node is used by V1.
    5. u4:vccvs1_in: Missing value, assumed 0V @ DC
    6. u4:vccvs2_in: Missing value, assumed 0V @ DC
    7. u4:vam1: Missing value, assumed 0V @ DC
    8. u2:vccvs1_in: Missing value, assumed 0V @ DC
    9. u2:vccvs2_in: Missing value, assumed 0V @ DC
    10. u2:vam1: Missing value, assumed 0V @ DC
    11. u1:vccvs1_in: Missing value, assumed 0V @ DC
    12. u1:vccvs2_in: Missing value, assumed 0V @ DC
    13. u1:vam1: Missing value, assumed 0V @ DC
    14. u3:vccvs1_in: Missing value, assumed 0V @ DC
    15. u3:vccvs2_in: Missing value, assumed 0V @ DC
    16. u3:vam1: Missing value, assumed 0V @ DC
    17. Per .tran options, skipping operating point for transient analysis.
    18. Changing Tseed to 1e-008 <about 1 billion of these
    19. ...
    20. Heightened Def Con from 4.26562e-009 ++++++++++++++++++++++++++++to 4.26562e-009  <About 2 billion of these
    21. ...
    22. Fatal Error: Analysis:  Time step too small; time = 4.36756e-009, timestep = 1.25e-019: trouble with gsd2004w-v-instance d1
    23.  
    24.  
    U1, U2, U3, and U4 are my 4 opamps. I thought maybe when I deleted the old opamps and put the new ones in, the new ones didn't like my traces, so I deleted all my traces going to the opamps and put them all back in, but still not working.

    So I made the changes you recommended and now I get this error (immediately):
    [​IMG]
    no idea what that means
     
  7. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    I love these messages:
    Hard drive not full yet? Let's write another few billion of those lines to the file... ;)

    OK, time to upload your .asc file to see what you're trying to do.
     
  8. strantor

    Thread Starter AAC Fanatic!

    Oct 3, 2010
    4,302
    1,988
    Here she is...
    It's probably something stupid.
     
  9. strantor

    Thread Starter AAC Fanatic!

    Oct 3, 2010
    4,302
    1,988
    BTW when I try to run your OPA4140 demo on my PC I get the same exact same as I described in post #3. maybe my computer just sucks too bad?
     
  10. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Did you try making the changes I described in reply #4?
    Many of those are not saved when you exit LTSpice.
     
  11. strantor

    Thread Starter AAC Fanatic!

    Oct 3, 2010
    4,302
    1,988
    Yes sir. just verified. Your demo did eventually sim, but it took about 30min.
     
  12. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Wow. What are you running the sim on? A Z80 with 4k RAM?
     
  13. strantor

    Thread Starter AAC Fanatic!

    Oct 3, 2010
    4,302
    1,988
    [​IMG]
    my work laptop.
     
  14. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Our processors are about the same (yours is just a tad faster) and you have 1.5GB more ram. I'm running Win 7 pro 64bit SP1. That test simulation I uploaded runs in just moments.
     
Loading...