Jump to content

For HP RPN calculator fans


Thanny

Recommended Posts

As many are no doubt frequently aware, the game won't show an estimated burn time unless the engines have been fired in that particular session (i.e. you haven't switched ships or just loaded a game). Probably fewer are aware that the estimate shown is wrong - it's showing a simple F = ma calculation, which doesn't account for fuel burn at all. This doesn't matter much for short burns (say anything under a minute), but it adds up for long burns.

While there's probably a mod or two that does this, I decided instead to do a bit of research, and I found the Tsiolkovsky rocket equation. I then created a simple program on my HP 50g to use it for calculating actual burn time. I also wrote a REXX program on my PC that both repeated the calculation and ran a simulation to check its sanity (i.e. do 1000 burns per second using F = ma, deducting fuel at each step).

I then thought about it a bit, and wondered whether the burn should be split around the maneuver node by time or by delta V. After a few responses to my question on that topic agreed with my intuition, I had a minor geek out and fancified the burn time calculator for my HP calculator. I also wrote a couple companion programs, one that calculates the combined Isp of a set of engines, and one that calculates the fuel burn rate of a set of engines.

If you have no idea what a HP RPN calculator is, you probably couldn't care less at this point (if you've even read this far). I'll simply say to those people that you don't actually need such a calculator to use these programs. You can simulate several such calculators on your PC with a program called Emu48, and at least one of them is available on (probably) any Android device with the Droid48 app. I've tested the programs on emulated 48GX and 50g calculators as well as a real 50g calculator (my two real 48GX calculators are broken, unfortunately).

Here's an archive that has all the relevant files. That includes *.rpl source files suitable for use in HPUserEdit, binary program files suitable for import directly on calculators (real or emulated - *.48.hp for HP48 calculators, *.49.hp for HP49/50 calculators), and pure ASCII text files. The latter I'll post here:

\<<

"KSP Burn Time"

{

{"Mass:" "Mass of the ship (tonnes)" 0}

{"Delta V:" "Required velocity change (m/s)" 0}

{"Thrust:" "Total thrust (kN)" 0}

{"Isp:" "Combined specific impulse (s)" 0}

{"Type:" "Type (1=LF+0, 2=Mono, 3=Xenon)" 0}

}

{2}

{NOVAL NOVAL NOVAL NOVAL 1}

{NOVAL NOVAL NOVAL NOVAL 1}

IF INFORM THEN

OBJ\->

DROP

200 250 10000

9 20 /

11 20 /

0 0 0 0 0 0 0 0 0 0 0 0 0 0

\-> INITMASS DELTAV THRUST ISP ETYPE FUELDENS MONODENS XENONDENS

LFRATIO OXRATIO HALFDV HALFMASS FINALMASS BURNRATE

HFUELMASS FUELMASS TOTALBURN FIRSTBURN SECONDBURN

FUELTOTAL LFTOTAL OXYTOTAL MONOTOTAL XENONTOTAL

\<<

THRUST ISP 9.82 * /

'BURNRATE' STO

DELTAV 2 /

'HALFDV' STO

ISP 9.82 * INV HALFDV NEG * EXP INITMASS *

'HALFMASS' STO

HALFMASS NEG INITMASS +

'HFUELMASS' STO

HFUELMASS BURNRATE /

'FIRSTBURN' STO

ISP 9.82 * INV HALFDV NEG * EXP HALFMASS *

'FINALMASS' STO

FINALMASS NEG HALFMASS +

'FUELMASS' STO

FUELMASS BURNRATE /

'SECONDBURN' STO

FUELMASS HFUELMASS +

'FUELMASS' STO

CASE

'ETYPE==1' THEN

FUELMASS FUELDENS *

'FUELTOTAL' STO

FUELTOTAL LFRATIO *

'LFTOTAL' STO

FUELTOTAL OXRATIO *

'OXYTOTAL' STO

END

'ETYPE==2' THEN

FUELMASS MONODENS *

'MONOTOTAL' STO

END

'ETYPE==3' THEN

FUELMASS XENONDENS *

'XENONTOTAL' STO

END

END

FIRSTBURN SECONDBURN +

'TOTALBURN' STO

FIRSTBURN 2 RND "DV/2 (s)" \->TAG

TOTALBURN 2 RND "Time (s)" \->TAG

CASE

'ETYPE==1' THEN

LFTOTAL 2 RND "Fuel (u)" \->TAG

OXYTOTAL 2 RND "Oxy (u)" \->TAG

END

'ETYPE==2' THEN

MONOTOTAL 2 RND "Mono (u)" \->TAG

END

'ETYPE==3' THEN

XENONTOTAL 2 RND "Xenon (u)" \->TAG

END

END

\>>

END

\>>

\<<

1 0 0 0 0 0 0 \-> ENUM ECOUNT CTHRUST CISP

TTHRUST TRATIO LOOPDONE

\<<

DO

"KSP Total Isp - Engine " ENUM \->STR +

{

{"Thrust:" "Engine thrust (kN)" 0}

{"Isp:" "Engine specific impulse (s)" 0}

{"Count:" "How many of these engines?" 0}

}

{}

{NOVAL NOVAL 1}

{NOVAL NOVAL 1}

IF INFORM THEN

OBJ\->

DROP

'ECOUNT' STO

'CISP' STO

'CTHRUST' STO

TTHRUST CTHRUST ECOUNT * +

'TTHRUST' STO

CTHRUST CISP /

ECOUNT * TRATIO +

'TRATIO' STO

ENUM 1 +

'ENUM' STO

ELSE

1 'LOOPDONE' STO

END

UNTIL LOOPDONE END

IF 'TTHRUST>0' 'TRATIO>0' AND THEN

TTHRUST 2 RND "Thrust (kN)" \->TAG

TTHRUST TRATIO / 2 RND "Isp (s)" \->TAG

END

\>>

\>>

\<<

1 1 0 0 0 0 0 0 0 200 250 10000 9 20 / 11 20 / 0 \->

ENUM ETYPE ECOUNT LOOPDONE

CISP CTHRUST LFOBURN MONOBURN XENONBURN

FUELDENS MONODENS XENONDENS

LFRATIO OXRATIO LFOTOTAL

\<<

DO

"KSP Fuel Burn - Engine " ENUM \->STR +

{

{"Thrust:" "Engine thrust (kN)" 0}

{"Isp:" "Engine specific impulse (s)" 0}

{"Count:" "How many of these engines?" 0}

{"Type:" "Type (1=LF+0, 2=Mono, 3=Xenon)" 0}

}

{}

{NOVAL NOVAL 1 1}

{NOVAL NOVAL 1 1}

IF INFORM THEN

OBJ\->

DROP

'ETYPE' STO

'ECOUNT' STO

'CISP' STO

'CTHRUST' STO

CTHRUST CISP 9.82 * / ECOUNT *

CASE

'ETYPE==1' THEN

LFOBURN +

'LFOBURN' STO

END

'ETYPE==2' THEN

MONOBURN +

'MONOBURN' STO

END

'ETYPE==3' THEN

XENONBURN +

'XENONBURN' STO

END

END

ENUM 1 + 'ENUM' STO

ELSE

1 'LOOPDONE' STO

END

UNTIL LOOPDONE END

IF 'LFOBURN>0' THEN

LFOBURN FUELDENS *

'LFOTOTAL' STO

LFOTOTAL LFRATIO * 2 RND "Fuel (u)" \->TAG

LFOTOTAL OXRATIO * 2 RND "Oxy (u)" \->TAG

END

IF 'MONOBURN>0' THEN

MONOBURN MONODENS *

2 RND "Mono (u)" \->TAG

END

IF 'XENONBURN>0' THEN

XENONBURN XENONDENS *

2 RND "Xenon (u)" \->TAG

END

\>>

\>>

All use the INFORM command to collect input.

Burn time asks for ship mass in tonnes, required delta V in m/s, total thrust in kN, combined Isp in seconds, and fuel type (1 = liquid fuel + oxidizer, 2 = monopropellant, 3 = xenon). The mass is available on the map screen with the info button, when the ship is focused. A mod like Kerbal Engineer will also show the mass (more accurately, too), as well as current thrust and Isp. The latter two can be calculated with the Isp program provided here (detail further on). Choosing the fuel type simply lets the program show you how much fuel is required for the burn.

The output:

  • DV/2 - time at which half the delta V has been reached, which is how long before the maneuver node you should start the burn.
  • Time - total time of the burn - note that time/2 is less than DV/2
  • Fuel/Oxy or Mono or Xenon - units of given fuel type required for the burn

The time values will be accurate regardless of the engine mix, provided the correct combined Isp is provided. The fuel quantities will only be accurate when all engines use the same fuel type. I decided it would be too tedious to collect engine information for each burn calculation, which is what would be required to show different fuel types.

The Isp program asks for one or more engine stats. Press OK after each active engine has been described (thrust, Isp, count, and fuel type), then press Cancel to stop entering engines and do the calculation. The ouput:

  • Thrust - total thrust of all entered engines
  • Isp - combined Isp of all entered engines

The fuel program shows consumption for one or more engines. Input is similar to Isp - press OK after each engine, then Cancel to do the calculation. The output:

  • Fuel - units/sec of liquid fuel
  • Oxy - units/sec of oxidizer
  • Mono - units/sec of monopropellant
  • Xenon - units/sec of xenon

If you have mixed engines, you can multiply the return values here by the total burn time to figure out how much fuel of each type is required for the burn.

Hopefully someone besides me will get some use out of these programs.

Link to comment
Share on other sites

You lost me at HP50g ... in my days as an aerospace engineering undergrad we iterated this stuff in BASIC or some other language on personal computers using the Runge-Kutte method. The first HP48 models didn't arrive in our college bookstore until the fall of 1989 (before they hit widespread retail channels, interestingly). I still have one today. :)

(Seriously, good work posting this stuff. I'm betting not many folks on these forums will have an HP though, sad to say).

Link to comment
Share on other sites

Oh, so you're writing programs for calculators just like me! Looks like you've made solid work in those programs, even though I don't read whatever language that program is written in, only TI-BASIC. This is good work, even though not many have an HP unlike LameLefty up there. Only calculator that people think of when they hear graphing calculator is the TI-84. I could draw some inspiration from these programs though and write my own programs based upon them.

...in my days as an aerospace engineering undergrad we iterated this stuff in BASIC or some other language on personal computers using the Runge-Kutte method.

I actually am writing programs like these in TI-BASIC, or at least a dialect of BASIC, for my project.

Link to comment
Share on other sites

The language is called UserRPL. It's basically typical programming language structure combined with Reverse Polish Notation (e.g. instead of doing "2 + 2 =", you do "2 2 +"). I personally can't stand to use non-RPN calculators anymore, ever since I got my first 48GX in 1993. Once you get used to stack-based RPN, everything else becomes inefficient and counter-intuitive.

Link to comment
Share on other sites

  • 6 months later...
This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...