Parallel Resistor Calculation - Page 1
Forum section: electronics / projects

author: ramin110
author_rank: Contributor
timestamp: March 11, 2017, 10:26:56 am
content: Hi guys, I just wrote a program to calculate parallel resistor values for all possible combinations that I needed for specified values.I think maybe someone needs this kind of program and I uploaded it on the forum. It's on beta version I have to do a lot of work for refactoring and multi threading for avoiding program freezing and etc.please look at the program and help me about extra features and English grammar correction.https://drive.google.com/open?id=0B_tpqPwA_7owNXAxRGpSVkRKR2cThanks.

author: bitwelder
author_rank: Super Contributor
timestamp: March 11, 2017, 06:20:35 pm
content: Ah, it's a *Windows* application.Pass.

author: Benta
author_rank: Super Contributor
timestamp: March 11, 2017, 06:29:42 pm
content: Given that parallel resistor calculation can be done in a few seconds on my (RPN) calculator, I fail to see the need of a program.And I have an allergy against unknown .exe files.Pass.

author: orolo
author_rank: Frequent Contributor
timestamp: March 11, 2017, 06:49:19 pm
content: For my filter experiments I use that same idea, but an executable is overkill. I just store my 10% SMD resistor by bins, the program merges the values in a single list, and iterates for single resistor, series pair or parallel pair, giving relative error and precision of the result:Code: (Python)#SMD resistor bins.res100 = [1., 5.1, 9.1, 33., 43., 47., 75., 82.]res1k = [100., 110., 160., 180., 240., 390., 430., 750.]res10k = [1.2e3, 1.5e3, 2.4e3, 3.3e3, 3.6e3, 3.9e3, 4.7e3, 5.1e3, 6.2e3, 7.5e3, 9.1e3]res100k = [12e3, 15e3, 24e3, 36e3, 43e3, 47e3, 51e3, 68e3]res1meg = [100e3, 120e3, 150e3, 180e3, 240e3, 300e3, 330e3, 360e3, 430e3, 670e3]res10m = [1e6, 2.7e6, 4.7e6, 3.3e6]res = [res100, res1k, res10k, res100k, res1meg, res10m]target = input("Target: ")# One resistor:found = -1diff = 10e10eps = 0for l in res:for x in l:eps = abs(x - target)if (eps < diff):found = xdiff = epsprint "\n\n1 resistor: ", foundprint "Bounds: %f to %f"% (found * 0.99, found * 1.01)print "Relative error: %f%%\n" % (100.0 * (found - target) / target)#Pair:found_s = -1found_p = -1diff_s = 10e10diff_p = 10e10eps_s = 0eps_p = 0for l1 in res:for l2 in res:for x in l1:for y in l2:eps_s = abs(x + y - target)eps_p = abs(1/(1/x + 1/y) - target)if (eps_s < diff_s):found_s = (x,y)diff_s = eps_sif (eps_p < diff_p):found_p = (x,y)diff_p = eps_pprint "Series pair: ", found_sprint "Bounds: %f to %f" % ((found_s + found_s)*0.99, (found_s + found_s)*1.01)print "Relative error: %f%%\n" % (100.0 * ((found_s + found_s) - target) / target)print "Parallel pair: ", found_pprint "Bounds: %f to %f" % (1/(1/(found_p*0.99) + 1/(found_p*0.99)), 1/(1/(found_p*1.01) + 1/(found_p*1.01)))print "Relative error: %f%%\n" % (100.0 * (1/(1/found_p + 1/found_p) - target) / target)So, for example, if I need 374.628 ohms (as in a thread in other subforum), my program gives:Code:Target: 374.6281 resistor: 390.0Bounds: 386.100000 to 393.900000Relative error: 4.103270%Series pair: (180.0, 180.0)Bounds: 356.400000 to 363.600000Relative error: -3.904673%Parallel pair: (750.0, 750.0)Bounds: 371.250000 to 378.750000Relative error: 0.099299%So a parallel combination of 750 ohms nails it. I've been thinking about getting serious and redoing the program with arbitrary depth, like A, A+B, A||B, A+B+C, A+(B||C), (A+B)||C, A||B||C, etc. But given the limitation of 2% precision in capacitance I work with, it'd be overkill.Another very interesting problem is getting the minimum collection of resistor values that will guarantee less than 1% relative error for any value from 100 ohm to 1 meg, so I can get lots of these values and be done with that. I've never got serious enough to actually sit and compute it.

author: Alex Eisenhut
author_rank: Super Contributor
timestamp: March 11, 2017, 09:37:17 pm
content: "It's on beta version I have to do a lot of work for refactoring and multi threading for avoiding program freezing and e"For calculating two resistors in parallel?What do you need to calculate a mortgage? Half of Google's server farm?

author: FrankBuss
author_rank: Unknown
timestamp: March 12, 2017, 01:54:53 am
content: Doesn't work on a German Windows version, shows lots of duplicate values (so why doesn't it delete these values automatically?). I guess some problems with the decimal point, which is a comma here.

author: mariush
author_rank: Super Contributor
timestamp: March 12, 2017, 07:24:03 am
content: I got bored and wrote a "calculator" in PHP while watching a couple of movies. Here you go :http://savedonthe.net/a/resistorcalc.php(download :http://savedonthe.net/a/resistorcalc.zip)It's not optimized in any way, so prevent people from killing the server the live version is restricted to 2 resistors max. You can edit the source code to raise the limit.

author: Ian.M
author_rank: Super Contributor
timestamp: March 12, 2017, 07:46:07 am
content: Heck, all you need is a laminated A3 sized nomogram, with extra tick marks the opposite side of each scale to the graduation indicating the E12/E24 preferred values, and auxiliary scales for parallel combos of the order of a decade apart + a straightedge. Its going to be faster and easier to use than any dedicated calculator.If you have to show off, write your electrical calculators in Javascript, so they can be tried online, but please make sure they will still work if the user saves the page locally.

author: Mechatrommer
author_rank: Super Contributor
timestamp: March 12, 2017, 09:24:04 am
content: well this is my parallel resistor program (attached), 3 resistors parallel max, i dont see why i need more. i'll make one for you if i need more than 3 resistors. and its not a beta test since if you put 0 ohm it will throw "division by zero" at you and quit just to show how stupid are you. and its super efficient since it only needs single thread. if you an exephobolic or has new Windows that cant run it well too bad.

author: ZeTeX
author_rank: Frequent Contributor
timestamp: March 12, 2017, 09:37:47 pm
content: its physically faster for me to go to google and write "parallel resistor calc" instead of pulling a calculator or a software.

author: ramin110
author_rank: Contributor
timestamp: March 12, 2017, 09:46:09 pm
content: New Changes

author: Zero999
author_rank: Super Contributor
timestamp: March 13, 2017, 01:39:09 pm
content: Quote from: orolo on March 11, 2017, 06:49:19 pmAll you need is the E24 series, from 1R and 10M. Any E96 value can be made, to within 0.2% using two E24 values in series or parallel.I did a table awhile ago.

author: cncjerry
author_rank: Unknown
timestamp: March 13, 2017, 08:39:10 pm
content: Let's see how complicated we can makes this:1) When I was fixing my fluke 332D, I needed a parallel resistor combination that came within .01% of 9.9925K ideally with opposing TCs. I made a simple spreadsheet and sub'ed available resistors into it after measuring the TCs of the two types I had. It took me about 90 minutes of screwing around with parallel and series combinations. I used a selected 10K in parallel with a series combination of selected 3.3M and 8M. The combination calculated to 9.99116K and measured pretty close to 9.9925K when done.2) I did a program like this in Prolog a couple years ago that had one table of 1% values and could do as many parallel combinations as you would like pretty quickly. I then added the option of doing series or parallel whichever came closest. That was basically an iterative process and required a lot of CPU. The problem with Prolog was setting the accuracy needed. If you asked it for a minimum of .01% variance and it found a combination, it stops even though a future combination could be lower. The only way to find the minimum was to calculate all parallel combinations and then use a minimum function on the resulting stage one table. This added to the calculation time as you can imagine, but we are talking microseconds here.3) I've been studying TensorFlow for machine learning. This is the modern wayto do it but I haven't had success yet which speaks to my Tensorflow skills.

author: cncjerry
author_rank: Unknown
timestamp: March 14, 2017, 01:39:34 am
content: for the heck of it, I rewrote the Prolog version of my code as I couldn't find it (of course). The program is nothing more than a table of values of resistors in the form of value(10.0) for instance. I could have just used the 1% bins and multiplied them but I didn't to keep the goal seeking program easily understandable so you wouldn't have to go learn Prolog. I used SWI Prolog by the way.The command 'value(A)' looks in the 'value' table and assigns the first value to the variable 'A'. It then does the same with the next goal 'value(B)'. After assigning values to A and B, it does the parallel resistor math resulting in the instantiation of C. If C is equal to the required value or within a range, the program succeeds, otherwise you get a false return meaning it couldn't find a solution. You can ask for more solutions by pressing the space bar.Here is the goal and the output for finding a resistor between 70 and 70.1:Code:?- value(A), value(B), C is (1/(1/A + 1/B)), C > 70.0, C<70.2.A = 76.8,B = 806.0,C = 70.11871318531944A = 78.7,B = 634.0,C = 70.00954118142276A = 78.7,B = 649.0,C = 70.18867665246668A = 80.6,B = 536.0,C = 70.06422315926045A = 82.5,B = 464.0,C = 70.04574565416286A = 84.5,B = 412.0,C = 70.11883182275932A = 97.6,B = 249.0,C = 70.11656087709174A = 249.0,B = 97.6,C = 70.11656087709174A = 412.0,B = 84.5,C = 70.11883182275932A = 464.0,B = 82.5,C = 70.04574565416286A = 536.0,B = 80.6,C = 70.06422315926045A = 634.0,B = 78.7,C = 70.00954118142276A = 649.0,B = 78.7,C = 70.18867665246668A = 806.0,B = 76.8,C = 70.11871318531944That's about as easy as it gets and it finds the first solution as fast as you press enter with each additional solution just as fast. This is using a table of values from .1 to 1000.When I tested it originally I knew there was a value of 140 in the table so I tried the following thinking it would spit out A=140 and B = 140 with C = 70:Code:?- value(A), value(B), C is (1/(1/A + 1/B)), C = 70.0.A = 105.0,B = 210.0,C = 70.0A = B, B = 140.0,C = 70.0A = 210.0,B = 105.0,C = 70.0false.I was surprised to see the 105 and 210 come up first followed by A and B being equal to 140. How many of us would have grabbed two 140 ohm resistors to hit 70 in parallel (assuming there is no 70 ohm resistor) without thinking of 105 and 210?This one threw me off as well:Code:?- value(A), value(B), C is (1/(1/A + 1/B)), C = 50.0.A = 75.0,B = 150.0,C = 50.0A = B, B = 100.0,C = 50.0A = 150.0,B = 75.0,C = 50.0false.I am always grabbing two, 100 ohm resistors to make a perfect 50 ohms without thinking of 150 and 75 ohms.Anyway, I plan to keep this around and expand it to the next few decades up to 10Meg.

author: Conrad Hoffman
author_rank: Super Contributor
timestamp: March 14, 2017, 04:10:32 am
content: I've got a bunch of Excel utilities like that I use constantly. If you're old enough to remember the dawn of the PC, all the electronic magazines had BASIC programs for common calculations that you could type in and run with IBM basica and other similar languages. I think most designers use Excel these days, though I still have a few exe utilities wrote and find useful.