Skip to content

Commit 1ae8c5f

Browse files
committed
0.1.06 2015-12-05 added support for other types of TC's (experimental)
1 parent 7993100 commit 1ae8c5f

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

libraries/MAX31855/MAX31855.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
//
22
// FILE: MAX31855.cpp
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.1.05
4+
// VERSION: 0.1.06
55
// PURPOSE: MAX31855 - Thermocouple
66
// DATE: 2014-01-01
77
// URL:
88
//
99
// HISTORY:
10+
// 0.1.06 2015-12-05 added support for other types of TC's (experimental)
1011
// 0.1.05 2015-07-12 refactor robust constructor
1112
// 0.1.04 2015-03-09 replaced float -> double (ARM support)
1213
// 0.1.03 fixed negative temperature
@@ -65,7 +66,7 @@ uint8_t MAX31855::read()
6566
// reserved bit 17
6667
value >>= 1;
6768

68-
// process temperature bit 18-31
69+
// process temperature bit 18-30 + sign bit = 31
6970
_temperature = (value & 0x1FFF) * 0.25;
7071
if (value & 0x2000) // negative flag
7172
{
@@ -76,6 +77,7 @@ uint8_t MAX31855::read()
7677
return _status;
7778
}
7879

80+
// TODO: optimize performance by direct port manipulation?
7981
uint32_t MAX31855::_read(void)
8082
{
8183
uint32_t value = 0;

libraries/MAX31855/MAX31855.h

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// FILE: MAX31855.h
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.1.05
4+
// VERSION: 0.1.06
55
// PURPOSE: MAX31855 - Thermocouple
66
// DATE: 2014-01-01
77
// URL:
@@ -17,14 +17,37 @@
1717
#include "Arduino.h"
1818
#endif
1919

20-
#define MAX31855_VERSION "0.1.05"
20+
#define MAX31855_VERSION "0.1.06"
2121

2222
#define STATUS_OK 0x00
2323
#define STATUS_OPEN_CIRCUIT 0x01
2424
#define STATUS_SHORT_TO_GND 0x02
2525
#define STATUS_SHORT_TO_VCC 0x04
2626
#define STATUS_NOREAD 0x80
2727

28+
// Thermocouples working is based upon Seebeck effect.
29+
// Different TC have a different Seebeck Coefficient (µV/°C)
30+
// From http://www.analog.com/library/analogDialogue/archives/44-10/thermocouple.html
31+
//
32+
// As the MAX31855 is designed for K type sensors, one can calculate
33+
// the factor needed to convert other sensors measurements.
34+
//
35+
// E_TC = 61 => 41/61 = 0.6721311475
36+
// J_TC = 52 => 41/52 = 0.7884615385
37+
// K_TC = 41 => 41/41 = 1
38+
// N_TC = 27 => 41/27 = 1.5185185185
39+
// R_TC = 9 => 41/9 = 4.5555555556
40+
// S_TC = 6 => 41/6 = 6.8333333333
41+
// T_TC = 41 => 41/41 = 1
42+
43+
#define E_TC 0.6721311475
44+
#define J_TC 0.7884615385
45+
#define K_TC 1
46+
#define N_TC 1.5185185185
47+
#define R_TC 4.5555555556
48+
#define S_TC 6.8333333333
49+
#define T_TC 1
50+
2851

2952
class MAX31855
3053
{
@@ -36,11 +59,18 @@ class MAX31855
3659

3760
double getInternal(void) const { return _internal; };
3861
double getTemperature(void) const { return _temperature; };
62+
double getTemperatureE(void)const { return _temperature * E_TC; };
63+
double getTemperatureJ(void)const { return _temperature * J_TC; };
64+
double getTemperatureK(void)const { return _temperature * K_TC; };
65+
double getTemperatureN(void)const { return _temperature * N_TC; };
66+
double getTemperatureR(void)const { return _temperature * R_TC; };
67+
double getTemperatureS(void)const { return _temperature * S_TC; };
68+
double getTemperatureT(void)const { return _temperature * T_TC; };
3969

4070
uint8_t getStatus(void) const { return _status; };
4171

42-
void setOffset(const double t) { _offset = t; };
43-
double getOffset() const { return _offset; };
72+
void setOffset(const double t) { _offset = t; };
73+
double getOffset() const { return _offset; };
4474

4575
private:
4676
uint32_t _read();

0 commit comments

Comments
 (0)