Potentiometer simulation

I’m trying to have a simulation for tone-stacks in kicad. This requires several sweeps of potentiometers.
I’m using
‘’’
.SUBCKT pot_lin 1 2 3
.param w=limit(0.01m,wiper,0.99999)
*
R1 1 3 {Rtot*(1-w)}
R2 3 2 {Rtot*(w)}
.ENDS
‘’’
But I cannot figure out how to pass wiper and rtot to the simulation. Right now i use
Spice_Model pot_lin(0.5 0.5) just for testing. But this results in a simulator error:

Error: unknown subckt: xrv1 /out 0 /dd2 pot_lin(0.5 1)

I’m kind of stuck, so I would really appreciate any help.

You might sweep the resistor electronically as shown in this thread:

Pretty close, but not what I was looking for. I want to sweep in the AC analysis. But thanks.
I guess the tool is not mature enough yet, but I’m really looking forward to when it is.

If you have a text box with the ac command, say

.ac dec 10 100 100k

on your circuit diagram page, why not edit it (double click onto the box) and add

.param Rtot=1k wiper=0.8

For the time being I use this one.

http://www.ti.com/tool/TINA-TI?keyMatch=tina&tisearch=Search-EN-Everything

It has been VERY helpful!

thanks, this got rid of the error, but I still need to set up the simulation manually (entering ac parameters), even though I’m having the .ac command.
It says:
No. of Data Rows : 0

What I typically do for this is a parameter sweep using .step. Here is an example in LTspice because it’s quicker for me to whip up. If you still have trouble, let me know and I’ll duplicate it in KiCad for you.

In this example, I have the step command set up such that it’s a linear sweep that starts at 1k and ends at 10k, with 1k steps in between. You can look up the .step command to see other ways. LIST is another common .step option and very helpful in hitting specific values.

To do a true potentiometer, you would need a 2nd resistor which is calculated based on the first. So you set up the first as above, and then second would just be something like
.param Rs2 = {10k - Rs + 1m}

The 1m (1 milliohm) is to make sure Rs2 doesn’t hit zero when Rs is 10k. Pure zero components usually screw up the circuit matrix unless there is special handling in the specific SPICE implementation to handle it.