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:
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.
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.