Simulating Pots With LTSpice

One of the good things about simulating circuits is that you can easily change component values trivially. In the real world, you might use a potentiometer or a pot to provide an adjustable value. However, as [Ralph] discovered, there’s no pot component in LTSpice. At first, he cobbled up a fake pot with two resistors, one representing the top terminal to the wiper, and the other one representing the wiper to the bottom terminal. Check it out in the video below.

At first, [Ralph] just set values for the two halves manually, making sure not to set either resistor to zero so as not to merge the nets. However, as you might guess, you can make the values parameters and then step them. 

By using .step you can alter one of the resistor values. Then you can use a formula to compute the other resistor since the sum of the two resistors has to add up to the pot’s total value. That is, a 10K pot will have the two resistors always add up to 10K.

Of course, you could do this without the .step and simply change one value to automatically compute both resistors if you prefer.

We’ve done our own tutorials with .step and parameters if you want a little more context. You can even use this idea to make your own custom pot component.

9 thoughts on “Simulating Pots With LTSpice

  1. Didn’t watch the video, but this is what I use:

    .param rt=5k
    .param ra=rt*rp+1m
    .param rb=rt-ra+1m
    .param rp=0.5

    The resistors are {ra} and {rb}. rt is the overall value (5k here) and rp can be varied from 0.0 to 1.0 as the wiper position (50% here) using .step etc.

    1. If anyone was wondering about the +1m, it seems random, but serves a purpose:

      SPICE optimizes nets it knows are identical (supernodes). When the .PARAM hits exactly 0 or 1 (without this tweak), the topology changes, and unexpected behavior, numerical instability, can happen.

      1m is a generic enough value, not likely to cause problems; in the rare case you use one of these for adjusting, like, a current-sense resistor (rt=10m say), you’ll find a problem, but you wouldn’t usually call a real component like that a “potentiometer”, and should reach for a different simulation solution. I suppose the technically-correct value should be around 1/GMIN.

      The enterprise-grade solution should clamp the value of rp itself (so that any value can’t cause weirdness: shorts or negative values). Just as well, we can avoid putting whole numbers into it. This modest tweak lets us use conveniently round numbers 0 ≤ rp ≤ 1 without having to code anything like that.

  2. Interesting to me are the undanswered questions “Why?” does SPICE not have a built-in potentiometer, does SPICE have a built-in variable capacitor (tuner to us normal folk)?

  3. I had to figure this out by myself 2 days ago. I think I’ll check my PC for spyware…

    I went with a DC source, set up a voltage sweep and set a net on the positive leg. then made the resistors dependent on that net

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.