Contents
  1. 1. Requirements
  2. 2. Dive Simulator
  3. 3. Installation
  4. 4. Project structure
  5. 5. Configuration
  6. 6. Simulation
  7. 7. Clean up
  8. 8. Example replay

DiveIno must be tested to avoid failures and bugs. I defined the following test categories:

  1. Dry test - tests the software, which powers DiveIno
  2. Wet test - tests the hardware in a pressurized environment
  3. Usability test - performs test dives with DiveIno

Dry tests will be performed quite frequently during development. Lot of things have to be tested over and over including dive simulation. This post is about how to simulate real dives on DiveIno without getting wet.

Honestly this provides a really good opportinity to make sure that your DiveIno works as expected.

Requirements

First things first you need a breadboard version of DiveIno. What is it? It is what its name suggests. All DiveIno parts connected together on a solderless breadboard. The benefit of this setup is that you don’t have to fully assemble DiveIno in order to be able to try it out.

I work with several DiveIno versions at the same time. One of them is this breadboard version, which I use for software development. Of course you also have to setup your development environment. I wrote a post about how this can be done.

Basically you have to setup your IDE, clone the DiveIno GitHub repository. Obtain the required third party Arduino libraries. Copy the images to the SD card. Verify and upload the DiveIno sketch to your breadboard version of DiveIno. If everything was successful, you should see the new DiveIno ASCII art during start up in the Arduino Serial Monitor view.

At this point the new DiveIno Serial API can be used to perform dry dives on DiveIno based on previouly logged dive profiles in DiveIno JSON format.

As you might notice only two things are missing to be able to do dry tests on DiveIno:

  1. Dive profiles - test data
  2. Dive Simulator

Dive Simulator

The Dive Simulator is able to simulate dives based on the Emulator and Replay modes built into DiveIno Serial API.

In order to showcase how such a simulator can be built, I created a demonstration version based on Node.js in the DiveInoSimulator GitHub repository. The remaining parts of this post demonstrates how this piece of software can be used.

Installation

DiveIno Serial API can talk with the attached computer through its serial port. It means that this computer has to run a software, which is attached to this serial communication port. I evaluated many options, but for my greatest surprise the easiest one was to use Node.js and node-serialport. That’s why DiveInoSimulator is based on these technologies.

The following installation steps have to be performed:

  1. Install Node.js
  2. Clone DiveInoSimulator from GitHub
  3. Install node-serialport
  4. Setup your IDE

Nowadays I use Nodeclipse for development, but WebStorm or Visual Studio Code can be used as well.

Project structure

DiveInoSimulator has the following structure:

There are several test DiveIno dive profile JSON files can be found in the data folder. Besides these - in the project root - the following interesting files can be found:

  1. config.json
  2. emulator.js
  3. replay.js

Configuration

The config.json file stores the configuration options, which will be loaded by emulator.js and replay.js.

1
2
3
4
5
6
7
{
"port" : "COM9",
"test" : "./data/TestSafetyStop.json",
"interval": 800,
"baudrate" : 115200,
"initialDelay" : 10
}

The port property describes the serial port name. In the example it is set to COM9, which is a standard serial port name on Windows. On Linux the following format can be used: /dev/ttyUSB0

The test property identifies the DiveIno dive profile JSON file from the data folder, which will be used by the simulator.

Between each profile items in replay mode a small delay has to be inserted, because it takes some time for the Arduino Mega 2560 microprocessor to calculate the deco algorithm steps. The interval property sets this delay in milliseconds.

The baudrate defines the speed of the communication. It must be 115200.

The initialDelay property defines the initial delay in seconds between the Node.js process start and the beginning of the dive simulation.

Simulation

DiveInoSimulator prints out DiveIno serial output to the Node.js console window. It is just like to have an Arduino Serial Monitor view besides the simulator output.

You can choose, which simulation mode is preferred:

  1. Emulate a dive - emulator.js
  2. Replay a dive - replay.js

The difference between these two modes are described in the Serial API post.

The steps involved in each mode are similar:

  1. The right file has to be started - e.g. replay.js
  2. DiveIno will reset itself and the Main Menu gets displayed
  3. You have to put DiveIno into dive mode - just press the OK button
  4. Simulation - emulator or replay - starts
  5. Simulation ends
  6. The Surface Time screen will be displayed in Dive Stop mode

The time interval defined in the initialDelay property is required to conveniently perform step 2 and 3.

Clean up

As a result of each simulated dive, a new logbook entry will be created. In order to clean these up the @RESET# command can be executed through the DiveIno Serial API.

Example replay

The following excerpts are from a successful dive replay:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
READY

REPLAY - Enabled

DIVE - Started

Compartment initialization - START
Compartment initialization - DONE

REPLAY: 1626.4 mbar, 6.1 m, 12 sec, 15.0 cel

0 - ppN2: 769.54 mb | ac ppN2: -247.63 mb | no deco: 99
1 - ppN2: 762.64 mb | ac ppN2: -154.61 mb | no deco: 99
2 - ppN2: 760.13 mb | ac ppN2: -73.42 mb | no deco: 99
3 - ppN2: 758.68 mb | ac ppN2: 1.94 mb | no deco: 99
4 - ppN2: 757.72 mb | ac ppN2: 111.91 mb | no deco: 99
5 - ppN2: 757.11 mb | ac ppN2: 213.22 mb | no deco: 99
6 - ppN2: 756.67 mb | ac ppN2: 274.42 mb | no deco: 99
7 - ppN2: 756.37 mb | ac ppN2: 317.52 mb | no deco: 99
8 - ppN2: 756.15 mb | ac ppN2: 346.54 mb | no deco: 99
9 - ppN2: 756.02 mb | ac ppN2: 374.43 mb | no deco: 99
10 - ppN2: 755.94 mb | ac ppN2: 397.40 mb | no deco: 99
11 - ppN2: 755.87 mb | ac ppN2: 422.54 mb | no deco: 99
12 - ppN2: 755.82 mb | ac ppN2: 447.62 mb | no deco: 99
13 - ppN2: 755.78 mb | ac ppN2: 472.22 mb | no deco: 99
14 - ppN2: 755.75 mb | ac ppN2: 487.54 mb | no deco: 99
15 - ppN2: 755.72 mb | ac ppN2: 504.88 mb | no deco: 99
NO DECO | Min to deco: 99

Desaturation time: 87
Was DECO dive? 0
Previous dive was DECO dive? 0
No Fly time: 1440, Is deco? 0, Is repetitive? 1
Dive stop timestamp: 1483545151
Compartment initialization - START
Compartment initialization - DONE

Surface interval (min): 0
The last dive was within 10 minutes!

DIVE - Stopped

REPLAY - Disabled

Contents
  1. 1. Requirements
  2. 2. Dive Simulator
  3. 3. Installation
  4. 4. Project structure
  5. 5. Configuration
  6. 6. Simulation
  7. 7. Clean up
  8. 8. Example replay