Post Reply 
[HP 12c] Programming - Making a 3 or 4 parameter RPN function
06-14-2023, 01:22 PM (This post was last modified: 06-14-2023 03:26 PM by Giganotosaurio1972.)
Post: #1
[HP 12c] Programming - Making a 3 or 4 parameter RPN function
For designing an algorithm for the HP 12c using RPN, that gets three or four parameters from the RPN stack for making a specific complex calculation, the two steps (two problems) I have to solve are,
  1. Getting the parameters from the stack to some registers
  2. Making the calculation using the values from these registers

Well, for doing the first step (getting the parameters...), I can,
  • Storing the value displayed in the screen, on a register (R0, R1, R2....), using [STO] + <The number of register, from 0 to 9>
  • Moving down in the RPN stack, by the [R↓] key>
And then, when I saved all the values I will need in the calculation route, I proceed with that calculation, using the values I stored when I need it, by pressing [RCL] + <The number of the register where I stored that value>

Well. For example, I want to make a program that works as a 3 parameter RPN function, that gets the 3 last registers stored in the RPN stack and puts the result in the first of these anterior 3 registers (like RPN (I imagine...) would do for any function of 3 parameters), that gets the width, the perfil and the ring diametter of a tire and presents the total diameter, in centimeters, of the tire.
(In the form of <Parameter 1>/<Parameter 2> R<Parameter 3>
The program gets,
  • The width in centimeters, in <Parameter 1>
  • The perfil of the tire, in percentage (%) <Parameter 2>
  • The diameter of the ring, in inches <Parameter 3>
And then, I want to run the calculation: <Parameter 1>*<Parameter 2>% * 2 + <Parameter 3>*2.54 (an inch equals 2.54cm more or less...).
Well, this in RPN calculates like <Parameter 1>[ENTER]<Parameter 2>[%]2[*]<Parameter 3>[ENTER]2.54[*][+]

I prepare the calculator for programming (for example, I will need to clear the program memory by [f][PRGM]...), and pressing [f][P/R] for setting the "PRGM" mode.
Then...
  • Get the <Parameter 3> in R2: [STO]2 ("001, 44 2")
  • Move to the anterior stack RPN register, using [R↓] ("002, 33"
  • Get the <Parameter 2> in the register R1: [STO]1 ("003, 44 1")
  • Move to the anterior stack RPN register: with [R↓] ("004, 33")
  • Get the <Parameter 1> on register R0; [STO]0, ("005, 44 0") - (Due to the nature of this particular calculation, this line may be omitted...)
  • Making the calculation: Get the value in R0, [RCL]0, ("006, 45 0") - (Due to the nature of this in particular, this line may be omitted...)
  • Press [ENTER] ("007, 36")
  • Retrieve the value in R1; [RCL]1, ("008, 45 1")
  • Press [%] ("009, 25")
  • Press [2], ("010, 2")
  • Press [X], ("011, 20")
  • Retrieve the value in R2; [RCL]2, ("012, 45 2")
  • Press[ENTER], ("013, 36")
  • Press [2], ("014, 2")
  • Press [.], ("015, 48")
  • Press [5], ("016, 5")
  • Press [4], ("017, 4")
  • Press [X], ("018, 20")
  • Press [+], ("019, 40")

Well.... Once I prepared the calculator for "RUN" operating, if I want to calculate the diameter of a 185/60 R15 tire, only I have to do,
18.5[ENTER]60[ENTER]15[R/S],
The result, 60.3cm
Find all posts by this user
Quote this message in a reply
Post Reply 




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