MILLER, give my program a try if you get a chance; I'd like to see if it does the trick. You're almost inspiring me to try to make this as a Doors CS program. Smile

Code:
prgmCLR2NUM
:3->dim(L1
:For(D,0,2
:ClrHome:Disp sub("FIRST SECONDTHIRD ",6D+1,6)+" BAND:
:Delvar XRepeat K=105
:Output(2,1,sub("BLCKBRWNRED ORNGYLLWGRN BLUEVLT GRAYWHT ",4X+1,4
:X+(K=25 and X=/=9)-(K=34 and X->X
:End
:X->L1(D+1
:End
:(10^L1(3))(10L1(1)+L1(3


I started this post explaining how the original program worked, but then I just optimized the hell out of it. :/

Code:
prgmCLR2NUM
:3->dim(L1
:For(D,0,2
:ClrHome:Disp sub("FIRST SECONDTHIRD ",6D+1,6)+" BAND:
:Delvar XRepeat K=105
:Output(2,1,sub("BLCKBRWNRED ORNGYLLWGRN BLUEVLT GRAYWHT ",4X+1,4
:getKey->K
:X+(K=25 and X=/=9)-(K=34 and X->X
:End
:X->L1(D+1
:End
:(10^L1(3))(10L1(1)+L1(2
Fixed two problems. Smile

Code:
prgmCLR2NUM
:3->dim(L1
:For(D,0,2
:ClrHome:Disp sub("FIRST SECONDTHIRD ",6D+1,6)+" BAND:
:Delvar XRepeat K=105
:Output(2,1,sub("SLVRGOLDBLCKBRWNRED ORNGYLLWGRN BLUEVLT GRAYWHT ",4X+9,4
:getKey->K
:X+(K=25 and X=/=9)-(K=34 and X>-2->X
:End
:X->L1(D+1
:End
:(10^L1(3))(10L1(1)+L1(2
With gold and silver bands added, adding the fourth band would be a bit more code but I need sleep so it can wait.
KermMartian wrote:
Sure, you should post it up. Do you have the cable to connect your calculator to your computer? If so, you can use SourceCoder to extract human-readable source code from .8xp file.


Code:
sub("BLCKBRWNRED ORNGYLLWGRN BLUEVLT GRAYWHT GOLDSLVR",4C+1,4
This would yield "BLCK" for C=0, "GRN " for C=5, "WHT" for C=9, "GOLD" for C=10, "SLVR" for C=11, etc.


using the line sub("BLCKBRWNRED ORNGYLLWGRN BLUEVLT GRAYWHT GOLDSLVR",4C+1,4 to display the colors
it doesnt correctly display gold or silver as the 3rd band (ex. 6.8 ohms or .77 ohms) b/c they are stored as a negative value
You almost had it right. Smile


Code:
prgmCLR2NUM
:3->dim(L1
:For(D,0,2
:ClrHome:Disp sub("FIRST SECONDTHIRD ",6D+1,6)+" BAND:
:Delvar XRepeat K=105
:Output(2,1,sub("SLVRGOLDBLCKBRWNRED ORNGYLLWGRN BLUEVLT GRAYWHT ",4X+9,4
:getKey->K
:X+(K=25 and X=/=9)-(K=34)((D=2 and X>-2)+(D=/=2 and X->X
:End
:X->L1(D+1
:End
:(10^L1(3))(10L1(1)+L1(2
I did not write that code haha
Someone edited a post I made.

what difference is
:X+(K=25 and X=/=9)-(K=34)((D=2 and X>-2)+(D=/=2 and X->X

compared to
:X+(K=25 and X=/=9)-(K=34 and X>-2->X
MILLERRRR wrote:
I did not write that code haha
Someone edited a post I made.

what difference is
:X+(K=25 and X=/=9)-(K=34)((D=2 and X>-2)+(D=/=2 and X->X

compared to
:X+(K=25 and X=/=9)-(K=34 and X>-2->X
That's to ensure that the gold and silver -1/-2 colors can only be used for the third band. There's also this change, which makes it not throw a dim error for gold or silver:

:Output(2,1,sub("[colors] ",4X+1,4

to

:Output(2,1,sub("[colors] ",4X+9,4
hello again

I've been busy wasting time at work again (got a new job assembling pressure transducers Cool ) and came up with a problem that I'm wondering if the TI can handle it

When balancing a pressure sensor, adding more resistance to one side of the sensor will change its output to the desired reading. We figure out this resistance with a decade box (basically a box that allows you to set resistance by increasing numbers in the 1's place, 10's 100's etc etc) and then we solder that value into the board. Well the selection of resistors is not as infinite as the decade box however, in fact from the range of 10 ohms to 3k ohms there are only 30 or so values to choose from Sad . This turns out not to be a problem though, as up to 3 resistors can be combined to make a value ( I.E 100 + 250 = 350 ohm resistor) The REAL problem however is finding which combination of either 2 or 3 resistors is closest to the target resistance. Currently what I do is take my target resistance, lets say 900 ohms, and start with the closest value resistor that we stock, in this case 825 ohms, and subtract it, giving me 75, and seeing what other resistor we have that is close to 75, in this case the closest is 69.2 ohms. I go through each value until by trial and error I find the closest value. I am wondering if the calculator can do this for me!

My idea is that the target resistor is entered, and then the calc goes through the saved record of resistor values in stock and returns the closest combination of 2 or even 3 resistors. Is this possible? And I'm not just asking someone to do this for me, I'd like to see if I can do it I'm just looking for some guidance! Very Happy
This is very easy to do! It's a simple optimization problem, and one that has (relative to other problems of its type) very few degrees of freedom.
So Im thinking of something like this...

entered value=x

calc searches memory for closest value to x , sets it to a
subtracts that value from x, sets it to y
searches memory for closest value to y , sets it to b
(a+b)=z then z-x=f


after that, it repeats the process with the next closest value to x, and does this until all the values have been gone through.

Then it finds the combination with the lowest f value and returns that

problems I've noticed while typing this:
1) Only needs to use values lower than X
2) having multiple combinations with the same f value
3) how do you compare the f values?

also I dont even have an idea for figuring out 3 resistors! Surprised
Obviously the naive implementation (try all possible combinations of two or three resistors) has O(n^2) or O(n^3) complexity. I think your approach is a good one. Something I think you may not have thought of - putting a pair (or triplet) of resistors in parallel to yield a smaller, more precise result.
KermMartian wrote:
Obviously the naive implementation (try all possible combinations of two or three resistors) has O(n^2) or O(n^3) complexity. I think your approach is a good one. Something I think you may not have thought of - putting a pair (or triplet) of resistors in parallel to yield a smaller, more precise result.


oh no big O notation its like im in CS classes all over again


That isn't an option unfortunately as the circuit board has 2 holes for the leads to go into and space is at a premium! must be in series!

the resistors get hooked together in a bundle by bending one lead over the resistor then crossing them over eachother and soldering
With 30 objects, there are 435 different ways to pick two, and 4060 different ways to pick three. If you were to add in a 31st object with a value of zero, then you would still have 4060 + 435 = 4495 different ways of picking three, yet you'll also have simplified the procedure in that you don't have to think about how many to pick!

Starting with the object closest to the target doesn't necessarily give the best results – six from {2,3,8} makes this clear. The naive approach is to go through the sums of every combination in order to see which is nearest to the target – more efficiently, "pocketing" each new sum as it is found to be better than the last one, while simply discarding the rest.
MILLERRRR wrote:
That isn't an option unfortunately as the circuit board has 2 holes for the leads to go into and space is at a premium! must be in series! the resistors get hooked together in a bundle by bending one lead over the resistor then crossing them over eachother and soldering
One of my favorite tricks is to put the resistors next to each other, wrap the leads of one resistor around the other and made a few turns very close to the other's body, cut and solder. Then I have a resistor piggybacked on top of another resistor, and the pair only has two leads and can fit in one resistor's spot.
Out of curiosity, what numbers do we have, specifically? Can each be chosen more than once?
Weregoose wrote:
Out of curiosity, what numbers do we have, specifically? Can each be chosen more than once?
Based on his problem description, you can reuse values. For what it's worth for non-EEs, R1 and R2 in series yield R1+R2, while R1 and R2 in parallel yield 1/((1/R1)+(1/R2)).
Weregoose wrote:
Out of curiosity, what numbers do we have, specifically? Can each be chosen more than once?


you can use the resistors more than once, and theoretically you can use as many as you'd like but for convenience and cost savings, usually I use 2, and I step up to 3 if I can't find a close enough value using 2.

from a range of 10 ohms to 3.01Mohms, there are 120 values that can be chosen from. I can list them all if you'd like, but maybe a smaller sampling would be best for the purpose of creating a model.

with that in mind, from a range of 10 ohms to 28.7 ohms, the selections are

10
11.3
12.1
13.3
15
16.5
18.2
20
22.1
24.3
26.1
28.7
KermMartian wrote:
MILLERRRR wrote:
That isn't an option unfortunately as the circuit board has 2 holes for the leads to go into and space is at a premium! must be in series! the resistors get hooked together in a bundle by bending one lead over the resistor then crossing them over eachother and soldering
One of my favorite tricks is to put the resistors next to each other, wrap the leads of one resistor around the other and made a few turns very close to the other's body, cut and solder. Then I have a resistor piggybacked on top of another resistor, and the pair only has two leads and can fit in one resistor's spot.



ooooo good idea I hadn't thought of that!
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?
  
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 2 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