Design proposal for new E96 (1%) resistor calculator (and I would implement it if approved)

71 views
Skip to first unread message

Steve Bollinger

unread,
Apr 20, 2023, 7:16:29 PM4/20/23
to dev...@kicad.org
I would like to add features to the resistor portion of the PCB calculator.

The reason for this is my primary need from a resistor calculator is simply to tell me the correct/nearest e-series value for a value I have just calculated. I use 1% resistors almost all the time so E96 is what I need. But the calculator doesn't do E96.

I prototyped adding this and so I see inside why it doesn't (computational complexity). I have taken this into account for my proposal. However, there is also one existing piece of functionality I would have to change. I will mention that first.

That is, the functionality of automatically excluding the entered value from the list of possible results works against you when you are looking for the closest match. For example, if I were to type in '100' (100K) the closest match is 100K and I'd like that as a match. The proposal assumes this functionality has been removed and I will discuss at the end what to do about replacing that functionality.

I would propose adding e96 (and possibly e48) to the selections in the calculator. When you enter a value using e96 mode it will calculate the nearest single resistor to that value. It also will calculate the nearest you can get with two resistors. Did you know that with at most two e96 resistors in series you can create any value to 3 significant figures? For example, say you want 164K, that's 105K + 59K. If you want 241 Ohms, that's 182 + 59. Oh, you actually wanted 165K? That's an E96 value by itself, a single 165K resistor. This property isn't an accident, it is a feature of the E96 series. It is a feature (to lesser precision) of the other series too.

Given E96 resistors are 1% accurate that really means you never need more than 2 resistors, you are already within 1% of the requested value (often much better). But if it is desired I could calculate 3 resistors or 4 to approximate the value even more closely. However I do not see a lot of value in this. These 3 and 4 resistor values would not be guaranteed to be the best possible as the search would not be exhaustive and not all topologies would be considered.

This algorithm is not well suited for the available option of two excluded values. However I think I can make it work.

I use values below 10 Ohm and (rarely) above 1M, so I would extend the range it will attempt to match down to 1 Ohm and up to 10M for E96. I could even go further. This is not a problem for the E96 algorithm. And due to how the algorithm works it would not cause the algorithm to use resistors outside the 10 to 1M range for the 2 resistor solutions unless you request a value at the ends of that range. This is the case as the resistors returned for the 2 value answers are always in the same decade as the desired value or the top portion of the one below. So if you ask for 97.6K it's never going to suggest you use a 97.5999K and 0.1 Ohm resistor in series.

Now about the issue of automatic exclusion of the entered value.

My preferred solution would be to remove this functionality. I just don't think it is a common use. As the 'exclude values' remain the user could just enter the initial value into the exclude box if she wants another approximation. The target value could even be automatically entered into the exclude box when you enter a value but I do not recommend as the common case is to find the nearest e-series value and it would make that a two step process.

I also propose that optionally an option to exclude higher or lower results could be added. The reason for this would be if you want a resistance which is *at least* the entered value or *at most* the entered value. I do feel this would make the window busy and is not needed in the most common case. However if you did need a value that was *at least* the entered value and a lower one is returned then you are in a situation where you either need to consult E-series tables yourself, do a bunch of math on your own, or start entering iterative values into the target resistance until you get a value that meets your criteria. So there is an argument for it.

JV

unread,
Apr 21, 2023, 2:08:28 AM4/21/23
to dev...@kicad.org, Steve Bollinger
The resistor calculator is for the moment something unlucky as it
misleads some users from intuitive use. It is intended to find any close
matching combinations for values what you NOT have in your drawer. It is
not intended to find any (E96) value what you already have on stock.

The code was written with Kicad V5 and stopped to be included as a new
feature in V6. In the meantime, the overcrowded calculator tabulator
selection is improved by a tree view selection. Unfortunately, the
resistor calculator went into the "Memo" section of the tree selector
beside the color table as its name is still "e-series". I choosed
E-series as it was the shortest imaginable name for use inside the
limited tabulator selection space and it was required to take all
possible language translations for names like "serial-parallel-
resistor-calculator" into account where there was simply no space.

There is a warning to try you suggestion as the calculation time already
goes up for E3/E6/E12 with the cube of the iterations. If adding further
finer grained E-series, calculation time always goes up with higher
powers. E24 already required several seconds a few years ago with my
Intel enthusiast machine. I tried to add a progress bar to determine if
Kicad crashed or calculator is busy. Unfortunately, screen updates were
only done in background by wxWidgets and only done after iterations were
complete although I added calls for screen updates in the iteration
loops. For same reasons the decades are limited for the most used range
from Ohm to Megaohm. Thats why I stopped this for not missing the the
Version 6 closing time for new features.

Higher e-series than E12 are already defined in eseries.h but not used
by the resistor calculator for above reasons. More reasons are the
component tolerances what are not taken into account by the calculator.
Probably in the meantime e-series header file is also shared for some
simulator code to avoid double definitions.

To solve your and some other bug reports with your remarkable
motivation, I suggest following steps:

- remove the E-series table in the resistor calculators help text
(there is already a bug report therefore what you may solve with)
- rename the resistor calculator from e-series into resistor-calculator
- move the resistor calculator to system design branch of tree selector
- add all series up to E96 or higher into eseries.h
- write html format static lookup table e-series using eseries.h
- locate this new lookup table in the memo branch of tree selector

best
Jan

Steve Bollinger

unread,
Apr 21, 2023, 2:09:17 PM4/21/23
to KiCad Developers, JV, Steve Bollinger
Okay, let me break this idea in half. Since it's grown and we can always try to do both halves in succession if it makes sense.

I would suggest to do first:

All of your 6 things at the bottom. However, NOT including adding E48 and E96 to the calculator at this time. I say this because we don't really haven't made a decision to make that tool useful in the way I think it would be useful (remove the exclusion). So for now, just leave it alone. It will remain only up to E24 and with the exclusion and all the topologies. But as you indicate in your 6 things, remove the help text.

I think we should consider renaming "color code" because I think in the future we could have a decoder for SMD resistors in this same pane. Or would we think that is a separate pane?

After these changes it will improve my personal workflow. I won't have to go to: https://www.logwell.com/tech/components/resistor_values.html to find E96 resistors anymore. It won't do any E96 calculations (finding the best 2 value solution), but I do that rather rarely and maybe I can just spruce up my python script I wrote to offer that for me.

After this is done and if we like it we can then consider adding E96 (and E48) into the resistor calculator using the method I mentioned. Or perhaps another if there is a better way.

To make my case for my suggested method not being not too calculation intensive to find E96 values I did a breakdown of the algorithm. A resistor value could be generated using the following steps.

1. Round the value to 3 significant figures. This is the target value.
2. Compose a list of every value in two E-Series decades containing the target value and the one below.
3. Is the target value in the list (binary search)? If so, done.
4. For every value in the list determine the difference between it and the target value. Is this value also in the list (binary search)? If so, done.

Step 3 would take up to 8 compares. Step 4 would take up to 1536 compares.

So it really wouldn't take long at all. If you want the value with 3 or 4 resistors (and haven't hit it yet) then you have to change your rounding in step 1 to round down. Then execute the algoritm once. After that, subtract the target value from the initial value and repeat the algorithm for the difference. Then you can hit any value to 6 significant figures to within 0.5% but with a potential error (due to resistor tolerance) of +/-2.002%. I really cannot see a value of any close approximation.
Reply all
Reply to author
Forward
0 new messages