| Electronics > Projects, Designs, and Technical Stuff |
| standard value resistor / capacitor combination tool |
| (1/5) > >> |
| OM222O:
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: ---series(3,E24,6) #series(Number of resistors to use, Standard series , Resulting value) parallel(3,E24,6) #same interface as series --- End code --- 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: ---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 --- End code --- 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. |
| Brutte:
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. |
| T3sl4co1l:
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 |
| OM222O:
--- Quote from: Brutte 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. --- End quote --- 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 --- Quote from: T3sl4co1l 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 --- End quote --- 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 |
| Brutte:
--- Quote from: OM222O on October 30, 2019, 05:41:19 pm ---what do you mean by unit testing? 1.5 and 3 ohms does give you the value that you're looking for. --- End quote --- :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. |
| Navigation |
| Message Index |
| Next page |