Notifications

Example: Programming a parallel resistance solver in User RPL for the HP 50g

Program: PRESQ

This program will:

  1. Take a list of resistance values from the stack.
  2. Clear any existing values in a variable named L1 (optional, but good practice).
  3. Calculate the product of the resistance values.
  4. Divide that product by the sum of the products of all possible combinations of resistance values excluding one in each product.
  5. Display the total parallel resistance.



rpl

<<

"Enter the list of resistances: " MSGBOX @ Prompt the user to enter a list of resistances

{} L1 STO @ Clear and initialize L1 as an empty list

EDITLIST L1 @ Allow the user to input the list of resistances into L1

L1 →NUM @ Convert the list L1 to a numeric list (if not already)

DUP @ Duplicate the list (one for product, one for sum of products)

PROD @ Calculate the product of all elements in the list

SWAP @ Swap the product and the original list on the stack

L1 INV @ Calculate the reciprocals of the list elements

ΣLIST @ Sum the reciprocals

INV @ Take the reciprocal of the sum

"Total Parallel Resistance: " SWAP + DISP @ Display the result with a message

>>


How to enter and use the program


1. Entering the program

  • Turn on your HP 50g calculator.
  • Press ALPHA (yellow key) twice to engage alpha-lock, then type PRESQ (for parallel resistance solver).
  • Press the key (the one with MTRW EQW above it).
  • Type in the program code exactly as shown above, including the << and >> delimiters.
  • Press ENTER.
  • Press STO to store the program, which will be accessible from the custom menu (soft key) later. 

2. Using the program

  1. Press the soft key associated with the PRESQ program (it should appear on the bottom row of your screen).
  2. The program will display a message box prompting you to enter the list of resistances.
  3. The EDITLIST command will open a list editor.
  4. Enter your resistor values, separated by spaces, within the list brackets {}. For example, to calculate the total resistance of a 10 ohm and a 15 ohm resistor in parallel, you would enter {10 15}.
  5. Press ENTER when you're done entering the list.
  6. The program will calculate and display the total parallel resistance with a message. 

Understanding the program

  • << ... >>: These delimiters define a program in User RPL.
  • "Enter the list of resistances: " MSGBOX: This line displays a message box to the user.
  • {} L1 STO: This initializes a local variable L1 as an empty list.
  • EDITLIST L1: This command opens the list editor and prompts the user to input values into L1.
  • L1 →NUM: Ensures the list is treated as numbers for calculation.
  • DUP: Duplicates the list on the stack. One copy is for the PROD calculation, and the other is for the INV and ΣLIST calculations.
  • PROD: Calculates the product of all elements in the list.
  • SWAP: Exchanges the top two elements on the stack (the product and the original list).
  • L1 INV: Calculates the reciprocal of each element in the list.
  • ΣLIST: Sums the elements of the list (the reciprocals in this case).
  • INV: Takes the reciprocal of the sum of reciprocals, which represents the total parallel resistance.
  • "Total Parallel Resistance: " SWAP + DISP: Constructs the final message string and displays it on the screen. 


Example:


To calculate the equivalent resistance of a 10 ohm and 15 ohm resistor in parallel: 

  1. Run the PRESQ program.
  2. Enter { 10 15 } in the list editor.
  3. Press ENTER.
  4. The calculator will display "Total Parallel Resistance: 6". 

This program uses the more accurate method of calculating parallel resistance (product of resistances divided by the sum of products of resistances, excluding one in each product) to minimize the impact of roundoff errors, according to an HP Forum discussion