M. Noone said:
Hi - I feel like I saw this somewhere but have since lost the link. It
was a website where you could put in the ratio you want a resistive
voltage divider to give, and it would give you combinations of standard
resistor values that would yield that ratio.
Anybody know of anything like this?
Or are there any tricks to finding these values that I'm just not aware
of?
Thanks,
-M. Noone
I once knocked up a C program that you are welcome to try, or perhaps
expand on.
It has a very lazy algorithm that searches all combinations of 2 and 3
resistor dividers to find the closest match. You can customise the
first line of main() to choose between e6, e12 or your own resistor
value series. There are still plenty of configurations it does not
try, such as three resistors in series. Also you have to get the
correct power of 10 by yourself!
John
===============================================================
#include "stdio.h"
#include "math.h"
/* The E12 series */
float e12_base[]= { 1.0, 1.2, 1.5, 1.8, 2.2, 2.7, 3.3, 3.9, 4.7, 5.6, 6.8, 8.2 };
float e6_base[] = { 1.0, 1.5, 2.2, 3.3, 4.7, 6.8};
float my_base[] = { 1.0, 1.5, 1.8, 2.2, 4.7, 6.8};
/* program to find the optimum series-parallel combination of
resistors, to get a given ratio */
float xyz1(float x, float y, float z)
{
return x/(1.0/(1.0/y+1.0/z));
}
float xyz2(float x, float y, float z)
{
return x/(y+z);
}
int main(void)
{
/* customise these three (6 or 12) */
float * base_series=e12_base;
int base_N=12;
int decades=6;
float target;
int N=base_N*decades;
int x,y,z;
float min_error=1E30;
float error;
float ratio;
int x_min, y_min, z_min;
float series[N];
int i;
float decade=1;
int n=0;
for(i=0;i<decades;i++)
{
for(x=0;x<base_N;x++)
{
series[n] = base_series[x]*decade;
printf("%f ",series[n]);
n++;
}
printf("\n");
decade *= 10;
}
printf("Resistor series-parallel calculator program!\n");
printf("Calculates optimum combinations of resistors\n");
printf("to acheive a target ratio of resistance R1/R2\n");
printf("\n\n\nEnter target ratio (1.000-9.999):");
scanf("%f", &target);
printf("Target ratio is %f\n\n", target);
/* algorithm: two-resistor divider (Rx, Ry): for each Rx, Ry in
series, find minimum ratio Rx/Ry.
*/
for(x=0;x<N;x++)
{
for(y=0;y<N;y++)
{
ratio = series[x]/series[y];
error = fabs(ratio-target);
if(error<min_error)
{
min_error=error;
x_min=x;
y_min=y;
}
}
}
ratio=series[x_min]/series[y_min];
printf("\n\nBest ratio with two resistors is %f\n",ratio);
printf("Percentage error is %f%%\n",100*(1-target/ratio));
printf("Ry=%f\n", series[y_min]);
printf("Rx=%f\n", series[x_min]);
min_error=1E30;
/* algorithm: three-resistor divider (Rx, (Ry||Rz)) */
for(x=0;x<N;x++)
{
for(y=0;y<N;y++)
{
for(z=0;z<N;z++)
{
ratio = xyz1(series[x],series[y],series[z]);
error = fabs(ratio-target);
if(error<min_error)
{
min_error=error;
x_min=x;
y_min=y;
z_min=z;
}
}
}
}
ratio = xyz1(series[x_min],series[y_min],series[z_min]);
printf("\n\nBest ratio with 3 resistors (Rx, (Ry||Rz) is %f\n",ratio);
printf("Percentage error is %f%%\n",100*(1-target/ratio));
printf("Rz=%f\n", series[z_min]);
printf("Ry=%f\n", series[y_min]);
printf("Rx=%f\n", series[x_min]);
/* algorithm: three-resistor divider (Rx, (Ry+Rz)) */
min_error=1E30;
for(x=0;x<N;x++)
{
for(y=0;y<N;y++)
{
for(z=0;z<N;z++)
{
ratio = xyz2(series[x],series[y],series[z]);
error = fabs(ratio-target);
if(error<min_error)
{
min_error=error;
x_min=x;
y_min=y;
z_min=z;
}
}
}
}
ratio = xyz2(series[x_min],series[y_min],series[z_min]);
printf("\n\nBest ratio with 3 resistors (Rx, (Ry+Rz) is %f\n",ratio);
printf("Percentage error is %f%%\n",100*(1-target/ratio));
printf("Rz=%f\n", series[z_min]);
printf("Ry=%f\n", series[y_min]);
printf("Rx=%f\n", series[x_min]);
return 0;
}