2014-01-02 08:26:26 -05:00
|
|
|
//
|
|
|
|
// FILE: MAX31855.h
|
|
|
|
// AUTHOR: Rob Tillaart
|
2015-12-06 10:43:25 -05:00
|
|
|
// VERSION: 0.1.07
|
2014-01-02 08:26:26 -05:00
|
|
|
// PURPOSE: MAX31855 - Thermocouple
|
|
|
|
// DATE: 2014-01-01
|
|
|
|
// URL:
|
|
|
|
//
|
|
|
|
// Released to the public domain
|
|
|
|
//
|
2015-03-09 15:08:11 -04:00
|
|
|
#ifndef MAX31855_H
|
|
|
|
#define MAX31855_H
|
2014-01-02 08:26:26 -05:00
|
|
|
|
|
|
|
#if (ARDUINO < 100)
|
|
|
|
#include "WProgram.h"
|
|
|
|
#else
|
|
|
|
#include "Arduino.h"
|
|
|
|
#endif
|
|
|
|
|
2015-12-06 10:43:25 -05:00
|
|
|
#define MAX31855_VERSION "0.1.07"
|
2014-01-02 08:26:26 -05:00
|
|
|
|
|
|
|
#define STATUS_OK 0x00
|
|
|
|
#define STATUS_OPEN_CIRCUIT 0x01
|
|
|
|
#define STATUS_SHORT_TO_GND 0x02
|
|
|
|
#define STATUS_SHORT_TO_VCC 0x04
|
2015-12-06 10:40:51 -05:00
|
|
|
#define STATUS_NOREAD 0x80
|
|
|
|
|
2015-12-06 10:42:33 -05:00
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// E_TC = 61 => 41/61 = 0.6721311475
|
|
|
|
// J_TC = 52 => 41/52 = 0.7884615385
|
|
|
|
// K_TC = 41 => 41/41 = 1
|
|
|
|
// N_TC = 27 => 41/27 = 1.5185185185
|
|
|
|
// R_TC = 9 => 41/9 = 4.5555555556
|
|
|
|
// S_TC = 6 => 41/6 = 6.8333333333
|
|
|
|
// T_TC = 41 => 41/41 = 1
|
|
|
|
|
2015-12-06 10:43:25 -05:00
|
|
|
// 0.1.07 updated with numbers from the MAX31855 datasheet
|
|
|
|
#define E_TC (41.276/76.373)
|
|
|
|
#define J_TC (41.276/57.953)
|
|
|
|
#define K_TC (41.276/41.276)
|
|
|
|
#define N_TC (41.276/36.256)
|
|
|
|
#define R_TC (41.276/10.506)
|
|
|
|
#define S_TC (41.276/9.587)
|
|
|
|
#define T_TC (41.276/52.18)
|
2015-12-06 10:42:33 -05:00
|
|
|
|
2014-01-02 08:26:26 -05:00
|
|
|
|
2014-01-02 16:24:55 -05:00
|
|
|
class MAX31855
|
2014-01-02 08:26:26 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
MAX31855(uint8_t SCLK, uint8_t CS, uint8_t MISO);
|
|
|
|
void begin();
|
2015-03-09 15:08:11 -04:00
|
|
|
|
2014-01-02 08:26:26 -05:00
|
|
|
uint8_t read();
|
2014-01-24 15:15:51 -05:00
|
|
|
|
2015-12-06 10:40:51 -05:00
|
|
|
double getInternal(void) const { return _internal; };
|
|
|
|
double getTemperature(void) const { return _temperature; };
|
2015-12-06 10:42:33 -05:00
|
|
|
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; };
|
2015-12-06 10:40:51 -05:00
|
|
|
|
|
|
|
uint8_t getStatus(void) const { return _status; };
|
2014-01-24 15:15:51 -05:00
|
|
|
|
2015-12-06 10:42:33 -05:00
|
|
|
void setOffset(const double t) { _offset = t; };
|
|
|
|
double getOffset() const { return _offset; };
|
2014-01-02 08:26:26 -05:00
|
|
|
|
|
|
|
private:
|
2015-12-06 10:40:51 -05:00
|
|
|
uint32_t _read();
|
2015-03-09 15:08:11 -04:00
|
|
|
double _internal;
|
|
|
|
double _temperature;
|
2014-01-02 08:26:26 -05:00
|
|
|
uint8_t _status;
|
2015-03-09 15:08:11 -04:00
|
|
|
double _offset;
|
2014-01-02 16:24:55 -05:00
|
|
|
|
2014-01-02 08:26:26 -05:00
|
|
|
uint8_t _sclk;
|
|
|
|
uint8_t _miso;
|
|
|
|
uint8_t _cs;
|
|
|
|
};
|
|
|
|
|
2014-01-02 16:24:55 -05:00
|
|
|
#endif
|
|
|
|
|
2015-03-09 15:08:11 -04:00
|
|
|
// END OF FILE
|