Quote of the Day

The trouble with the world is that the stupid are cocksure and the intelligent are full of doubt.

— Bertrand Russell. This quote describes my experience in the engineering world. I recently discovered that this observation is called the Dunning-Kruger effect, a form of cognitive bias.

## Introduction

I recently needed to realize a non-standard resistance value precisely in production. Historically, I have used potentiometers (mechanical or electronic) to trim these precision circuits. Potentiometers are undesirable in production because they tend to be expensive, unreliable, mechanical units that require adjustment accessibility, and they can drift.

While I was researching options, I ran across an interesting approach that uses three resistors to realize any resistance from 10 Ω to 1 MΩ within 0.1 % from a set of 70 standard resistance values plus short and open values.

This approach was developed by W. Stephen Woodward, who is a master of analog design. His original article included software to select the resistors, but I was unable to find that code. I have implemented my own version of the code in both Excel VBA and Mathcad, which I discuss below.

## Background

### Definitions

- Brute Force Algorithm
- In computer science, brute-force search or exhaustive search, also known as generate and test, is a very general problem-solving technique that consists of systematically enumerating all possible candidates for the solution and checking whether each candidate satisfies the problem's statement (Source).
- Trimming
- The act of setting a circuit parameter to a specific value by adjusting a component value – usually a resistance. This can be done through a number of means, such as a trim potentiometer, laser trimming, or manual resistor selection from a large stock of values.
- Standard Resistor Values
- Some electronic components (resistors, capacitors, inductors, and Zener diodes) are available from manufacturers in standard values that were determine using the Renard system. The specific values used are referred to as the E-series. For a complete discussion of the E-series of standard component values, see this post.
- Select-In-Test Resistor
- During a calibration activity, a specific resistor value is determined to be required for proper circuit operation. This resistor is then selected from a set of discrete resistors. This approach has the disadvantage of requiring a large set of slightly different resistor values – this is not a practical approach in most cases.

### Operational Use

Many analog circuits require calibration. Often, this calibration involves determining a specific resistor value to ensure that a device meets its requirements. While potentiometers are easy to design in, they can be unreliable in practice. Woodward's circuits (Figure 1) allow three discrete resistors with standard values to be used to set a specific resistance within 0.1%. This is impressive – it allows you to have a small set of standard parts satisfy a requirement for a precise, non-standard resistance value.

## Analysis

For those of you that want to experiment with this routine, I have implemented it in Excel and Mathcad (Source). My discussion below will focus on the implementation in Mathcad, but the Excel implementation is similar. The Excel implementation uses VBA, so you will receive security warnings when you open it.

### Utility Functions

Figure 2 shows some of the utility functions that I used to realize the algorithm.

### Brute Force Resistor Selection Algorithm

Figure 3 shows the algorithm that I used to try every resistor combination. It may not be very efficient, but this algorithm does not need to execute often.

### Test Cases

Figure 4 shows the results of my limited testing.

## Conclusion

This was a good exercise for demonstrating how you can code the same algorithm in both Excel VBA and Mathcad – I thought about using Python, but more electrical engineers use Excel than Python. In any case, I often prototype my algorithms in Mathcad – I find it very easy to experiment in Mathcad.

From a mathematical standpoint, I am not sure how to prove Woodward's claim that you can find a three standard resistor combination to realize any resistor value from 10 Ω to 1 MΩ within 0.1%. I need to think about that for a bit.

Pingback: Standard Resistor Values | Math Encounters Blog

The more common problem for me has been finding values for two standard value resistors to set a certain ratio (to set voltage dividers and whatnot). I came across this great website years ago and have been using it ever since.

http://www.stratoloft.com/teledesign/ResistorRatio.html

This has saved a lot of time over the years.

I completely agree! I always try to design with ratiometric circuits. In fact, I have a post with Mathcad and Excel algorithms for determining optimum resistor ratio combinations coming out next week. Thanks for the link. I was not familiar with that page and I will recommend it to folks.

mathscinotes

Hi Mark,

I have plantar fasciitis which means that I need to stay off my feet for a few days at a time. So, I took at look at Woodward's claim that we can realize any resistor value from 10 ohms to 1 M ohms within 0.1% by using his algorithm. I found a few resistance values out to one decimal place where his algorithm has a error of greater than 0.1% by using MS Access and VBA. The below error results were obtained by using your Excel workbook.

The number of distinct combinations not permutations of his table resistances from your Excel workbook is C(5*14=70,3) for all series resistances plus C(70,3) for parallel resistances plus 70*C(69,2) for his series/parallel resistances for a grand total of 2,437,248 resister possibilities. This does not count the 0.001 or 10^9 ohm resistance rows. When we filter by his ranges of 10 to 500, 500 to 25,000, and 25,000 for respective parallel, series/parallel and series calculations, we have 187,382 different approximations based on MS Access calculations. If I round the resistance approximations to three decimal places, we have 109,445 different approximations.

By looking at the halfway points between each resistance approximation, I was able to verify his claim of his resistance approximation being within 0.1% error with the exception of the above, first paragraph numbers.

There is one change that I'd do to his algorithm, I'd allow a series check in addition to his parallel and combination checks. For example, from the first column labeled RSet_1 in the Excel workbook, we have resistance values of 27.1, 33.2 and 38.8 which sum to 99.1. Woodward's algorithm provides an approximation value of 99.1 to one decimal place using parallel resisters with a minor error percentage.

For the fun of it, I also made an Excel Workbook using Linear Programming to come up with the best match for any series combination of those resisters.

Thanks for a fun mathematical excursion

I have a case of I have plantar fasciitis in my left foot right now. I also am trying to keep off of it. Ouch!

mathscinotes

Note that there is a space separating the "Desired" and "Error" numbers in my above comments. Is there a formatting option for data entry in this comments section?

I know that you can add html to the comments. I swooped in and added some HTML table commands. Hope that looks ok.

mathscinotes

Looks Great

One slight correction to the my above info. The combination counts are based on the inner 14 by 5 resistance table, but the filtered results of 187,382 and 109,445 are based on the complete 16 by 5 resistance table which includes the 14 by 5 table plus rows for 0.001 and 10^9 resistance.

I would see two possible ways to fix this:

(1) You delete my original post, so that I can post the revised version once more; this might bring up certain issues with the creation date, though.

(2) I send you the revised version via e-mail, and you simply replace the preliminary version with the revised one. To avoid unwanted line breaks (Windows often suffers from such issues), I would include my corresponding Unix plain text file as e-mail attachment.

Of course, the revised version is not fundamentally different from the preliminary version. I've just fixed certain list issues (your lists are somewhat different from the standard HTML lists) and added a few clarifications to my original description.

By the way: My guess is that your ‘edit’ function does not work as it's supposed to do, at least ‘delete’ does not really delete everything, including the entire history. In view of this, a true preview option might be highly desirable…

I deleted everything there. If that is a problem, I can restore it and fix it on my side.

Hi Mark,

I came across this interesting blog about two years ago. And as I had recently produced an extensive set of easy-to-use tables dealing with combinations of E-series values and with ratios thereof, this blog immediately caught my attention.

Douglas Self, who was the first ‘external’ user of some of my tables, had asked me to make them publicly available to interested users. The complete set, including documentation, can now be downloaded from The Amplifier Institute.

I had produced these tables with dedicated MacSpice scripts. This software offers a high-quality front-end (shell) which also serves as a higher-level programming language with built-in multidimensional vector support, a very clean IEEE 754 floating-point arithmetic, and numerous predefined functions, including numerical integration/differentiation and sorting—plus a complete SPICE 3f5 circuit simulator. Due to these unique features, MacSpice has been my favorite simulation tool for many years and I've been using it for circuit simulations as well as for most related mathematical computations.

MacSpice is available for free at MacSpice.com and currently requires Mac OS X 10.6.8 or later.

Woodward's Accuracy ClaimAs I already had most of the required scripts at hand, I first tried to verify Woodward's claim that any resistance value between 10 ohm and 1 Mohm can be realized with an accuracy better than 0.1%. For this, I generated all feasible combinations of resistance values under the given restrictions (excluding permutations), sorted the resulting values in ascending order, and then evaluated the corresponding array of values. All calculations were performed in IEEE double precision (about 16 decimal digits).

With Woodward's original set of 70 base values, this whole array comprised exactly 159222 combinations with 152820 distinct values. In order to remove unwanted numerical artifacts, however, I used idealized values to represent open circuits (infinity instead of 10^9 or 10^12 ohm) and short circuits (0 ohm instead of 0.001 ohm); the combination-generating parts of my scripts allowed to implement this quite smoothly.

Besides, the reason for using non-infinite or non-zero dummy values is not quite clear to me. If this is to account for certain parasitic elements (i.e., 10^12 ohm for a left-out resistor and a residual of 0.001 ohm for a shorted resistor), such parasitic elements would have to be added to all other resistors, too, which is obviously not the case. And IEEE floating-point arithmetic does not require it either.

As regards computer floating-point arithmetic, a brief excursion might be enlightening at this point. With binary floating-point arithmetic, even a supposedly simple decimal value such as 1.2 cannot be represented exactly (1.25, 1.5, and 1.875 can be), and as a consequence, sums of three or more such values can vary slightly depending on the sequence of operations. Hence, ‘a+b+c’ need not necessarily yield exactly the same result as ‘c+b+a’, and the divisions in connection with parallel resistors tend to make things even worse. Because of this, comparisons and tests for equality or inequality have to be implemented carefully in this context, for example:

• ‘if (R < 500)’ is best implemented as ‘if (R < 500*(1–eps))’

• ‘if (R <= 500)’ is best implemented as ‘if (R <= 500*(1+eps))’

• ‘if (R = 500)’ is best implemented as ‘if (abs(R–500) <= 500*eps)’

In case of IEEE double precision, ‘eps’ will typically be in the order of 10^–14. Such subtle potential pitfalls should always be kept in mind when dealing with computer floating-point arithmetic.

For the three non-overlapping resistance intervals, we then have:

• 41101 combinations in the interval 10 ohm ≤ R < 500 ohm

• 76444 combinations in the interval 500 ohm ≤ R ≤ 25 kohm

• 41677 combinations in the interval 25 kohm < R ≤ 1 Mohm

I'm assuming exactly the same interval bounds as Mark. Woodward's original publication of 2010 is a bit lazy in this respect so that, in the strict sense, the two values 500 ohm and 25 kohm would be excluded.

A careful evaluation of the sorted array of resulting resistance values then revealed the following twelve resistance sub-ranges, where the claimed 0.1% accuracy cannot be achieved:

Besides these admittedly minor imperfections, however, Woodward's attempt also suffers from three other drawbacks:

(1)It uses only one single type of combinations to approximate a given resistance value, depending on the above three resistance intervals. This is an unnecessary restriction, as already noted by Ronan Mandra.(2)It includes numerous combinations of resistors (in fact more than 30% of all combinations) with values too far apart from each other to render such a combination practically useful. For instance, 91 out of the 94 values between 100 kohm and 100.1 kohm are realized with series connections of a 100 kohm resistor with one or two resistors of less than 100 ohm. However, the nominal tolerance of this 100 kohm resistor itself (typically in the order of 0.1% in the current context) will be the limiting factor here, thus rendering series connections with resistors of less than about 100 ohm virtually irrelevant.(3)It does not include a fourth, generic three-resistor combination which would provide additional flexibility, namely the parallel/series combination where R1 is connected in parallel to R2+R3 (see the ASCII graphic below). This is combination type ‘D’ from my tables with total resistance 1 ⁄ (1 ⁄ R1 + 1 ⁄ (R2+R3)).These points, together with the above critical resistance sub-ranges, raised the question whether a better strategy exists which would probably need even fewer resistors as base values. This will be addressed in the following.

An Improved AttemptMy first observation was that Woodward's set of resistors uses the closest E192 approximations to the set of E12 values (100, 120, 150, 180, 220, 270, 330, 390, 470, 560, 680, and 820) plus two additional E192 approximations to the E24 values 510 and 750 as base values in all decades. This particular choice need not necessarily be optimal. Besides, the E192 series is less common and perhaps also a bit more expensive than the widely-used E96 series.

Second, the above critical resistance sub-ranges are exclusively located either near the lower or near the upper end of values, hardly affecting more than the first or last decade, respectively, whereas the ‘middle’ decades do not suffer from such approximation issues. This is an indication that fewer values per decade might be sufficient for the middle decades.

In particular, I wanted to determine the smallest set (or at least one of the smallest sets) of distinct resistance values from the E96 series needed to realize any arbitrary value in the range from 10 ohm to 1 Mohm with an accuracy strictly better than 0.1%, using a single resistor or arbitrary, yet reasonable combinations of two or three resistors.

Performing an exhaustive search over all possible subsets of resistors was of course totally out of reach due to the huge number of such subsets. And trying to use a standard optimization algorithm would not work either because the underlying problem belongs to the class of so-called integer optimization problems which are inherently hard to solve and, even worse, for which no efficient general-purpose algorithms are known. So I needed a better strategy—and in retrospect, this was both an interesting and a surprisingly complex research project!

I tackled this in two steps:

Step 1:Find the best minimal set (or at least one of the best sets) of base values per decade which allows to approximate any arbitrary value in a middle decade with an accuracy better than 0.1%, using either a single resistor or arbitrary combinations of two or three resistors, yet under the restriction that the ratio between the largest finite value and the smallest non-zero value used in a particular combination does not exceed an upper limit of 1000. Such an upper limit corresponds to nominal component tolerances in the order of 0.1% for the dominant values of a combination. The series/parallel and parallel/series combinations would in principle allow a bit more flexibility in this respect; this didn't have significant impact on the results, though.Step 2:Find the two minimal sets of additional values, if any, which have to be included in the first or last decade, respectively, of the considered resistance interval so that the first and last decades also satisfy the above accuracy criterion. From Woodward's results it can be expected that this will require just a few additional values in the first and last decade.After a number of preliminary trials, it became clear that a strictly or near-strictly logarithmic spacing of base values would yield the most promising results in Step 1. Note that Woodward's set of base values differs significantly from this, particularly at the upper end of each decade.

I started with 12 logarithmically spaced values per decade in Step 1, all taken from the E96 series, yet with the first value of the base decade kept fixed at 100, for convenience and also to keep things reasonably simple and computationally tractable. As 12 values were by far sufficient for the desired accuracy, I reduced the number of values to 10, then to 9, and finally to 8 per decade; further reductions didn't seem to be advisable with Step 2 in mind. The resulting eight base values were 100, 133, 178, 237, 316, 422, 562, and 750.

Using this set of values as starting point, I then performed an exhaustive search over all feasible combinations that included the respective next-lower and next-higher E96 values, except for the first value, which was still kept fixed at 100. This exhaustive search therefore comprised 3^7 = 2187 distinct combinations of E96 values and needed almost one day of CPU time on my older Mac (MacSpice scripts run in interpreter mode). Using five instead of three adjacent values would have taken 36 times as long, so I abandoned this.

The best combination from this exhaustive search yielded a maximum error of 0.0605% for the middle decade; and more than 200 combinations were still below 0.07%. With this, there ought to be sufficient headroom left for Step 2.

For Step 2, I then took all combinations from Step 1 which were better than 0.065% (about 30 in total) into account, plus another 40 or so promising combinations out of the remaining 170 with maximum errors below 0.07%.

I made again some preliminary, systematic studies using different candidate combinations from Step 1 and trying different sets of additional values. The results showed that it should be sufficient to insert four additional values near the beginning of the first decade and another four near the end of the last decade; three values were not sufficient, no matter what I tried. It also turned out to be highly desirable to place 1 Mohm explicitly at the end of the set, thus making the beginning and the end of the entire set virtually symmetrical on a logarithmic scale. Furthermore, empirical evidence indicated that the best locations for these additional values ought to be approximately half-way between the first or last five values, respectively. Other distributions of these additional values turned out to be sub-optimal.

Similarly to Step 1, I once more performed an exhaustive search over all feasible combinations that included three adjacent E96 values for each of the additional values. Because the upper end of the considered resistance interval from 10 ohm to 1 Mohm is nicely de-coupled from the lower end, both ends could be treated here simultaneously, thus requiring the analysis of 3^4 = 81 distinct sets of values for each one of the 70 or so most promising candidates from Step 1. This consumed almost one week of CPU time.

After all, I was able to determine the (supposedly) best set of merely 49 carefully chosen values from the E96 series which were sufficient to satisfy all requirements. This set is as follows:

Not surprisingly, the final set of base values for middle decades is very close to the set of initial values from Step 1, differing only in two positions (243 instead of 237, and 732 instead of 750).

With these 49 resistors on stock, any value from 10 ohm to 1 Mohm can be realized with an accuracy better than 0.0943%, using no more than three resistors from this set; the expected error for a randomly chosen target value (on a logarithmic scale) is merely 0.0087%. This represents a considerable improvement compared to Woodward's original attempt, particularly as the total number of resistors is also reduced from 70 to 49. Besides, the number of combinations is reduced, too, from 159222 to 87436 with 86262 distinct values.

Without the restriction to the target interval from 10 ohm to 1 Mohm, that is, with all feasible combinations of values allowed (90815 combinations with 89531 distinct values), resistance values from about 3.333 ohm (3 × 10 ohm in parallel) to 3 Mohm (3 × 1 Mohm in series) can be realized. The 0.1% accuracy criterion is then met for all values from about 8.01 ohm to 1.186 Mohm.

Side note: With just two resistors allowed in a combination, the above set of values leads to 1857 combinations with 1848 distinct values and yields a maximum error of 2.1069% and an expected error of 0.34%; and a still quite reasonable accuracy of 2.5% could then be achieved from 5.57 ohm to 1.776 Mohm.

In cases where an accuracy of 1% is sufficient (with three-resistor combinations), the required set of resistors can be made even smaller, comprising just the following 23 values:

Incidentally, all these values are from the E48 series. For the underlying computations, the logarithmic spacing of base values was less crucial than in the preceding case, supposedly because mere numerical coincidences did also play an important role here. Therefore, I performed broader exhaustive searches, taking nine instead of just three adjacent values into account in Step 1 and a minimum of 20 candidate values for each of the two additional values in Step 2. Also, a maximum allowed ratio of 100 between combined values appeared to be adequate here, corresponding to nominal component tolerances in the order of 1%.

With this, the total number of combinations is 5861 with 5819 distinct values, yielding a maximum error of 0.8331% and an expected error of 0.1068%. The 1% accuracy criterion could in principle be met with this set from about 6.79 ohm to 1.471 Mohm.

From the above two tables, it ought to be quite obvious how the target resistance interval can be extend towards lower and/or higher decades, if this is desired.

Some Final RemarksAnd finally, a word on the PCB layout for practical circuit implementations. To allow any one of the seven possible resistor combinations, that is,

1. one single resistor

2. two resistors in series

3. three resistors in series

4. two resistors in parallel

5. three resistors in parallel

6. one resistor in series with two in parallel

7. one resistor in parallel with two in series

to be populated on the PCB, a set of five properly interconnected resistor placement areas is sufficient, thus requiring 10 pads in SMD technology. One possible topology is as follows (ASCII graphic):

Each horizontal pair of pads ‘–[ ]–’ represents a resistor placement area, line-like symbols and plus signs are interconnections. With this topology, only the combinations 4, 5, and 6 will need additional 0 ohm resistors (one for the combinations 4 and 6, two for combination 5). This ought to be acceptable in view of the fact that such ‘odd’, high-precision resistance values will only be needed in very few places.

The basic motivation for providing my set of pre-computed tables of combinations of E-series values (see the beginning of this reply) was to relieve users from having to perform the rather complex computations for finding best fits over and over again for each individual request, when a simple table look-up can do this in a fraction of the time. The required memory to store such a table is not a limiting factor on today's computers, notepads, or even smart-phones. And filtering a table, for example, according to Woodward's partitioning scheme is also straightforward.

Hence, it might be desirable to make the above two special tables of resistor combinations also directly available for download, for instance, in the form of zipped text files. These two files would be roughly 1 MB in total.

Mark, if you're interested in these two tables, just let me know…