Skip to content

Commit

Permalink
Smaller frame for CTD-10 and w/o precision loss
Browse files Browse the repository at this point in the history
Issues #9 and #50
  • Loading branch information
jdavid committed May 17, 2019
1 parent 42b3ff8 commit 5335dd8
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ Create symbolic links to the libraries needed:
# Contents

See the README files within the libraries and sketches folders for a
drescription of the libraries and sketches.
description of the libraries and sketches.
34 changes: 34 additions & 0 deletions docs/sensors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

This page documents the sensors from a data point of view. We're intersted in
three aspects:

1. How the information is read from the sensors: range, resolution and unit.
2. How the information is saved and sent in the frames.
3. How the information is stored in the server.

Unless stated otherwise 1. and 3. are the same.

The information may be transformed for transport. Here we try to avoid floats
and use only integer, for two purposes:

- Reduce the frame size, see issue #50
- Avoid accuracy errors, see issue #9

Eventually the information contained here may be used for more efficient
storage in the server as well.

The ranges are taken from the sensor specifications, and are used to determine
the type to use in the frame. However we have observed sometimes values not
within the specified range, so it's best to analyze first the real data we've.


CTD-10
========================================================================

| | Depth | Temp | BEC |
| ---------------- | -----------:| ------------:| ----------:|
| Input (example) | +542 | +22.3 | +645 |
| Range (spec) | 0 : 10000 | -11.0 : 49.0 | 0 : 120000 |
| Range (read) | -13 : 3959 | -0.3 : 31.0 | 0 : 1330 |
| Transport (type) | int16 | int16 | int32 |
| Transform | | x10 | |
2 changes: 1 addition & 1 deletion libraries/WaspUIO/WaspUIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,6 @@ CR_TASK(taskSlow);
#define SENSOR_BAT 52
#define SENSOR_GPS 53
#define SENSOR_TST 123
#define SENSOR_CTD10 200
#define SENSOR_DS18B20 203
#define SENSOR_GPS_ACCURACY 205
#define SENSOR_VOLTS 206
Expand All @@ -610,5 +609,6 @@ CR_TASK(taskSlow);
#define SENSOR_VL53L1X 213
#define SENSOR_MB73XX 214
#define SENSOR_ATMOS 215
#define SENSOR_CTD10 216

#endif
38 changes: 23 additions & 15 deletions libraries/WaspUIO/frames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const char frame_format_n [] PROGMEM = "n";
const char frame_format_fffuf [] PROGMEM = "fffuf";
const char frame_format_ffffff[] PROGMEM = "ffffff";
const char frame_format_uf [] PROGMEM = "uf";
const char frame_format_jjk [] PROGMEM = "jjk";

const char* const FRAME_FORMAT_TABLE[] PROGMEM = {
null, null, null, null, null, null, null, null, null, null, // 00x
Expand All @@ -46,10 +47,10 @@ const char* const FRAME_FORMAT_TABLE[] PROGMEM = {
null, null, null, null, null, null,
// 07x
null, null, null, null,
null, // 74 Reserved, was BME temperature
null, // 74 Reserved (was BME temperature)
null,
null, // 76 Reserved, was BME humidity
null, // 77 Reserved, was BME pressure
null, // 76 Reserved (was BME humidity)
null, // 77 Reserved (was BME pressure)
null, null,
null, null, null, null, null, null, null, null, null, null, // 08x
// 09x
Expand All @@ -70,11 +71,11 @@ const char* const FRAME_FORMAT_TABLE[] PROGMEM = {
null, null, null, null, null, null, null, null, null, null, // 18x
null, null, null, null, null, null, null, null, null, null, // 19x
// 20x
frame_format_fff, // 200 CTD-10
null, // 201 Reserved, do not reuse (was 201 DS-2 1)
null, // 202 Reserved, do not reuse (was 201 DS-2 2)
null , // 200 Reserved (was CTD-10)
null, // 201 Reserved (was 201 DS-2 1)
null, // 202 Reserved (was 201 DS-2 2)
frame_format_n, // 203 DS18B20
null, // 204 Reserved, do not reuse (was MB73XX)
null, // 204 Reserved (was MB73XX)
frame_format_uf, // 205 GPS number of satellites and accuracy
frame_format_f, // 206 Battery Volts
frame_format_fffuf, // 207 WS100-UMB
Expand All @@ -86,6 +87,7 @@ const char* const FRAME_FORMAT_TABLE[] PROGMEM = {
frame_format_n, // 213 VL53L1X
frame_format_n, // 214 MB73XX
frame_format_ffffff, // 215 ATMOS-22
frame_format_jjk, // 216 CTD-10
};

const char frame_name_bat [] PROGMEM = "BAT";
Expand All @@ -94,7 +96,6 @@ const char frame_name_rssi [] PROGMEM = "RSSI";
const char frame_name_acc [] PROGMEM = "ACC";
const char frame_name_altitude [] PROGMEM = "ALT";
const char frame_name_tst [] PROGMEM = "TST";
const char frame_name_ctd10 [] PROGMEM = "CTD10";
const char frame_name_ds18b20 [] PROGMEM = "DS18B20";
const char frame_name_gps_accuracy[] PROGMEM = "GPS Accuracy";
const char frame_name_bat_volts [] PROGMEM = "BAT VOLTS";
Expand All @@ -107,6 +108,7 @@ const char frame_name_tmp [] PROGMEM = "TMP";
const char frame_name_vl [] PROGMEM = "VL";
const char frame_name_mb73xx [] PROGMEM = "MB73XX";
const char frame_name_atmos [] PROGMEM = "ATMOS";
const char frame_name_ctd10 [] PROGMEM = "CTD10";

const char* const FRAME_NAME_TABLE[] PROGMEM=
{
Expand All @@ -127,10 +129,10 @@ const char* const FRAME_NAME_TABLE[] PROGMEM=
null, null, null, null, null, null,
// 07x
null, null, null, null,
null, // 74 Reserved, was BME temperature
null, // 74 Reserved (was BME temperature)
null,
null, // 76 Reserved, was BME humidity
null, // 77 Reserved, was BME pressure
null, // 76 Reserved (was BME humidity)
null, // 77 Reserved (was BME pressure)
null, null,
null, null, null, null, null, null, null, null, null, null, // 08x
// 09x
Expand All @@ -151,11 +153,11 @@ const char* const FRAME_NAME_TABLE[] PROGMEM=
null, null, null, null, null, null, null, null, null, null, // 18x
null, null, null, null, null, null, null, null, null, null, // 19x
// 20x
frame_name_ctd10, // 200 CTD-10
null, // 201 Reserved, do not reuse (was 201 DS-2 1)
null, // 202 Reserved, do not reuse (was 201 DS-2 2)
null, // 200 Reserved (was CTD-10)
null, // 201 Reserved (was DS-2 1)
null, // 202 Reserved (was DS-2 2)
frame_name_ds18b20, // 203 DS18B20
null, // 204 Reserved, do not reuse (was MB73XX)
null, // 204 Reserved (was MB73XX)
frame_name_gps_accuracy, // 205 GPS Accuracy
frame_name_bat_volts, // 206 Battery Volts
frame_name_ws100, // 207 WS100-UMB
Expand All @@ -168,6 +170,7 @@ const char* const FRAME_NAME_TABLE[] PROGMEM=
frame_name_vl, // 213 VL53L1X
frame_name_mb73xx, // 214 MB73XX
frame_name_atmos, // 215 ATMOS-22
frame_name_ctd10, // 216 CTD-10
};

/**
Expand Down Expand Up @@ -537,6 +540,11 @@ void WaspUIO::showFrame(uint8_t *p)
cr.println(F("Sensor %d (%s): %d"), type, name, *(int16_t *)p);
p += 2; nbytes -= 2;
}
else if (c == 'k')
{
cr.println(F("Sensor %d (%s): %d"), type, name, *(int32_t *)p);
p += 4; nbytes -= 4;
}
else if (c == 'u')
{
cr.println(F("Sensor %d (%s): %d"), type, name, *p++);
Expand Down
2 changes: 1 addition & 1 deletion libraries/WaspUIO/sdi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ CR_TASK(taskSdiCtd10)
a = strtod(sdi.buffer+1, &next);
b = strtod(next, &next);
c = strtod(next, &next);
ADD_SENSOR(SENSOR_CTD10, a, b, c);
ADD_SENSOR(SENSOR_CTD10, (int16_t)a, (int16_t)(b*10), (int32_t)c);

// Success
CR_END;
Expand Down

0 comments on commit 5335dd8

Please sign in to comment.