While working on the next article, I had to figure out what to do with potentiometers. LTSpice I use does not come with pots out of the box. While I have no issue with using two resistors and emulate a potentiometer, it’s not as good if I wanted to add that to an article. Having a proper pot symbol is just nicer and simpler.
There’s a library (pote.lib) with pots (pot.asy) on LTWiki (not affiliated with Analog), but it’s not exactly what I wanted.
Pinout
I have a slight gripe with pots, I never know how are they marked and how to wire them up without looking at the actual code of the library (in this case) or printing out the PCD layout and seeing if everything goes where it should.
All pots I came across look the same, more or less. Looking them from the front (the way I imagine being front anyway), pins are numbered 1-2-3. 2nd pin is the wiper, and going clockwise (assuming positive linear/audio taper), resistance increases between pins 1 and 2, and decreases between 2 and 3. Going counter-clockwise, resistance between 1 and 2 decreases and between 2 and 3 increases. Something like this:

But aforementioned libraries have them marked as A-B-C and with random order of pins. The models do work, but it simply isn’t the way I look at and use pots. It just causes confusion (to me) and I have to triple check whatever I do.
Footprints
I mean, it’s not just that the “unofficial” pot library confuses me. Looks like the footprints for Alps pots that I use is wrong in KiCad:

It might be just me, but that order of pins is flipped. It actually caused me some issues when I ordered PCBs, I had to mount pots on the other side of the PCB to get them to work correctly. Having said that, the footprint has been there for years, I’m sure I must be wrong or somebody else would’ve already complained about it.
Here’s the “compatible” footprint that has correct pinout and should fit my pot just the same:

Just something to be careful about.
SPICE Library
With all that, I decided to just simply adjust the aforementioned SPICE library and get it adapted to how I use pots. All credits to the original creator (I left the credits to the original creator in the file), I only did minor changes and clean-ups removing things I did not need.
Here’s the zip file with the library and the symbol file:
To use it, either extract it in the same folder where your asc file is, or to the lib folder of LTSpice (pot.asy file goes to sym subfolder, pot.lib file goes to sub subfolder).
How to use the file is when adding a new component is to select correct folder from the drop down and choose pot:

Linear
Here’s how it looks like using 10K linear pot:

To use linear pot select pot_lin as the model and set parameters Rt (total resistance) and set (which is a value from 0.0 to 1.0 indicating knob position – e.g: 0.0 all the way counter clockwise, 1.0 all the way clockwise, 0.5 in the middle).
Audio
Audio pot has more parameters:

Model is pot_audio and it requires additional parameters: Rtap and tap. Rtap is resistance between terminals 1 and 2 at position tap. In the above example, it just states that at the 0.65 (just past the middle) position of the pot the resistance is 2.5Kohms. I picked up those values up from Alps datasheet:

The audio pot taper does not look that close, but in reality is not that far off. Which brings me to another 2 models.
Piecewise Linear
In reality, audio potentiometers are really made up of multiple sections of linear potentiometer with different slopes. Based on the resistance diagrams I did an attempt to replicate them with pot_alps_a model:

Audio model does not look that far off from this now that I plotted them at the same diagram size. In the original library there was already a similar pot model, I just adjusted it to fit the diagram from the datasheet.
Similarly, for reverse-audio taper: 15C from the datasheet diagram:

Using pot_alps_c model I get reverse-audio pot. The diagram is different from the datasheet but this is because the datasheet plots resistance between terminals 2 and 3, and I plotted resistance between 1 and 2.
Note: The diagram from the datasheet does not make much sense and I had this wrong first time around. The above is corrected version. I’ll get to documenting some gripes with data sheets in another post.
Summary
In summary here are the models to use:
| Model | Description |
|---|---|
| pot_lin | Linear taper |
| pot_audio | Audio taper |
| pot_alps_a | Piecewise linear audio taper, modeling Alps 15A taper |
| pot_alps_c | Piecewise linear reverse-audio taper, modeling Alps 15C taper |
| pot_alps_3b | Piecewise linear “tone” taper taken from Alps datasheet |
| pot_bourns_3b | Piecewise linear “tone” taper taken from Bourns datasheet |
| pot_bourns_4b | Piecewise linear “tone” taper taken from Bourns datasheet |
And parameters for the models:
| Parameter | Description |
|---|---|
| Rt | Total resistance for the potentiometer |
| set | Position of the wiper 0.0 to 1.0, 0.0 being completely counter-clockwise, 1.0 is completely clockwise, 0.5 is the middle. Ratio of the wiper travel if you will. |
| Rtap | Resistance between terminals 1 and 2 at “tap” position. Only used for audio pot |
| tap | Ratio of wiper travel to reach Rtap resistance. Only used for audio pot |
I’ll be expanding this if I need to but so far this should be enough to get me going for most of the analysis I need to do.
NOTE (1st April ’24): I fixed the issue reported in the comments (finally) with using limit function. The library should work in other simulators other than LTSpice. Also, I added pot_alps_3b, pot_bourns_3b and pot_bourns_4b models. They are slightly different between themselves. If you look at Bourns pot datasheets, you’ll find B, B1, B2, B3, B4, B5 taper diagrams. B is linear, the rest of them are also linear but increasingly steeper like this:


7 replies on “Pots for SPICE”
There are known problems with Kicad, Spices and pins.
https://electronics.stackexchange.com/questions/509392/kicad-component-doesnt-match-manufacturers-model
And
“KiCad uses different pin assignments for semiconductor components than is expected by the ngspice engine. For example, the standard SPICE pin assignments for a BJT transistor are pin 1 = collector, pin 2 = base, and pin 3 = emitter, whereas KiCad uses 1 = E, 2 = B, and 3 = C. This can cause great confusion for users wondering what the heck is going on. ”
https://www.woolseyworkshop.com/2019/07/01/performing-a-circuit-simulation-in-kicad/
Hope this helps.
Thanks! Informative and good coverage!
You have used limit incorrectly. You have:
limit(0,Set,1)
But, it should be:
limit(Set,0,1)
Hi Tige,
Looks like the order of arguments does not matter (source LTWiki.org):
limit(x,y,z) | intermediate value of x, y, and z, equivalent to min(max(x,y),z)
Either limit(0, Set, 1) or limit(Set, 0, 1), or limit(0, 1, Set) for that matter, will work correctly. This is used just to limit Set value to between 0 and 1, so if Set is negative, the result of that function (either option) will be 0, if Set is greater than 1 the result will be 1.
Btw, for other people reading this: that’s from the Pot.lib file 🙂
This seems to be a peculiar behavior of LTSPICE. X/NGSPICE, PSPICE, Multisim, and Micro-cap all expect the pass-through as the first parameter and minimum as the second parameter.
Well that’s not good :), thanks for pointing that out. I’m using LTSpice so this did not come up as an issue for me. I’ll update the library, there’s no reason to discriminate other simulators 😉
Finally fixed it. Updated the download file with the latest version.