mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.1.08 2015-12-06 replaced all temperature calls with one TCfactor
+ update demos + new demo for TCfactor
This commit is contained in:
parent
39945003d6
commit
fcf6bd9cd1
@ -1,12 +1,13 @@
|
||||
//
|
||||
// FILE: MAX31855.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.07
|
||||
// VERSION: 0.1.08
|
||||
// PURPOSE: MAX31855 - Thermocouple
|
||||
// DATE: 2014-01-01
|
||||
// URL:
|
||||
// URL: http://forum.arduino.cc/index.php?topic=208061
|
||||
//
|
||||
// HISTORY:
|
||||
// 0.1.08 2015-12-06 replaced all temperature calls with one TCfactor + update demos.
|
||||
// 0.1.07 2015-12-06 updated TC factors from the MAX31855 datasheet
|
||||
// 0.1.06 2015-12-05 added support for other types of TC's (experimental)
|
||||
// 0.1.05 2015-07-12 refactor robust constructor
|
||||
@ -27,6 +28,7 @@ MAX31855::MAX31855(uint8_t sclk, uint8_t cs, uint8_t miso)
|
||||
_cs = cs;
|
||||
_miso = miso;
|
||||
_offset = 0;
|
||||
_TCfactor = 1;
|
||||
_status = STATUS_NOREAD;
|
||||
_temperature = -999;
|
||||
_internal = -999;
|
||||
|
@ -1,10 +1,10 @@
|
||||
//
|
||||
// FILE: MAX31855.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.07
|
||||
// VERSION: 0.1.08
|
||||
// PURPOSE: MAX31855 - Thermocouple
|
||||
// DATE: 2014-01-01
|
||||
// URL:
|
||||
// URL: http://forum.arduino.cc/index.php?topic=208061
|
||||
//
|
||||
// Released to the public domain
|
||||
//
|
||||
@ -17,7 +17,7 @@
|
||||
#include "Arduino.h"
|
||||
#endif
|
||||
|
||||
#define MAX31855_VERSION "0.1.07"
|
||||
#define MAX31855_VERSION "0.1.08"
|
||||
|
||||
#define STATUS_OK 0x00
|
||||
#define STATUS_OPEN_CIRCUIT 0x01
|
||||
@ -28,10 +28,11 @@
|
||||
// Thermocouples working is based upon Seebeck effect.
|
||||
// Different TC have a different Seebeck Coefficient (µV/°C)
|
||||
// From http://www.analog.com/library/analogDialogue/archives/44-10/thermocouple.html
|
||||
//
|
||||
//
|
||||
// As the MAX31855 is designed for K type sensors, one can calculate
|
||||
// the factor needed to convert other sensors measurements.
|
||||
//
|
||||
// note this is only a linear approximation.
|
||||
//
|
||||
// E_TC = 61 => 41/61 = 0.6721311475
|
||||
// J_TC = 52 => 41/52 = 0.7884615385
|
||||
// K_TC = 41 => 41/41 = 1
|
||||
@ -59,26 +60,23 @@ public:
|
||||
uint8_t read();
|
||||
|
||||
double getInternal(void) const { return _internal; };
|
||||
double getTemperature(void) const { return _temperature; };
|
||||
double getTemperatureE(void)const { return _temperature * E_TC; };
|
||||
double getTemperatureJ(void)const { return _temperature * J_TC; };
|
||||
double getTemperatureK(void)const { return _temperature * K_TC; };
|
||||
double getTemperatureN(void)const { return _temperature * N_TC; };
|
||||
double getTemperatureR(void)const { return _temperature * R_TC; };
|
||||
double getTemperatureS(void)const { return _temperature * S_TC; };
|
||||
double getTemperatureT(void)const { return _temperature * T_TC; };
|
||||
double getTemperature(void) const { return _temperature * _TCfactor; }
|
||||
|
||||
uint8_t getStatus(void) const { return _status; };
|
||||
|
||||
void setOffset(const double t) { _offset = t; };
|
||||
double getOffset() const { return _offset; };
|
||||
|
||||
void setTCfactor(const double TCfactor) { _TCfactor = TCfactor; };
|
||||
double getTCfactor() const { return _TCfactor; };
|
||||
|
||||
private:
|
||||
uint32_t _read();
|
||||
double _internal;
|
||||
double _temperature;
|
||||
uint8_t _status;
|
||||
double _offset;
|
||||
double _TCfactor;
|
||||
|
||||
uint8_t _sclk;
|
||||
uint8_t _miso;
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// FILE: max31855_demo3.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.02
|
||||
// VERSION: 0.1.03
|
||||
// PURPOSE: thermocouple lib demo application
|
||||
// DATE: 2014-01-02
|
||||
// URL:
|
||||
@ -55,8 +55,8 @@ void loop()
|
||||
// this loop returns multiples of about 73mSec (counter multiples of ~143)
|
||||
// so the # measurements per second is about 14?
|
||||
uint32_t counter = 0;
|
||||
float t1 = tc.getTemperature();
|
||||
float t2 = t1;
|
||||
double t1 = tc.getTemperature();
|
||||
double t2 = t1;
|
||||
|
||||
uint32_t start = micros();
|
||||
while (t2 == t1)
|
||||
|
@ -1,10 +1,10 @@
|
||||
//
|
||||
// FILE: max31855_demo5.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.00
|
||||
// VERSION: 0.1.01
|
||||
// PURPOSE: thermocouple lib demo application
|
||||
// DATE: 2014-01-02
|
||||
// URL:
|
||||
// URL: http://forum.arduino.cc/index.php?topic=208061
|
||||
//
|
||||
// Released to the public domain
|
||||
//
|
||||
@ -42,7 +42,7 @@ void setup()
|
||||
tc.read();
|
||||
double t2 = tc.getTemperature();
|
||||
Serial.print(" temp after:\t");
|
||||
Serial.println(t1, 2);
|
||||
Serial.println(t2, 2);
|
||||
|
||||
Serial.print(" temp delta:\t");
|
||||
Serial.println(abs(t1 - t2), 2);
|
||||
|
@ -0,0 +1,56 @@
|
||||
//
|
||||
// FILE: max31855_demo6.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.00
|
||||
// PURPOSE: thermocouple lib demo TCfactor
|
||||
// DATE: 2015-12-06
|
||||
// URL: http://forum.arduino.cc/index.php?topic=208061
|
||||
//
|
||||
// Released to the public domain
|
||||
//
|
||||
|
||||
#include "MAX31855.h"
|
||||
|
||||
const int doPin = 7;
|
||||
const int csPin = 6;
|
||||
const int clPin = 5;
|
||||
|
||||
MAX31855 tc(clPin, csPin, doPin);
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.print("Start max31855_demo6: ");
|
||||
Serial.println(MAX31855_VERSION);
|
||||
Serial.println();
|
||||
|
||||
tc.begin();
|
||||
tc.read();
|
||||
double t1 = tc.getTemperature();
|
||||
Serial.print(" temp before:\t");
|
||||
Serial.println(t1, 2);
|
||||
|
||||
double tcf = tc.getTCfactor();
|
||||
Serial.print("TCfactor before:\t");
|
||||
Serial.println(tcf, 4);
|
||||
|
||||
Serial.println("\nDefault adjust for J-type ThermoCouple");
|
||||
tc.setTCfactor(J_TC);
|
||||
tcf = tc.getTCfactor();
|
||||
Serial.print(" TCfactor after:\t");
|
||||
Serial.println(tcf, 4);
|
||||
|
||||
tc.read();
|
||||
double t2 = tc.getTemperature();
|
||||
Serial.print(" temp after:\t");
|
||||
Serial.println(t2, 2);
|
||||
|
||||
Serial.print(" temp delta:\t");
|
||||
Serial.println(abs(t1 - t2), 2);
|
||||
|
||||
Serial.println("\ndone...");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user