A little Perl script to calculate resistor networks.
Resistor Calc is a little Perl project to make it easier to attain given resistance by networking resistors in series and parallel. It is designed to make choosing resistors easier by suggesting networks based off of a given set of available resistors.
Simply download and extract the package somewhere. Then place mkResistorCache and resistorCalc somewhere on the PATH.
- Create a file containing the numeric values of all available resistors one per line. The order does not matter.
- Then create the cache for that file by executing something like
mkResistorCache /path/to/resistor/file 4
This will create a cache file that can be referred to by the name 'file' when running resistorCalc. It worthwhile to note that the depth parameter will increase the time it takes to create the cache exponentially depending on the size of the given resistor set. The script will prompt for confirmation if the number of possibilities exceeds 5M.
- To calculate the necessary resistor network to provide a given resistance run
resistorCalc file 101 1
This will provide suggestions that yield 101 Ohm give or take 1% ordered by the networks providing the least number of components to the most, limited by the maxdepth parameter of the mkResistorCache call, in our case 4. If a perfect match is achieved with less than 4 components, the remainder will be skipped.
It is possible to maintain many caches for example one for 1/4 watt, one for 1/2 watt or SMT resistors.
To explain how to read the results, consider the following example:
resistorCalc file 10101 1 You get 10000.00 from 10000 You get 10100.00 from 100 S 10000 You get 10100.99 from 10000 P 1000000 S 100 S 100
Because we specified a 1% range, we get several options. The grouping of the results is as follows:
(((10000 P 1000000) S 100) S 100)
To explain this more clearly the ASCII drawing below shows the resistor network described above:
+---10000---+ ---+ +--100--100--- +--1000000--+