From fe2d128b4453903ffb61feb0c10cbc69e9f3b81e Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Thu, 13 Apr 2017 21:26:56 +0200 Subject: [PATCH] Apply the calibration correction only for the Predator The calibration values for the Petrel are typically in the range 1600 to 2400, while for Predator they are much smaller, with values in the range 800 to 1400. The consequence is that the calculated ppO2 values are too low for the Predator. Adding a constant offset of about 1000 changes the calibration value to be in approximately the same range as the Petrel, and hence more reasonable ppO2 values. But this correction should only be applied for the Predator, and not the Petrel. Reviewed-by: Anton Lundin --- src/parser.c | 4 ++-- src/shearwater_petrel.h | 2 +- src/shearwater_predator.h | 2 +- src/shearwater_predator_parser.c | 23 +++++++++++++++-------- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/parser.c b/src/parser.c index 98d2c89..9fdb1a9 100644 --- a/src/parser.c +++ b/src/parser.c @@ -149,10 +149,10 @@ dc_parser_new_internal (dc_parser_t **out, dc_context_t *context, dc_family_t fa rc = atomics_cobalt_parser_create (&parser, context); break; case DC_FAMILY_SHEARWATER_PREDATOR: - rc = shearwater_predator_parser_create (&parser, context); + rc = shearwater_predator_parser_create (&parser, context, model); break; case DC_FAMILY_SHEARWATER_PETREL: - rc = shearwater_petrel_parser_create (&parser, context); + rc = shearwater_petrel_parser_create (&parser, context, model); break; case DC_FAMILY_DIVERITE_NITEKQ: rc = diverite_nitekq_parser_create (&parser, context); diff --git a/src/shearwater_petrel.h b/src/shearwater_petrel.h index 8b927d6..c23bb74 100644 --- a/src/shearwater_petrel.h +++ b/src/shearwater_petrel.h @@ -34,7 +34,7 @@ dc_status_t shearwater_petrel_device_open (dc_device_t **device, dc_context_t *context, const char *name); dc_status_t -shearwater_petrel_parser_create (dc_parser_t **parser, dc_context_t *context); +shearwater_petrel_parser_create (dc_parser_t **parser, dc_context_t *context, unsigned int model); #ifdef __cplusplus } diff --git a/src/shearwater_predator.h b/src/shearwater_predator.h index f21d445..4665f80 100644 --- a/src/shearwater_predator.h +++ b/src/shearwater_predator.h @@ -34,7 +34,7 @@ dc_status_t shearwater_predator_device_open (dc_device_t **device, dc_context_t *context, const char *name); dc_status_t -shearwater_predator_parser_create (dc_parser_t **parser, dc_context_t *context); +shearwater_predator_parser_create (dc_parser_t **parser, dc_context_t *context, unsigned int model); #ifdef __cplusplus } diff --git a/src/shearwater_predator_parser.c b/src/shearwater_predator_parser.c index 7c36651..58d1704 100644 --- a/src/shearwater_predator_parser.c +++ b/src/shearwater_predator_parser.c @@ -48,10 +48,14 @@ #define NGASMIXES 10 +#define PREDATOR 2 +#define PETREL 3 + typedef struct shearwater_predator_parser_t shearwater_predator_parser_t; struct shearwater_predator_parser_t { dc_parser_t base; + unsigned int model; unsigned int petrel; unsigned int samplesize; // Cached fields. @@ -106,7 +110,7 @@ shearwater_predator_find_gasmix (shearwater_predator_parser_t *parser, unsigned static dc_status_t -shearwater_common_parser_create (dc_parser_t **out, dc_context_t *context, unsigned int petrel) +shearwater_common_parser_create (dc_parser_t **out, dc_context_t *context, unsigned int model, unsigned int petrel) { shearwater_predator_parser_t *parser = NULL; const dc_parser_vtable_t *vtable = NULL; @@ -131,6 +135,7 @@ shearwater_common_parser_create (dc_parser_t **out, dc_context_t *context, unsig } // Set the default values. + parser->model = model; parser->petrel = petrel; parser->samplesize = samplesize; parser->cached = 0; @@ -150,16 +155,16 @@ shearwater_common_parser_create (dc_parser_t **out, dc_context_t *context, unsig dc_status_t -shearwater_predator_parser_create (dc_parser_t **out, dc_context_t *context) +shearwater_predator_parser_create (dc_parser_t **out, dc_context_t *context, unsigned int model) { - return shearwater_common_parser_create (out, context, 0); + return shearwater_common_parser_create (out, context, model, 0); } dc_status_t -shearwater_petrel_parser_create (dc_parser_t **out, dc_context_t *context) +shearwater_petrel_parser_create (dc_parser_t **out, dc_context_t *context, unsigned int model) { - return shearwater_common_parser_create (out, context, 1); + return shearwater_common_parser_create (out, context, model, 1); } @@ -290,9 +295,11 @@ shearwater_predator_parser_cache (shearwater_predator_parser_t *parser) // 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. - parser->calibration[0] += 1024; - parser->calibration[1] += 1024; - parser->calibration[2] += 1024; + if (parser->model == PREDATOR) { + parser->calibration[0] += 1024; + parser->calibration[1] += 1024; + parser->calibration[2] += 1024; + } // Cache the data for later use. parser->headersize = headersize;