Post Reply 
New guy and programming problem
08-27-2017, 03:15 PM (This post was last modified: 08-27-2017 03:40 PM by Dieter.)
Post: #2
RE: New guy and programming problem
(08-27-2017 06:18 AM)Skirmitch Wrote:  LBL "PAR2"
INPUT "R1"
1/X
INPUT "R2"
1/X
+
1/X
END

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:

Code:
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="
11 AVIEW
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:

Code:
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:

Code:
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

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


Messages In This Thread
RE: New guy and programming problem - Dieter - 08-27-2017 03:15 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)