Replace the constant offset with a scaling factor

Correcting the Predator calibration value with a scaling factor produces
even more reasonable ppO2 values compared to using a constant offset.
The scaling factor of 2.2 is based on a linear regression between the
average ppO2 reported by the dive computer, and the average ppO2
calculated over all (calibrated) sensors using the raw calibration
value.

Reviewed-by: Anton Lundin <glance@acc.umu.se>
This commit is contained in:
Jef Driesen 2017-04-13 21:26:56 +02:00
parent fe2d128b44
commit 7e7cbd55b1

View File

@ -65,7 +65,7 @@ struct shearwater_predator_parser_t {
unsigned int ngasmixes;
unsigned int oxygen[NGASMIXES];
unsigned int helium[NGASMIXES];
unsigned int calibration[3];
double calibration[3];
dc_divemode_t mode;
};
@ -288,17 +288,17 @@ shearwater_predator_parser_cache (shearwater_predator_parser_t *parser)
}
// Cache sensor calibration for later use
parser->calibration[0] = array_uint16_be(data + 87);
parser->calibration[1] = array_uint16_be(data + 89);
parser->calibration[2] = array_uint16_be(data + 91);
parser->calibration[0] = array_uint16_be(data + 87) / 100000.0;
parser->calibration[1] = array_uint16_be(data + 89) / 100000.0;
parser->calibration[2] = array_uint16_be(data + 91) / 100000.0;
// The Predator expects the mV output of the cells to be within 30mV
// to 70mV in 100% O2 at 1 atmosphere.
// If we add 1024 (1000?) to the calibration value, then the sensors
// lines up and matches the average.
// If the calibration value is scaled with a factor 2.2, then the
// sensors lines up and matches the average.
if (parser->model == PREDATOR) {
parser->calibration[0] += 1024;
parser->calibration[1] += 1024;
parser->calibration[2] += 1024;
for (size_t i = 0; i < 3; ++i) {
parser->calibration[i] *= 2.2;
}
}
// Cache the data for later use.
@ -448,14 +448,15 @@ shearwater_predator_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal
sample.ppo2 = data[offset + 6] / 100.0;
if (callback) callback (DC_SAMPLE_PPO2, sample, userdata);
#else
sample.ppo2 = data[offset + 12] * parser->calibration[0] / 100000.0;
sample.ppo2 = data[offset + 12] * parser->calibration[0];
if (callback && (data[86] & 0x01)) callback (DC_SAMPLE_PPO2, sample, userdata);
sample.ppo2 = data[offset + 14] * parser->calibration[1] / 100000.0;
sample.ppo2 = data[offset + 14] * parser->calibration[1];
if (callback && (data[86] & 0x02)) callback (DC_SAMPLE_PPO2, sample, userdata);
sample.ppo2 = data[offset + 15] * parser->calibration[2] / 100000.0;
sample.ppo2 = data[offset + 15] * parser->calibration[2];
if (callback && (data[86] & 0x04)) callback (DC_SAMPLE_PPO2, sample, userdata);
}
#endif
// Setpoint