KermMartian wrote:
So how about a program that will give you the closest value it can with two resistors, and with three resistors, and then you can decide which one is worth it?


yea ideally I was thinking of an output like this

Target Resistance: 45 Ohms
Closest 2 resistors: 28.7 & 16.5 (+.2 ohms .444%)
Closest 3 resistors: 15 & 15 & 15 (+ 0 ohms 0%)

and then I would just decide if that .2 ohm difference was worth using 3 or 2 resistors (in this case it does make a difference when trying to have output as close as .1% Surprised )

also after your mention of parallel resistors I'd even go so far as to have the same output again, but for parallel! Laughing

I've been thinking about different approaches to the problem as well such as just having the calculator compare EVERY resistor together even if it is well out of the range (ex. comparing a 3M and a 2.5M for a 200 ohm resistor Laughing ) and if that would make solving the problem easier at the expense of adding more computations. My original idea of narrowing the search list from the get go was to avoid those unnecessary comparisons, but in the end does it matter to the calculator? what is the speed of the ti-83 processor btw? lol

also my idea for the "memory" of resistors was starting the program with another program that writes all the values to a list, then in the main program calling those values from the list. Do the lists work like that where i can write, for example, 10 ohms to the first number in the list, 11.3 ohms to the 2nd and so on then recall those numbers by saying "L1 + L2" or something?
Or, you could have them all in one list and then add those individual elements together.

Even though you may want to see this task through independently, the significance of the quality of writing in your program cannot be undervalued for a running time of this magnitude. To mirror one of Kerm's statements, a waste of a few cycles will be magnified to the cube of the number of elements – at the fastest, iterating through a list of 12 on the calculator is livable, 30 is past the threshold of it being a problem, and 120 would be battery suicide.

If you're only putting one and one together, then things do get a little nicer. This is about the fastest routine that one could create in this setting: it returns the best combination of two, as well as the absolute distance from their sum to the input. (Objects are stored in L1.)

Code:
:Input X
:X-L1→L2
:seq(min(abs(Ans-L1(X))),X,1,dim(L1
:For(X,0,1
:L1(max(cumSum(Ans xor 0)(Ans=min(Ans
:Disp Ans
:abs(L2-Ans
:End
:min(Ans

Do make sure to include zero in your list of objects; otherwise, a solitary resistor that is spot-on will be forced to pair up with an excess.

Perhaps a hard-copy lookup would be better overall. If you produce a list of all that you have access to, I could use Mathematica to quickly generate a table of sums.
What about the fact that resistors vary 5% or 1% (etc) depending on what tolerance you're dealing with? Have all of your resistors been tested for their exact value?
Weregoose wrote:
Or, you could have them all in one list and then add those individual elements together.

Even though you may want to see this task through independently, the significance of the quality of writing in your program cannot be undervalued for a running time of this magnitude. To mirror one of Kerm's statements, a waste of a few cycles will be magnified to the cube of the number of elements – at the fastest, iterating through a list of 12 on the calculator is livable, 30 is past the threshold of it being a problem, and 120 would be battery suicide.

If you're only putting one and one together, then things do get a little nicer. This is about the fastest routine that one could create in this setting: it returns the best combination of two, as well as the absolute distance from their sum to the input. (Objects are stored in L1.)

Code:
:Input X
:X-L1→L2
:seq(min(abs(Ans-L1(X))),X,1,dim(L1
:For(X,0,1
:L1(max(cumSum(Ans xor 0)(Ans=min(Ans
:Disp Ans
:abs(L2-Ans
:End
:min(Ans

Do make sure to include zero in your list of objects; otherwise, a solitary resistor that is spot-on will be forced to pair up with an excess.

Perhaps a hard-copy lookup would be better overall. If you produce a list of all that you have access to, I could use Mathematica to quickly generate a table of sums.




I guess the first 60 values would be more appropriate since we generally don't balance with anything over 5k. On my next break I'll post that list.


Quote:
What about the fact that resistors vary 5% or 1% (etc) depending on what tolerance you're dealing with? Have all of your resistors been tested for their exact value?


We just buy precision resistors and trust them at face value
MILLERRRR wrote:
We just buy precision resistors and trust them at face value
Ah, that will save you a lot of headaches then, good to hear.
so here are the first 60 values, the ones most used

10
11.3
12.1
13.3
15
16.5
18.2
20
22.1
24.3
26.1
28.7
33.2
35.7
39.2
42.2
46.4
51.1
56.2
61.9
68.1
75
82.5
90.9
100
107
121
133
150
162
174
200
215
237
261
287
301
332
348
383
422
475
499
604
681
750
825
909
1000
1100
1210
1330
1500
1620
1820
2000
2260
2370
2490
2550

and I appreciate the help with

:Input X
:X-L1→L2
:seq(min(abs(Ans-L1(X))),X,1,dim(L1
:For(X,0,1
:L1(max(cumSum(Ans xor 0)(Ans=min(Ans
:Disp Ans
:abs(L2-Ans
:End
:min(Ans

but I'm fairly new and don't quite understand how this works. Would someone be so kind to explain it to me? Very Happy
Don't worry, even I have trouble understanding Weregoose's code. Smile I'll add line numbers and break it down one-by-one:


Code:
1 :Input X
2 :X-L1→L2
3 :seq(min(abs(Ans-L1(X))),X,1,dim(L1
4 :For(X,0,1
5 :L1(max(cumSum(Ans xor 0)(Ans=min(Ans
6 :Disp Ans
7 :abs(L2-Ans
8 :End
9 :min(Ans

1: Input the desired ohm value
2: If the list of available resistors is in L1, then this will take the difference between the desired value (X) and each resistor (elements of L1) and store the difference in L2. For example, if X=50 ohms, and you have a 40, 50, and 55 ohm resistor, then L1={40,50,55}, and L2={10,0,-5}. You can see from that that the 50 ohm resistor is the closest, and the 55 is second closest.
3: Innermost to outermost: Ans-L1(X): X is now different; X is now iterating from 1 to dim(L1), ie, over all the elements of L1 and L2. For each of these values, we'll find the difference between all the elements of L2 and the original resistor value for that Xth element, take the abs (since -5 and 5 are equally good), then find the minimum. This will give us a list of how close each resistor will get us to the target value, in Ans.
4: Now, try the following three lines (5, 6, 7) with X=0, then X=1. Basically, we'll try one resistors (X=0) and display the best combination, then try two resistors (X=1) and display the best combination.
5: Grab out the resistor value that corresponds with the best match for one resistor.
6: Display that resistor value
7: Remove that value, leaving us with the remaining difference in desired vs. achieved resistance
5a through 7a: Repeat for a possible second resistor
9: Display the difference that still remains after using the two resistors.
Sorry to put you through all that, Kerm. Very Happy

I made tables for the sums of two and three resistors, the latter of which is a superset of the former.

This is better than asking a program to perform the equivalent of adding three numbers together T60 = 37,820 times (see: tetrahedral number).
Definitely agreed that this is better; hope it helps him out. I'd be very curious in trying the parallel option too, but I suspect that there won't be an O(n) equivalent. Not a problem at all about having me explain it; I had fun puzzling out code that was non-trivial to decipher.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 3 of 3
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement