I want to compare signals from my fancy
subcircuit (very complex) and multiple subcircuits level1
(should be almost equivalent, but simpler) with different parameters; these parameters should be passed to level2
subcircuits.
Below is a (simplified) nonworking sample code:
Xfncy 2 0 fancy
Xlvl10 2 0 level1 PARAMS: Y1=1 Y2=1
Xlvl11 2 0 level1 PARAMS: Y1=1 Y2=10
Xlvl12 2 0 level1 PARAMS: Y1=10 Y2=1
Xlvl13 2 0 level1 PARAMS: Y1=10 Y2=10
.SUBCKT fancy 1 2
* STUFF
.ENDS fancy
.SUBCKT level1 1 2 PARAMS: Y1=1 Y2=2
.param Z10=1 Z20=1 Z11=1 Z21=1 Z12=1 Z22=1
Xlvl20 1 2 level2 PARAMS: Y3=Z10*Y1 Y3=Z20*Y2
Xlvl21 1 2 level2 PARAMS: Y3=Z11*Y1 Y4=Z21*Y2
...
...
Xlvl28 1 2 level2 PARAMS: Y3=Z18*Y1 Y4=Z28*Y2
.SUBCKT level2 1 2 PARAMS: Y3=1 Y4=1
* STUFF
.ENDS level2
.ENDS level1
Running like this, I get the following error:
WARNING: Can't resolve .param Y3=Z10*Y1
Select OK to continue the simulation with the default model or Cancel to quit now
My first version of the instance Xlvl20
line:
Xlvl20 1 2 level2 PARAMS: Y3={Z10*Y1} Y3={Z20*Y2}
yields the same error. If I change the line to:
Xlvl20 1 2 level2 PARAMS: {Y3=Z10*Y1 Y3=Z20*Y2}
I get:
Missing expression in
"{Y3=Z10*Y1 Y3=Z20*Y2}"
Is passing parameters like this even possible in LTSpice and if so, how? Alternative approaches are also welcome.
PS: Yes, I've tried .step param
to avoid packing level1
stuff into a subcircuit, but then I can't compare it to fancy
, because fancy
takes about 30 times more time to simulate.
Best Answer
The LTSpice manual gives an example of how to do this:
The full syntax is given as:
The rules for writing expressions are given in the section of the manual on "arbitrary behavioral voltage and current sources".