# Logarithmically-spaced resistances using switches

If you want a linearly-spaced set of resistances, you can use a ladder of logarithmically-spaced resistors and short out different combinations, as described here.

Is there a way to get a logarithmically-spaced set of resistances?

Simplest case:

If you have 2 SPST switches, there are 4 different states they can be in (off-off, on-off, off-on, on-on).

Is there a way to connect these switches with (any arrangement of) resistors, such that the total resistance between two nodes of the 4 states is {1, 10, 100, 1000}? In other words, a digitally-controlled logarithmic rheostat. The states don't have to be in any particular order.

If this is possible, can it be extended to larger numbers of switches (8 values from 3 switches, 16 from 4, etc.)?

• Would be a fun coding challenge I think :P – Wesley Lee Feb 15 '17 at 17:21
• any reason that you couldn't use a subthreshold mosfet? – b degnan Feb 15 '17 at 17:35
• @bdegnan There are other alternatives, I'm just curious about this from a theory perspective. Is it even possible to do this? It seems like it is, but I couldn't find any solution. – endolith Feb 15 '17 at 17:57
• @endolith How about 10 out of 4 switches? See my updated answer. – Neil_UK Feb 22 '17 at 20:52
• @endolith tidied up my answer, and illustrated the ones that work. – Neil_UK Feb 23 '17 at 7:23

I enjoy little combinatorial puzzles, and 'what if' questions, and trying to wring the maximum usefulness out of constrained situations. So while I expect my 'solutions' are not exactly what you're looking for, they may provoke some thought, and possibly further experiment.

If series switches as in a conventional 1, 2, 4, 8 resistor box don't work, how about a parallel arrangement? Like these configurations?

simulate this circuit – Schematic created using CircuitLab

It's a bit of a drag to compute manually, or even build a spreadsheet to compute the total resistance for all switch combinations, so I wrote a python program to crunch the numbers, and used the scipy optimizer to find good values, as although the 3 resistor solution looks systematic, it's not obvious how that extends to more resistors. If you want a copy to play with just ask.

The top arrangement produces the following end to end resistances for all 4 switch combinations: 47ohm, 100ohm, 220ohm, 470ohm. Pretty log, huh! It even follows the E3 resistor selections.

Adding more switches gets finer steps, but we get fewer than 2^n steps from n switches, and we get even fewer ones that are nicely spaced.

The second figure gave 14 unique resistance settings, covering a range of 28.4:1, with the 10 most evenly spaced geometrically being ...

17.2, 23.3, 32.3, 47.9, 67.0, 100.0, 149.2, 222.7, 332.4, 488.1

... which have step ratios between 1.36 and 1.49. Apart from the first one, those values happen to be very close to the E6 series, 22, 33, 47, 68, 100, 150, 220, 330, 470!

This is a plot on a log axis of the resistances

Unfortunately, things don't improve much when we add even more switches. I tried 8 switches, 9 resistors. I tried random values, optimized values, tight spreads, wide spreads. However there was always a big step, often several, in the middle of the range. Had the big step been at the end, that would have been more tolerable. But a big step in the middle cripples general purpose usability, you can't guarantee that you'll be able to find the step you want.

Here is one example of a random run. This allowing a random choice for each resistor in the range 100 to 500ohms.

Over two decades of variation, and mostly fine steps. But you can see those bigger steps, the largest is ratio 1.35, very little better than the 5 resistor case. So while extra switches improved the range a lot, the fineness in the lower resistances a lot, the lack of improvement in big steps in the upper resistances means I don't feel the extension to more switches has the bang for buck. While optimisation can move the big steps around, it doesn't really reduce them that much.

\edit 2019\

A sort of related topic. I wanted to do some low current experiments, and to simplify that, house some large value and wide-range resistors. I like to minimise the number used, and maximise the number of connection possibilities. The following arrangement occured to me using E3 series resistors.

simulate this circuit

Each junction goes to a 4mm socket. Connecting to each resistor in turn obviously gives me the E3 series.

Connecting to pairs of resistors in series, for instance R4+R5 = 3.2M (instead of 3.3M). The other pairs give approximately the other interpolating resistors in the E6 series. 1, 1.47 (1.5), 2.2, 3.2 (3.3), 4.7, 6.9 (6.8).

Connecting to four resistors in series, for instance R4+R5+R6+R7 = 17.9M (instead of 18M). The other quads give approximately half of the remaining interpolating resistors in the E12 range.

Connecting to three resistors in series, with the middle one shorted with a link, for instance R4+R6 = 5.7M (instead of 5.6M). The other 'spaced pairs' give approximately the other remaining interpolating resistors in the E12 range.

/edit 2019\

• Yeah, can you post your code somewhere? – endolith Feb 23 '17 at 14:48
• @endolith Look for user NeilT-UK (notice extra letter) on github, it's the obviously-named repo. It's a bit of a mess, so I apologise, I'm an electronic engineer who also programs, rather than a programmer. My particular switch configuration is hard-baked into the code, needs rewriting to accept others. – Neil_UK Feb 23 '17 at 17:25
• Do you still have that python code laying around? I would love to have a look at it. I'm obsessed with finding out how to make a switched log pot work. – Cape Zoloh Mar 2 '19 at 10:27
• @endolith added a bit more slightly related to my answer – Neil_UK Jun 9 '19 at 20:35

In two terminals, with only binary excitation (on or off), the reason the R, 2R, 4R, 8R ladder works to make "all possible values" is because the numerical system of the resistors matches the numerical system of the excitation.

So, you have 0 with all switches closed, 1 with the first open, 2 with the second open, 3 with the first and second open. And etc if you like.

To get a series of actual decades, unfortunately, you need as many switches as you want useful decades above 1, in a set-up like this:

simulate this circuit – Schematic created using CircuitLab

Which does allow you to also make other weird values, but no easy "multiples", as the system of excitation does not numerically match the system of output and thus inherently requires non-linear elements if you want to make sure 2 binary inputs make (only) the 4 desired outputs.