importing a model to LTspice.

Thread Starter

strantor

Joined Oct 3, 2010
6,782
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)
 

SgtWookie

Joined Jul 17, 2007
22,230
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:
.SUBCKT OPA4140 -IN +IN V- V+ Vout
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.
 

Thread Starter

strantor

Joined Oct 3, 2010
6,782
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:


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?
 

Attachments

SgtWookie

Joined Jul 17, 2007
22,230
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.
 

SgtWookie

Joined Jul 17, 2007
22,230
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.
 

Attachments

Last edited:

Thread Starter

strantor

Joined Oct 3, 2010
6,782
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:


here is the error log:
Rich (BB code):
Circuit: * C:\Program Files\LTC\LTspiceIV\motorcontrol2[1]edit.asc
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
WARNING: Less than two connections to node -6V.  This node is used by V1.
u4:vccvs1_in: Missing value, assumed 0V @ DC
u4:vccvs2_in: Missing value, assumed 0V @ DC
u4:vam1: Missing value, assumed 0V @ DC
u2:vccvs1_in: Missing value, assumed 0V @ DC
u2:vccvs2_in: Missing value, assumed 0V @ DC
u2:vam1: Missing value, assumed 0V @ DC
u1:vccvs1_in: Missing value, assumed 0V @ DC
u1:vccvs2_in: Missing value, assumed 0V @ DC
u1:vam1: Missing value, assumed 0V @ DC
u3:vccvs1_in: Missing value, assumed 0V @ DC
u3:vccvs2_in: Missing value, assumed 0V @ DC
u3:vam1: Missing value, assumed 0V @ DC
Per .tran options, skipping operating point for transient analysis.
Changing Tseed to 1e-008 <about 1 billion of these
...
Heightened Def Con from 4.26562e-009 ++++++++++++++++++++++++++++to 4.26562e-009  <About 2 billion of these
...
Fatal Error: Analysis:  Time step too small; time = 4.36756e-009, timestep = 1.25e-019: trouble with gsd2004w-v-instance d1
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):

no idea what that means
 

Attachments

SgtWookie

Joined Jul 17, 2007
22,230
I love these messages:
...
Heightened Def Con from 4.26562e-009 ++++++++++++++++++++++++++++to 4.26562e-009 <About 2 billion of these
...
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.
 

Thread Starter

strantor

Joined Oct 3, 2010
6,782
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?
 

SgtWookie

Joined Jul 17, 2007
22,230
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.
 
Top