Post Reply 
New guy and programming problem
08-27-2017, 05:52 PM
Post: #5
RE: New guy and programming problem
(08-27-2017 03:15 PM)Dieter Wrote:  
(08-27-2017 06:18 AM)Skirmitch Wrote:  LBL "PAR2"

This program will not work correctly if you enter a value at the R1 resp. R2 prompt. If you do so, the previous content of that variable (the value displayed after "R1?" resp. "R2?") will be pushed to Y and the new value is in X. So this mixes up the stack contents and the calculation will go wrong. Some later calculators, e.g. the 35s, behave differently in this regard.

Anyway, you can do it this way:

01 LBL "PAR2"
02 INPUT "R1"
03 INPUT "R2"
04 RCL"R1"
05 1/X
06 RCL"R2"
07 1/X
08 +
09 1/X
10 "Rtotal="
12 END

You can insert a STO "R1" between line 09 and 10 so that the result is stored as input for the next calculation. This way you can add further resistors in parallel without having to re-enter the last result.

But you can also do it without this fancy prompting and named variables:

01 LBL "PAR"
02 1/X
03 x<>y
04 1/X
05 +
06 1/X
07 END

Or even better since it also allows zero resistances:

01 LBL "PAR"
02 RCLx ST Y
03 x<>y
04 RCL+ ST L
05 /
06 END

If you replace line 03 with RCL ST Y you can even see both the current result in X and the previous one in Y. ;-)

Both versions work for as many resistors in parallel as you like:

100 [ENTER] 150 [XEQ]"PAR" => 60
200 [R/S] => 46,15
  50 [R/S] => 24


Your third code not only allows zero resistances but is also more accurate, especially if there are both large and small resistances involved. Joe Horn explains the concept here.

For the 48gx and later, this can be simply expressed as:


for a list of two or more resistances.

Find all posts by this user
Quote this message in a reply
Post Reply 

Messages In This Thread
RE: New guy and programming problem - John Keith - 08-27-2017 05:52 PM
RE: New guy and programming problem - sasa - 09-01-2018, 03:18 PM
RE: New guy and programming problem - sasa - 09-01-2018, 05:33 PM

User(s) browsing this thread: 1 Guest(s)