Electronic – Step Subcircuit in LTSpice

ltspice

I try to simulate different MOSFET's for wich a spice model is provided by the manufacturer as a .lib file containing a subcircuit. In my schematic, the subcircuit is included with a .inc <fname> statement and used by changing the Prefix of a NMOS from M to X and setting to value to the name of the subcircuit.

All of this works, however, as I want to compare different MOSFETS, I want to step through a list of different models.

I tried to use the same method as found here:

  1. Define numerical models: .model 1 ako:<FET Type>
  2. Step over the numerical models

However, this does not work. A error "Unknown subcircuit called" is returned.

Is there another way of stepping over different subcurcuits?

Best Answer

It's not officially supported, since LTspice flattens the schematics prior to simulation. That is, all subcircuits, hierarchies, are expanded and flattened to fit in the matrix solver, so if, for example, a second circuit that is stepped doesn't coincide element by element and node by node with the first one, then LTspice may have problems expanding the circuit "mid-flight".

A minor proof is using any stepped subcircuit and looking at the extended netlist format, in the log, after the simulation. You'll see that the expanded subcircuit is the first one, repeated over all the steps.

But that doesn't mean it's not impossible, only that, if it fails, you shouldn't complain. First, ako only works with models, which are well-defined internally, while subcircuits can have any topology. For this, rename your subcircuits with numerals, 1, 2, 101, etc, so that they can be used with a .step variable. Then you're set, but, again, don't expect miracles. Here's a quick example:

test

Alternatively, you can use switches and/or resistors that connect the subcircuits to the rest of the schematic, and step their values between 1m and 1g, for example, but that will make all the subcircuits count towards the matrix solver, even if they won't be used.