Prefered resistor range

I do this with Brute Force (ie matlab). I have a simple s-file that takes an array of available values, which may or may not be entire ranges - smt design optimisation usually involves minimising the number of different parts.

Then I calculate every possible 1,2,3,4 resistor combination, using:

1 resistor 2 series 2 parallel 1 paralleled with (2 series) 2 paralleled with (2 series)

and for each of the 5 cases sort the result in order of increasing error

I specify a required accuracy, then throw away all results which are worse.

then display the first 10 entries in each of the 5 combinations.

Yeah, it makes HAL9000 do a *lot* of calculations, but so what - it results in a barely perceptible delay between hitting and getting the answers.

Cheers Terry

Reply to
Terry Given
Loading thread data ...

This is called "The Fence Post Effect". There are 97 values, if you count both ends. There are 96 _steps_. The first of the 97 is the zeroth step.

i.e. you have a 100 foot border, and want to put up a straight fence along that border, with a post every 10 feet. How many fenceposts do you need to buy?

Cheers! Rich

Reply to
Rich Grise

...

I bet you could get within .1% by finding two to put in parallel - here's a case where a lookup table would really do the trick! Give it a target, and a delta, and it'll give you a list of series and/or parallel combinations of two and a list of what's in range with its delta.

Of course, the overall tolerance will be probably not quite 1%, but you can get arbitrarily precise with the nominal value. ;-P

Cheers! Rich

Reply to
Rich Grise

I posted a general solution to this problem last fall. What's neat about this routine is that, unlike a straight root-of-10 solution, it actually returns the correct standard values for 20%, 10%, and 5% ranges.

" Quite a few years ago, more than 20, somebody published the following little Basic routine in one of the free magazines. I have lost the original article and cannot give proper credit. This routine accepts a resistor value that perhaps came from an exact calculation, and a tolerance, and returns the nearest standard value from that tolerance range.

10 INPUT "R, TOLERANCE? ";R,T 20 Z4=.0119926*INT(1+1.5*T+.004*T^2) 30 Z3=INT(LOG10(R)-INT(2.2-3*Z4)) 40 R=R/(10^Z3) 50 FOR I=1 TO 2 60 Z(I)=INT(EXP(Z4*(INT(LN(R)/Z4)+I-1))+.5) 70 Z5=.0000188*Z(I)^3-.00335*Z(I)^2+.164*Z(I)-1.284 80 Z(I)=Z(I)+INT(Z5*INT(3*Z4+.8)) 90 IF Z(I)=919 THEN Z(I)=920 100 NEXT I 110 R=10^Z3*Z(INT(R/SQR(Z(1)*Z(2)))+.5) 120 PRINT R

Notice that both LOG10 and LN are used. Some Basic's may not have both. Make the appropriate changes.

Line 90 is there to correct a peculiarity of the E192 series of resistor values. It seems that when the original series was created, a slight rounding error occurred. The expression for the 186th value in the series would be 10^(185/192) which gives 9.19478686, which rounded to 3 digits would give 9.19; but the official value is 9.20. Since the routine above would give the mathematically correct value which would not be a standard part, line 90 is needed.

This routines works for 20%, 10%, 5%, 2%, 1%, .5%, .25%, and .1% resistor series. "

Reply to
The Phantom

No help with a formula, but, you can get ResCAD for Win32 here

formatting link

which will give you nearest E6/12/24/96 values and combinations for series/parallel/voltage divider.

It uses lookup tables.

Reply to
nospam

Entirely right. What do you have besides bare assertion and invective to make your case? Nothing I'll wager.

Tables are used only for certain limited arbitrary data and to correct for those few results that do not agree with the publish tables when computed algorithmically.

Your inability to discern an algorithmic approach when it is there in plain sight marks you as the pretender with respect to claims of intellectual power.

Fred, I wish you could comprehend how disappointed I would be if you liked me or respected me or my work.

--
--Larry Brasfield
email: donotspam_larry_brasfield@hotmail.com
Above views may belong only to me.
Reply to
Larry Brasfield

examples. The program, however, seems to want '1' as

sign, it fails, and prints the usage.

than the one you are running?

I'm using bash on cygwin. I used the perl debugger to dig into your code, which simply doesn't want the %. When it gets it, it fails. Look at it again.

On line 83, $pick is the argument. You check for $pick to be a number. If it is, you append a % to it, and use it to set $tolerance using the stdtols hash. Otherwise, you go on to check for it being -n. Othewise, you print usage and bail.

I'm guessing that it's YOUR shell that's swallowing the %...; % is used as an environment variable introduction in windows. Windows is probably just tossing it. Try it with the perl debugger "perl -d stdvals 1%", and then look at the value $pick gets set to by the shift, or just 'p @ARGV'.

Insert this snippet before line 83 to fix it: >>>

if ($pick =~ m/^\d+%$/) { if ($decsplit = $stdtols{$pick}) { $tolerance = $pick; } else { die $usage; } } else

Reply to
Robert Monsen

....

examples. The program, however, seems to want '1' as

sign, it fails, and prints the usage.

....

....

which simply doesn't want the %. When it gets it, it

You are entirely correct, to my great surprise. (This is the first time I can remember when 4NT has been found to do something less sensible than cmd.exe.)

is, you append a % to it, and use it to set

-n. Othewise, you print usage and bail.

That code would be fixed per your later suggestion if not for having been recently eliminated in favor of a (usually) simpler invocation.

environment variable introduction in windows.

Yes, (again).

The OS does virtually nothing to command lines in the way of parsing, quoting, etc. There may be an Ascii/Unicode translation, but that's it.

$pick gets set to by the shift, or just 'p @ARGV'.

Echoing @ARGV reveals the issue clearly.

standard values:

same file, and the thing works by rewriting frame data.

Thanks. I've pulled it down and looked at it. I'm not up on browser/HTML conventions or coding, so some of that is greek to me.

program input syntax, environment variables, etc.

Yes, it does. But the poor program is so hacked that documenting it is a loser's game. For laughs, you should see the endless efforts of the 4NT authors to make a reasonably compatible shell. One undocumented quirk after another trickles in.

--
--Larry Brasfield
email: donotspam_larry_brasfield@hotmail.com
Above views may belong only to me.
Reply to
Larry Brasfield

Hmmm, mebbe I shouldn't have asked ??

-- Regards ..... Rheilly Phoull

Reply to
Rheilly Phoull

I don't know; I was hoping you would. :-)

Seriously, though, I have never seen an explanation I would consider truly authoritative. But some years the question came up in the British magazine, Wireless World, and I believe that "Cathode Ray" said that slight perturbations were made so that the color combinations on the resistor body would be more distinguishable. Perhaps John Woodgate can help us out here.

Reply to
The Phantom

IEC 60063

Google will find a copy, e.g.

formatting link

It seems that John is wrong (an infrequent occurrence!). The E6 series does *not* include 8.2, and there are only 6 multiplications by the 6th root of ten.

Regards, Allan

Reply to
Allan Herriman

A table lookup is about 10000 times faster, though. Doing all that math is going to hurt, particularly in basic...

You could also just look here:

formatting link

--
Regards,
   Robert Monsen

"Your Highness, I have no need of this hypothesis."
     - Pierre Laplace (1749-1827), to Napoleon,
        on why his works on celestial mechanics make no mention of God.
Reply to
Robert Monsen

I copied it for later study shortly after you posted it. There is an interesting mix of both the straightforward logarithmic decade splitting and some adjustment via a cubic polynomial. It is quite a tangle, analytically. I suspect it was quite a trial and error effort rather than founded on anything like the original algorithm.

If it covers the whole set of tolerances without any corrections, I will be amazed. But using that kind of method is very fragile against changing requirements. Using tables judiciously can make for better code.

--
--Larry Brasfield
email: donotspam_larry_brasfield@hotmail.com
Above views may belong only to me.
Reply to
Larry Brasfield

Have a look at the little Basic routine I posted. Whoever originally wrote it did a good job of curve fitting and came up with a formula (algorithm?) that properly calculates those oddball values that a simple root-of-10 method doesn't get right. Thus you don't need any tables.

Reply to
The Phantom

-------> But using that kind of

Reply to
The Phantom

It's not even *much* of a pain at that. On my 20 year old HP-71, it only takes about a second to return a value. The HP48 is faster. You just leave this little routine in your calculator and if you need a standard value, you have it in a second. Quicker even than looking it up on a sheet of paper.

Reply to
The Phantom

Nice guess, wimp- but entirely wrong.

You call that kluge an algorithm- it's slightly less than a table.

I seriously doubt your competence at testing too. What a worthless fool you are.

Reply to
Fred Bloggs

I read in sci.electronics.design that The Phantom wrote (in ) about 'Prefered resistor range', on Wed, 16 Mar 2005:

The previous editor wanted to recruit readers to scan and OCR back issues! Fat chance!

There is a set of 5 full-text CDs covering 1999 to 2003. £30 each. A CD was produced, containing the indexes for both EW and 'Television' from

1988 to 1999, but it seems not to be available any more.

I managed to locate T Roddam's explanation, in a Letter to the Editor, May 1984. This includes a very interesting piece about calculations using preferred values. I can't render it in ASCII, because it includes logs to base 6! So I'll scan it and put it on A.B.S.E. as 'Preferred values and colour codes'.

The participants would have been middle-aged before WW2, so I think not.

Roddam isn't specific about which 'committee' was responsible. It may have been one under the aegis of the (British) Radio Manufacturers' Association.

--
Regards, John Woodgate, OOO - Own Opinions Only. 
The good news is that nothing is compulsory.
The bad news is that everything is prohibited.
http://www.jmwa.demon.co.uk Also see http://www.isce.org.uk
Reply to
John Woodgate

[Useless invective cut.]

those few results that do not agree

way of saying WHEN THE "ALGORITHM" FAILS, then you

I suppose, in your world, it would be a better algorithm to duplicate whatever calculation errors led to those odd values. Or devise some hoky polynomial of sufficiently high order to fit the misfits, then not recognize it as the equivalent of a lookup table.

I am thankful that your influence is so limited.

What do you make of the fact that the odd 7 values near the middle of the E24 series are too low and just 1 is too high near, but not at, the end of the series, recognizing, as you must, that the underlying exponential has no possiblity of such behavior? And what do you make of the fact that only the E24 (and consequently E12) series has that behavior whereas the finer-stepped series do not?

Those are honest questions, Fred -- a chance to exhibit some of that intellectual firepower you would seem to possess.

[Useless invective cut.]

the more you open your ignorant, pompous, mouth, the

Wow! Do I detect, from your slightly obscured spelling, the beginning of a move away from your obsession with excrement? I hope it is something you are doing for your own good rather than mine. And I hope your invisible friends let you continue.

--
--Larry Brasfield
email: donotspam_larry_brasfield@hotmail.com
Above views may belong only to me.
Reply to
Larry Brasfield

Right, it was the generate and test algorithm I was a bit concerned with when I posted.

Ok, caching is a usually a good strategy.

Sadly, I don't have a basic interpreter, so I guess I'm stuck with the clumsy table lookup. It's ok, since I already have all the values typed (actually cut and pasted) in here:

formatting link

You have a cute routine, though. Curve fitting is fun. Somebody had alot of fun doing it, I think. That "if 919, output 920" is hilarious.

I'm hoping Bloggs posts the simpler scheme he claims to know.

--
Regards,
   Robert Monsen

"Your Highness, I have no need of this hypothesis."
     - Pierre Laplace (1749-1827), to Napoleon,
        on why his works on celestial mechanics make no mention of God.
Reply to
Robert Monsen

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.