Post Reply 
SCUBA - Nitrox and Trimix for HP-41
09-14-2016, 04:25 PM (This post was last modified: 09-16-2016 02:15 AM by 4ster.)
Post: #1
SCUBA - Nitrox and Trimix for HP-41
My second hobby lately has been rediscovering my HP-41. I wrote this to support my first hobby.

Many SCUBA divers take a NITROX course to enable them to use a higher percentage of oxygen in their breathing gas to extend their time underwater. If you are a real diving junkie you learn how to use TRIMIX which is a mixture of Oxygen, Helium and Nitrogen to extend the depth limits of NITROX or AIR. The math for this is dead simple and can be done with paper and pencil, but it is tedious to remember which term goes where. If you are a NITROX diver this program solves the "Dalton's Diamond" problems in the coursework.

The following program works out the best mix for a given target depth. Alternatively, it allows a diver to determine the working limits of an existing mix in a scuba cylinder.

The program uses local labels in the top row of keys and a key nemonic on the display to help with visualizing key assignments. SIZE=5, Total Registers=31. For divers outside the US and Canada who think of depth in meters instead of feet, change lines 36 and 105 from 33 to 10. You will also want to change line 110 to label the depth answers as meters and edit line 09 and 10 to FIX 1 SF 29. Edit: ignore the following: (Because the program uses the CLRGX function an extended function module is required.) As Dieter points out in his post below CLRGX is only available on a 41CX, and it has been eliminated from the program listing per Dieter's suggestion.

To use, enter two or three knowns using the keys A though E. Find the unknowns using shifted keys a though e. Work the keys from the outside in for the unknowns, as keys b, c and d require that O2 (key A or a) and maximum depth (key E or e) are entered or solved for first. The program does not solve for partial pressure of O2, the diver must enter the target number using key C (for nitrox diving the generally accepted number is 1.4). Key c solves for Minimum Operating Depth and is used when diving hypoxic trimix. For divers using nitrox, just ignore the keys B and b which deal with helium, the helium value is set to zero when the program initializes. Any nitrox mix is breathable all the way to the surface so key c will always return a minimum depth of 0 using nitrox.

Definition of terms:
O2= % oxygen
He= % helium
PP= Partial Pressure of oxygen
ND= END or Equivalent Narcotic Depth (in feet)
D= MOD or Maximum Operating Depth (in feet)
Min. OD= Minimum Operating Depth (for Hypoxic Mixes). To be conservative the program considers hypoxic to be below 17% O2.

Disclaimer: Do not rely on this program to do any real dive planning. Never exceed your training and check results against the methods you were taught to dive safely.

EXAMPLE 1:
Of course, USER mode is set to ON for a program that uses single letter local labels.

A nitrox diver analyzes her cylinder and finds it contains 32.4% nitrox (32.4% oxygen and 67.6% nitrogen and trace gasses, Air is 20.9%/79.1%). What is her maximum depth if she does not want to exceed an O2 partial pressure of 1.4? What is the Equivalent Narcotic Depth at the maximum depth?

XEQ: TRIMIX (The display will read "O2/HePP ND D", which correspond to the top row keys below the display.)
Enter Oxygen: 32.4, press "A" (key below "O2" in display), Display: "O2/HePP ND D"
Enter Partial Pressure: 1.4, press "C" (key below "PP" in display), Display: "O2/HePP ND D"
Press "e" (shifted key below "D" in display), Display: "MOD=110 FT" So the diver will not go below 110 ft.
Press "d" (shifted key below "ND" if it was in the display), Display: "END=63 FT" So even though she may dive to 110 ft, she will feel as alert as she would be at 63 feet on air.

Example 2:

A Trimix diver wants to plan a dive to 300 feet. Air is deadly at that depth: The oxygen partial pressure exceeds safe standards and the nitrogen in air is so narcotic at that depth the diver would be incapable of rational thought. The diver wants the partial pressure of oxygen to be no more than 1.3 at 300 feet and he wants the narcotic effect of nitrogen to be no more than if he were diving to 66 feet. The remainder of the gas will be helium, what is the required mix? What is the shallowest depth that the mixture can be breathed?

XEQ: TRIMIX, Display: "O2/HePP ND D"
Enter maximum depth: 300, key "E", Display: "O2/HePP ND D"
Enter the Equivalent Narcotic Depth: 66, key "D", Display: "O2/HePP ND D"
Enter the Partial Pressure of O2: 1.3, key "C", Display: "O2/HePP ND D"
Press key "a", Display: "13% O2"
Press key "b", Display: "57% He"
Press key "c", Display: "MIN. OD=11 FT" The shallowest depth the diver can be to safely breathe this mixture.

Note: A standard convention in trimix diving is to label the cylinder with the gas contents as "O2%/He%", in this case "13/57". The nitrogen portion of the mix is left off of the label. That is why the first two key labels in the nemonic on the display are "O2/He" and why there is no solution for nitrogen % in the program.



01 LBL "TRIMIX"
02 CLX 'Clears registers 00 thru 04
03 STO 00
04 STO 01
05 STO 02
06 STO 03
07 STO 04
08 SF 21
09 FIX 0
10 CF 29
11 LBL 00
12 "O2/HePP ND D" 'Key nemonic
13 PROMPT
14 LBL A 'Oxygen %
15 100
16 /
17 STO 00
18 GTO 00
19 LBL B 'Helium %
20 100
21 /
22 STO 01
23 GTO 00
24 LBL C 'PPO2
25 STO 02
26 GTO 00
27 LBL D 'END
28 XEQ 05
29 STO 03
30 GTO 00
31 LBL E 'MOD
32 XEQ 05
33 STO 04
34 GTO 00
35 LBL 05 'Converts feet to ata pressure
36 33
37 /
38 1
39 +
40 RTN
41 LBL a 'Calc O2%
42 RCL 02
43 RCL 04
44 /
45 STO 00
46 100
47 *
48 CLA
49 ARCL X
50 ">% O2"
51 AVIEW
52 GTO 00
53 LBL b 'Calc He%
54 RCL 03
55 RCL 04
56 /
57 RCL 00
58 +
59 1
60 X<>Y
61 -
62 STO 01
63 100
64 *
65 CLA
66 ARCL X
67 ">% He"
68 AVIEW
69 GTO 00
70 LBL c 'Calc Min. OD
71 0.17
72 RCL 00
73 /
74 XEQ 06
75 X<0? 'To keep O2 mixtures > .17 from returning negative values
76 0
77 "MIN. OD="
78 GTO 10
79 LBL d 'Calc END
80 1
81 RCL 00
82 RCL 01
83 +
84 -
85 RCL 04
86 *
87 STO 03
88 XEQ 06
89 "END="
90 GTO 10
91 LBL e 'Calc MOD
92 RCL 02
93 RCL 00
94 /
95 STO 04
96 XEQ 06
97 "MOD="
98 GTO 10
99 LBL 06 'Converts ata to feet
100 1
101 -
102 33
103 *
104 RTN
105 LBL 10 'Output routine for feet
106 ARCL X
107 "> FT"
108 AVIEW
109 GTO 00
110 END

Steve
In order of appearance: HP 41CV, CMT-MCGPS, HP 41CX, DM 41, DM 42
Find all posts by this user
Quote this message in a reply
09-14-2016, 09:20 PM
Post: #2
RE: SCUBA - Nitrox and Trimix for HP-41
(09-14-2016 04:25 PM)4ster Wrote:  My second hobby lately has been rediscovering my HP-41. I wrote this to support my first hobby.

A few remarks:

1. CLRGX is a CX function and not available on other '41 calculators. Instead of 0,004 CLRGX you should simply use CLX STO 01 STO 02 STO 03 STO 04. That's just five bytes and thus even requires less memory than the CLRGX version. And, more important, it runs on any 41.

2. There are several XEQ 13 calls that obviously are used to display output. But there never is a return from this subroutine as it ends with a jump to LBL 00 (prompt for next input). I looks like you meant GTO 13 in every case that now reads XEQ 13. Or, to be honest, simply replace the two occurences of "XEQ 13" by a simple AVIEW GTO 00. This does the same and it's shorter and faster. After this LBL 13 can be removed completely.

The same is true for the XEQ 12s. In both cases this should be GTO 12.

3. The CLA in line 08 is not required. And why do you set flag 29 in line 7 and clear it directly afterwards (without any operation where flag 29 makes a difference)?

4. I don't know anything about diving, but this sounds like a useful program. So why don't you post it to the HP41 Software Library? After some minor changes... ;-)

Dieter
Find all posts by this user
Quote this message in a reply
09-15-2016, 12:53 AM (This post was last modified: 09-15-2016 03:41 PM by 4ster.)
Post: #3
RE: SCUBA - Nitrox and Trimix for HP-41
(09-14-2016 09:20 PM)Dieter Wrote:  
(09-14-2016 04:25 PM)4ster Wrote:  My second hobby lately has been rediscovering my HP-41. I wrote this to support my first hobby.

A few remarks:

1. CLRGX is a CX function and not available on other '41 calculators. Instead of 0,004 CLRGX you should simply use CLX STO 01 STO 02 STO 03 STO 04. That's just five bytes and thus even requires less memory than the CLRGX version. And, more important, it runs on any 41.

2. There are several XEQ 13 calls that obviously are used to display output. But there never is a return from this subroutine as it ends with a jump to LBL 00 (prompt for next input). I looks like you meant GTO 13 in every case that now reads XEQ 13. Or, to be honest, simply replace the two occurences of "XEQ 13" by a simple AVIEW GTO 00. This does the same and it's shorter and faster. After this LBL 13 can be removed completely.

The same is true for the XEQ 12s. In both cases this should be GTO 12.

3. The CLA in line 08 is not required. And why do you set flag 29 in line 7 and clear it directly afterwards (without any operation where flag 29 makes a difference)?

4. I don't know anything about diving, but this sounds like a useful program. So why don't you post it to the HP41 Software Library? After some minor changes... ;-)

Dieter

Dieter,

Thanks for the input.

CLRGX - You are correct. I had an issue running the program on the iphone 41C app that halted the program at the CLRGX instruction with a NONEXISTENT and assumed that it was because CLRGX was an extended memory function. I looked it up after I wrote the post and was hoping to edit the original post before anyone noticed. :-)

I'll edit the CLRGX and XEQs and replace them with GTOs in the original post.

After all these years I am still confused when CLA is needed and when its not. So I tend to put too many in. Flag 29: Since normal flow in the program is to halt at the PROMPT, it is likely that it leaves flag 29 set, instead of having to reset it outside the TRIMIX program. Your right, it's fluff and SF 29 is no longer in the listing.

I wasn't sure what the policy is on adding programs to the libraries. There are some really good programs in there and I didn't want to litter the space. After a few days residing here for more improvements, I'll copy the program over to the HP-41 library if there are no objections.

Steve
In order of appearance: HP 41CV, CMT-MCGPS, HP 41CX, DM 41, DM 42
Find all posts by this user
Quote this message in a reply
09-15-2016, 03:19 AM
Post: #4
RE: SCUBA - Nitrox and Trimix for HP-41
(09-15-2016 12:53 AM)4ster Wrote:  I wasn't sure what the policy is on adding programs to the libraries. There are some really good programs in there and I didn't want to litter the space. After a few days residing here for more improvements, I'll copy the program over to the HP-41 library if there are no objections.

For any non-trivial program, I think it's best to include a sample problem with a walk-through of the steps one follows to solve the problem using the program. I know I always appreciate going through an example that reinforces the UI, clarifies the intended sequence, and sometimes even helps educate the user about the problem he/she is using the program to solve. Just a suggestion if you're going to add it to the Library, which I agree is a good idea.

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
09-15-2016, 06:34 AM
Post: #5
RE: SCUBA - Nitrox and Trimix for HP-41
I added a couple of examples. Are they clear as mud?

Steve
In order of appearance: HP 41CV, CMT-MCGPS, HP 41CX, DM 41, DM 42
Find all posts by this user
Quote this message in a reply
09-15-2016, 02:36 PM
Post: #6
RE: SCUBA - Nitrox and Trimix for HP-41
(09-15-2016 06:34 AM)4ster Wrote:  I added a couple of examples. Are they clear as mud?

Excellent!!

Better than most examples IMHO. These not only clarify how to use the program, but also make it seem more interesting and invites folks to try it out.

Thanks for taking the time to add these, I think they will bring many more users to evaluate (and use) your program. Also, extra credit for not stereotyping by including a woman as your example diver.

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
09-15-2016, 10:12 PM (This post was last modified: 09-15-2016 10:15 PM by Dieter.)
Post: #7
RE: SCUBA - Nitrox and Trimix for HP-41
(09-15-2016 12:53 AM)4ster Wrote:  CLRGX - You are correct. I had an issue running the program on the iphone 41C app that halted the program at the CLRGX instruction with a NONEXISTENT and assumed that it was because CLRGX was an extended memory function.

CLRGX is a function that is only available on the CX (like some others). It is not a part of the Standard Extended Functions as they are available in the X-Functions module. So for CLRGX you must have an CX. At least if Ángel did not make some kind of ROM that includes it. ;-)

(09-15-2016 12:53 AM)4ster Wrote:  After all these years I am still confused when CLA is needed and when its not.

Simple. CLA clears the alpha register. This is not required if you enter a new Alpha text because this text overwrites any previous Alpha content that may exist. For instance, the CLA in the current line 77, 90 and 99 is not required, because the "MOD=" etc. text that follows overwrites any other previous Alpha content.

CLA is required if you want to start with an empty Alpha register and the next Alpha function *appends* text. This e.g. is the case with ARCL. It *appends* the content of the specified data register to the current Alpha string. For instance "VALUE=" ARCL X produces "VALUE=3.14" if X is Pi. If you want a message that *starts* with the x-value you'd have to clear Alpha first. Otherwise ARCL X would append X to whatever happens to be in Alpha at that point. That's why the CLA in line 48 and 65 is required.

Dieter
Find all posts by this user
Quote this message in a reply
09-16-2016, 02:46 AM (This post was last modified: 09-16-2016 01:16 PM by 4ster.)
Post: #8
RE: SCUBA - Nitrox and Trimix for HP-41
(09-15-2016 10:12 PM)Dieter Wrote:  
(09-15-2016 12:53 AM)4ster Wrote:  CLRGX - You are correct. I had an issue running the program on the iphone 41C app that halted the program at the CLRGX instruction with a NONEXISTENT and assumed that it was because CLRGX was an extended memory function.

CLRGX is a function that is only available on the CX (like some others). It is not a part of the Standard Extended Functions as they are available in the X-Functions module. So for CLRGX you must have an CX. At least if Ángel did not make some kind of ROM that includes it. ;-)

(09-15-2016 12:53 AM)4ster Wrote:  After all these years I am still confused when CLA is needed and when its not.

Simple. CLA clears the alpha register. This is not required if you enter a new Alpha text because this text overwrites any previous Alpha content that may exist. For instance, the CLA in the current line 77, 90 and 99 is not required, because the "MOD=" etc. text that follows overwrites any other previous Alpha content.

CLA is required if you want to start with an empty Alpha register and the next Alpha function *appends* text. This e.g. is the case with ARCL. It *appends* the content of the specified data register to the current Alpha string. For instance "VALUE=" ARCL X produces "VALUE=3.14" if X is Pi. If you want a message that *starts* with the x-value you'd have to clear Alpha first. Otherwise ARCL X would append X to whatever happens to be in Alpha at that point. That's why the CLA in line 48 and 65 is required.

Dieter

I write programs like I work on cars... They seem to run better when I have parts left over after putting them back together. ;-)

Steve
In order of appearance: HP 41CV, CMT-MCGPS, HP 41CX, DM 41, DM 42
Find all posts by this user
Quote this message in a reply
Post Reply 




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