LTSpice and subcircuits - diyAudio
Go Back   Home > Forums > Amplifiers > Solid State

Solid State Talk all about solid state amplification.

Please consider donating to help us continue to serve you.

Ads on/off / Custom Title / More PMs / More album space / Advanced printing & mass image saving
Reply
 
Thread Tools Search this Thread
Old 15th June 2003, 05:53 PM   #1
Account Disabled
 
Join Date: Apr 2003
Location: US
Default LTSpice and subcircuits

Hi, folks:

I am trying to incorporate the spice models provided by IRF in my design simulated under LTSpice. the IRF models come in as sub circuits and I went through the FAQ and here is what it said about using 3rd party subcircuit spice model:

"If you want to use a subcircuit, follow the following steps:

1. Change the "Prefix" attribute of the component instance of the symbol to be an 'X'. Don’t change the symbol, just the instances of the symbol as a component on a schematic.

2. Edit the value of the component to coincide with the name of the subcircuit you wish to use.

3. Add a SPICE directive on the schematic such as ".inc filename" where filename is the name of the file containing the definition of the subcircuit."

Just precisely what I should do to incorporate a subcircuit in a file called IRF540.spi that reads like:

Thanks in advance.

=======IRF540.spi==========================
.SUBCKT irf540 1 2 3
**************************************
* Model Generated by MODPEX *
*Copyright(c) Symmetry Design Systems*
* All Rights Reserved *
* UNPUBLISHED LICENSED SOFTWARE *
* Contains Proprietary Information *
* Which is The Property of *
* SYMMETRY OR ITS LICENSORS *
*Commercial Use or Resale Restricted *
* by Symmetry License Agreement *
**************************************
* Model generated on Apr 24, 96
* Model format: SPICE3
* Symmetry POWER MOS Model (Version 1.0)
* External Node Designations
* Node 1 -> Drain
* Node 2 -> Gate
* Node 3 -> Source
M1 9 7 8 8 MM L=100u W=100u
* Default values used in MM:
* The voltage-dependent capacitances are
* not included. Other default values are:
* RS=0 RD=0 LD=0 CBD=0 CBS=0 CGBO=0
.MODEL MM NMOS LEVEL=1 IS=1e-32
+VTO=3.56362 LAMBDA=0.00291031 KP=25.0081
+CGSO=1.60584e-05 CGDO=4.25919e-07
RS 8 3 0.0317085
D1 3 1 MD
.MODEL MD D IS=1.02194e-10 RS=0.00968022 N=1.21527 BV=100
+IBV=0.00025 EG=1.2 XTI=3.03885 TT=1e-07
+CJO=1.81859e-09 VJ=1.1279 M=0.449161 FC=0.5
RDS 3 1 4e+06
RD 9 1 0.0135649
RG 2 7 5.11362
D2 4 5 MD1
* Default values used in MD1:
* RS=0 EG=1.11 XTI=3.0 TT=0
* BV=infinite IBV=1mA
.MODEL MD1 D IS=1e-32 N=50
+CJO=2.49697e-09 VJ=0.5 M=0.9 FC=1e-08
D3 0 5 MD2
* Default values used in MD2:
* EG=1.11 XTI=3.0 TT=0 CJO=0
* BV=infinite IBV=1mA
.MODEL MD2 D IS=1e-10 N=0.4 RS=3e-06
RL 5 10 1
FI2 7 9 VFI2 -1
VFI2 4 0 0
EV16 10 0 9 7 1
CAP 11 10 2.49697e-09
FI1 7 9 VFI1 -1
VFI1 11 6 0
RCAP 6 10 1
D4 0 6 MD3
* Default values used in MD3:
* EG=1.11 XTI=3.0 TT=0 CJO=0
* RS=0 BV=infinite IBV=1mA
.MODEL MD3 D IS=1e-10 N=0.4
.ENDS

==========end=========================
  Reply With Quote
Old 15th June 2003, 06:18 PM   #2
diyAudio Member
 
Join Date: Sep 2002
Location: Sweden
Forget what they write in the FAQ and do it this way, which
should work (I actually just tested since it has been a while
since I did it).

1) Save the file with the subcircuit definition (the one you quoted)
in the lib/sub directory and call it irf540.sub

2) in the lib/sym directory, you find all the graphical symbols.
Copy the file nmos.asy and call it irf540.asy (must be the same
name as the sub file above). Then click on this file to open the
symbol editor where you can change the generic name NMOS
to IRF540.

"Advanced course"
------------------------
The asy file may be placed in a subdirectory of lib/sym. Since
many MOSFET models come as subcircuits rather than just
spice models, I have a directory named transistors where
I put all such transistors. You will find there already are
such subdirectories for opamps etc. and this ís reflected by
the component selection hierarchy you see when using LTSpice.
As far as I remember you cannot have a hierarchy in the mod
directory on the other hand, but that matters less since the
sym directory dictates the selection hierarchy.

Furthermore, in case you don't already know it, components
that come as .model commands need not be handled
in the above way. They are better just added to the appropriate
file in the lib/cmp directory. There are files called standard.bjt
standard.cap etc, with the obvious meaning.
  Reply With Quote
Old 15th June 2003, 07:00 PM   #3
Account Disabled
 
Join Date: Apr 2003
Location: US
Thanks, Christer.

another question: how do you link the symbol with the model? I can pick up the irf540, and place it on the schematic. but when I right click on it, choose "Pick New MOSFET", how do I tell LTSpice that it should use the newly created IRF540.sub?

Thanks in advance.
  Reply With Quote
Old 15th June 2003, 07:15 PM   #4
diyAudio Member
 
Join Date: Sep 2002
Location: Sweden
Quote:
Originally posted by millwood
Thanks, Christer.

another question: how do you link the symbol with the model? I can pick up the irf540, and place it on the schematic. but when I right click on it, choose "Pick New MOSFET", how do I tell LTSpice that it should use the newly created IRF540.sub?

Thanks in advance.
You can't

LTSpice doesn't know that it is a MOSFET since it is defined
by a subcircuit. Hence, every component suchly defined must
have its own symbol file (the .asy file). Those MOSFETs that
ship with the program are defined by .model commands only
and are located in the standard.mos (or whatever it was) file.
These are known by the program to be MOSFETs and share
a common generic symbol, so you can choose any particular
device of those in this file. However, this file cannot contain
subcircuits, so these must be treated as special cases. A bit
awkward, but nothing one cannot live with.

This also means that you must know from the beginning that
you are going to use an IRF540. You cannot put a generic
MOSFET in and then say that it is an IRF540. You can delete
the generic MOSFET and replace it with an IRF540, though.
Actually, you do have the same problem with opamps. You
can't start with a generic one and then decide that it should
be an LT1115.
  Reply With Quote
Old 15th June 2003, 10:36 PM   #5
Account Disabled
 
Join Date: Apr 2003
Location: US
looks like we are back to square one.

It seems to me that the software is capable of using 3rd party models it is just that the write-up is hard to follow without a specific example.

Any suggestions?
  Reply With Quote
Old 15th June 2003, 10:40 PM   #6
diyAudio Member
 
Join Date: Sep 2002
Location: Sweden
Didn't it work to do as I described? You should get a component
named IRF540 at the top of the component hierarchy, or in a
subhierarchy if you put the .asy file in a subdir. Do you get that
far?

Or did you mean that my explanation was hard to follow??
  Reply With Quote
Old 15th June 2003, 10:58 PM   #7
Account Disabled
 
Join Date: Apr 2003
Location: US
Christer,

I had created IRF540.sub in lib/sub directory, as well as IRF540.asy under lib/sym/My Devices.

the problem is that when I put in an IRF540, it is the default NMOS model. so if I right click it, i have just the choices in standard.mos.

In essence, there is no link between IRF540.asy to IRF540.sub. Whenever I put in IRF540 in the schematics, the software is actually thinking that it is a perfect n-channel mosfet.

I just wanted to add a little bit. the lt opamps are implemented somewhat different (via subckt I believe) in that once you had them selected, you cannot switch. I guess all I needed to do is to figure out how the LT opamps are implemented and do the samething with the irf subcircuits.
  Reply With Quote
Old 15th June 2003, 11:16 PM   #8
diyAudio Member
 
Join Date: Sep 2002
Location: Sweden
You are quite right. I actually did think that I had to provide
such linking last time I did it, but was fooled by the fact that
the newer version of LTSPice brings up a graphical editor instead
of Notepad when you click an asy file, and I didn't find a way
to access the linkage info (there probably is one). Sorry
for that.

You must actually edit the .asy file with a text editor. Below is an
example how I modified the .asy file for an 2SK1058, which is
also an NMOS. Perhaps it is simplest that you take this file and
just replace the device number everywhere. I think that should
be all there is to it. You may compare it to the generic NMOS
file to see the pattern for how to modify these files.

Version 3
SymbolType CELL
LINE Normal 12 12 12 24
LINE Normal 4 20 12 20
LINE Normal 10 12 12 12
LINE Normal 4 12 10 11
LINE Normal 4 12 10 13
LINE Normal 10 11 10 13
LINE Normal 4 2 4 6
LINE Normal 4 10 4 14
LINE Normal 4 18 4 22
LINE Normal 0 20 2 20
LINE Normal 2 4 2 20
LINE Normal 12 4 4 4
LINE Normal 12 0 12 4
WINDOW 0 14 8 Left 0
WINDOW 3 14 18 Left 0
SYMATTR Prefix X
SYMATTR SpiceModel 2sk1058.mod
SYMATTR Value 2SK1058
SYMATTR Value2 2SK1058
SYMATTR Description N-Channel MOSFET transistor
PIN 0 20 NONE 0
PINATTR PinName G
PINATTR SpiceOrder 2
PIN 12 0 NONE 0
PINATTR PinName D
PINATTR SpiceOrder 1
PIN 12 24 NONE 0
PINATTR PinName S
PINATTR SpiceOrder 3
  Reply With Quote
Old 16th June 2003, 02:00 AM   #9
Account Disabled
 
Join Date: Apr 2003
Location: US
Quote:
Originally posted by Christer
SYMATTR Prefix X
...
SYMATTR Value 2SK1058
now, the FAQ makes perfect sense,

You had replaced the prefix with "X", as step 1 in the FAQ;
you had also named the subcircuit "2SK1058", as step 2 in the FAQ said;

The only thing that isn't here is the ".inc filename". I will give it a shot.

Thanks for the help.
  Reply With Quote
Old 16th June 2003, 02:12 AM   #10
Account Disabled
 
Join Date: Apr 2003
Location: US
I am this close to it,

used .include to include irf540.spi, and got a "SPICE Error: Too many parameters for subcircuit type "irf540" (instance: xu1)".

Any suggestions?
  Reply With Quote

Reply


Hide this!Advertise here!
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to simulate OPT in LTspice? Akita Tubes / Valves 15 29th December 2013 05:39 PM
ltspice crystal jeesus Everything Else 1 18th July 2008 11:53 PM
Using LTSpice gaetan8888 Solid State 6 19th July 2007 01:33 AM
UcD / LTSpice help fokker Class D 94 1st October 2006 02:12 PM
Ltspice.... mikeks Solid State 10 13th June 2004 09:10 PM


New To Site? Need Help?

All times are GMT. The time now is 07:25 PM.


vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2014 DragonByte Technologies Ltd.
Copyright ©1999-2014 diyAudio

Content Relevant URLs by vBSEO 3.3.2