# Create .step list based on another parameter

Problem:

I'm trying to create a .step list of values based on another parameter but none of the syntax I've tried seems to work.

Example:

In the voltage divider below, I'd like to step the values of R2 in multiples (1x, 1.5x, 2x) of R1. I can do this manually for a given R1 but I'd like to be able to vary R1 and still have the .step values of R2 calculated by LTspice.

Both of the forms I tried yield the same error message:

Syntax error in .step command (2nd dimension) Related:

LTSpice - Printing resultant parameters based on expressions looks similar, but using single quotes doesn't work either.

Question:

Is there a way to do this? If so, what's the correct syntax?

Your general usage of curly braces is incorrect as it should be: .step param R2 list {R1} {R1*1.5} {R1*2}. But it doesn't matter since you cannot evaluate expressions within a .step command, so you'll always get those syntax errors. You either need to make multiple copies of your circuit, or create a behavioral resistor which can evaluate the resistance based on other information on your circuit.

Here is one such way to do it. Independent voltage source V1 is stepped through 1, 1.5, and 2 and the behavioral resistor is evaluated as R1 multiplied by the value of the node at the top of the voltage source: R=R1*V(step) You can also step the independent voltage source directly without using a param as follows. Just like a .dc sweep, you need to give the voltage source a default value (I simply picked zero). Simple method:

It is possible to achieve the results posited by Ste Kulov even without using an independent voltage source. All that is needed is a single parameter, which can be defined in the .step directive and referenced directly.

As per Ste Kulov's comment below:

Since you don't need the voltage source then you don't even need the behavioral resistor. It's always better to use a regular resistor whenever possible. So I would replace the R=R1*multiplier with {R1*multiplier} so a regular resistor is used.

Putting it all together we get: Note: the .param multiplier=0 is commented out in this case. If you have a programmer's mindset you might want to have it in there as a directive (i.e. uncommented) just to be pedantic... but it's not required, .step will override the initialisation value anyway.

Ste Kulov's answer was as an essential stepping stone in figuring this out. It just seemed too convoluted to define a voltage source with the sole purpose of acting as an input parameter. So I tried to eliminate this additional step and got lucky. Thanks a bunch, Ste Kulov!

• Duh. Of course! Good job. I can't believe my brain overlooked this and over-complicated the solution. My bad. Since you don't need the voltage source then you don't even need the behavioral resistor. It's always better to use a regular resistor whenever possible. So I would replace the R=R1*multiplier with {R1*multiplier} so a regular resistor is used. You should definitely accept this answer once the timeout period expires. Mar 2 at 22:03
• I've just edited in your further excellent suggestions. Thanks for helping me piece this together! Mar 2 at 22:21
• No problem! Glad I was able to help. Mar 3 at 2:00
• Oh ya. Just noticed the new photo still shows the R=. You have to get rid of that so the behavioral resistor is not used. It should look like this: i.stack.imgur.com/YEKy2.png Mar 3 at 5:15
• @SteKulov Ach, well spotted! ... and now corrected too. :) Mar 3 at 8:50