Skip to content

Commit

Permalink
Shearwater: Add Sensor Calibration Info.
Browse files Browse the repository at this point in the history
Add the calibration values for ppO2 sonsors in CCR mode as extra info
fields.

Signed-off-by: Michael Keller <github@ike.ch>
  • Loading branch information
mikeller committed May 6, 2024
1 parent 6e65428 commit a7fb341
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions src/shearwater_predator_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -727,25 +727,31 @@ shearwater_predator_parser_cache (shearwater_predator_parser_t *parser)
dc_field_add_string_fmt(&parser->cache, "Logversion", "%d%s", logversion, pnf ? "(PNF)" : "");

// Cache sensor calibration for later use
unsigned int nsensors = 0;
unsigned int base = parser->opening[3] + (pnf ? 6 : 86);
parser->calibrated = data[base];

for (size_t i = 0; i < 3; ++i) {
unsigned int calibration = array_uint16_be(data + base + 1 + i * 2);
parser->calibration[i] = calibration / 100000.0;
if (parser->model == PREDATOR) {
// The Predator expects the mV output of the cells to be
// within 30mV to 70mV in 100% O2 at 1 atmosphere. If the
// calibration value is scaled with a factor 2.2, then the
// sensors lines up and matches the average.
parser->calibration[i] *= 2.2;
}
if (data[base] & (1 << i)) {
nsensors++;
if (parser->calibrated & (1 << i)) {
unsigned int calibration = array_uint16_be(data + base + 1 + i * 2);
parser->calibration[i] = calibration / 100000.0;
if (parser->model == PREDATOR) {
// The Predator expects the mV output of the cells to be
// within 30mV to 70mV in 100% O2 at 1 atmosphere. If the
// calibration value is scaled with a factor 2.2, then the
// sensors lines up and matches the average.
parser->calibration[i] *= 2.2;
}

static const char *name[] = {
"Sensor 1 calibration [bar / V]",
"Sensor 2 calibration [bar / V]",
"Sensor 3 calibration [bar / V]",
};
dc_field_add_string_fmt(&parser->cache, name[i], "%.2f", parser->calibration[i] * 1000);

}
}

parser->calibrated = data[base];

// Get the dive mode from the header (if available).
if (logversion >= 8) {
divemode = data[parser->opening[4] + (pnf ? 1 : 112)];
Expand Down

0 comments on commit a7fb341

Please sign in to comment.