Author Topic: Multi element resistor divider - optimization and construction  (Read 2744 times)

0 Members and 1 Guest are viewing this topic.

Offline ch_scrTopic starter

  • Frequent Contributor
  • **
  • Posts: 860
  • Country: de
Ever since someone mentioned the use of dismantled Peltier element as cheap ceramic PCB, the thought stuck with me. Turns out, 0805 smd resistors fit quite well to the provided grid. The copper pads are big, thick and very firmly attached. Upsides seem obvious: Good thermal contact between elements; good match between ceramic material of PCB and resistors, yielding low force on resistors from thermal expansion; no humidity effect on PCB. Only downside is usually prohibitive price of such PCB. To insulate from environmental influence and aging effects on resistors (humidity, oxygen, etc.), special resistors or hermetic case is still needed though. So why not construct resistor divider of arbitrary ratio from equal elements to try idea? Resistor tempco should get better by statistical averaging in creating compounding resistors like this as well. But divider ratio will never be perfect, especially with cheap 0.5% resistors. Trimming by soldering elements afterwards is awkward on ceramic PCB and might introduce stress. But with 6 1/2 digit meter, resistors can be measured with quite high resolution - since all are close in value, measured at the same time and temperature, and in the end only division ratio is what counts; it seems like errors of offset, linearity, tempco of meter should cancel out? Sure, soldering will affect resistors, but hopefully in somewhat equal manner, especially on ceramic PCB when all are re-flowed at the same time.
A generalized python program was devised to find optimum arrangement and selection of resistors for divider, series and parallel connection (as shown below) are supported. It can just optimize the grouping of resistors, but if spare resistors are specified it will also make optimal selection. Program works by trying all combinations  >:D
Connection legend:

Integrated help:

Example prompt for hamon divider, with many spare resistors initial error can be virtually eliminated and other effects (measuring error, soldering shift, residual tempco, connection resistance, ...) should dominate:

Here is how ceramic divider looks:

Here is another example with case:
« Last Edit: August 04, 2023, 12:30:30 pm by ch_scr »
 
The following users thanked this post: BU508A, MiDi, iMo

Offline manganin

  • Regular Contributor
  • *
  • Posts: 190
  • Country: fi
Re: Multi element resistor divider - optimization and construction
« Reply #1 on: August 05, 2023, 02:32:19 pm »

Rigid mechanical connection on both sides of the resistor not a good idea. The large substrate always beats the tiny resistor. Strain gauge sensors built the same way.

Even if the thermal expansion coefficient of the base matches the resistor body, the temperature change rate doesn't. And the system is not ceramic only, also the solder material is part of the "closed" chain.

Connecting one side of the resistor with a thin copper wire allows free expansion.

 

Online iMo

  • Super Contributor
  • ***
  • Posts: 4977
  • Country: cv
Re: Multi element resistor divider - optimization and construction
« Reply #2 on: August 05, 2023, 04:51:48 pm »
I've been looking for an app which can find a divider where the upper and lower resistors legs can have any arbitrary wiring of the elements resistors - ie parallel or serial or any combination of. Would be great if your tool could be modified somehow, even the computation would take much longer..
« Last Edit: August 05, 2023, 05:05:32 pm by iMo »
 

Offline ch_scrTopic starter

  • Frequent Contributor
  • **
  • Posts: 860
  • Country: de
Re: Multi element resistor divider - optimization and construction
« Reply #3 on: August 05, 2023, 05:26:20 pm »
But you think more about a tool finding the topology, if I understand right? Yeah, that would be nice too. Quite a bit harder to make it seems, maybe easier to implement (but with limited "might") if it had a selection of topologies to go through.
The idea behind this was: "I need a divider to 0.198755, this topology with ideal resistors gives 0.2, can I measure and arrange the real resistors in a way to get there anyway" And it seems so! Obviously there is only "so much" wiggle room, but in my trial with "20 measured 0.5% resistors, 15 of which to be used" the error was basically zero, at least in theory - heaven't finished and measured the resulting divider yet.
I used an earlier version of the tool, that could only optimize the grouping, with 6 THT resistors (measured for lowest deviation relative to each other from a box of maybe 30) to build a hammon divider. The optimizer gave an error of ~10ppm, and the resulting divider seems to do as well, when measured as a voltage divider (please don't mind the mess).
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 4977
  • Country: cv
Re: Multi element resistor divider - optimization and construction
« Reply #4 on: August 05, 2023, 06:03:11 pm »
There is a tool called "Resistor Optimizer 0.58"  (it could pick up resistors from E6-E192 series, was discussed in past) but it works similarly as your app (legs serial or parallel with some limit like 4 pieces max).
I think Monte Carlo could be perhaps the easiest solution, the "max" topology with N resistors in hand the upper leg is (N-1) resistors in parallel x (N-1) resistors in series, and the same for lower leg. The wiring will be "empty" and you shoot two to N resistors into the wiring randomly, till you get the best fit..

PS: in the thread I mentioned there is a post on matrix math - perhaps useful.
https://www.eevblog.com/forum/projects/resistor-combination-calculator/
« Last Edit: August 05, 2023, 06:36:27 pm by iMo »
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 4977
  • Country: cv
Re: Multi element resistor divider - optimization and construction
« Reply #5 on: August 06, 2023, 12:54:20 pm »
Below I've made a small mod - it searches for the best RATIO of Upper/Lower resistor, the initial residual ratio error is set to 100000 ppm (such you may see some results even when you are a bit off the optimal ratio), and it prints out all the iterations when it finds a better fit (such you may see some action on the screen while waiting until it processes all the combinations) :)

Code: [Select]
ratio-optimizer.py 0.415864785 S 12 5 2199.1 2199.2 2199.3 2199.4 2199.5 2199.6 2199.7 2199.8 2199.9 2200.0 2200.1 2200.2 2200.3 2200.4 2200.5 2200.6 2200.7 2200.8 2200.9 2201.0 2201.1 2201.2 2201.3 2201.4
Code: [Select]
..
Residual Ratio error 1685.3720083531 ppm
With these 5 in series for upper leg:
(2199.6, 2199.9, 2199.7, 2199.8, 2200.0)
and these 12 in series for lower leg:
(2199.1, 2199.2, 2199.3, 2199.4, 2199.5, 2200.6, 2200.9, 2201.0, 2201.1, 2201.2, 2201.3, 2201.4)

Residual Ratio error 1681.5783347494 ppm
With these 5 in series for upper leg:
(2199.9, 2199.6, 2199.7, 2199.8, 2200.0)
and these 12 in series for lower leg:
(2199.1, 2199.2, 2199.3, 2199.4, 2199.5, 2200.7, 2200.9, 2201.0, 2201.1, 2201.2, 2201.3, 2201.4)

Residual Ratio error 1677.7846898810 ppm
With these 5 in series for upper leg:
(2199.9, 2199.6, 2199.7, 2199.8, 2200.0)
and these 12 in series for lower leg:
(2199.1, 2199.2, 2199.3, 2199.4, 2199.5, 2200.8, 2200.9, 2201.0, 2201.1, 2201.2, 2201.3, 2201.4)
« Last Edit: August 06, 2023, 05:03:53 pm by iMo »
 

Offline ch_scrTopic starter

  • Frequent Contributor
  • **
  • Posts: 860
  • Country: de
Re: Multi element resistor divider - optimization and construction
« Reply #6 on: August 07, 2023, 08:31:18 am »
I've made a combined version, it allows to select "Ratio" or "resistive Divider" mode and also optionally shows the iterative result.
The initial error was adjusted as per above as well. Caveat: Now needs at least Python 3.10
« Last Edit: August 07, 2023, 03:47:42 pm by ch_scr »
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 4977
  • Country: cv
Re: Multi element resistor divider - optimization and construction
« Reply #7 on: August 08, 2023, 03:08:26 pm »
How to set a resistor(s) value(s) to be taken in the Upper or in the Lower leg as a "priority resistor(s)"?
For example - I've got 30x 2k2 resistors and 10x 1k5 resistors, while I know in advance I will need two 1k5 resistors for the Upper leg.
Except the 2x 1k5 I will need 4x 2k2 in the Upper leg, and 12x 2k2 in the Lower leg.
I want to tell to the algorithm - "include and process the search for the two 1k5 resistors from the very beginning while always keep them in the Upper leg".
« Last Edit: August 08, 2023, 03:30:30 pm by iMo »
 

Offline ch_scrTopic starter

  • Frequent Contributor
  • **
  • Posts: 860
  • Country: de
Re: Multi element resistor divider - optimization and construction
« Reply #8 on: August 08, 2023, 07:01:33 pm »
I think I've got it, please give this a try.
« Last Edit: August 08, 2023, 07:40:54 pm by ch_scr »
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 4977
  • Country: cv
Re: Multi element resistor divider - optimization and construction
« Reply #9 on: August 09, 2023, 06:40:20 am »
I tried, but the -pu switch with the tuple formatting is unclear for me, tried everything. Also I do not know whether to put there in -pu 2 or all 10 upper 1k5s, it should use 2x1k5 and 4x2k2 in the upper leg - see below schematics with resulting divider I want test.
 
Without -pu I get MemoryError with below example (it runs over 8GB).

Quote
C:\Users\user\divider optimizer py>divider_ratio_optimizer.py -i 0.69119372 D S 12 6 2199.1 2199.2 2199.3 2199.4 2199.5 2199.6 2199.7 2199.8 2199.9 2200.0 2200.1 2200.2 2200.3 2200.4 2200.5 2200.6 2200.7 2200.8 2200.9 2201.0 2201.1 2201.2 2201.3 2201.4 2201.5 2201.6 2201.7 2201.8 1500.1 1500.2 1500.3 1500.4 1500.5 1500.6 1500.7 1500.8 1500.9 1501.0
Traceback (most recent call last):
  File "C:\Users\user\divider optimizer py\divider_ratio_optimizer.py", line 46, in <module>
    combination_list_lower = list(itertools.combinations(res_stock, N_R_lower))
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
MemoryError


Python 3.11.4., Win10.
Mind the underscore in the .py

Here is the test command for below schematics:

Code: [Select]
divider_ratio_optimizer.py -i -pu "1500.1 1500.2 1500.3 1500.4 1500.5 1500.6 1500.7 1500.8 1500.9 1501.0" 0.69119372 D S 12 6 2199.1 2199.2 2199.3 2199.4 2199.5 2199.6 2199.7 2199.8 2199.9 2200.0 2200.1 2200.2 2200.3 2200.4 2200.5 2200.6 2200.7 2200.8 2200.9 2201.0 2201.1 2201.2 2201.3 2201.4 2201.5 2201.6 2201.7 2201.8 1500.1 1500.2 1500.3 1500.4 1500.5 1500.6 1500.7 1500.8 1500.9 1501.0
« Last Edit: August 09, 2023, 07:22:22 am by iMo »
 

Offline ch_scrTopic starter

  • Frequent Contributor
  • **
  • Posts: 860
  • Country: de
Re: Multi element resistor divider - optimization and construction
« Reply #10 on: August 09, 2023, 07:10:46 am »
Don't have the priority resistors also in the list, they exist entirely separate (the are pinned on the corresponding leg after getting the combinations for the remaining resistor count)
Can only have as much priority resistors as will be used (not enforced by now), seems you specify 6 upper leg resistors but then 10 as priority - this will not work
Priority resistors subtract internally from the series/parallel of the corresponding leg. Say you want 6 series as upper, just specify "6", you can then optionally specify e.g. 2 as priority and only the other 4 will be iterated over for that run with the 2 always fixed
Hope this makes it a bit clearer, does this work?
Code: [Select]
divider_ratio_optimizer.py 0.69119372 D S 12 6 2199.1 2199.2 2199.3 2199.4 2199.5 2199.6 2199.7 2199.8 2199.9 2200.0 2200.1 2200.2 2200.3 2200.4 2200.5 2200.6 2200.7 2200.8 2200.9 2201.0 2201.1 2201.2 2201.3 2201.4 2201.5 2201.6 2201.7 2201.8 1500.6 1500.7 1500.8 1500.9 1501.0 -i -pu 1500.1 1500.2 1500.3 1500.4 1500.5
« Last Edit: August 09, 2023, 07:13:17 am by ch_scr »
 
The following users thanked this post: iMo

Online iMo

  • Super Contributor
  • ***
  • Posts: 4977
  • Country: cv
Re: Multi element resistor divider - optimization and construction
« Reply #11 on: August 09, 2023, 02:57:42 pm »
Ok, when hard setting the two 1k5 "priority resistors" with the -pu directive and with the list of twenty available 2k2 resistors it finds the correct divider as depicted in the above schematics in 50 secs.. (on my notebook)  :-+

Quote
C:\Users\user\Desktop\Utility\divider optimizer py>py divider_ratio_optimizer_new.py 0.69119372 D S 12 6 2199.2 2199.3 2199.4 2199.7 2200.0 2200.1 2200.3 2200.4 2200.5 2200.6 2200.7 2200.8 2200.9 2201.0 2201.1 2201.2 2201.3 2201.4 2201.7  2201.8 -i -pu 1500.3 1500.7

Quote
...
Residual Divider error 0.0464560855 ppm
With these 6 in series for upper leg:
(1500.3, 1500.7, 2199.4, 2200.0, 2199.3, 2199.2 )
and these 12 in series for lower leg:
(2199.7, 2200.1, 2200.3, 2200.4, 2200.5, 2200.6, 2200.8, 2201.0, 2201.1, 2201.2, 2201.7, 2201.8 )

Residual Divider error 0.0128191418 ppm
With these 6 in series for upper leg:
(1500.3, 1500.7, 2199.2, 2199.7, 2200.4, 2200.3 )
and these 12 in series for lower leg:
(2200.5, 2200.6, 2200.7, 2200.8, 2200.9, 2201.0, 2201.1, 2201.2, 2201.3, 2201.4, 2201.7, 2201.8 )
« Last Edit: August 09, 2023, 03:04:37 pm by iMo »
 

Offline ch_scrTopic starter

  • Frequent Contributor
  • **
  • Posts: 860
  • Country: de
Re: Multi element resistor divider - optimization and construction
« Reply #12 on: August 09, 2023, 05:15:36 pm »
Nice! I've added some basic error messages for "more priority resistors than resistors in the leg" and "no result found at all". Slight modification to make the code more readable as well. Enjoy.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf