## On potentiometers and parameter mapping, part 1

Posted by Stefano at 02/02/2023, 17:45:20 UTC.

They infest synthesizers, effect units, amplifiers, studio gear, electric musical instruments, DAWs, and plugins. Potentiometers, whether knobs or sliders, real or virtual, are definitely the most common mean of interaction with music gear.

No doubt there's much more to them than just representing some value within a given range. Let's uncover a few secrets and see how they can inspire day-to-day DSP.

In this first episode (out of two, presumably) we'll touch on the relevant, and perhaps trivial, analog aspects. Getting them right is, however, essential to the more advanced DSP concepts to be discussed in part 2.

### The basics

Electronically speaking, a potentiometer is a resistor of fixed total resistance $$R$$ with a third terminal that "splits" such resistance in two partial resistances $$R_1$$ and $$R_2$$ (between one end and the extra terminal, and between the other end and the extra terminal). The sum of these two resistances is equal to the total resistance, that is $$R_1+R_2=R$$. The values of partial resistances at any given time depend on the user-controlled position setting as, e.g., indicated by a knob's marker or a slider's wiper.

There are also dual-ganged potentiometers on the market, which are quite useful when dealing with stereo signals and in certain circuit topologies, and I know there are also at least 3-ganged ones, but I've never seen them used so far in audio circuits.

### Linear, logarithmic, anti-logarithmic tapers, and more

The relationship between the position and resistance values is called "taper".

The most basic and, I guess, common potentiometers are linear taper ones, where the resistances vary linearly w.r.t. position. If we call the position value $$p \in [0, 1]$$, we have $R_1=pR,\quad R_2=(1-p)R$

All very simple and straightforward. Now, let's say we want to use such a potentiometer to control the volume of an audio signal by means of a simple voltage divider, as shown here.

In this case we have $$V_{\rm out}=pV_{\rm in}$$, which on paper seems correct, yet it doesn't take into account that loudness perception is proportional to the logarithm of the signal intensity, according to the Weber-Fechner law (which is itself a coarse approximation — things are much more complicated than that — but also a very useful one).

This means that, given an input signal $$V_{\rm in}$$ of fixed amplitude, we need the amplitude of $$V_{\rm out}$$ to vary exponentially w.r.t. $$p$$. This can be accomplished by so-called "logarithmic" or "audio" taper potentiometers, whose partial resistances follow such exponential mappings. Indeed, I believe the name "audio" stems from this very application.

We need 3 non-collinear points to define an exponential, just like circles, and we certainly want $$R_1=0,R_2=R$$ when $$p=0$$ and $$R_1=R,R_2=0$$ when $$p=1$$. It is then sufficient and customary to specify the midpoint $$p=0.5$$ resistance value $$R_{\rm m}=mR$$ to fully qualify a logarithmic taper. I'll spare you the calculations, the mathematical outcome is

$R_1=l(p,m)R,\quad R_2=(1-l(p,m))R$ $l(p,m)=\frac{m^2\left(1-\left(\frac{1}{m}-1\right)^{2p}\right)}{2m-1}$

The figure above shows curves for potentiometers with 10%, 20%, and 30% midpoint values. I believe that 10% ones are the most common logarithmic potentiometers on the market, but I might be wrong.

Conversely, you'll also find "reverse logarithmic" potentiometers on the market. Mathematically speaking, these are just logarithmic potentiometers where $$m \in (0.5,1)$$, resulting in

If you think about it, the only reason why these exist is that knobs, in particular, are not vertically symmetrical, so from a UX point of view you don't want to just turn a logarithmic knob potentiometer upside down to get such characteristic electronically.

Another kind of potentiometers you might find, especially in wahs, are S-taper ones, in which the slope of the taper curve at both ends is smaller than around the midpoint. I actually don't think there's a more precise definition, so I made up one just to show you what they might look like:

$R_1=s(p,v)R,\quad R_2=(1-s(p,v))R$ $s(p,v)=\frac{1}{2}+\frac{1}{2{\rm tanh}\left(\frac{v}{2}\right)}{\rm tanh}\left(v\left(p-\frac{1}{2}\right)\right)$

TBH, this is atrocious as $$v$$ is rather abstract. You can probably come up with a better definition/parameterization.

Now, this is all very theoretical. In the real world taper curves tend to be less than ideal. Here are some examples.

Finally, in many schematics potentiometers are associated with a letter that actually indicates the taper. There are different conflicting conventions, but the one I've seen most commonly used is the following (which is said to be American/Asian, probably since manufacturers from those parts of the world use it).

CodeType
Alogarithmic (a.k.a., log, audio)
Blinear (a.k.a., lin)
Crevese logarithmic (a.k.a, reverse log, anti log, negative log, reverse audio)

### Emulating tapers

In many actual audio circuits, potentiometers are directly coupled with other resistances for one reason or another. This means that, most often, the resulting curves are further modified by such interactions.

You can deliberately turn this "bug" into a "feature", especially given how bad actual tapers are, and turn linear potentiometers into (reverse) logarithmic ones (well… sort of) by adding extra resistors.

For example, in a voltage divider application, you can add a fixed resistance $$R_p=kR$$ in parallel with the partial resistance across which the output signal is taken to obtain a logarithmic-like taper, like this:

You get the rational mapping

$V_{\rm out}=\frac{kp}{k+p(1-p)}V_{\rm in}$

and you can get the midpoint value $$m$$ you want by choosing

$k=\frac{m}{2-4m}$

Here's a comparison between the amplitude scaling functions when using the ideal 10% logarithmic taper vs the actual corresponding emulated taper.

Likewise, you can put a fixed resistance in parallel with the other partial resistance instead to obtain a reverse logarithmic mapping, like so:

I'll leave the math to you, if you're interested.

As you can see, the results are not necessarily wonderful (they get worse as $$m$$ gets further away from $$0.5$$), but also keep in mind that the total resistance of the potentiometer + extra resistance is also modified and not constant anymore. There are probably other arrangements in which these unwanted side effects are somehow mitigated, but TBH, this is already enough as far as I am concerned.