I don't think you can generate a txt format directly from the ltspice command line. I recently looked into this and I came across an old discussion which includes the primary author of LTSpice and indicates (at least as of 2003) 1) you can't export text directly from the command line, 2) the binary format is intentionally "secret", 3) there is a separate executable available to do a translation.
( http://www.electronicspoint.com/threads/pspice-global-parameters-time-and-temperature.25088/ note that although the link says pspice, ltspice is also discussed)
So I think the best option is a two step process.
1) run the simulation from command line to generate binary data output
2) run the conversion utility from the command line to generate txt format
You can get the conversion utility "ltsputil" from the yahoo LTspice users group (https://groups.yahoo.com/neo/groups/LTspice/files/%20Util/ltsputil/) and its usage seems to be fairly well documented but with no guarantee it is 100% correct in output or that it won't break in future LTSpice.
I didn't try it yet but may in the near future. Please let me know if you have success with it.
If I simply save that PSpice file to a ntk3139p.lib
file and import it in LTspice, it all works fine:
The Rds(on) looks in line with the datasheet for that part.
What you need to keep in mind is to change the PMOS statement line to X (because it's a subcircuit) and match the name to the subckt name declared in that lib. Ctrl-click to access the advanced properties page for the FET:
This is actually explained in detail at http://www.linear.com/solutions/1083
And if you actually want to import that model into LTspice so that you don't have to use an .include
statement, what you need to do is
- Copy the aforementioned
ntk3139p.lib
into LTspiceIV\lib\sub
; this directory can [and does] contain both .lib
and .sub
files.
- Create a
ntk3139p.asy
in LTspiceIV\lib\sym
(or in one of its subfolders, in which case the component will show up in the corresponing category in the F2
select component dialog). This .asy
file is initially a copy of pmos.asy
that comes with LTspice in this case. Now you need to edit this ntk3139p.asy
file either in a text editor or using LTspice itself (via Edit->Attributes
or Ctrl+A
) so that it reads:
Now you can add the new component, but since we're using X as type it automatically get labelled as an IC (U
) rather than MOSFET as before. But we don't need an .inc
line anymore for the simulation to work:
Honestly this procedure is usually not worth the hassle for me... and if you reinstall LTspice or load your schematic on a different machine, you have to do it all over again, never mind that it becomes less clear in the schematic what components you need[ed] extra libraries for. Furthermore, you can no longer change the MOSFET by right-clicking on it an picking a new model. If you try that with your custom asy
file, you get:
Which for me is the most annoying part. So I don't recommend doing this import procedure for MOSFETS; I think it's only worth the hassle for ICs.
I honestly don't know exactly what the .sub
files are restricted to contain in LTspice, but the ones that come with the program are all binary files containing LT's proprietary models, some of which also make use of LT's extensions like steady and so forth. I don't think the .sub
binary format that LTspice uses is publicly documented anywhere.
Best Answer
In the way you constructed your block with the two resitors, in that same way you can pass parameters to subcircuits using your block:
As you can see, not all subcircuit parameters need to be defined in
.param
statements, the same way not all need to be defined inside the instance of the subcircuit; they can be mixed. Using an.inc
can be done the usual way from this point forward.Just to be sure it's clear: subcircuits are like a scope and anything that happens inside a subcircuit stays within that subcircuit, unless it's made available to the outside from within the subcircuit. That means either passing parameters to the subcircuit (what you're showing in your picture) or external pins that make available internal quantities (voltage, current) to the outside world.
Also see this answer.
If your purpose is to have the
.param
statemens residing in an external file to be included with.inc
then the only way to change them is through assignment with{}
, which implies editing by hand -- one or another. The only other shortcut to defining each parameter, separately, is to have all the parameters related through a function, in which case, instead of a long.param
line you can have a.func
. The values will then bef(1)
,f(2)
, etc, and the function.func f(x) {2*x+1}
(for example).