Passing Parameters to Hierarchical Block in LTSPICE

There were a couple of questions on how to pass parameters to Hierarchical Blocks from main level schematic in LTSPICE. In fact, until recently, I was having troubles doing this. But solution is very simple and strait forward.

Here is how it could be done.

Create your Hierarchical Block schematic and symbol the regular way as described in previous section.

In Hierarchical Block schematic, put parameter variable in value field of component you would like to pass different parameter to from your main level schematic.

In our example it will be value of resistor R2.

In Hierarchical Block schematic, assign default value for this parameter by using .PARAM statement.

This is necessary to be able to pass this parameter value from top level schematic and to set default value just in case you would not want to pass anything to this instance of your Hierarchical Block.

Hierarchical Block schematic

Hierarchical Block schematic

In Main Level schematic, place as many instances of Hierarchical Block symbols as you need.

For every instance that you want to pass parameters to: right click on Hierarchical Block symbol, enter parameter assignment in PARAMS window in the form “param value name”=”param value”.

Select PARAMS checkbox to enable passing parameters. Don’t put .PARAMS statement before “value name” in PARAMS window. Just put “value name”=”param value”.

Press OK to close this window. Parameter should be passed to corresponding instance of your Hierarchical Block.

Parameter assignment in PARAMS window

Parameter assignment in PARAMS window

I created simple example to illustrate how to pass parameters to Hierarchical Block.

It could be downloaded by using this link:

Passing-Parameters-to-Hierarchical-Block.zip

Just unzip all files in the same directory and run ‘PassingParametersHierarchicalBlock.asc”

Comments

4 Responses to Passing Parameters to Hierarchical Block in LTSPICE

  1. Pingback: Hierarchical Blocks in LTSPICE | Audio Perfection

  2. ido says:

    Hi

    Thank you for the detailed description.

    I need to pass parameters to a third party generated subckt i.e. I have a symbol and then I include the netlist. I do not have the schematic of the lower hierarchy .

    How should this be done in this case ?
    I need to pass two different parameters to this subckt

    Thank you

    Ido

    • Eugene says:

      Subcircuit should have the capability to accept parameters. In general, it should have .PARAM statement inside for parameters that you want to pass to it from higher level schematic. Meaning that if it does not have this capability, you have to modify subcircuit definition (text) to be able to accept parameters. You do not have to have subcircuit schematic. But you may have to dig into its text to be able to modify it to accept parameters (if it can’t do this already). And you can use existing symbol.

  3. trochw says:

    If you want to pass multiple comments to a hierarchical block, you can use following syntax:

    “param value name 1”=”param value 1” “param value name 2”=”param value 2”

    (space sperated)

    Kr,

    Wim