**DISCLAIMER :**

ZH16B is a DM42 deco program that is given for educational

purpose only (RPN deco calculations)

IT SHOULD NOT BE USED TO PLAN YOUR DIVES...

... although it gives same results (around 99%) as

MULTIDECO ANDROID commercial planner!

===================================================

**Version changes :**

- 13/08/2021 : added ppO2 calculation and prompt in register T, there is also a check with 1.4bar ppO2 limit at depth and 1.6bar ppO2 limit at stop and a BEEP alarm sounds if ppO2 is over the limit values (risk of hyperoxia), and a check with BEEP alarm if ppO2 gets below 0.16bar (risk of hypoxia), corrected a bug (could "call a dive" when at surface)

- 11/08/2021 : corrected/augmented documentation, delivered DM41X version (viewtopic.php?f=30&t=3070), improved/simplified code

- 10/08/2021 : corrected/augmented documentation, delivered DM15L_M1B version (viewtopic.php?f=23&t=3068)

- 02/08/2021 : corrected some bugs and documented code

- 26/07/2021 : added surface interval and second dive computing

- 25/07/2021 : Corrected some bugs and documentation errors, split original program in 3 parts, documented code, added mix change during deco stops, added Trimix mixes using Erik Baker's gradient factors

- 21/07/2021 : First release with only Nitrox mixes, no deco mixe changes

**Introduction :**

This is the first version of a RPN deco planner using the Buhlmann algorithm, the ZH16B algorithm to be precise.

(https://en.m.wikipedia.org/wiki/B%C3%BC ... _algorithm)

The Buhlmann ZH16B algorithm uses a base of 16 M-Values (A and B) for Nitrogen and Helium decompression TABLES.

The program also uses Erik Baker's gradient factors when computing ceiling using Trimix (https://wrobell.dcmod.org/decotengu/model.html)

**KNOWN LIMITATIONS :**(beware that some are voluntary limitations)

- this version is using Air/Nitrox mixes only (Helium mixes not included but on it's way in some next releases)

(not true anymore in last release)

- this version of the program is limited to only one off-gasing mix (deco mix) (not true anymore in last release)

- the program is METRIC only (but is it really a limitation )

- the program is limited to 99 meters and 999 minutes

- deco is calculated at sea level in fresh water (but internal data can be changed to accommodate altitude diving in fresh water)

- descent speed is 20m/min, ascent speed is 10m/min, between stops speed is 10m/min (but internals can be changed to accommodate any speed)

- gradient factor is between 0,3 and 0,85 (but internals can be changed to accommodate other values)

- there is NO CHECK on valid/invalid gaz usage in this version. Narcosis and High/Low Oxygen levels are still managed by the computer available between your ears! (not true anymore in the last version, ppO2 is checked against high and low values)

- Narcosis is still managed by the computer available between your ears!

**DIVE MODEL :**

A dive is modeled by a succession of flat segments (legs?), an ascent to the first deco stop, and deco stops until surface is reached.

You can add as many flat segments (legs?) as you need to model your dive, each segment with it's own diving mix.

Once you decide to "call the dive", the program calculates the ascent to the first deco stop, first deco stop and each successive stops until surface is reached.

Deco can also be done with different deco mixes, you can change deco mix at the end of any stop.

When at surface, you can add a surface interval, then a second dive.

**WARNING :**

1) As usual during the dive (with travel/bottom mixes) :

- Descent time in INCLUDED in segment time and is retrieved form time spent at depth

- Ascent time is EXCLUDED in segment time and time spent at depth is unchanged

- you change mix once arrived at the flat portion of the segment

2) As usual during deco stops (with deco mixes) :

- Ascent time to the following stop is included in following deco stop time

- deco mix is changed at the bottom and ascent to first stop is done with deco mix

**HINTS :**

A) Bottom/Travel or Deco Mix change :

You can always force a mix change, at any point of the dive, inserting a "0 minute" segment during the dive when prompted with "(?)"

Example :

Y = oo.hh new mix (oo = 02% and hh = HE%)

X = dd.000 where dd is current depth with 0 minutes

Then hit R/S to compute the dive

B) Message prompt in ALHPA

When ALPHA prompt a message including a :

- "(?)" => then the program asks you for a new segment data or to "call the dive"

- "(R/S)" => then the program asks you to hit R/S to get more travel/deco info

C) Each segment is keyed in as this :

1) the mix used for the segment in register Y as oo.hh, oo being the O2 percentage in the mix, hh being the He percentage in the mix (21.00 for air, 32.00 for a 32% Nitrox, 50.00 for a 50% deco gas, 18.30 for a 18/30 Trimix for example)

2) the next diving segment in register X as dd.mmm , dd being the depth reached in meters and mmm being the duration in minutes of the dive segment (duration INCLUDING descent time and EXCLUDING ascent time)

3) then you hit "R/S" to add the segment to calculations

D) 2 results are show when adding a segment :

1) First result is ascent/descent management to targeted depth shown with a "DIVE (R/S)" or a "DIVE (R/S)" message in ALPHA

- ppO2 value (in bars) in register T, and a BEEP alarm sounds if not in LOW/HIGH range

- total diving time in register Z, often called RUN time (in minutes)

- current mix used by program in register Y (as oo.hh)

- dd.mmm in register X, depth as nn and mmm as real time spent in ascent/descent ONLY

Hit "R/S" to continue (as shown in ALHPA message)

2) Second result is time spent at depth shown with a "DIVE (?)" message in ALPHA

- ppO2 value in bars in register T, and a BEEP alarm sounds if not in LOW/HIGH range

- total diving time in register Z (in minutes)

- current mix used by program in register Y (as oo.hh)

- dd.mm in register X, depth as dd and real time spent at depth in mmm (time spent in ascent or descent from previous depth is removed from segment time)

**E) You can add as many segments as you need to simulate your dive.**

F) "calling the dive" or computing the deco stops

When you "call the dive", you have to key :

- the first mix used during deco in register Y as oo.he (see explanation up somewhere)

- 0 in register X because you are asking to reach the surface (0 meters)

then hit R/S to calculate first deco stop

1) You get first an ascent to the first deco stop, then as many information as there is stops in the deco (every 3 meters)

1.1) First the result is ascent to the first stop with a "ASCENT (R/S)" message in ALPHA

- ppO2 value in bars in register T, and a BEEP alarm sounds if not in LOW/HIGH range

- total dive time still in register Z (in minutes)

- Mix used during deco in register Y (as oo.hh)

- dd.mmm in register X, dd as depth of first deco stop and mmm as duration of the first stop INCLUDING ascent time from last segment

Hit R/S to continue and get all the deco stops informations

1.2) Following results are all the deco stops

- ppO2 value in bars in register T, and a BEEP alarm sounds if not in LOW/HIGH range

- total dive time still in register Z (in minutes)

- Mix used during deco in register Y (as oo.hh)

- dd.mmm in register X, dd as depth of deco stop and mmm as duration of the first stop INCLUDING ascent time from last stop

1.3) after each stop you have two choices

1.3.1) You either hit R/S to continue the deco with the same mix,

1.3.2) Or you enter a new deco mix

- the new mix used during deco in register Y as oo.he (see explanation up somewhere)

- 00.000 in register X because you are still asking to reach the surface

then hit R/S to calculate next deco stop with new deco mix

G) Reaching surface, surface interval and second dive

When you reach 0m you get a "SURFACE (?)" message in ALPHA and register X is showing 00.000 and register Y is showing 21.00 (we suppose you are breathing Air at surface)

You can add a surface segment with 00.mmm where 0 is for surface and mmm the surface interval, you get a "SURFACE (?)" asking either for another surface interval segment or a second dive

**EXAMPLE OF A DIVE :**

You want to plan the following dive :

- segment 1 : 30 minutes at 30m with air

- segment 2 : 30 minutes at 20m with 32% Nitrox

- Then you call the dive USING a 50% Nitrox mix for deco

- At 6m stop, you SWITCH to 100% Oxygen deco mix

Launch "zh16b" program

you get a "SURFACE (?)" message in ALHPA, then key

21.00 (air as travel/bottom mix)

ENTER

30.030 (30m, 30 minutes)

R/S

you get a "DIVE (R/S)" message in ALPHA with

T = 0.829 (ppO2 in bar)

Z = 1.5 min (RUN time)

Y = 21.00 (air used)

X = 30.002 (2 minutes descent time from surface to 30m)

HIT R/S

you get a ""DIVE (?)" message in ALPHA with

T = 0.829 (ppO2 in bar)

Z = 30 min (RUN time)

Y = 21.00 (air used)

X = 30.029 (29 minutes spent at 30m depth)

You key in

32.00 (new travel/bottom mix)

ENTER

20.030 (20m, 30 minutes)

R/S

You get a "DIVE (R/S)" message in ALPHA

T = 0.829 (ppO2 in bar)

Z = 31 min (RUN time)

Y = 21.00 (air used up to next flat segment)

X = 20.001 (1 minutes ascent time from 30m to 20m)

HIT R/S

you get a "DIVE (?)" message in ALPHA with

T = 0.943 (ppO2 in bar)

Z = 61 minute (RUN time)

Y = 32.00 (32% Nitrox used)

X = 20.030 (30 minutes spent at 20m)

You key in

50.00 (we switch to a 50% Nitrox mix for deco)

ENTER

0 (request deco stops computing)

R/S

you get a "ASCENT (R/S)" message in ALPHA with

T = 1.474 (ppO2 in bar) with an alarm BEEP

Z = 62.1 (RUN time)

Y = 50.00 (50% Nitrox used)

X = 9.001 (first stop is 9m and one minute ascent between 20m and 9m)

HIT R/S

you get a "STOP (R/S)" message in ALPHA with

T = 0.925 (ppO2 in bar)

Z = 63 (RUN time)

Y = 50.00 (50% Nitrox used)

X = 9.001 (first stop is 9m and one minute stop at 9m, including the ascent time)

You key in

100.00 (we switch to a 100% Oxygen mix for deco)

ENTER

0 (request following deco stops computing)

R/S

you get a "STOP (R/S)" message in ALPHA with

T = 1.550 (ppO2 in bar)

Z = 64 (RUN time)

Y = 100.00 (100% Oxygen used)

X = 6.001 (next stop is 6m and one minute stop at 6m, including the ascent time)

HIT R/S

you get a "STOP (R/S)" message in ALPHA with

T = 1.250 (ppO2 in bar)

Z = 69 (RUN time)

Y = 100.00 (100% Oxygen used)

X = 3.005 (next stop is 3m and 5 minutes stop at 3m, including the ascent time)

HIT R/S

you get a "SURFACE" message in ALPHA with

T = 0.951 (ppO2 in bar)

Z = 69 (RUN time)

Y = 100.00 (100% Oxygen used)

X = 0.000 (you reached surface)

HIT R/S

===================================

I will try to keep in this post short with only the informations to run the ZH16B program on DM42

=> all test dives and comparison with the ANDOID commercial MULTIDECO program in a following post

=> all the program internal informations in a following post to allow anyone to tune their deco scheme

===================================

I have split the (very long program) into 3 parts :

Couldn't load zh16b.raw due to "board attachement quota limit reached" ===============================================

Code: Select all

```
00 { 1699-Byte Prgm }
01▸LBL "ZH16B"
02 XEQ "ZHINIT"
03 "SURFACE (?)"
04▸LBL "LOOP"
05 XEQ "ZHSHOW"
06 STOP
@ we first look at the mix entered
07 X<>Y
08 STO "O2.HE"
09 R↓
@ PROF2 is stored in the format dd.mmm
@ dd = depth and mmm = minutes of the leg
10 STO "PROF2"
11 RCL "O2.HE"
@ did we enter a mix = 0?
12 X=0?
13 GTO 00
@ mix!=0, we extract the mix composition
@ HE2% is just the fractional part of the mix
14 FP
15 STO "%HE2"
@ now we compute the N22% part
@ N2 = (100 - O2)/100 - HE2%
@ we start at N22% = 100%
16 100
@ we retreive O2 part and compute the %
17 RCL "O2.HE"
18 IP
19 -
20 100
21 ÷
@ we retreive now HE2%
22 RCL "%HE2"
23 -
24 STO "%N22"
@ main and no mix change
25▸LBL 00
@ PROF2 is still in the format dd.mmm
@ dd = depth and mmm = minutes of the leg
26 RCL "PROF2"
@ did we request a stop calculcation
@ if yes, we go to stop calculations
27 X=0?
28 GTO "STOPS"
@ not a stop, we add a new leg
@ we extract first the depth and time of the leg
@ PROF2 = dd.mmm
@ T2 = mmm
29 FP
30 1ᴇ3
31 ×
32 STO "T2"
@ PROF2 = dd
33 RCL "PROF2"
34 IP
35 STO "PROF2"
@ now we calculate the depth gradient
@ new depth - current depth
36 RCL "PROF"
37 -
@ are we ascending (new depth - current depth>0?)
38 X<0?
39 GTO "UP"
@ are we descending (new deth - current detph>0?)
40 X>0?
41 GTO "DOWN"
@ we are staying at same depth! no need to calculate
@ ascent od descent part of the leg
@ nor ascent or descent values (R=TR=0)
42 0
43 STO "R"
44 STO "TR"
@ no need to calculate PP because of heavy calculations,
@ just copy B => C
45 XEQ "ZHPPB2C"
@ new mix is now current mix
46 RCL "%N22"
47 STO "%N2"
48 RCL "%HE2"
49 STO "%HE"
@ we have now to calculate the horizontal part of leg
50 GTO "HORIZ"
@ case we are ascending
@ we need to calculate tr and R with Vdwn
51▸LBL "UP"
52 "DIVE ↑ (R/S)"
@ we calculate the ascending leg with current mix
@ rule is to use the current mix when ascending
@ (certainly due to risk of high O2 if we use new
@ mix of the leg)
@ we use V = Vup
53 RCL "VUP"
54 STO "V"
55 GTO 01
@ case we are descending
@ we need to calculate tr and R with Vdwn
56▸LBL "DOWN"
57 "DIVE ↓ (R/S)"
58 RCL "VDWN"
@ is it the first leg?
59 RCL "PROF"
60 X≠0?
61 GTO 04
@ if it is the first leg, the current mix used during
@ decent is the leg mix!
62 RCL "%N22"
63 STO "%N2"
64 RCL "%HE2"
65 STO "%HE"
@ we reset DTR because it is first leg
@ important if we track surface intervals
66 0
67 STO "DTR"
@ now we are sure to have the good mix in %N2 and %HE
68▸LBL 04
@ we calculate the descending with current mix
@ rule is to use the current mix when descending
@ we use k = Vdwn
69 RCL "VDWN"
70 STO "V"
@ all the calculation are now independent of Vup
@ and Vdwn stored in V
71▸LBL 01
@ tr = (Proff - Profi)/V
@ proff is leg depth
@ profi is current depth
72 RCL "PROF2"
73 RCL "PROF"
74 -
75 RCL "V"
76 ÷
77 STO "TR"
@ R = mtob*N2*V
78 RCL "%N2"
79 RCL "MTOB"
80 ×
81 RCL "V"
82 ×
83 STO "R"
@ Pio2 = (Prof*mtob + Patm - Pwvp)
@ Pio = Pio2 * N2
84 RCL "PATM"
85 RCL "PWVP"
86 -
87 RCL "PROF"
88 RCL "MTOB"
89 ×
90 +
91 STO "PIO2"
92 RCL "%N2"
93 ×
94 STO "PIO"
@ we calculate then PP during ascent/descend
@ PP (Pio, tr, R, Periode, B => C)
95 RCL "TN2"
96 XEQ "ZHPPV"
@ R = mtob*He*V
97 RCL "%HE"
98 RCL "MTOB"
99 ×
100 RCL "V"
101 ×
102 STO "R"
@ Pio = Pio2 * He
103 RCL "PIO2"
104 RCL "%HE"
105 ×
106 STO "PIO"
@ we calculate then PP during ascent/descend
@ PP (Pio, tr, R, Periode, B => C)
107 RCL "THE"
108 XEQ "ZHPPV"
@ dtr = dtr + tr
109 RCL "TR"
110 STO+ "DTR"
111 XEQ "ZHSHOWV"
112 STOP
@ after calculating ascent/descent with current mix,
@ the leg is now calculated with leg mix
113 RCL "%N22"
114 STO "%N2"
115 RCL "%HE2"
116 STO "%HE"
@ calculate the flat portion of the leg
117▸LBL "HORIZ"
118 "DIVE → (?)"
@ did we dive or is it just a surface interval?
119 RCL "PROF2"
120 X=0?
@ here we know that we are dealing with a surface
@ interval
121 "SURFACE → (?)"
@ is it a "virtual leg" with no time at depth.
@ this is used to change mixes for example
122 RCL "T2"
123 X=0?
124 GTO 02
@ were we ascending ? if we are time during ascent
@ is not retreived from time at depth
@ total leg time is kept unchanged
125 RCL "PROF2"
126 RCL "PROF"
127 -
128 X<0?
129 GTO 03
@ were are descending, so time during descent is
@ included in total leg time
130 RCL "TR"
131 STO- "T2"
@ do we find ourselves with a negative time at depth,
@ so we need to correct with 0 and skip heavy PP
@ calculations
132 RCL "T2"
133 X>0?
134 GTO 03
135 0
136 STO "T2"
@ we skip heavy PP computing because time in flat
@ part of the leg is =0
137 GTO 02
@ now we calculate the flat portion of the leg
138▸LBL 03
@ new depth = leg depth
139 RCL "PROF2"
140 STO "PROF"
@ Pio2 = (Prof*mtob + Patm - Pwvp)
@ Pio = Pio2 * N2
141 RCL "PROF"
142 RCL "MTOB"
143 ×
144 RCL "PATM"
145 +
146 RCL "PWVP"
147 -
148 STO "PIO2"
149 RCL "%N2"
150 ×
151 STO "PIO"
@ we calculate PP (Pio, t, Periode, C => B)
152 RCL "TN2"
153 XEQ "ZHPP"
@ Pio = Pio2 * He
154 RCL "PIO2"
155 RCL "%HE"
156 ×
157 STO "PIO"
@ we calculate PP (Pio, t, Periode, C => B)
158 RCL "THE"
159 XEQ "ZHPP"
@ dtr = dtr + t2
160 RCL "T2"
161 STO+ "DTR"
162 GTO "LOOP"
@ in case flat portion of leg is = 0
@ we just copy C => B due to heavy calculation in PP
163▸LBL 02
@ new depth = leg depth (should already be the case!)
164 RCL "PROF2"
165 STO "PROF"
166 XEQ "ZHPPC2B"
@ dtr = dtr + t2 (should be +0!)
167 RCL "T2"
168 STO+ "DTR"
169 GTO "LOOP"
@ ==========================
@ part of the program that computes the end of the dive
@ ==========================
170▸LBL "STOPS"
@ are we already at surface ?
171 RCL "PROF"
172 X=0?
173 GTO "LOOP"
@ we suppose ceiling is surface
174 0
175 STO "PALIER2"
@ we start with gf = gfmin
176 RCL "GFMIN"
177 STO "GF"
@ calculate the ceiling in Palier2 going from bottom
@ ceiling is calculated for both N2 and He
178 XEQ "ZHCEIL"
179 RCL "PALIER2"
@ new target depth is now the calculated ceiling
180 STO "PROF2"
@ tr = (proff - profi) / Vup
@ proff is first stop
@ profi is bottom depth
181 RCL "PROF2"
182 RCL "PROF"
183 -
184 RCL "VUP"
185 ÷
186 STO "TR"
@ R = Vup*mtob*N2
@ we are still ascending with Vup speed
@ mix used is new deco mix rather than current bottom @ mix so we use %N22 and %HE2
187 RCL "VUP"
188 RCL "%N22"
189 ×
190 RCL "MTOB"
191 ×
192 STO "R"
@ Pio = (prof*mtob + Patm - Pwvp)
@ Pio = Pio2 * N2
@ Prof is bottom
193 RCL "PATM"
194 RCL "PWVP"
195 -
196 RCL "PROF"
197 RCL "MTOB"
198 ×
199 +
200 STO "PIO2"
201 RCL "%N22"
202 ×
203 STO "PIO"
@ we calculate then PP during ascent/descend
@ PP (Pio, tr, R, Periode, B => C)
204 RCL "TN2"
205 XEQ "ZHPPV"
@ R = Vup*mtob*He
@ we are still ascending with Vup speed
206 RCL "VUP"
207 RCL "%HE2"
208 ×
209 RCL "MTOB"
210 ×
211 STO "R"
@ Pio = Pio2*HE
@ Prof is bottom
212 RCL "PIO2"
213 RCL "%HE2"
214 ×
215 STO "PIO"
@ we calculate then PP during ascent/descend
@ PP (Pio, tr, R, Periode, B => C)
216 RCL "THE"
217 XEQ "ZHPPV"
@ dtr = dtr + tr
218 RCL "TR"
219 STO+ "DTR"
@ we need to switch now current mix with new mix
@ or the display will be wrong showing bottom mix
@ now that we have ascended, we switch to new deco mix
@ for flat leg
220 RCL "%N22"
221 STO "%N2"
222 RCL "%HE2"
223 STO "%HE"
224 "ASCENT (R/S)"
225 XEQ "ZHSHOWV"
226 STOP
@ new depth is first stop depth for flat leg
227 RCL "PROF2"
228 STO "PROF"
@ did we reach surface?
229 X=0?
@ if we reached surface during first ascent
230 GTO 31
@ we didn't reach surface we need to calculate stop time
@ first stop time is was is left from ascent rounded to
@ nearest minute
231 RCL "TR"
232 RCL "TR"
233 IP
234 -
235 STO "TR"
@ we compute now gfsteps using
@ steps = int(palier/3)
@ gfsteps = (gfmax- gfmin)/steps or 0
236 RCL "PROF"
237 3
238 ÷
239 IP
@ if steps = 0 we do not divide by steps
@ we should NOT have palier = 0!
240 X=0?
241 GTO 22
242 RCL "GFMAX"
243 RCL "GFMIN"
244 -
245 X<>Y
246 ÷
247▸LBL 22
248 STO "GFSTEP"
@ loop on stops until stop <= 0 (surface is reached)
249▸LBL 30
250 RCL "PROF"
@ did we reach surface, then we exit
251 X≤0?
252 GTO 31
@ we didn't reach surface, we compute time spent at stop
@ Pio2 = (palier*mtob + Patm - Pwvp)
253 RCL "PATM"
254 RCL "PWVP"
255 -
256 RCL "PROF"
257 RCL "MTOB"
258 ×
259 +
260 STO "PIO2"
@ t2 -= tr
@ we remove from first minute of deco time spent
@ ascending to the stop
261 RCL "TR"
262 +/-
263 STO "T2"
@ Palier2 = palier for the +1minute loop
264 RCL "PROF"
265 STO "PALIER2"
@ gf += gfstep
266 RCL "GFSTEP"
267 STO+ "GF"
@ loop did we change deco stop adding +1minute
@ in computing
268▸LBL 40
269 RCL "PROF"
270 RCL "PALIER2"
@ did we change stop depth?
@ we get out of the "LBL 40" loop
271 X≠Y?
272 GTO 41
@ we add +1minute to stop time
273 1
274 STO+ "T2"
@ Pio = Pio2 * N2
275 RCL "PIO2"
276 RCL "%N2"
277 ×
278 STO "PIO"
@ we compute PP with one more minute at stop
@ we compute PP (Pio, t, Periode, C => B)
279 RCL "TN2"
280 XEQ "ZHPP"
@ Pio = Pio2 * He
281 RCL "PIO2"
282 RCL "%HE"
283 ×
284 STO "PIO"
@ we compute PP with one more minute at stop
@ we compute PP (Pio, t, Periode, C => B)
285 RCL "THE"
286 XEQ "ZHPP"
287 0
288 STO "PALIER2"
289 XEQ "ZHCEIL"
290 RCL "PALIER2"
291 RCL "PROF"
292 3
293 -
@ did the new ceiling > current depth +3m ?
@ in that case new ceiling is current - 3m
294 X<Y?
295 X<>Y
296 STO "PALIER2"
@ we loop for one more minute?
297 GTO 40
@ we reached enought time to go to next stop
298▸LBL 41
@ DTR = DTR + t2
299 RCL "T2"
300 STO+ "DTR"
301 RCL "TR"
302 STO+ "T2"
303 "STOP (R/S)"
304 XEQ "ZHSHOWP"
305 STOP
@ are we requesting a new deco mix beetween stops?
@ new deco mix requested with X=0
306 X≠0?
307 GTO 42
@ new mix requested
308 R↓
309 STO "O2.HE"
@ the HE% part is just the frational part
310 FP
311 STO "%HE2"
@ now we compute the N22% part
@ N2 = (100 - O2)/100 - HE2%
@ we start at N22% = 100%
312 100
@ we retreive O2 part and compute the %
313 RCL "O2.HE"
314 IP
315 -
316 100
317 ÷
@ we retreive now HE2%
318 RCL "%HE2"
319 -
320 STO "%N22"
@ we continue to next stop
321▸LBL 42
@ tr = (palier2 - current) / Vpalier
322 RCL "PALIER2"
323 RCL "PROF"
324 -
325 RCL "VPALIER"
326 ÷
327 STO "TR"
@ mix is still the last on ascent one before swithing
@ R = Vpalier*mtob*N2
328 RCL "VPALIER"
329 RCL "MTOB"
330 ×
331 RCL "%N2"
332 ×
333 STO "R"
@ Pio is still ok from last calculation
@ depth for Pio is last stop
334 RCL "PIO2"
335 RCL "%N2"
336 ×
337 STO "PIO"
@ we calculate then PP during ascent/descend
@ PP (Pio, tr, R, Periode, B => C)
338 RCL "TN2"
339 XEQ "ZHPPV"
@ R = Vpalier*mtob*He
340 RCL "VPALIER"
341 RCL "MTOB"
342 ×
343 RCL "%HE"
344 ×
345 STO "R"
@ Pio is still ok from last calculation
346 RCL "PIO2"
347 RCL "%HE"
348 ×
349 STO "PIO"
@ we calculate then PP during ascent/descend
@ PP (Pio, tr, R, Periode, B => C)
350 RCL "THE"
351 XEQ "ZHPPV"
@ now new mix will be used
352 RCL "%N22"
353 STO "%N2"
354 RCL "%HE2"
355 STO "%HE"
@ new depth is current stop
356 RCL "PALIER2"
357 STO "PROF"
@ did we surface => end
358 X=0?
359 GTO 31
@ we didn't surface we add ascent to stop in run time
360 RCL "TR"
361 STO+ "DTR"
@ loop
362 GTO 30
@ end of the dive, we reched surface
363▸LBL 31
@ we reached surface, depth = 0, time leg = 0
364 "SURFACE ↑ (R/S)"
365 0
366 STO "PROF2"
367 STO "PROF"
368 STO "T2"
369 XEQ "ZHSHOW"
370 STOP
@ before looping to surface
@ we put the DTR = 0
@ and reset mix to surface air mix
371 0
372 STO "DTR"
373 STO "TR"
374 STO "%HE2"
375 STO "%HE"
376 RCL "N2SURF"
377 STO "%NE"
378 STO "%NE2"
379 "SURFACE (?)"
380 GTO "LOOP"
381 END
```

Code: Select all

```
00 { 929-Byte Prgm }
01▸LBL "ZHTOOLS"
02▸LBL "ZHPP"
03 STO "I"
04▸LBL 50
05 RCL "I"
06 RCL 00
07 4
08 ×
09 +
10 STO "J"
11 2
12 LN
13 RCL IND "I"
14 ÷
15 RCL "T2"
16 ×
17 +/-
18 E^X
19 1
20 -
21 RCL IND "J"
22 RCL "PIO"
23 -
24 ×
25 RCL IND "J"
26 +
27 RCL "I"
28 RCL 00
29 3
30 ×
31 +
32 X<>Y
33 STO IND ST Y
34 ISG "I"
35 GTO 50
36 RTN
37▸LBL "ZHPPV"
38 STO "I"
39▸LBL 60
40 RCL "I"
41 RCL 00
42 3
43 ×
44 +
45 STO "J"
46 2
47 LN
48 RCL IND "I"
49 ÷
50 STO "K"
51 RCL "PIO"
52 RCL IND "J"
53 -
54 RCL "R"
55 RCL "K"
56 ÷
57 -
58 RCL "K"
59 RCL "TR"
60 ×
61 +/-
62 E^X
63 ×
64 +/-
65 RCL "PIO"
66 +
67 RCL "TR"
68 RCL "K"
69 1/X
70 -
71 RCL "R"
72 ×
73 +
74 RCL "I"
75 RCL 00
76 4
77 ×
78 +
79 X<>Y
80 STO IND ST Y
81 ISG "I"
82 GTO 60
83 RTN
84▸LBL "ZHPPB2C"
85 RCL "BN2"
86 XEQ 70
87 RCL "BHE"
88 XEQ 70
89 RTN
90▸LBL 70
91 STO "I"
92▸LBL 71
93 RCL "I"
94 RCL 00
95 +
96 STO "J"
97 RCL IND "I"
98 STO IND "J"
99 ISG "I"
100 GTO 71
101 RTN
102▸LBL "ZHPPC2B"
103 RCL "BN2"
104 XEQ 80
105 RCL "BHE"
106 XEQ 80
107 RTN
108▸LBL 80
109 STO "I"
110▸LBL 81
111 RCL "I"
112 RCL 00
113 +
114 STO "J"
115 RCL IND "J"
116 STO IND "I"
117 ISG "I"
118 GTO 81
119 RTN
@ ===========================================
@ we compute ceiling first for N2 then for He
@ ===========================================
120▸LBL "ZHCEIL"
@ we compute the ceiling using Buhlmann equation
@ extended with gradient factors by Erik Baker
121 XEQ 10
@ we have the ceiling in PROF2
@ we first check if we are near surface
122 RCL "EPSILON"
123 RCL "PROF2"
124 X<Y?
@ celiling is 0 (surface)
125 GTO 12
@ else we fing the nearest stop (multiple of 3m)
126 3
127 ÷
128 RCL "EPSILON"
129 +
130 IP
131 1
132 +
133 3
134 ×
135 GTO 13
136▸LBL 12
137 0
138▸LBL 13
139 STO "PROF2"
140 RTN
141▸LBL 10
142 RCL "N2A"
143 LSTO "I"
144 RCL "HEA"
145 LSTO "J"
146▸LBL 11
@ we retreive PBN2b (BN2)
147 RCL "I"
148 RCL 00
149 2
150 ×
151 +
@ PPN2
152 RCL IND ST X
153 LSTO "PN2"
@ P = PPN2 (+ PPHE)
154 LSTO "P"
@ we retreive N2A
155 RCL IND "I"
156 RCL "PN2"
157 ×
@ A = PPN2 x N2A
158 LSTO "A"
@ we retreive PBHEb (BHE)
159 RCL "J"
160 RCL 00
161 2
162 ×
163 +
@ PPHE
164 RCL IND ST X
165 LSTO "PHE"
@ P = PPN2 + PPHE
166 STO+ "P"
@ we retreive HEA
167 RCL IND "J"
168 RCL "PHE"
169 ×
@ A = PPN2 * N2A + PPHE * HEA
170 STO+ "A"
171 RCL "P"
@ A = A/P
172 STO÷ "A"
@ we retreive N2B
173 RCL "I"
174 RCL 00
175 +
@ N2B
176 RCL IND ST X
@ B = N2B * PN2
177 RCL "PN2"
178 ×
179 LSTO "B"
@ we retreive HEB
180 RCL "J"
181 RCL 00
182 +
@ HEB
183 RCL IND ST X
@ B = N2B * PN2 + HEB * PHE
184 RCL "PHE"
185 ×
186 STO+ "B"
187 RCL "P"
@ B = B/P
188 STO÷ "B"
@ we retreive N2A
189 RCL "P"
190 RCL "A"
191 RCL "GF"
192 ×
193 -
194 RCL "GF"
195 RCL "B"
196 ÷
197 1
198 +
199 RCL "GF"
200 -
201 ÷
202 RCL "PATM"
203 -
204 RCL "MTOB"
205 ÷
@ did we find a greater ceiling?
@ if yes, we must store it
206 RCL "PROF2"
207 X<Y?
208 X<>Y
209 STO "PROF2"
210 1
211 STO+ "J"
212 ISG "I"
213 GTO 11
214 RTN
@ ========================================================
@ function that shows information during an ascent/descent
@ T = PPO2 in bars
@ X = leg as dd.mmm with PROF2
@ ========================================================
215▸LBL "ZHSHOWV"
216 RCL "TR"
217 1ᴇ3
218 ÷
219 RCL "PROF2"
220 +
221 STO "I"
@ during ascent/descent we take the greatest depth between prof
@ and prof2
222 RCL "PROF2"
223 RCL "PROF"
224 X<Y?
225 X<>Y
@ we convert depth to bars
226 RCL "MTOB"
227 ×
228 RCL "PATM"
229 +
230 RCL "PWVP"
231 -
@ we calculate the % of oxygen
232 1
233 RCL "%N2"
234 -
235 RCL "%HE"
236 -
@ pressure of oxygen x %O2
237 ×
238 STO "J"
239 RCL "PPDEPTH"
240 X<Y?
241 BEEP
242 X<>Y
243 RCL "PPMIN"
244 X>Y?
245 BEEP
246 GTO 97
@ ========================================================
@ T = PPO2 in bars
@ X = leg as dd.mmm with PROF
@ ========================================================
247▸LBL "ZHSHOW"
@ during ascent/descent we take the greatest depth between prof
@ and prof2
248 RCL "T2"
249 1ᴇ3
250 ÷
251 RCL "PROF"
252 +
253 STO "I"
@ during ascent/descent we take the greatest depth between prof
@ and prof2
254 RCL "PROF2"
255 RCL "PROF"
256 X<Y?
257 X<>Y
@ we convert depth to bars
258 RCL "MTOB"
259 ×
260 RCL "PATM"
261 +
262 RCL "PWVP"
263 -
@ we calculate the % of oxygen
264 1
265 RCL "%N2"
266 -
267 RCL "%HE"
268 -
@ pressure of oxygen x %O2
269 ×
270 STO "J"
271 RCL "PPDEPTH"
272 X<Y?
273 BEEP
274 X<>Y
275 RCL "PPMIN"
276 X>Y?
277 BEEP
278 GTO 97
@ ========================================================
@ function that shows information during a stop
@ T = PPO2 in bars
@ X = leg as dd.mmm with stop informations
@ ========================================================
279▸LBL "ZHSHOWP"
@ I = dd.mmm = stop.time
280 RCL "T2"
281 1ᴇ3
282 ÷
283 RCL "PROF"
284 +
285 STO "I"
@ during stop we take PROF to calculate PPO2
286 RCL "PROF"
@ we convert depth to bars
287 RCL "MTOB"
288 ×
289 RCL "PATM"
290 +
291 RCL "PWVP"
292 -
@ we calculate the % of oxygen
293 1
294 RCL "%N2"
295 -
296 RCL "%HE"
297 -
@ pressure of oxygen x %O2
298 ×
299 STO "J"
300 RCL "PPSTOP"
301 X<Y?
302 BEEP
303 X<>Y
304 RCL "PPMIN"
305 X>Y?
306 BEEP
@ function that shows information
@ T = PPO2 in bars
@ Z = RUN time in minutes
@ Y = mix as oo.hh
@ X = leg as dd.mmm
307▸LBL 97
@ we start with 100% O2
308 100
@ we retreive now the N2 part
309 RCL "%N2"
310 100
311 ×
312 IP
313 -
@ we retreive now the HE part
314 RCL "%HE"
315 100
316 ×
317 IP
318 -
@ we add the fractional part of HE%
319 RCL "%HE"
320 +
321 STO "O2.HE"
322 RCL "J"
323 RCL "DTR"
324 RCL "O2.HE"
325 RCL "I"
326 RTN
327 END
```

Code: Select all

```
00 { 1633-Byte Prgm }
01▸LBL "ZHINIT"
@ size is 5 x N2 + 5 x He = 160 elements
@ N2 is : TN2, N2A, N2B, BN2, CN2
@ He is : HE2, HEA, HEB, BHE, CHE
02 SIZE 161
03 FIX 03
04 0
05 STO "PROF"
06 STO "DTR"
07 STO "TR"
08 STO "%HE"
09 STO "PROF2"
10 STO "T2"
11 STO "%HE2"
12 0.7902
13 STO "%N2"
14 STO "%N22"
15 STO "N2SURF"
16 20
17 STO "VDWN"
18 10
19 +/-
20 STO "VUP"
21 STO "VPALIER"
22 0
23 STO "V"
24 0.3
25 STO "GFMIN"
26 0.85
27 STO "GFMAX"
28 1ᴇ-6
29 STO "EPSILON"
30 0.0627
31 STO "PWVP"
32 1.01325
33 STO "PATM"
34 0.09985
35 STO "MTOB"
36 1.4
37 STO "PPDEPTH"
38 1.6
39 STO "PPSTOP"
40 0.16
41 STO "PPMIN"
42 16
43 STO "I"
44 STO 00
45 1.01601
46 STO "TN2"
47 STO "I"
48 5
49 STO IND "I"
50 ISG "I"
51 8
52 STO IND "I"
53 ISG "I"
54 12.5
55 STO IND "I"
56 ISG "I"
57 18.5
58 STO IND "I"
59 ISG "I"
60 27
61 STO IND "I"
62 ISG "I"
63 38.3
64 STO IND "I"
65 ISG "I"
66 54.3
67 STO IND "I"
68 ISG "I"
69 77
70 STO IND "I"
71 ISG "I"
72 109
73 STO IND "I"
74 ISG "I"
75 146
76 STO IND "I"
77 ISG "I"
78 187
79 STO IND "I"
80 ISG "I"
81 239
82 STO IND "I"
83 ISG "I"
84 305
85 STO IND "I"
86 ISG "I"
87 390
88 STO IND "I"
89 ISG "I"
90 498
91 STO IND "I"
92 ISG "I"
93 635
94 STO IND "I"
95 17.03201
96 STO "N2A"
97 STO "I"
98 1.1696
99 STO IND "I"
100 ISG "I"
101 1
102 STO IND "I"
103 ISG "I"
104 0.8618
105 STO IND "I"
106 ISG "I"
107 0.7562
108 STO IND "I"
109 ISG "I"
110 0.6667
111 STO IND "I"
112 ISG "I"
113 0.56
114 STO IND "I"
115 ISG "I"
116 0.4947
117 STO IND "I"
118 ISG "I"
119 0.45
120 STO IND "I"
121 ISG "I"
122 0.4187
123 STO IND "I"
124 ISG "I"
125 0.3798
126 STO IND "I"
127 ISG "I"
128 0.3497
129 STO IND "I"
130 ISG "I"
131 0.3223
132 STO IND "I"
133 ISG "I"
134 0.285
135 STO IND "I"
136 ISG "I"
137 0.2737
138 STO IND "I"
139 ISG "I"
140 0.2523
141 STO IND "I"
142 ISG "I"
143 0.2327
144 STO IND "I"
145 33.04801
146 STO "N2B"
147 STO "I"
148 0.5578
149 STO IND "I"
150 ISG "I"
151 0.6514
152 STO IND "I"
153 ISG "I"
154 0.7222
155 STO IND "I"
156 ISG "I"
157 0.7825
158 STO IND "I"
159 ISG "I"
160 0.8126
161 STO IND "I"
162 ISG "I"
163 0.8434
164 STO IND "I"
165 ISG "I"
166 0.8693
167 STO IND "I"
168 ISG "I"
169 0.891
170 STO IND "I"
171 ISG "I"
172 0.9092
173 STO IND "I"
174 ISG "I"
175 0.9222
176 STO IND "I"
177 ISG "I"
178 0.9319
179 STO IND "I"
180 ISG "I"
181 0.9403
182 STO IND "I"
183 ISG "I"
184 0.9477
185 STO IND "I"
186 ISG "I"
187 0.9544
188 STO IND "I"
189 ISG "I"
190 0.9602
191 STO IND "I"
192 ISG "I"
193 0.9653
194 STO IND "I"
195 49.06401
196 STO "BN2"
197 STO "I"
198 RCL "PATM"
199 RCL "PWVP"
200 -
201 RCL "N2SURF"
202 ×
203▸LBL 99
204 STO IND "I"
205 ISG "I"
206 GTO 99
207 65.08001
208 STO "CN2"
209 STO "I"
210 0
211▸LBL 98
212 STO IND "I"
213 ISG "I"
214 GTO 98
215 81.09601
216 STO "THE"
217 STO "I"
218 1.88
219 STO IND "I"
220 ISG "I"
221 3.02
222 STO IND "I"
223 ISG "I"
224 4.72
225 STO IND "I"
226 ISG "I"
227 6.99
228 STO IND "I"
229 ISG "I"
230 10.21
231 STO IND "I"
232 ISG "I"
233 14.48
234 STO IND "I"
235 ISG "I"
236 20.53
237 STO IND "I"
238 ISG "I"
239 29.11
240 STO IND "I"
241 ISG "I"
242 41.20
243 STO IND "I"
244 ISG "I"
245 55.19
246 STO IND "I"
247 ISG "I"
248 70.69
249 STO IND "I"
250 ISG "I"
251 90.34
252 STO IND "I"
253 ISG "I"
254 115.29
255 STO IND "I"
256 ISG "I"
257 147.42
258 STO IND "I"
259 ISG "I"
260 188.24
261 STO IND "I"
262 ISG "I"
263 240.03
264 STO IND "I"
265 97.11201
266 STO "HEA"
267 STO "I"
268 1.6189
269 STO IND "I"
270 ISG "I"
271 1.3830
272 STO IND "I"
273 ISG "I"
274 1.1919
275 STO IND "I"
276 ISG "I"
277 1.0458
278 STO IND "I"
279 ISG "I"
280 0.9220
281 STO IND "I"
282 ISG "I"
283 0.8205
284 STO IND "I"
285 ISG "I"
286 0.7305
287 STO IND "I"
288 ISG "I"
289 0.6502
290 STO IND "I"
291 ISG "I"
292 0.5950
293 STO IND "I"
294 ISG "I"
295 0.5545
296 STO IND "I"
297 ISG "I"
298 0.5333
299 STO IND "I"
300 ISG "I"
301 0.5189
302 STO IND "I"
303 ISG "I"
304 0.5181
305 STO IND "I"
306 ISG "I"
307 0.5176
308 STO IND "I"
309 ISG "I"
310 0.5172
311 STO IND "I"
312 ISG "I"
313 0.5119
314 STO IND "I"
315 113.12801
316 STO "HEB"
317 STO "I"
318 0.4770
319 STO IND "I"
320 ISG "I"
321 0.5747
322 STO IND "I"
323 ISG "I"
324 0.6527
325 STO IND "I"
326 ISG "I"
327 0.7223
328 STO IND "I"
329 ISG "I"
330 0.7582
331 STO IND "I"
332 ISG "I"
333 0.7957
334 STO IND "I"
335 ISG "I"
336 0.8279
337 STO IND "I"
338 ISG "I"
339 0.8553
340 STO IND "I"
341 ISG "I"
342 0.8757
343 STO IND "I"
344 ISG "I"
345 0.8903
346 STO IND "I"
347 ISG "I"
348 0.8997
349 STO IND "I"
350 ISG "I"
351 0.9073
352 STO IND "I"
353 ISG "I"
354 0.9122
355 STO IND "I"
356 ISG "I"
357 0.9171
358 STO IND "I"
359 ISG "I"
360 0.9217
361 STO IND "I"
362 ISG "I"
363 0.9267
364 STO IND "I"
365 129.14401
366 STO "BHE"
367 STO "I"
368 0
369▸LBL 97
370 STO IND "I"
371 ISG "I"
372 GTO 97
373 145.16001
374 STO "CHE"
375 STO "I"
376 0
377▸LBL 96
378 STO IND "I"
379 ISG "I"
380 GTO 96
381 RTN
382 END
```