Resistor Decade Values and Resistor Selectors

Resistor Ratio Selectors Code

Standard 5% Resistor Values in a Single Decade

res5={1.0,1.1,1.2,1.3,1.5,1.6,1.8,2.,2.2,2.4,2.7,3.,3.3,3.6,3.9,4.3,4.7,5.1,5.6,6.2,6.8,7.5,8.2,9.1,10.0};

Standard 1% Resistor Values in a Single Decade

res1={1.00,1.02,1.05,1.07,1.10,1.13,1.15,1.18,1.21,1.24,1.27,1.30,1.33,1.37,1.40,1.43,1.47,1.50,1.54,1.58,1.62,1.65,1.69,1.74,1.78,1.82,1.87,1.91,1.96,2.00,2.05,2.10,2.15,2.21,2.26,2.32,2.37,2.43,2.49,2.55,2.61,2.67,2.74,2.80,2.87,2.94,3.01,3.09,3.16,3.24,3.32,3.40,3.48,3.57,3.65,3.74,3.83,3.92,4.02,4.12,4.22,4.32,4.42,4.53,4.64,4.75,4.87,4.99,5.11,5.23,5.36,5.49,5.62,5.76,5.90,6.04,6.19,6.34,6.49,6.65,6.81,6.98,7.15,7.32,7.50,7.68,7.87,8.06,8.25,8.45,8.66,8.87,9.09,9.31,9.53,9.76,10.0};

Build lists of ratios for all pairs of values. Save the Log (base 10) of each ratio.

ratios[r_]:= Module[{pairs=Subsets[Sort[r],{2}]},
Sort[
Join[
Table[{Log[10,pairs[[n,2]]/pairs[[n,1]]],pairs[[n]]},{n,1,Length[pairs]}],Table[{Log[10,10 pairs[[n,1]]/pairs[[n,2]]],{pairs[[n,2]],10 pairs[[n,1]]}},{n,1,Length[pairs]}]
]
]
]

res5ratios= ratios[res5];

res1ratios=ratios[res1];

Pair of values which give the best match to a provided Log (base 10) ratio. The provided Log must be between 0.0 and 1.0.

bestfitlog[ratios_,x_]:=
Module[{i=1,r=ratios[[1]],t=Abs[x-ratios[[1,1]]]},
While[++i≤Length[ratios],
If[Abs[x-ratios[[i,1]]]<t,
t=Abs[x-ratios[[i,1]]];
r=ratios[[i]];
];
];
r
]

List of pairs of values which give a good match to a provided Log (base 10) ratio, along with a tolerance. The provided Log must be between 0.0 and 1.0.

goodfitslog[ratios_,x_,tol_]:=
Module[{i=0,r={}},
While[++i≤Length[ratios],
If[Abs[x-ratios[[i,1]]]<=tol,
r=Append[r,ratios[[i]]];
];
];
r
]

Using the provided resistor ratio set, match a given ratio (not a logarithm) with an optional tolerance. Returns fractional error and the resistor pair.

match[ratioset_,ratio_]:=
Module[{x,y,z, r, ans},
x=Abs[Log[10,ratio]]; 
y=IntegerPart[x];
z=FractionalPart[x];
r=bestfitlog[ratioset,z];
r[[2,2]]=(10^y) r[[2,2]];
Print["Desired ratio = "<>ToString[N[ratio]]];
Print["Returned value: {<ratio fractional error>, {<Smaller R>, <Larger R>}}"];
r={Abs[(r[[2,2]]/r[[2,1]])/If[ratio>1.0,ratio,1/ratio]-1],r[[2]]}
]

match[ratioset_,ratio_,tol_]:=
Module[{x,y,z, r, ans},
x=Abs[Log[10,ratio]]; 
y=IntegerPart[x];
z=FractionalPart[x];
r=goodfitslog[ratioset,z,Log[10,1+tol]];
Print["Desired ratio = "<>ToString[N[ratio]]];
Print["Returned values: a list of {<ratio fractional error>, {<Smaller R>, <Larger R>}}"];
Do[ r[[i,2,2]]=(10^y) r[[i,2,2]] , {i,Length[r]}];
r=Table[{Abs[(r[[i,2,2]]/r[[i,2,1]])/If[ratio>1.0,ratio,1/ratio] -1],r[[i,2]]},{i,Length[r]}]//Sort
]

match5[ratio_]:=match[res5ratios,ratio]
match5[ratio_,tol_]:=match[res5ratios,ratio,tol]

match1[ratio_]:=match[res1ratios,ratio]
match1[ratio_,tol_]:=match[res1ratios,ratio,tol]

Examples: Using the match function

Match a ratio using standard 5% tolerance values 
Example: a simple Butterworth VCVS filter needs a noninverting amp with gain 3-(Sqrt[2]).
The Rf/Ri resistor ratio must be 1 less than this ratio

The function match5[ ] uses resistors from the standard 5% value set.

It returns:
	{fractional error,{resistor1, resistor2}}

match5[3-Sqrt[2]-1]

For a list of resistor pairs providing a ratio within a specified fractional tolerance, e.g. 1% = .01, use the following function call:

match5[3-Sqrt[2]-1,.01]//Column

Match the ratio using standard 1% tolerance values

The function match1[ ] uses resistors from the standard 1% value set.

It returns:
	{fractional error,{resistor1, resistor2}}

match1[3-Sqrt[2]-1]

User area