From f683f5896964dbdadbd70f636b43bd1d5088be6e Mon Sep 17 00:00:00 2001 From: RobTillaart Date: Thu, 5 Jul 2018 12:35:56 +0200 Subject: [PATCH] 0.1.8 Fix #109 incorrect constants --- libraries/MS5611/MS5611.cpp | 12 +++-- libraries/MS5611/MS5611.h | 4 +- libraries/MS5611/library.json | 2 +- libraries/MS5611/library.properties | 2 +- libraries/MS5611/todo.txt | 77 +++++++++++++++++++++++++++++ 5 files changed, 88 insertions(+), 9 deletions(-) create mode 100644 libraries/MS5611/todo.txt diff --git a/libraries/MS5611/MS5611.cpp b/libraries/MS5611/MS5611.cpp index c7b529b2..f0e66942 100644 --- a/libraries/MS5611/MS5611.cpp +++ b/libraries/MS5611/MS5611.cpp @@ -2,11 +2,12 @@ // FILE: MS5611.cpp // AUTHOR: Rob Tillaart // Erni - testing/fixes -// VERSION: 0.1.7 +// VERSION: 0.1.8 // PURPOSE: MS5611 Temperature & Humidity library for Arduino // URL: // // HISTORY: +// 0.1.8 fix #109 incorrect constants (thanks to flauth) // 0.1.7 revert double to float (issue 33) // 0.1.6 2015-07-12 refactor // 0.1.05 moved 6 float multiplies to init [adds ~70 bytes !!!] @@ -92,15 +93,16 @@ int MS5611::read(uint8_t bits) float sens = C[1] + dT * C[3]; // SECOND ORDER COMPENSATION - PAGE 8/20 - // COMMENT OUT < 20 CORRECTION IF NOT NEEDED - if (_temperature < 20) + // COMMENT OUT < 2000 CORRECTION IF NOT NEEDED + // NOTE TEMPERATURE IS IN 0.01 C + if (_temperature < 2000) { float T2 = dT * dT * 4.6566128731E-10; float t = _temperature - 2000; float offset2 = 2.5 * t * t; float sens2 = 1.25 * t * t * t; - // COMMENT OUT < -15 CORRECTION IF NOT NEEDED - if (_temperature < -15) + // COMMENT OUT < -1500 CORRECTION IF NOT NEEDED + if (_temperature < -1500) { t = _temperature + 1500; t = t * t; diff --git a/libraries/MS5611/MS5611.h b/libraries/MS5611/MS5611.h index 9b7b55a7..9b6a9c2d 100644 --- a/libraries/MS5611/MS5611.h +++ b/libraries/MS5611/MS5611.h @@ -2,7 +2,7 @@ // FILE: MS5611.h // AUTHOR: Rob Tillaart // Erni - testing/fixes -// VERSION: 0.1.7 +// VERSION: 0.1.8 // PURPOSE: MS5611 Temperature & Pressure library for Arduino // URL: // @@ -19,7 +19,7 @@ #include #endif -#define MS5611_LIB_VERSION (F("0.1.7")) +#define MS5611_LIB_VERSION (F("0.1.8")) #define MS5611_READ_OK 0 diff --git a/libraries/MS5611/library.json b/libraries/MS5611/library.json index 0551de40..93e8d854 100644 --- a/libraries/MS5611/library.json +++ b/libraries/MS5611/library.json @@ -18,7 +18,7 @@ "type": "git", "url": "https://github.com/RobTillaart/Arduino.git" }, - "version":"0.1.7", + "version":"0.1.8", "frameworks": "arduino", "platforms": "*", "export": { diff --git a/libraries/MS5611/library.properties b/libraries/MS5611/library.properties index f4585147..11250b5a 100644 --- a/libraries/MS5611/library.properties +++ b/libraries/MS5611/library.properties @@ -1,5 +1,5 @@ name=MS5611 -version=0.1.7 +version=0.1.8 author=Rob Tillaart maintainer=Rob Tillaart sentence=Experimental library for MS5611 Temperature & Pressure for Arduino. diff --git a/libraries/MS5611/todo.txt b/libraries/MS5611/todo.txt new file mode 100644 index 00000000..ed11e8c5 --- /dev/null +++ b/libraries/MS5611/todo.txt @@ -0,0 +1,77 @@ + +http://forum.arduino.cc/index.php?topic=272402.msg1923962#new + +TODO's +- none +DHT11 blauwe testen .... + +DONE +====================== +- there are many delay()'s still in the library and these should be removed if possible or at least minimized. +- the PRE1.0 Arduino support needs still to be implemented. Or removed completely. +- test test test test test and .... + +Remark Erni +============ +int64_t offset = (unsigned long)C[2] * 65536L + (C[4] * dT ) / 128L; + + +OPtimiize +============ + uint16_t C[8] = { 80, 53513, 56427, 32594, 31335, 31612, 27894, 45785}; + uint32_t D1 = 7909856L; + uint32_t D2 = 8246240L; + + + int32_t dT = D2 - C[5] * 256L; + int32_t temp = 2000 + (dT * C[6])/8388608L; + + int64_t offset = C[2] * 65536L+ (C[4] * dT ) / 128L; + int64_t sens = C[1] * 32768L + (C[3] * dT ) / 256L; + int32_t P = ((D1 * sens)/2097152L - offset) / 32768L; + + + Port open +MS5611 test version: 0.0.00 +reset: 0 +0 50 80 +0 D109 53513 +0 DC6B 56427 +0 7F52 32594 +0 7A67 31335 +0 7B7C 31612 +0 6CF6 27894 +0 B2D9 45785 +convD1: 0 +7909856 +convD2: 0 +8246240 + + +float is 40% faster 168 versus 296 == 130 uSec. +test sketch size, RAM +int64 => 7220, 476 +float => 6522, 476 + +==> scheelt 700 bytes. + + + dT = D2 - C[5] * 256L; + int16_t T2 = 2000 + (dT * C[6]) /8388608L; + + float offset2 = C[2] * 65536.0 + (C[4] * dT ) / 128.0; + float sens2 = C[1] * 32768.0 + (C[3] * dT ) / 256.0; + uint32_t P2 = ((D1 * sens2)/2097152.0 - offset2) / 32768.0; + + +Start +296 +153568 +1999 +89177 + +168 +153568 +1999 +89177 +