Hello everybody,
I'm not really an electronics engineer. I'm a hobbyist in electronics but i'm a software-engineer as well. Lately I needed to develop an android application, so I installed Qt Creator and all associated android dev-tools on my system.
To get started I decided to develop a small program that I had mind for a long time.
It allows you to synthesize a resistor-circuit based on a given value and the number of resistors to use:
Really funny results can be achieved by constraining the minimum and maximum allowed value to be used. If, for example, you only have 4k7 resistors but you need a 1234.5678 ohm value, you could do something like this:
I know this is just an academic exercise, but if there is interest in the binary or code:
At
https://github.com/theageman/rfun/releases you can get both!
Greetings, Olli!
EDIT:
I started this project in C++/Qt/QML. But I changed it to Delphi XE2 later in the process.
To get the latest version, please have a look at https://github.com/theageman/rfun/releases.
The most recent version at the moment is here : https://github.com/theageman/rfun/releases/tag/0.25.
Have fun,
Olli.
Heh, cool
Would it be possible to add tolerance calculation to that? That is, assuming each resistor is maybe 3 sigma = rated tolerance (+/- 5%), and adding up the total for the derived network.
Tim
I think that should not be a real problem (if I get the maths right).
Is there a paper out there regarding that subject?
You're evaluating an expression, implicitly or otherwise, as you produce the correct value; you need only keep a second expression which contains the derivative. More math than circuits, at least(?). I'd have to scratch on some paper to see what the correct formula is (per stage or holistically).
Important note: tolerance is the derivative divided by the nominal value, hence unitless. The derivative doesn't change for resistors in series, but the tolerance does.
There's also the issue of dependent versus independent; all the derivative contributions need to be summed as RMS, not just added. And all resistors need to be assumed as independent, so you can't just push in the same derivative and have it come out right (which would give the same total tolerance as rated, which is intuitively wrong).
Worst case max/min might be interesting too, but probably not very useful.
By the way, what method are you using to generate networks? If it's straight approximation (add until high enough, parallel until low enough, repeat until within spec), it's guaranteed to terminate but not to be optimal. Not sure what would do that, exactly. Probably a tree search starting from the final value (which is either composed of series or parallel, which are composed of...), and finding the path of descent along that tree which gives all values within tolerance. Hmm, that still might not be very fast, there's no obvious way to choose a unique path.
Tim
You're evaluating an expression, implicitly or otherwise, as you produce the correct value; you need only keep a second expression which contains the derivative. More math than circuits, at least(?). I'd have to scratch on some paper to see what the correct formula is (per stage or holistically).
I just asked Wikipedia about 3 sigma
(just briefly flew over the presented article)
Standard deviation seems to be the topic.
Give me a few days...
Important note: tolerance is the derivative divided by the nominal value, hence unitless. The derivative doesn't change for resistors in series, but the tolerance does.
Very interesting!
Worst case max/min might be interesting too, but probably not very useful.
Well, that's the easiest thing to implement
By the way, what method are you using to generate networks? If it's straight approximation (add until high enough, parallel until low enough, repeat until within spec), it's guaranteed to terminate but not to be optimal. Not sure what would do that, exactly. Probably a tree search starting from the final value (which is either composed of series or parallel, which are composed of...), and finding the path of descent along that tree which gives all values within tolerance. Hmm, that still might not be very fast, there's no obvious way to choose a unique path.
Tim
Sorry, I planned to include some information about the algorithm. (i will write a paper about the implementation in a few days).
Basically we are talking about two algo's, one data-structure and one (designed) limitation here.
The limitation:
There are two operations (|| = parallel, + = serial combination).
So you can say R = R1 || R2 + R3, for example. But this gets evaluated from back to front, so in reality you get R = R1 || (R2 + R3).
The limitation in this app is, that you can't set parantheses in the expression. Everything gets evaluated from back to front.
This limitation leads to the data-structure used:
Just a simple list of:
struct entity {
double value;
Operation op;
}
The algorithm used to find a solution works recursivly (pseudo code):
double findCombination(double value, double currentError, double min, max etc.)
{
// serial combinations
for (resistor=min; resistor<max; resistor++)
{
idealValue = value-resistor;
actualValue = findCombination(idealValue, err, min, max)
calc err
if newMinium(err) store result...
}
// parallel combinations
for (resistor=min; resistor<max; resistor++)
{
idealValue = (value*resistor)/(value-resistor);
actualValue = findCombination(idealValue, err, min, max)
calc err
if newMinium(err) store result...
}
}
I hope that this makes at least a little sense ;)
Greetings, Olli.
Struck me as relevant to the discussion:
Combining Multiple Resistors to Improve Tolerance - P. OliveiraTL;DR summary: Assuming identical resistors and normal distribution, tolerance of the Thevenin-equivalent resistor network is proportional to the inverse root of the number of resistors used...relative to specific manufacturer bias, not nominal value.
EDIT: Goofed the URL tag...fixed.
Olli, great tool, thanks !
Is it possible to build it as "portable" version ? So no setup hassle and can be run just from a single EXE file.
Perhaps add tempco calculation too, but that would need ability to add tempco value to each resistor in array.
Would be nice tool for volt-nuts then.
How about making a program for potential dividers using more than three resistors?
For thermistors, this is the (exact) solution for a given thermistor, one resistor in series, and one resistor in parallel. (Obviously, an arbitrary network could be solved for a limited set of resistor values, but that would be hard.
) Or inductors (not that you usually have inductors of very well known value and tempco), or reciprocal for capacitors (which was the original problem I had encountered).
http://seventransistorlabs.com/Calc/Tempco.htmlEd: for two resistor combinations (single and ratios), there's:
http://jansson.us/resistors.htmlI also have a divider calculator which may be of interest,
http://seventransistorlabs.com/Calc/ResDiv.htmlTim
Olli, great tool, thanks !
Is it possible to build it as "portable" version ? So no setup hassle and can be run just from a single EXE file.
As soon as I get the static QT libs installed and linked, this should be a single exe.
Perhaps add tempco calculation too, but that would need ability to add tempco value to each resistor in array.
Would be nice tool for volt-nuts then.
Perhaps I should split this application into a synthesizing and an analizing part. Hmmm....
Here are a couple possible additions :
(1) Include tables of the preferred number series corresponding to a particular tolerance based set of standard resistor values and enable the selection of one of those as the set from which the final values are synthesized.
I don't know if I get this right. Are you suggesting to put a "User set 1" and "User set 2" into the E-Series combo-box?
That will change the traversal in the search-tree. But should be possible.
(2) Support the creation of not a particular value of resistance, but a particular ratio of resistance such as would apply when creating a potentiometer from fixed resistor values and one wants the resulting ratio to be some particular value. Applicable constraints for this situation would be minimum and maximum values of resistors to be used, which preferred number series of resistors will be used, and how many series / parallel elements are usable to create the best approximate ratio. Taking the voltage divider search further one could specify a given input voltage + tolerance and a target voltage to be created and search for the best available resistors to implement the divider.
This voltage divider part seems to be a logical extension to the project.
(3) Given a particular thermistor characteristic, what is the tolerance of resistance values observable for a given temperature. One could also look at what values and temperature characteristics of associated resistors would produce the best linearization of the thermistor circuit voltage over a given temperature range, and what would be the tolerance vs. temperature. I don't suppose linearization is nearly as important these days given the usability of MCUs to calculate corrections, but tolerance is always useful.
Wow. To be honest, I didn't plan this to be a professional tool. But the sources are available. Everybody is invited!
But thank you very much for your suggestions.
Olli
How about making a program for potential dividers using more than three resistors?
Sure, using single resistors or optimized combinations?
For thermistors, this is the (exact) solution for a given thermistor, one resistor in series, and one resistor in parallel. (Obviously, an arbitrary network could be solved for a limited set of resistor values, but that would be hard. ) Or inductors (not that you usually have inductors of very well known value and tempco), or reciprocal for capacitors (which was the original problem I had encountered).
http://seventransistorlabs.com/Calc/Tempco.html
Ed: for two resistor combinations (single and ratios), there's:
http://jansson.us/resistors.html
I also have a divider calculator which may be of interest, http://seventransistorlabs.com/Calc/ResDiv.html
Tim
Ok, just to summarize. We need:
1) Single executable version
2) tempco calculations (or estimations)
3) error/tolerance calculations
4) Voltage dividers
5) Multi-tap voltage dividers
Give me a few days. Regarding the temperature coefficient I might come back to you with some questions
Greetings,
Olli.
How about making a program for potential dividers using more than three resistors?
Sure, using single resistors or optimized combinations?
Optimised combinations.
Something like this web based app but with the option to have more voltages and resistor combinations would be really good.
http://sim.okawa-denshi.jp/en/teikokeisan.htm
Just a little teaser...
I switched back to Delphi development and changed
the layout a bit...
More coming soon.
Greetings,
Olli.
Hmm...
In principle, you could have resistors from +V to tap 2, or any inbetween node.
This could be extremely complicated...
Hmm...
In principle, you could have resistors from +V to tap 2, or any inbetween node.
This could be extremely complicated...
I fear this is too complicated for me.
I had to use real netlists. The drawing-algo would
have to deal with crossing nets.
Another problem would be that the load impedances
would affect more than one tap.
But nevertheless this *is* a very interesting problem to
deal with. I will keep this idea in mind.
At the moment i am trying to include tempco's and tolerances.
Greetings,
Olli.
I started implementing tempco-calculations and looked up some typical tempco values at digikey (just to have some default values).
And here is a point I don't understand. (Sorry, I'm just a hobbyist)
In many datasheets the tempco is given by a range (+/- 100ppm/°C) for example. As I understand it, the tempco can only be a single value (either positive or negative).
Can somebody clarify please?
Thanks,
Olli.
The tempco need not be a single value:
A given sample of a part number may have some tempco at room temperature, but as temperature changes, so does the tempco (a tempcoco, if you will?).
The tempco may not be reciprocal, i.e., after some cycles, it doesn't end up in the same place. Or it's history dependent / hysteretic.
Across different samples, the tempcos (and behaviors) may all vary, so that in a statistical sample, a range is the only thing that can be listed confidently.
In practice, the actual or average results may not be so pessimistic; but you'd have to measure them to find out, since the manufacturer does not.
Tim
The tempco need not be a single value:
A given sample of a part number may have some tempco at room temperature, but as temperature changes, so does the tempco (a tempcoco, if you will?).
The tempco may not be reciprocal, i.e., after some cycles, it doesn't end up in the same place. Or it's history dependent / hysteretic.
Across different samples, the tempcos (and behaviors) may all vary, so that in a statistical sample, a range is the only thing that can be listed confidently.
In practice, the actual or average results may not be so pessimistic; but you'd have to measure them to find out, since the manufacturer does not.
Tim
Ok. So in practice a tempco-calculation like the one shown in the picture would be OK?
Olli.
Hey, thanks for this tool!
I will get a lot of use out of it. Nice of you to use Delphi. Any interest in using
Lazarus so you can create Linux executables?
Hey, thanks for this tool! I will get a lot of use out of it. Nice of you to use Delphi. Any interest in using Lazarus so you can create Linux executables?
I know Lazarus. It's a great IDE. I'm using Delphi XE2 at the moment. As I'm not using super special components, the sources should be compatible to Lazarus. I could upload the sources to Github if you like.
Olli.
Yeah, that's probably good enough.