LTSpice pots simple functions

ftumch

Well-known member
Don't know about you guys but I've been hammering pot values into LTSpice like a caveman for the longest time

Finally got around to making some pot functions, it covers ABC tapers and works from pin 1 or pin 3:

Code:
.param x = 1e-7
.func rlog(a) { 1 - (1-a)**3.3 }
.func alog(a) { a **3.3 }
.func pot(val, rot) { val * (rot + x)}
.func B1(val, rot) { pot(val, rot/10 + x) }
.func B3(val, rot) { pot(val, 1 - rot/10 + x) }
.func A1(val, rot) { pot(val, alog(rot/10 + x) }
.func A3(val, rot) { pot(val, 1 - alog(rot/10) + x) }
.func C1(val, rot) { pot(val, rlog(rot/10) + x) }
.func C3(val, rot) { pot(val, 1 - rlog(rot/10) + x) }

The syntax is [taper][pin](value, rotation)

So position 7 on pin 3 of a 50k C taper pot would be:

{ C3(50k, 7) }

Simples

Rotation is a number between 1 and 10. A tiny offset is added to stop divide by zeros

The tapers are useful for stepping ie

.step param gain 0 10 1

Where resistor value is:

{ C3(100k, gain) }

Anyway thought this might be helpful. If anyone still actually uses it lol
 
There was a missing bracket. Don't think I can edit OP but here is a corrected version

I also separated the rotation conversion and divide by zero offset to its own function

Code:
.param x = 1e-7
.func rlog(a) { 1 - (1-a)**3.3}
.func alog(a) { a **3.3 }
.func r(a) { (a+x) / 10 }
.func pot(val, rot) { val * (rot) }
.func B1(val, rot) { pot(val, r(rot)) }
.func B3(val, rot) { pot(val, 1 - r(rot)) }
.func A1(val, rot) { pot(val, alog(r(rot))) }
.func A3(val, rot) { pot(val, 1 - alog(r(rot))) }
.func C1(val, rot) { pot(val, rlog(r(rot))) }
.func C3(val, rot) { pot(val, 1 - rlog(r(rot))) }

As an aside, does anyone still use LTSpice or has the world moved on? The text editor (macOS) is comically infuriating
 
There was a missing bracket. Don't think I can edit OP but here is a corrected version

I also separated the rotation conversion and divide by zero offset to its own function

Code:
.param x = 1e-7
.func rlog(a) { 1 - (1-a)**3.3}
.func alog(a) { a **3.3 }
.func r(a) { (a+x) / 10 }
.func pot(val, rot) { val * (rot) }
.func B1(val, rot) { pot(val, r(rot)) }
.func B3(val, rot) { pot(val, 1 - r(rot)) }
.func A1(val, rot) { pot(val, alog(r(rot))) }
.func A3(val, rot) { pot(val, 1 - alog(r(rot))) }
.func C1(val, rot) { pot(val, rlog(r(rot))) }
.func C3(val, rot) { pot(val, 1 - rlog(r(rot))) }

As an aside, does anyone still use LTSpice or has the world moved on? The text editor (macOS) is comically infuriating
I still use it happily, typically a few days a week, on a Windows PC. I'll have to take a look at your pot definitions, I've just been using the usual ones from the LTspice forum repository for many many years.
 
Back
Top