Using the Rebreather
Version of the VPM Program

in Visual Basic for Applications


Copyright 1999 by Eric Maiken



Using the Program RebreatherVPM.xls

The program should unzip with the Example displayed. 

To calculate an ascent schedule, begin in cell C4, and type in a depth. Then enter the corresponding run-time for the stage in cell D4 . Enter any successive stages in the next lower rows (C5 and D5, then C6 and D6, etc.). The program will read the "Depth" and "Run-Time" columns in this sequence from top to bottom until it encounters a blank row. At his point, it calculates the ascent schedule for the sequence of stages above the blank row.

Each complete entry is assigned a stage number in column B after the program reads it in. An incomplete or incorrect entry will result in an error message with instructions for correcting the problem. Examples of incomplete entries are: a stage depth but no runtime or stage run-time but no depth. Examples of incorrectly formatted entries include entering a deeper-than-previous stage depth in a lower row or entering a stage run-time that is equal to or less than a previous stage's run time. Note that unlike the QuickBasic version, an error message is generated if dive stages are not in order of deepest first. Also keep it in mind that it is possible to make nonsensical entries that survive error checking --remember the program is supposed to be minimalist.... One example is a dive to 10 feet on a ppO2 of 1.6. Try testing some pathological entries to see what's going on.

After you complete the entry of the stages, hit the Run button and an ascent schedule should then be output.

Everything is on one sheet, (except for the help form) with no controls on additional forms, etc. A .jpg of the sheet VPM.xls is shown below with yellow flags calling out notes that describe the controls and display. There are no ToolTips or help for the controls. Just a little bit of input checking and error control.

Input Example

(1) A one hour dive is made at 130 feet with setpoints of 1.3 for the bottom mix, 1.4 for the deco up to 20 feet, and then 100% O2 for the final stop pulled at 20 ft.

Dive: Enter 130 in cell C4, and 60 in cell D4. Set the Bottom Mix Set Point at 1.3 Ata ppO2;

Ascent : Set the scroll bars as: Deep Deco Set Point = 1.4 ppO2; Shallow Deco Set Point = 100% O2. Check the Pull Last Stop At 20 ft Box. Total deco time = 31 min.


Now, compare some VPM schedules to the ascents calculated by Neo-Haldane (Keller/Buhlmann) based programs (ie: every other program that is available). Especially, try plugging the VPM deep stops into these programs as a multilevel dive and see how schedules compare.


Controls and Display

Below the picture of the Rebreather VPM.xls sheet, notes on each of the seven flagged items are called out. The gray color sections are areas for input. The blue color sections are for program output. All objects are enabled and unprotected. Examples of input are also given.




For each multilevel dive stage, enter the Depth and Run-time in the corresponding gray colored columns. The Stage column is for program output. Each complete depth/run-time entry is automatically assigned a stage number.


(2) Depth and Run-time Columns

The input format for each dive stage is in feet of salt water and run-time in minutes. Just enter numbers --the units are implied. Run-time is the time since starting the decent. If you think in terms of what your bottom timer would read at the end of each stage, then that's your run-time.

33 feet of salt water = 34 feet of fresh water. 3.3 feet of anything = 1 meter. For example, a dive to 50 m should be input as 165 feet. See the Making Your Own Changes section below for more notes on conversions.

For multilevel dives, run the program as you add each new dive stage to verify that the first deco stop is shallower than the next shallowest dive stage. You'll need to run the program a couple of times for multilevel dives.


(3) Buttons

The buttons can be activated by either a mouse click or from the keyboard with alt+Underlined character.


After entering depth(s) and run-time(s), Run to calculate the decompression profile.


All input and output is cleared.


A form summarizing the controls is displayed.


(4) Check Boxes

A mouse click either activates or deactivates each item. Activation (denoted by a check) prior to running a calculation results in the following:

[v] Plot Dive Profile

The stair-step formatted ascent profile that is hidden in the black border of columns H and I is plotted.

[v] Display 1st Iteration

Outputs the first un-converged ascent schedule.

As described in the Algorithm Details section below, the VPM algorithm is different from conventional decompression calculations because the ascent schedule is calculated iteratively. A sequence of increasingly liberal ascent schedules are produced before the final, converged schedule is output. Compare the first and last schedules for some short dives (big difference) and also for long dives (not much difference).

[v] Pull last stop at 20 ft

The last in-water decompression stop is at 20 ft. Note that the ascent schedule outputs two sequential 20 ft stops.


(5) Scroll Bars

Breathing gas set points for bottom mix and two deco mixes are changed by sliding the scroll button. A mouse click on the button may be required to display the proper ppO2 in the text box. The program does calculations using the incremental settings of the scroll bars regardless of the value displayed.

Bottom Mix Set Point

Sets the ppO2 of the bottom mix. You track your END, and O2 tox.

Deep Deco Set Point

Sets ppO2 of all stops below 20 feet.

Shallow Deco Set Point

Rather than setting the ppO2, the %O2 of 20 and 10 foot deco mix are set.

Before correcting for the partial pressure of CO2 and H2O in the lungs, 100% O2 corresponds to ppO2 of 1.6 at 20 feet and 1.3 at 10 feet. After correction within the program, the ppO2s of 100% O2 are displayed as 1.47 Ata at 20 feet and 1.17 Ata at 10 feet.



The ascent schedule is output in a table in a depth/run-time format.

Differences of one minute in profiles are not significant and result from how the program rounds numbers. As an example, an odd 2 minute stop will occasionally show up among 1 min stops. Also short deep stops often skip a 10 foot increment for the same reason.


(7) Chart

A stair-step formatted plot of the ascent schedule is plotted. Note that the chart plots data in columns H and I.

 The chart is built entirely from excel menus. It is not a VBA object.  


RebreatherVPM.xls Program Notes

To see what's going on with this program, open up the source code with the Excel Visual Basic for Applications editor under the "Tools"-Macro menus. 

I've tried to keep the program as straight-forward as possible with the code for the sheet "VPM I-O" serving as a complete module along with minimal input and output formatting and control. Nonetheless, lots of lines are devoted solely to I/O and have nothing to do with the real algorithm. The code is clearest in the QuickBasic form, so download the VPM.txt file to figure out how it works.

This program assumes constant ppO2 set points as appropriate for an electronic closed circuit system. RebreatherVPM.xls was adapted from the open circuit version VPM.xls by changing how the concentration of the nitrogen diluent is input, output, and used in calculations. The essential difference is that during the dive and stops up to 20 feet, the nitrogen partial pressure is calculated as: PN2 = (PAMBIENT - PH20 - PC02 - P02) rather than the expression: PN2 = fN2*(PAMBIENT - PH20 - PC02) used in the open circuit version. (PH20 + PC02) = 102mmHg/760mmHg was used as a constant.


Making Your Own Changes

The layout of the controls is handled by the "Control Toolbox" menu bar. Although everything is enabled, you'll need to "ungroup" similar objects before changing properties.

By using the VBA project explorer, you can make lots of changes to the input and output without worrying about the details of the algorithm.

Simple ways to patch the input and output units from feet to meters are to either write the conversion formulas in two new columns on the sheet VPM or to modify the input lines in SUB DIVEDATA and output in SUB PROFILE. You will need to do a lot of re-coding to do the actual calculations in metric units. Most of the calculations are actually done in the pressure units of "Atmospheres," with 1 atm ~ 1 bar ~ 105 Pascals, so when you see a 33, this is almost certainly 1 ata = 33 feet of salt water. Stops are in 10 foot increments (which is essentially identical to 3 m for nitrox decompression purposes). Also, be careful in SUB DIVEDATA where the four bubble model constants are set. There is a conversion to ata there too.

In a similar fashion, you can patch stop times from runtimes to incremental times on the spread sheet. 

No provision for writing a profile to an output file was made. The easiest way to save output is to just cut and paste to notepad or another spreadsheet.