Author Topic: standard value resistor / capacitor combination tool  (Read 7474 times)

0 Members and 1 Guest are viewing this topic.

Offline OM222OTopic starter

  • Frequent Contributor
  • **
  • Posts: 768
  • Country: gb
standard value resistor / capacitor combination tool
« on: October 30, 2019, 02:19:30 am »
I've been needing to use some resistor or capacitor values that are not standard and have to be achieved via using a combination of series or parallel resistors from the standard sets. This gets extremely tedious, especially when you do it by hand so I decided to write a python script to do it for me  ;D

This tool allows you to find a set of resistors (you can specify how many!) from a given standard set (supports E3 to E192!) that result in a desired final resistance.

the interface is quite simple: there are two functions, each of which return a set of values that has been found. to call them you need 3 variables: the number of resistors that are used to reach the desired value, the standard set to use and finally the desired value. you can call them like below:
Code: [Select]
series(3,E24,6)   #series(Number of resistors to use, Standard series , Resulting value)
parallel(3,E24,6) #same interface as series

also there is a function which tidies up the results and prints them in a table like format. it's called print_results and takes two parameters: the title of the table and the values to be printed. it can be used like this:

Code: [Select]
print_results("Series resistor combinations: " , series(3,E24,6)) #This will print the results of searching for 3 resistors in E24 series that have a total of 6ohms resistance

I have also made an online version that you can use without even installing a python compiler. just go to the link below and run the program:
https://repl.it/repls/WarpedOilyHarddrive

the names of the series you can use are listed at the very top (i.e: E192,E96,E48,etc. ) and the functions are called at the very bottom, so you can just change the values you're searching for at the very last 2 lines.

My next goals are to add functionality to search for potential divider ratios and add a tolerance value as well, so if the exact value was not found, the results within tolerance are displayed. please leave your feedback and let me know if you would like to use a similar program if I make it a bit more user-friendly or if you think it's pointless and doing it by hand is still easier for you.
 
The following users thanked this post: thm_w, Brutte, Kirr, syau

Offline Brutte

  • Frequent Contributor
  • **
  • Posts: 614
Re: standard value resistor / capacitor combination tool
« Reply #1 on: October 30, 2019, 09:12:45 am »
Hi and thanks.  :-+
Idea is ok but to make it practical you need to introduce tolerance and find all nearest solutions within tolerance and not empty sets: parallel(2,E24,2.1).

Also, I suggest including some unit testing.
For example currently parallel(2,E24,1) returns 1.5||3 which is unlikely.
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 22435
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: standard value resistor / capacitor combination tool
« Reply #2 on: October 30, 2019, 09:18:51 am »
You'll probably hate this but "it's been done":
http://kirr.homeunix.org/electronics/resistor-network-finder/
:D
Kirill is on the forum if you have questions.  Forget if he was working on a ratio too?

Also http://jansson.us/resistors.html which is simpler but does ratios.

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 
The following users thanked this post: cgroen, Kirr

Offline OM222OTopic starter

  • Frequent Contributor
  • **
  • Posts: 768
  • Country: gb
Re: standard value resistor / capacitor combination tool
« Reply #3 on: October 30, 2019, 05:41:19 pm »
Hi and thanks.  :-+
Idea is ok but to make it practical you need to introduce tolerance and find all nearest solutions within tolerance and not empty sets: parallel(2,E24,2.1).

Also, I suggest including some unit testing.
For example currently parallel(2,E24,1) returns 1.5||3 which is unlikely.

Hi! the tolerance feature is now added. the 4th variable indicates the tolerance in percentage, you can check it again here:

https://repl.it/repls/WarpedOilyHarddrive

what do you mean by unit testing? 1.5 and 3 ohms does give you the value that you're looking for. if you want to use the same resistor value, then perhaps you should try increasing the number of allowed resistors to 3 or 4? or maybe I misunderstood your comment, please clarify in more details :D

You'll probably hate this but "it's been done":
http://kirr.homeunix.org/electronics/resistor-network-finder/
:D
Kirill is on the forum if you have questions.  Forget if he was working on a ratio too?

Also http://jansson.us/resistors.html which is simpler but does ratios.

Tim

I don't claim to be the first one to come up with the idea and I don't even hate it! I actually used to search for that online, but most of them are hard to find / clunky or not flexible which wastes more time than actually doing them by hand which is a really backwards way of doing things. for example the links you provided: even after reading the help section, I still have no idea how to use the tool! As for the second one is easy to use, but it's only good if you want to use 2 resistors, not more. I'm still working on adding functionality such as exact voltage divider ratios. Obviously I'm biased towards my own work, but I think my tool is more flexible and easier to use compared to what already exists  :P
 

Offline Brutte

  • Frequent Contributor
  • **
  • Posts: 614
Re: standard value resistor / capacitor combination tool
« Reply #4 on: October 30, 2019, 10:20:56 pm »
what do you mean by unit testing? 1.5 and 3 ohms does give you the value that you're looking for.
:palm: Yes, you are right, I messed up the arguments.

Anyway, it is not a bad idea to run some automated unit tests to check if your code works fine with every change included.


 

Offline Kirr

  • Regular Contributor
  • *
  • Posts: 66
  • Country: jp
Re: standard value resistor / capacitor combination tool
« Reply #5 on: October 30, 2019, 11:15:01 pm »
Hey all,

Nice to have more activity in this area!

OM222O, nice code. It would probably be even more useful if it could mix parallel and serial connections.

T3sl4co1l, thanks for mentioning my calculator! Yeah, I was going to add ratio targets, but did not get to it yet. Some day. :)

for example the links you provided: even after reading the help section, I still have no idea how to use the tool!
I'm really curious about what could be made more clear in my calculator interface. There's always space for improvement I guess! I will be thankful for any pointers as to what you find confusing or unintuitive!
« Last Edit: October 30, 2019, 11:17:17 pm by Kirr »
 

Offline Kirr

  • Regular Contributor
  • *
  • Posts: 66
  • Country: jp
Re: standard value resistor / capacitor combination tool
« Reply #6 on: October 30, 2019, 11:42:59 pm »
Obviously I'm biased towards my own work, but I think my tool is more flexible and easier to use compared to what already exists  :P
Just for the purpose of avoiding misunderstanding, please allow me to highlight some of the features of Resistor Network Finder:

1. It finds optimal networks among all possible topologies, and can mix serial, parallel and bridges. (The topologies to use are selectable).

2. It allows using fully custom stock, by mixing standard range of values, specifying gaps (missing values), and extras (e.g., non-standard values).

I think this qualifies my tool as uniquely flexible. (I don't think OM222O's tool has these features - yet?).

As for the ease of use - it probably depends mostly on personal preferences. So, more different choices can be only good. :-+

Offline OM222OTopic starter

  • Frequent Contributor
  • **
  • Posts: 768
  • Country: gb
Re: standard value resistor / capacitor combination tool
« Reply #7 on: October 31, 2019, 12:35:38 am »
Hi Kirr, thanks for the feedback!

I'll try to explain why I don't find the tool intuitive to use. here is what it looks like:


The series is straight-forward, nothing wrong there.
Having a few specific values seems odd, you usually design for a product which means buying stock shouldn't be an issue, but I guess it's fine for desperate times and one off builds.

I have no idea what "All from - to -" means. all the values in the selected series? the custom input? what happens if both a standard set and some custom values are entered? maybe having a radio-button to select between the two is a good idea.

How should the gaps be entered? are multiple gaps covered? is it specific values or a range? these are not mentioned in the help section.

Extra values don't make any sense imho. if you had the money to have a custom value resistor made for you, the chances are that you get it in the exact value that you want, rather than having it mixed with other standard or even more non standard values! these are just practical considerations, but I think it should be taken into account.

what are the "most useful additional values"? again nothing is mentioned in the help section.

what is a resistor bridge? do you mean the famous Wheatstone bridge or a combination of series and parallel?

There also seems to be some issues with the calculations of the tool. try searching for 14 ohm target , allow upto 3 resistors and set tolerance to 10%, it misses the obvious choice of 13+1 or 12+2 ohm resistors and tells you to just use the 13 ohm resistor anyways  :-DD now that's not very helpful is it?

I have managed to break my code as well during experimentations, but I will post an update when I fix it.
« Last Edit: October 31, 2019, 12:43:23 am by OM222O »
 
The following users thanked this post: Kirr

Offline OM222OTopic starter

  • Frequent Contributor
  • **
  • Posts: 768
  • Country: gb
Re: standard value resistor / capacitor combination tool
« Reply #8 on: October 31, 2019, 02:10:59 am »
You can find the latest update here (I decided to make new addresses in order to stop breaking the code when people are using it  :-DD):
https://repl.it/repls/LustrousOddballSpool

I wrapped both search methods into one function , so the first parameter is now the searching method, but the rest are the same. the two methods are called:
Quote
alg_sum : algebraic sum of the values, used for series resistance and parallel capacitance calculations

inv_sum : sum of the inverse values, used for parallel resistance and series capacitance calculations

this version will find all the values and sorts them in order of tolerance (there might be some duplicates, due to rounding errors of floats which I don't think is easily fixable for right now, short of brute forcing values to a certain number of decimal places and converting back to floats which isn't a great solution). Other than that small gripe, I don't think I've missed anything, but feel free to correct me if you see something odd  ;D this is just some code I threw together in a few hours.
« Last Edit: October 31, 2019, 02:13:59 am by OM222O »
 

Offline Kirr

  • Regular Contributor
  • *
  • Posts: 66
  • Country: jp
Re: standard value resistor / capacitor combination tool
« Reply #9 on: October 31, 2019, 02:12:36 am »
Thank you for the excellent feedback, OM222O!

The series is straight-forward, nothing wrong there.
Having a few specific values seems odd, you usually design for a product which means buying stock shouldn't be an issue, but I guess it's fine for desperate times and one off builds.
Yes, specific values in each decade is an edge case. I guess it's mostly useful for puzzles, like only using powers of 10.

I have no idea what "All from - to -" means. all the values in the selected series? the custom input?
Right, "From ... to ..." is for specifying the range of the selected series. If left unspecified, the default is from 1 Ohm to 1 MOhm (indicated in the result report). However sometimes you may want to use larger range (e.g., till 22 MOhm range is still common depending on application), or reduce the range to speed up calculation (and avoid hitting the limit due to combinatorial explosion of possible networks).

The "From .... to ..." range only applies to the fields above it in the form. I.e., to series and significands. The list of extra values does not care about range, because extra values are listed one by one.

what happens if both a standard set and some custom values are entered? maybe having a radio-button to select between the two is a good idea.
They are mixed and used together!

How should the gaps be entered? are multiple gaps covered? is it specific values or a range? these are not mentioned in the help section.
Space-separated list of specific values. I'll have to add explanation for this, thanks and sorry for confusion!!

Extra values don't make any sense imho. if you had the money to have a custom value resistor made for you, the chances are that you get it in the exact value that you want, rather than having it mixed with other standard or even more non standard values! these are just practical considerations, but I think it should be taken into account.
Non-standard, in the sense that those values are not included in your selected series. This is useful in a very common scenario, where you stock the entire E24 series, and just some selected E48 or E96 that you needed previously, so you stocked 200 of them. So you select E24 series, and add those extra values in the extra list. This allows specifying your entire stock in such mixed series cases.

what are the "most useful additional values"? again nothing is mentioned in the help section.
This is indeed a weak point of my tool. It's currently underpowered and unfinished. I should probably move this function to a separate tool. The idea is simple though - it's for suggesting which extra value you need to get to be able to achieve all your target values, using your current stock + the additional value. I admit that it's of mainly theoretical interest.

what is a resistor bridge? do you mean the famous Wheatstone bridge or a combination of series and parallel?
Yes, it's Wheatstone bridge with a resistor on all 5 connections. Such topology can produce values that cannot be obtained by only series and parallel connections of 5 resistors.

There also seems to be some issues with the calculations of the tool. try searching for 14 ohm target , allow upto 3 resistors and set tolerance to 10%, it misses the obvious choice of 13+1 or 12+2 ohm resistors and tells you to just use the 13 ohm resistor anyways  :-DD now that's not very helpful is it?
The tool adds another resistor only if it did not hit the error target yet. Since 13 Ohm is already within 10% of 14 Ohm, the tool is satisfied, and does not add second resistor. If you are looking for the most precise fit possible, it's best to set the error to 0.

Thanks for great questions and feedback! It seems I have work to do!  :-+
« Last Edit: October 31, 2019, 02:19:26 am by Kirr »
 
The following users thanked this post: OM222O

Offline OM222OTopic starter

  • Frequent Contributor
  • **
  • Posts: 768
  • Country: gb
Re: standard value resistor / capacitor combination tool
« Reply #10 on: October 31, 2019, 02:28:18 am »
Right, "From ... to ..." is for specifying the range of the selected series. If left unspecified, the default is from 1 Ohm to 1 MOhm (indicated in the result report). However sometimes you may want to use larger range (e.g., till 22 MOhm range is still common depending on application), or reduce the range to speed up calculation (and avoid hitting the limit due to combinatorial explosion of possible networks).

The "From .... to ..." range only applies to the fields above it in the form. I.e., to series and significands. The list of extra values does not care about range, because extra values are listed one by one.

I see! I get around that issue entirely by using these few lines to "normalize" the data to a range between 0 and 10:
Code: [Select]
    unmodified_x = x
    scale_factor = 1
   
    if (x>np.amax(values)):
        while(x>np.amax(values)):
            scale_factor *= 10
            x /= 10
    elif(x<np.amin(values)):
        while(x<np.amin(values)):
            scale_factor /= 10
            x *= 10

I'm not sure which language you're using, but you should be able to do a very similar thing. In order to use values close to the desired one, I'm adding more values to the set which are one order of magnitude larger or smaller than the values in the series:

Code: [Select]
    values = np.hstack((values/10 , values))
    values = np.hstack((values , values*10))

I figured that 10 times larger and smaller should be good enough since the effects of resistors outside that range are either way too large (parallel resistors that are 10 times smaller or series resistors that are 10 times larger!) or way too small (opposite of what I said before). but you can easily add 100 times or even 1000 times values. this keeps the finite element analysis under control and prevents data sizes from exploding  :-+ you can completely bypass the range issue this way.

If you really want to use notations such as K m etc, it's as simple as keeping a copy of the notation used, normalizing and finding the values, then sticking the notation to the end of all the results. it's a really basic formatting issue haha. This greatly simplifies your code and makes the software less confusing in my opinion!

The tool adds another resistor only if it did not hit the error target yet. Since 13 Ohm is already within 10% of 14 Ohm, the tool is satisfied, and does not add second resistor. If you are looking for the most precise fit possible, it's best to set the error to 0.

Thanks for great questions and feedback! It seems I have work to do!  :-+

Oh! so this tries to find a best match that is larger than the provided tolerance, I see! it seems a bit of a backwards way to do things since you miss most of the values that actually meet the spec you want and seems like always choosing 0 is the best option  ??? I tried it with 0 tolerance and it still only found one possible solution: 13 + 1, but there are indeed 3 solutions: 13 + 1 , 12 +2 and 11 + 3. the output is formatted like a table, so I assume you planned on displaying more than just a single result? I'm not sure tbh.
« Last Edit: October 31, 2019, 02:32:48 am by OM222O »
 

Offline Kirr

  • Regular Contributor
  • *
  • Posts: 66
  • Country: jp
Re: standard value resistor / capacitor combination tool
« Reply #11 on: October 31, 2019, 06:04:32 am »
I see! I get around that issue entirely by using these few lines to "normalize" the data to a range between 0 and 10: ...
I see. So you are effectively auto-ranging the 3 decades of stock around the requested target value. I'm not a fan of this approach, because:

1. If the target value is close to the lower or upper bound of the actual stock range, your calculation will include values that are in fact not stocked. E.g., when requesting 1.12 Ohm value, your tool will assume I have values from 0.1 to 1 Ohm in stock, even though this might not be the case.

2. When requesting a value closer to the middle of actual stock, your tool won't use the entire stock, even though it might help to get a better fit for some values. (Though I don't have statistics about how often such remote values help).

I'm not sure which language you're using, but you should be able to do a very similar thing.
I used D in this case. I also use auto-ranging, but for a different purpose. I calculate using rational numbers, and adjusting range helps to avoid overflows.

In order to use values close to the desired one, I'm adding more values to the set which are one order of magnitude larger or smaller than the values in the series:

Code: [Select]
    values = np.hstack((values/10 , values))
    values = np.hstack((values , values*10))
Not sure I read this correctly, but won't you end up with two copies of the original values? Since the second line takes the already doubled range?

If you really want to use notations such as K m etc, it's as simple as keeping a copy of the notation used, normalizing and finding the values, then sticking the notation to the end of all the results. it's a really basic formatting issue haha. This greatly simplifies your code and makes the software less confusing in my opinion!
Yeah, adding unit prefixes is not a big problem. Though I prefer the other way around: "k" and "M". :)

Oh! so this tries to find a best match that is larger than the provided tolerance, I see! it seems a bit of a backwards way to do things since you miss most of the values that actually meet the spec you want and seems like always choosing 0 is the best option  ???
For practical purposes, usually smaller network is preferable, among those satisfying the required tolerance. But possibly this shortcut can be counter-intuitive or unexpected. I'll think about how to better explain it.

I tried it with 0 tolerance and it still only found one possible solution: 13 + 1, but there are indeed 3 solutions: 13 + 1 , 12 +2 and 11 + 3. the output is formatted like a table, so I assume you planned on displaying more than just a single result? I'm not sure tbh.
Yeah, displaying multiple results could be sometimes useful. I haven't needed this personally. In case if I don't like the particular suggested network, I can put one of the used values into Gaps list and recompute, to see what else is available. But may be I'll add multiple answers option some day.

As for the table output - it's for cases when you request multiple target values. :)
« Last Edit: October 31, 2019, 06:06:56 am by Kirr »
 

Offline OM222OTopic starter

  • Frequent Contributor
  • **
  • Posts: 768
  • Country: gb
Re: standard value resistor / capacitor combination tool
« Reply #12 on: October 31, 2019, 12:09:27 pm »
Code: [Select]
    values = np.hstack((values/10 , values))
    values = np.hstack((values , values*10))
Not sure I read this correctly, but won't you end up with two copies of the original values? Since the second line takes the already doubled range?
[/quote]

Good catch haha  |O it's a simple fix however:

Code: [Select]
    values = np.hstack((values/10 , values , values*10))
it was just another one of the bugs left from the debugging stage  :-DD

1. If the target value is close to the lower or upper bound of the actual stock range, your calculation will include values that are in fact not stocked. E.g., when requesting 1.12 Ohm value, your tool will assume I have values from 0.1 to 1 Ohm in stock, even though this might not be the case.

2. When requesting a value closer to the middle of actual stock, your tool won't use the entire stock, even though it might help to get a better fit for some values. (Though I don't have statistics about how often such remote values help).
when requesting 1.12ohm for example, it's larger than the base value which is 1, so it searches from 0.1ohm to 10 ohm. if the stock is only limited to resistors of higher than 1 ohm, then parallel is your best bet, otherwise series is fine too. it just comes down to how you plan on designing the final schematic and here the advantage of having a large list of values helps  ;D you choose the values that best fit your stock.

I'm not sure what you mean by it doesn't use the entire stock if middle is chosen. It creates a list of all possible n element sub-arrays (where n is the number of resistors chosen) then calculates the sum based on the chosen method (parallel or series), stores all the values and filters the ones where the sum is within tolerance of the desired value. I'm not actually "solving a network", I'm doing finite element analysis and filtering the good values from all the possibilities.
« Last Edit: October 31, 2019, 12:17:41 pm by OM222O »
 

Offline Kirr

  • Regular Contributor
  • *
  • Posts: 66
  • Country: jp
Re: standard value resistor / capacitor combination tool
« Reply #13 on: October 31, 2019, 02:49:03 pm »
Code: [Select]
    values = np.hstack((values/10 , values , values*10))
:-+

I'm not sure what you mean by it doesn't use the entire stock if middle is chosen. It creates a list of all possible n element sub-arrays (where n is the number of resistors chosen) then calculates the sum based on the chosen method (parallel or series), stores all the values and filters the ones where the sum is within tolerance of the desired value. I'm not actually "solving a network", I'm doing finite element analysis and filtering the good values from all the possibilities.
OK, I played a bit with both our tools to work out some examples. Here is one:

For example, let's say we have a full stock of E12 values, in the range from 1 Ohm to 1 MOhm.

And let's say I we need three missing values: 6.73k, 67.3k and 673k, to be approximated using parallel networks of at most 2 resistors.

My tool suggests the following:
Formated as: "Request: Approximation = Network (Error)"
6.73k: ~6.733k = 6.8k || 680k (0.039%)
67.3k: ~67.754k = 82k || 390k (0.675%)
673k: 680k = 680k (1.040%)

In other words, it respects the boundary of our stock at 1 MOhm. When we request a value closer to the middle of stock range (6.73k), the tool has more options and thus can find a closer fit. However as the request gets closer to the boundary, options get more limited, and error gets larger.

I then tried your tool using:
Code: [Select]
print_results("Parallel combinations for 6.73k: " , find_combo(parallel,2,E12,6730,1))
print_results("Parallel combinations for 67.3k: " , find_combo(parallel,2,E12,67300,1))
print_results("Parallel combinations for 673k: " , find_combo(parallel,2,E12,673000,1))
which generates:
Code: [Select]
Parallel combinations for 6.73k:

0.7%    ->   8200.00     39000.00
1.0%    ->   12000.00    15000.00

########################################

Parallel combinations for 67.3k:

0.7%    ->   82000.00    390000.00
0.9%    ->   120000.00   150000.00

########################################

Parallel combinations for 673k:

0.7%    ->   820000.00   3900000.00
1.0%    ->   1200000.00  1500000.00

########################################

Which means:

1. Your tool does not find the optimal approximation when extra range is available. It suggests 8.2k || 39k rather than more optimal 6.8k || 680k, because it looks only one decade away from the target value. (Of course you can add more decades by adding values*100 and values/100).

2. Your tool feels free to use values that we don't have in our stock: When building 673k it uses 3.9M, which we don't have.

(Both issues are rooted in there being no interface to specify stock boundaries).

Which summarily means that your tool uses the stock that it feels convenient to use, rather than the actual stock available to a project. I personally feel this is important limitation, as I like my actual stock to be respected and fully utilized. I guess your approach may be OK if you make sure to only request targets that are at least 1 decade away from your stock bondaries, and don't mind occasionally missing a better fit.

Offline mariush

  • Super Contributor
  • ***
  • Posts: 5250
  • Country: ro
  • .
Re: standard value resistor / capacitor combination tool
« Reply #14 on: November 01, 2019, 07:41:44 pm »
I was bored and decided to complete a similar tool I started to write some time ago.

So I uploaded it here: https://github.com/mariush-github/resistor-calculator-php

It's written in PHP, you can simply download a Windows version of php and type  php.exe calculator.php --value 100  to get combinations of resistors that produce 100 ohm resistor.
It allows up to 4 resistors and mixes of series and parallel, but keep in mind it's a memory hog : if you choose 3 or 4 resistors, you may have to go in php.in and raise the memory limit from 128 MB to 1024-2048 MB.

I may rewrite it in Go as an exercise,  for faster speed and less memory usage, and to play around with the concurrency features of Go.

I suppose you could also add a feature to import a list of resistors you actually own.


Example: 

php.exe calculator.php --min 100 --max 10000 --e 24 --tol 1 --mix 1  --results 50 --count 4 --value 470

will give 938 results, which are dumped in CSV files (three separate files). The closest are printed on screen, up to 100.

Results are grouped by resistor count by default (there's parameter you can set to 0 to disable this)

Code: [Select]
2        470    0.000% 360 + 110
2        470    0.000% 270 + 200
3        470    0.000% 390 + 2p160
3        470    0.000% 360 + 2p220
3        470    0.000% 160 + 2p620
3        470    0.000% 130 + 2p680
3        470    0.000% 270 + 100 + 100
3        470    0.000% 240 + 130 + 100
3        470    0.000% 240 + 120 + 110
3        470    0.000% 220 + 150 + 100
3        470    0.000% 220 + 130 + 120
3        470    0.000% 200 + 160 + 110
3        470    0.000% 200 + 150 + 120
3        470    0.000% 180 + 180 + 110
3        470    0.000% 180 + 160 + 130
3        470    0.000% 160 + 160 + 150
4        470    0.000% 2p430 + 2p510
4        470    0.000% 430 + 3p120
4        470    0.000% 300 + 3p510
4        470    0.000% 390 + 3p240
4        470    0.000% 360 + 3p330
4        470    0.000% 220 + 3p750
4        470    0.000% 2p120 + 2p820
4        470    0.000% 180 + 110 + 2p360
4        470    0.000% 160 + 130 + 2p360
4        470    0.000% 220 + 100 + 2p300
4        470    0.000% 200 + 120 + 2p300
4        470    0.000% 160 + 160 + 2p300
4        470    0.000% 300 + 110 + 2p120
4        470    0.000% 300 + 120 + 2p100
4        470    0.000% 270 + 100 + 2p200
4        470    0.000% 270 + 110 + 2p180
4        470    0.000% 270 + 120 + 2p160
4        470    0.000% 270 + 150 + 2p100
4        470    0.000% 240 + 110 + 2p240
4        470    0.000% 220 + 130 + 2p240
4        470    0.000% 240 + 120 + 2p220
4        470    0.000% 200 + 150 + 2p240
4        470    0.000% 240 + 130 + 2p200
4        470    0.000% 240 + 180 + 2p100
4        470    0.000% 240 + 150 + 2p160
4        470    0.000% 200 + 160 + 2p220
4        470    0.000% 220 + 150 + 2p200
4        470    0.000% 220 + 200 + 2p100
4        470    0.000% 180 + 180 + 2p220
4        470    0.000% 220 + 160 + 2p180
4        470    0.000% 200 + 180 + 2p180
4        470    0.000% 160 + 110 + 100 + 100
4        470    0.000% 150 + 120 + 100 + 100
4        470    0.000% 150 + 110 + 110 + 100

 
The following users thanked this post: Kirr

Offline Kirr

  • Regular Contributor
  • *
  • Posts: 66
  • Country: jp
Re: standard value resistor / capacitor combination tool
« Reply #15 on: November 02, 2019, 04:21:48 am »
mariush, very cool! :-+

I see your example has networks like "430 + 3p120", which means I guess that 3 of 120 are connected in parralel, and then serially with 430. I guess it's not restricted to only use identical values in parallel connections? Also, can it parallel serially connected sub-networks? Curious because as I haven't yet tried it myself. :)

E.g., can you try making 474 or 478 Ohm out of up to 4 E3 values (in the range of 1 Ohm to 1 MOhm)? Curious what it will find for these cases.

OM222O, I hope you are not discouraged by the complexity of this problem!

Cheers!

Offline mariush

  • Super Contributor
  • ***
  • Posts: 5250
  • Country: ro
  • .
Re: standard value resistor / capacitor combination tool
« Reply #16 on: November 02, 2019, 04:49:40 am »
Yes,  s means in series and p means in parallel  ... so  10 | 3s100  means 10 paralleled with 3 100 resistors in series (a 300 ohm resistor)

The software isn't that "smart", it just takes a brute force approach, generating all unique combinations of 2..4 resistors and does the math to figure out if the final value is within the tolerance.
If the total number of resistors is below the maximum resistors you opted for the script splits resistors in 2 or 3, or doubles them and does the math again.
So right now  it's just  all series, all parallel,  or series+parallel combinations

to answer your question ... here's 474 ohm, 50 results  :
 
Note it's assuming 1% max error, 5% gives 221 results for the 474 ohm ...
also used --group 0 so it's sorted by error instead of smallest number of resistors first)

Code: [Select]
4    473.934    0.014% 1000 | 1000 | 10000 | 100000
4      474.2    0.042% 470 + 2.2 + 1 + 1
3      474.4    0.084% 470 + 2.2 + 2.2
4     474.55    0.116% 470 + 2.2 + 2p4.7
4     473.35    0.137% 470 + 1 + 2p4.7
4    473.333    0.141% 470 + 3p10
2      474.7    0.148% 470 + 4.7
4      473.3    0.148% 470 + 2.2 + 2p2.2
3      473.2    0.169% 470 + 2.2 + 1
3        475    0.211% 470 + 2p10
4        473    0.211% 470 + 1 + 1 + 1
4    475.162    0.245% 1000 | 1000 | 10000 | 220000
4      475.2    0.253% 470 + 4.7 + 2p1
4      472.7    0.274% 470 + 2.2 + 2p1
4      475.4    0.295% 470 + 2.2 + 2.2 + 1
3     472.35    0.348% 470 + 2p4.7
3      475.7    0.359% 470 + 4.7 + 1
4    475.709    0.361% 1000 | 1000 | 10000 | 470000
2      472.2    0.380% 470 + 2.2
4      475.8    0.380% 470 + 4.7 + 2p2.2
4      472.1    0.401% 470 + 1 + 2p2.2
4    475.964    0.414% 1000 | 1000 | 10000 | 1000000
4        476    0.422% 470 + 1 + 2p10
3        472    0.422% 470 + 1 + 1
4        472    0.422% 220 + 220 + 22 + 10
3     476.19    0.462% 1000 | 1000 | 10000
4    471.567    0.513% 470 + 3p4.7
4      471.5    0.527% 470 + 1 + 2p1
4    471.414    0.546% 1000 | 1000 | 10000 | 47000
4      476.6    0.549% 470 + 2.2 + 2.2 + 2.2
4      476.7    0.570% 470 + 4.7 + 1 + 1
4    471.285    0.573% 1000 | 2200 | 2200 | 4700
3      471.1    0.612% 470 + 2p2.2
3      476.9    0.612% 470 + 4.7 + 2.2
2        471    0.633% 470 + 1
4        477    0.633% 220 + 22 + 2p470
4     477.05    0.643% 470 + 4.7 + 2p4.7
4      477.2    0.675% 470 + 2.2 + 2p10
4    470.733    0.689% 470 + 3p2.2
4    477.333    0.703% 470 + 3p22
3      470.5    0.738% 470 + 2p1
4    470.333    0.774% 470 + 3p1
4      477.9    0.823% 470 + 4.7 + 2.2 + 1
4        470    0.844% 2p470 + 2p470
2    469.779    0.891% 470 | 1000000
4    478.261    0.899% 1000 | 1000 | 22000 | 22000
3    469.559    0.937% 470 | 1000000 | 1000000
2     469.53    0.943% 470 | 470000
4    469.338    0.984% 470 | 1000000 | 1000000 | 1000000
3     469.31    0.989% 470 | 470000 | 1000000

Here's 478 ... 41 results.
Code: [Select]
4      477.9    0.021% 470 + 4.7 + 2.2 + 1
4    478.261    0.055% 1000 | 1000 | 22000 | 22000
4    477.333    0.140% 470 + 3p22
4      477.2    0.167% 470 + 2.2 + 2p10
4     477.05    0.199% 470 + 4.7 + 2p4.7
4        477    0.209% 220 + 22 + 2p470
4      479.1    0.230% 470 + 4.7 + 2.2 + 2.2
3      476.9    0.230% 470 + 4.7 + 2.2
4      476.7    0.272% 470 + 4.7 + 1 + 1
3      479.4    0.293% 470 + 4.7 + 4.7
4      476.6    0.293% 470 + 2.2 + 2.2 + 2.2
4      479.7    0.356% 470 + 4.7 + 2p10
3     476.19    0.379% 1000 | 1000 | 10000
2        480    0.418% 470 + 10
4        476    0.418% 470 + 1 + 2p10
4    475.964    0.426% 1000 | 1000 | 10000 | 1000000
4      475.8    0.460% 470 + 4.7 + 2p2.2
4    475.709    0.479% 1000 | 1000 | 10000 | 470000
3      475.7    0.481% 470 + 4.7 + 1
4      480.4    0.502% 470 + 4.7 + 4.7 + 1
4      480.5    0.523% 470 + 10 + 2p1
4      475.4    0.544% 470 + 2.2 + 2.2 + 1
4      475.2    0.586% 470 + 4.7 + 2p1
4    475.162    0.594% 1000 | 1000 | 10000 | 220000
3        481    0.628% 470 + 2p22
3        475    0.628% 470 + 2p10
3        481    0.628% 470 + 10 + 1
4      481.1    0.649% 470 + 10 + 2p2.2
2      474.7    0.690% 470 + 4.7
4     474.55    0.722% 470 + 2.2 + 2p4.7
4      481.6    0.753% 470 + 4.7 + 4.7 + 2.2
3      474.4    0.753% 470 + 2.2 + 2.2
4      474.2    0.795% 470 + 2.2 + 1 + 1
4        482    0.837% 470 + 1 + 2p22
4        482    0.837% 470 + 10 + 1 + 1
4    473.934    0.851% 1000 | 1000 | 10000 | 100000
3      482.2    0.879% 470 + 10 + 2.2
4     482.35    0.910% 470 + 10 + 2p4.7
4     473.35    0.973% 470 + 1 + 2p4.7
4    473.333    0.976% 470 + 3p10
4      473.3    0.983% 470 + 2.2 + 2p2.2
 

Offline OM222OTopic starter

  • Frequent Contributor
  • **
  • Posts: 768
  • Country: gb
Re: standard value resistor / capacitor combination tool
« Reply #17 on: November 02, 2019, 12:05:22 pm »
mariush, very cool! :-+

I see your example has networks like "430 + 3p120", which means I guess that 3 of 120 are connected in parralel, and then serially with 430. I guess it's not restricted to only use identical values in parallel connections? Also, can it parallel serially connected sub-networks? Curious because as I haven't yet tried it myself. :)

E.g., can you try making 474 or 478 Ohm out of up to 4 E3 values (in the range of 1 Ohm to 1 MOhm)? Curious what it will find for these cases.

OM222O, I hope you are not discouraged by the complexity of this problem!

Cheers!

Unfortunately I have a few university assignments taking all of my time, so I can't work on the tool right now. I will come back and update it as soon as I have enough time  :-+
 

Offline Kirr

  • Regular Contributor
  • *
  • Posts: 66
  • Country: jp
Re: standard value resistor / capacitor combination tool
« Reply #18 on: November 03, 2019, 09:59:19 am »
Yes,  s means in series and p means in parallel  ... so  10 | 3s100  means 10 paralleled with 3 100 resistors in series (a 300 ohm resistor)

The software isn't that "smart", it just takes a brute force approach, generating all unique combinations of 2..4 resistors and does the math to figure out if the final value is within the tolerance.
If the total number of resistors is below the maximum resistors you opted for the script splits resistors in 2 or 3, or doubles them and does the math again.
So right now  it's just  all series, all parallel,  or series+parallel combinations

I see!

For reference, my tool's suggestion for the same question (found with maximum precision, target error = 0):
Format: "Request: Approximation = Network (Error)"
474: ~474.001 = 470k || (4.7 + (470 || 1M)) (0.000%)
478: ~478.000 = 10 + (470 || (10k + 100k)) (0.000%)

I am beginning to miss multiple answer output.

Unfortunately I have a few university assignments taking all of my time, so I can't work on the tool right now. I will come back and update it as soon as I have enough time  :-+
:-+

Offline mariush

  • Super Contributor
  • ***
  • Posts: 5250
  • Country: ro
  • .
Re: standard value resistor / capacitor combination tool
« Reply #19 on: November 03, 2019, 10:22:24 am »
I've updated the code on github (see post above), used a trick to make it much faster and not have to cache stuff on disk, now it runs faster and with much less memory usage.

Yes, the version I made currently lacks the feature of going "three levels deep" as in :

474: ~474.001 = 470k || (4.7 + (470 || 1M)) (0.000%)

it can do R1 || R2,  or R1+R2, and then goes one level deeper where R1 or R2 or both are split and the operation between these two resistors is the opposite of the operation between R1 and R2
So, you get
(R1a+R1b) || R2
R1 || (R2a + R2b)
(R1a+R1b) || (R2a + R2b)

I do this (alternate parallel and sum)  because if the user says "i want up to 4 resistors", I'd get duplicate results otherwise ex.
Solution 1: 2 resistor groups: (R1a+R1b) + (R2a+R2b)
Solution 2: 4 resistors R1a + R1b + R2a + R2b

I can certainly add a third level, provided the maximum number of resistors allows going deeper.

ex  if you say up to 4 resistors, and a solution is 0.5% close to desired value and looks like this  R1 || ( 2sR2), the code could further split the 2 R2 in series  to  R2 + ( R3||R4) and I arrive to your result.

I was reluctant to add this because when using E96 or E192 ranges it takes a long time even with just 4 resistors (20s or so to go through the 20 million or whatever unique combinations of 4 resistors, using only 128 closest resistors to desired value)
It would work ok with a reduced set, like E24 and restricting to let's say 1 ohm min,  100k max
« Last Edit: November 03, 2019, 10:30:55 am by mariush »
 

Offline Kirr

  • Regular Contributor
  • *
  • Posts: 66
  • Country: jp
Re: standard value resistor / capacitor combination tool
« Reply #20 on: November 04, 2019, 04:14:59 am »
I've updated the code on github (see post above), used a trick to make it much faster and not have to cache stuff on disk, now it runs faster and with much less memory usage.
Nice. Will have to download and play with it some time.

Yes, the version I made currently lacks the feature of going "three levels deep" as in :

474: ~474.001 = 470k || (4.7 + (470 || 1M)) (0.000%)

it can do R1 || R2,  or R1+R2, and then goes one level deeper where R1 or R2 or both are split and the operation between these two resistors is the opposite of the operation between R1 and R2
So, you get
(R1a+R1b) || R2
R1 || (R2a + R2b)
(R1a+R1b) || (R2a + R2b)

I do this (alternate parallel and sum)  because if the user says "i want up to 4 resistors", I'd get duplicate results otherwise ex.
Solution 1: 2 resistor groups: (R1a+R1b) + (R2a+R2b)
Solution 2: 4 resistors R1a + R1b + R2a + R2b

I can certainly add a third level, provided the maximum number of resistors allows going deeper.

ex  if you say up to 4 resistors, and a solution is 0.5% close to desired value and looks like this  R1 || ( 2sR2), the code could further split the 2 R2 in series  to  R2 + ( R3||R4) and I arrive to your result.
Interesting, because my tools works from the opposite direction: Starts with single resistors, and then combines them into networks of two. Then combines those into next set of networks, and so on.

I was reluctant to add this because when using E96 or E192 ranges it takes a long time even with just 4 resistors (20s or so to go through the 20 million or whatever unique combinations of 4 resistors, using only 128 closest resistors to desired value)
It would work ok with a reduced set, like E24 and restricting to let's say 1 ohm min,  100k max

Yes, huge number of combination is a major problem with the brute force approach (which I also use). My tool stops searching when the number of network required for next iteration (with another added resistor) is greater than 20 million (IIRC). However when the stocked range is small, even larger networks are possible, up to 6 resistors in case of my tool. (Although for practical uses simple approaches are often enough).

Offline sleemanj

  • Super Contributor
  • ***
  • Posts: 3126
  • Country: nz
  • Professional tightwad.
    • The electronics hobby components I sell.
Re: standard value resistor / capacitor combination tool
« Reply #21 on: November 04, 2019, 04:52:40 am »
FWIW some years ago I made this...

https://sparks.gogo.co.nz/resistor_paralleler.html

which works on a slightly different basis in that it is focused around using resistors you actually keep in stock rather than just a full set of all values in a series.

I keep roughly a "half set" of a series, with a few "holes" (values I don't keep) and "bumps" (values not in the series but I do keep), I made the tool to help me find appropriate mostly parallel combinations (because SMD resistors can easily be stacked on top of each other in a hobby situation), and as a last resort some series ones.


~~~
EEVBlog Members - get yourself 10% discount off all my electronic components for sale just use the Buy Direct links and use Coupon Code "eevblog" during checkout.  Shipping from New Zealand, international orders welcome :-)
 

Offline Kirr

  • Regular Contributor
  • *
  • Posts: 66
  • Country: jp
Re: standard value resistor / capacitor combination tool
« Reply #22 on: November 05, 2019, 02:11:03 am »
FWIW some years ago I made this...

https://sparks.gogo.co.nz/resistor_paralleler.html
Yes, another fine tool. I have it linked in the links section on the about page of my tool.

By the way, OM222O and mariush, please let me know if you like your tools linked there (and url).

which works on a slightly different basis in that it is focused around using resistors you actually keep in stock rather than just a full set of all values in a series.

I keep roughly a "half set" of a series, with a few "holes" (values I don't keep) and "bumps" (values not in the series but I do keep), I made the tool to help me find appropriate mostly parallel combinations (because SMD resistors can easily be stacked on top of each other in a hobby situation), and as a last resort some series ones.
I think we both share the idea of using the real actual stock. (Your "holes" and "bumps" are "gaps" and "extras" in my tool, but otherwise same thing).  :-+

Offline mariush

  • Super Contributor
  • ***
  • Posts: 5250
  • Country: ro
  • .
Re: standard value resistor / capacitor combination tool
« Reply #23 on: November 05, 2019, 10:50:07 am »
You can do whatever you want, the repository is public
I added loading resistors from a file  (values separated by new lines, commas, tabs , and it's also possible to enter 2r2 or 100k or 0.1m .. that's all, just r,k,m are detected and handled)
Making an exclusion list would also be possible and easy.

Here's link again if people don't want to scroll up a lot : https://github.com/mariush-github/resistor-calculator-php

I'm still interested in doing that "deep" search ( using series and parallel and series, not just two "levels" of mixing) like your version does, but have other things to work on at the moment.
« Last Edit: November 05, 2019, 10:51:38 am by mariush »
 

Offline Kirr

  • Regular Contributor
  • *
  • Posts: 66
  • Country: jp
Re: standard value resistor / capacitor combination tool
« Reply #24 on: November 05, 2019, 03:27:33 pm »
Added link and tweaked interface a bit.

A puzzle for testing these calculators (not a practical task, just for fun): Suppose you have E3 series from 1R to 470R (ideal resistors). Which network of at most 5 resistors gives precisely 4.64 Ohm (with 0% error)?

[EDIT] Compacted.
« Last Edit: November 08, 2019, 10:04:02 am by Kirr »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf