Author Topic: Fun with resistors  (Read 26791 times)

0 Members and 1 Guest are viewing this topic.

Offline theagemanTopic starter

  • Contributor
  • Posts: 39
  • Country: de
    • My Blog
Fun with resistors
« on: August 12, 2015, 12:03:22 am »
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.
« Last Edit: September 03, 2015, 04:12:30 pm by theageman »
Jazz is not dead, it just smells funny
 
The following users thanked this post: Cliff Matthews

Online T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21673
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Fun with resistors
« Reply #1 on: August 12, 2015, 12:14:58 am »
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
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline theagemanTopic starter

  • Contributor
  • Posts: 39
  • Country: de
    • My Blog
Re: Fun with resistors
« Reply #2 on: August 12, 2015, 12:19:06 am »
I think that should not be a real problem (if I get the maths right).
Is there a paper out there regarding that subject?
Jazz is not dead, it just smells funny
 

Online T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21673
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Fun with resistors
« Reply #3 on: August 12, 2015, 12:52:33 am »
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
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline theagemanTopic starter

  • Contributor
  • Posts: 39
  • Country: de
    • My Blog
Re: Fun with resistors
« Reply #4 on: August 12, 2015, 01:29:46 am »
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:
Code: [Select]
struct entity {
double value;
Operation op;
}

The algorithm used to find a solution works recursivly (pseudo code):
Code: [Select]
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.

Jazz is not dead, it just smells funny
 

Offline slateraptor

  • Frequent Contributor
  • **
  • Posts: 833
  • Country: us
Re: Fun with resistors
« Reply #5 on: August 12, 2015, 03:18:03 am »
Struck me as relevant to the discussion:
Combining Multiple Resistors to Improve Tolerance - P. Oliveira

TL;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.
« Last Edit: August 12, 2015, 03:19:59 am by slateraptor »
 

Offline BravoV

  • Super Contributor
  • ***
  • Posts: 7547
  • Country: 00
  • +++ ATH1
Re: Fun with resistors
« Reply #6 on: August 12, 2015, 03:53:14 am »
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.

Offline TiN

  • Super Contributor
  • ***
  • Posts: 4543
  • Country: ua
    • xDevs.com
Re: Fun with resistors
« Reply #7 on: August 12, 2015, 04:31:02 am »
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.  :popcorn:
YouTube | Metrology IRC Chat room | Let's share T&M documentation? Upload! No upload limits for firmwares, photos, files.
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19514
  • Country: gb
  • 0999
Re: Fun with resistors
« Reply #8 on: August 12, 2015, 09:35:04 am »
How about making a program for potential dividers using more than three resistors?
 

Online T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21673
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Fun with resistors
« Reply #9 on: August 12, 2015, 10:21:41 am »
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
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline theagemanTopic starter

  • Contributor
  • Posts: 39
  • Country: de
    • My Blog
Re: Fun with resistors
« Reply #10 on: August 12, 2015, 02:09:17 pm »
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.  :popcorn:

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
Jazz is not dead, it just smells funny
 

Offline theagemanTopic starter

  • Contributor
  • Posts: 39
  • Country: de
    • My Blog
Re: Fun with resistors
« Reply #11 on: August 12, 2015, 02:15:35 pm »
How about making a program for potential dividers using more than three resistors?

Sure, using single resistors or optimized combinations?


Jazz is not dead, it just smells funny
 

Offline theagemanTopic starter

  • Contributor
  • Posts: 39
  • Country: de
    • My Blog
Re: Fun with resistors
« Reply #12 on: August 12, 2015, 02:25:40 pm »
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.
Jazz is not dead, it just smells funny
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19514
  • Country: gb
  • 0999
Re: Fun with resistors
« Reply #13 on: August 12, 2015, 03:02:51 pm »
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
 

Offline theagemanTopic starter

  • Contributor
  • Posts: 39
  • Country: de
    • My Blog
Re: Fun with resistors
« Reply #14 on: August 22, 2015, 07:47:24 am »
Just a little teaser...

I switched back to Delphi development and changed
the layout a bit...

More coming soon.

Greetings,
Olli.

Jazz is not dead, it just smells funny
 

Online T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21673
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Fun with resistors
« Reply #15 on: August 22, 2015, 09:53:06 am »
Ooh :)
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline theagemanTopic starter

  • Contributor
  • Posts: 39
  • Country: de
    • My Blog
Re: Fun with resistors
« Reply #16 on: August 22, 2015, 02:12:29 pm »
Ok, there is a new version online. By far not finsished.
Voltage divider via ratio not implemented.

But i appreciate your suggestions!

Greetings, Olli.

Download:
https://github.com/theageman/rfun/releases/tag/v0.2
Jazz is not dead, it just smells funny
 

Online T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21673
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Fun with resistors
« Reply #17 on: August 22, 2015, 03:53:56 pm »
Hmm...

In principle, you could have resistors from +V to tap 2, or any inbetween node.

This could be extremely complicated...
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline theagemanTopic starter

  • Contributor
  • Posts: 39
  • Country: de
    • My Blog
Re: Fun with resistors
« Reply #18 on: August 26, 2015, 12:38:08 pm »
Hmm...

In principle, you could have resistors from +V to tap 2, or any inbetween node.

This could be extremely complicated...

 :scared: 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.
Jazz is not dead, it just smells funny
 

Offline theagemanTopic starter

  • Contributor
  • Posts: 39
  • Country: de
    • My Blog
Re: Fun with resistors
« Reply #19 on: August 28, 2015, 10:20:15 am »
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.


Jazz is not dead, it just smells funny
 

Online T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21673
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Fun with resistors
« Reply #20 on: August 28, 2015, 04:34:42 pm »
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
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline theagemanTopic starter

  • Contributor
  • Posts: 39
  • Country: de
    • My Blog
Re: Fun with resistors
« Reply #21 on: August 28, 2015, 05:27:28 pm »
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.
Jazz is not dead, it just smells funny
 

Offline quantalume

  • Supporter
  • ****
  • Posts: 26
  • Country: 00
Re: Fun with resistors
« Reply #22 on: August 28, 2015, 05:39:24 pm »
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?
 

Offline theagemanTopic starter

  • Contributor
  • Posts: 39
  • Country: de
    • My Blog
Re: Fun with resistors
« Reply #23 on: August 28, 2015, 05:52:08 pm »
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.
Jazz is not dead, it just smells funny
 

Online T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21673
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Fun with resistors
« Reply #24 on: August 28, 2015, 09:14:36 pm »
Yeah, that's probably good enough.
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf