1
\$\begingroup\$

I am trying to use a subcircuit to replace a normal resistor for an FMEA. The .sub file looks like this:

.subckt testResistor In Out
.step param testResistorIterrator 0 4 1
.param BaseResistance= table(testResistorIterrator,   0, 1T,    1,  1,  2, 1.5k,    3, 0.5k,    4,1k)
.param BlockResistance = table(testResistorIterrator, 0, 1T,    1, 1T,  2, 1T,      3, 1T,      4,1)
R§Base Out In {BaseResistance}
R§Block Out 0 {BlockResistance}
.ends testResistor

In theory it should step iterate through 0 to 4 and assign the two resistors a value based on the step, however when I try to integrate the subcircuit in this test circuit: enter image description here

It gives me these errors:

WARNING: Can't resolve .param baseresistance=table(testresistoriterrator, 0, 1t, 1, 1, 2, 1.5k, 3, 0.5k, 4,1k)
WARNING: Can't resolve .param blockresistance=table(testresistoriterrator, 0, 1t, 1, 1t, 2, 1t, 3, 1t, 4,1)
Questionable use of curly braces in "râ§base out in {baseresistance}"
    Error: yet unevaluated parameter in: "[baseresistance]"
Questionable use of curly braces in "râ§block out 0 {blockresistance}"
    Error: yet unevaluated parameter in: "[blockresistance]"
Fatal Error:  Unable to find definition of model "baseresistance"

Did I declare something wrong, or is my entire setup wrong?

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

You cannot run a .step command within a subcircuit. The way to solve this is to make testResistorIterrator a regular parameter and then pass the stepped value from your top-level schematic to your subcircuit. You also need to define a default value to testResistorIterrator within your subcircuit. In other words, something like this:

.subckt testResistor In Out
.param testResistorIterrator=0
.param BaseResistance = table(testResistorIterrator,   0, 1T,    1,  1,  2, 1.5k,    3, 0.5k,    4,1k)
.param BlockResistance = table(testResistorIterrator, 0, 1T,    1, 1T,  2, 1T,      3, 1T,      4,1)
R§Base Out In {BaseResistance}
R§Block Out 0 {BlockResistance}
.ends testResistor

Then you right-click your subcircuit symbol and define either of the Value2, SpiceLine, or SpiceLine2 fields (doesn't matter which) as testResistorIterrator={value}, as shown below.

enter image description here

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.