LM317 Calculator

The LM317 is a simple to use 3-pin adjustable voltage regulator. Basically its output voltage is equal to the voltage at the ADJ pin plus 1.25V. A voltage divider is all that is needed to set the output voltage anywhere between 1.25V and 35V.
This program allows you to calculate the output Voltage, when both R1 and R2 are given. Or it can calculate R1 or R2 when the required output voltage is given and the other resistor is known.
Don't make R1 too high, for that will introduce an error due to the current through the ADJ pin. A typical value for R1 is between 200Ω and 300Ω.

LM317 schematic

Formulas

U = 1.25 x (1 + R2 / R1)

R1 = (R2 x 1.25) / (U - 1.25)

R2 = (U - 1.25) x R1 / 1.25

The Program

000–
h LBL A001–25 13 11
g X=0002–15 71Is R2 unknown?
GTO 2003–22 2Yep, let's calculate R2
X⇋Y004–21
g X=0005–15 71Is R1 unknown?
GTO 1006–22 1Yep, let's calculate R1
÷007–71R1 and R2 are given, lets calculate
1008–1the output Voltage
+009–51
1010–1
011–73
2012–2
5013–5
×014–61
h RTN015–25 12
 
h LBL 1016–25 13 1Calculate R1
g R↓017–15 22X=R2, Y=U
1018–1
019–73
2020–2
5021–5
×022–61R2 x 1.25
X⇋Y023–21
h LST X024–25 0Get 1.25 back
025–41U - 1.25
÷026–71
h RTN027–25 12
 
h LBL 2028–25 13 2Calculate R2
g R↓029–15 22
X⇋Y030–21X=U, Y=R1
1031–1
032–73
2033–2
5034–5
035–41U - 1.25
h LST X036–25 0Let's store 1.25 in T
g R↓037–15 22
X⇋Y038–21
×039–61(U - 1.25) x R1
f R↑040–14 22
÷041–71
h RTN042–25 12

Examples

The idea behind this program is that it will figure out by itself which one of the 3 properties it needs to calculate. You enter the Voltage, the value for R1 and the value of R2, and then press the A key to start the calculation. The unknown property has to be entered with a value of 0.
You do not have to enter 0 for the voltage by the way, the program will calculate the output voltage when both R1 and R2 are given.
The program does not check the range of any of the values. Rubbish in will result in rubbish out.

Calculate the output voltage when R1 = 220Ω and R2 = 680Ω.
220 ENTER🠕 680 A
The answer will be 5.11V.

Calculate R2 if the required output voltage is 12V and R1 is 240Ω.
12 ENTER🠕 240 ENTER🠕 0 A
And the answer will be 2k06.

Calculate R1 if the required output voltage is 9V and R2 is 1kΩ.
9 ENTER🠕 0 ENTER🠕 1500 A
And the answer will be 242Ω.