0.1.8 Fix #109 incorrect constants

This commit is contained in:
RobTillaart 2018-07-05 12:35:56 +02:00
parent cc695a5499
commit f683f58969
5 changed files with 88 additions and 9 deletions

View File

@ -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;

View File

@ -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 <Arduino.h>
#endif
#define MS5611_LIB_VERSION (F("0.1.7"))
#define MS5611_LIB_VERSION (F("0.1.8"))
#define MS5611_READ_OK 0

View File

@ -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": {

View File

@ -1,5 +1,5 @@
name=MS5611
version=0.1.7
version=0.1.8
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Experimental library for MS5611 Temperature & Pressure for Arduino.

77
libraries/MS5611/todo.txt Normal file
View File

@ -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