+ version 0.1.04

+ float replaced by double to support ARM
+ updated examples too
This commit is contained in:
rob tillaart 2015-03-09 20:08:11 +01:00
parent b3c0f3e85f
commit 6c78febf11
8 changed files with 109 additions and 46 deletions

View File

@ -1,12 +1,13 @@
//
// FILE: MAX31855.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.1.03
// VERSION: 0.1.04
// PURPOSE: MAX31855 - Thermocouple
// DATE: 2014-01-01
// URL:
//
// HISTORY:
// 0.1.04 2015-03-09 replaced float -> double (ARM support)
// 0.1.03 fixed negative temperature
// 0.1.02 added offset
// 0.1.01 refactored speed/performance

View File

@ -1,15 +1,15 @@
#ifndef MAX31855_H
#define MAX31855_H
//
// FILE: MAX31855.h
// AUTHOR: Rob Tillaart
// VERSION: 0.1.03
// VERSION: 0.1.04
// PURPOSE: MAX31855 - Thermocouple
// DATE: 2014-01-01
// URL:
//
// Released to the public domain
//
#ifndef MAX31855_H
#define MAX31855_H
#if (ARDUINO < 100)
#include "WProgram.h"
@ -17,7 +17,7 @@
#include "Arduino.h"
#endif
#define MAX31855_VERSION "0.1.03"
#define MAX31855_VERSION "0.1.04"
#define STATUS_OK 0x00
#define STATUS_OPEN_CIRCUIT 0x01
@ -29,22 +29,22 @@ class MAX31855
public:
MAX31855(uint8_t SCLK, uint8_t CS, uint8_t MISO);
void begin();
uint8_t read();
float getInternal(void) { return _internal; };
// Celsius
float getTemperature(void) { return _temperature; };
uint8_t getStatus(void) {return _status; };
void setOffset(float t) { _offset = t; };
float getOffset(float t) { return _offset; };
double getInternal(void) { return _internal; };
double getTemperature(void) { return _temperature; };
uint8_t getStatus(void) { return _status; };
void setOffset(double t) { _offset = t; };
double getOffset() { return _offset; };
private:
uint32_t _read();
float _internal;
float _temperature;
uint32_t _read();
double _internal;
double _temperature;
uint8_t _status;
float _offset;
double _offset;
uint8_t _sclk;
uint8_t _miso;
@ -53,4 +53,4 @@ private:
#endif
// END OF FILE
// END OF FILE

View File

@ -1,7 +1,7 @@
//
// FILE: max31855_demo.ino
// FILE: max31855_demo0.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.01
// VERSION: 0.1.02
// PURPOSE: thermocouple lib demo application
// DATE: 2014-01-01
// URL:
@ -20,7 +20,7 @@ MAX31855 tc(clPin, csPin, doPin);
void setup()
{
Serial.begin(115200);
Serial.print("Start max31855_demo: ");
Serial.print("Start max31855_demo0: ");
Serial.println(MAX31855_VERSION);
Serial.println();
@ -33,11 +33,11 @@ void loop()
Serial.print("stat:\t\t");
Serial.println(status);
float internal = tc.getInternal();
double internal = tc.getInternal();
Serial.print("internal:\t");
Serial.println(internal);
float temp = tc.getTemperature();
double temp = tc.getTemperature();
Serial.print("temperature:\t");
Serial.println(temp);
delay(1000);

View File

@ -1,7 +1,7 @@
//
// FILE: max31855_demo1.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.01
// VERSION: 0.1.02
// PURPOSE: thermocouple lib demo application
// DATE: 2014-01-02
// URL:
@ -20,7 +20,7 @@ MAX31855 tc(clPin, csPin, doPin);
void setup()
{
Serial.begin(115200);
Serial.print("Start max31855_demo: ");
Serial.print("Start max31855_demo1: ");
Serial.println(MAX31855_VERSION);
Serial.println();
@ -36,7 +36,7 @@ void loop()
Serial.println(status);
}
float temp = tc.getTemperature();
double temp = tc.getTemperature();
int m = temp*10 - 200;
Serial.print(temp);
Serial.print('\t');

View File

@ -1,7 +1,7 @@
//
// FILE: max31855_demo2.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.01
// VERSION: 0.1.02
// PURPOSE: thermocouple lib demo application
// DATE: 2014-01-02
// URL:
@ -17,25 +17,28 @@ const int clPin = 5;
MAX31855 tc(clPin, csPin, doPin);
double t1, t2;
void setup()
{
Serial.begin(115200);
Serial.print("Start max31855_demo: ");
Serial.print("Start max31855_demo2: ");
Serial.println(MAX31855_VERSION);
Serial.println();
tc.begin();
tc.read();
t1 = tc.getTemperature();
delay(1000);
}
void loop()
{
float t1 = tc.getTemperature();
delay(1000);
tc.read();
float t2 = tc.getTemperature();
t2 = tc.getTemperature();
Serial.print("delta:\t");
Serial.println(t2-t1, 2);
t1 = t2;
delay(1000);
}

View File

@ -1,7 +1,7 @@
//
// FILE: max31855_demo3.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.01
// VERSION: 0.1.02
// PURPOSE: thermocouple lib demo application
// DATE: 2014-01-02
// URL:
@ -27,19 +27,19 @@ void setup()
tc.begin();
uint32_t start = micros();
for (int i=0; i< 10; i++) tc.read();
tc.read();
uint32_t stop = micros();
Serial.print("10x read:\t");
Serial.print("read:\t");
Serial.println(stop - start);
start = micros();
float t1 = tc.getTemperature();
double t1 = tc.getTemperature();
stop = micros();
Serial.print("getTemperature:\t");
Serial.println(stop - start);
start = micros();
float t2 = tc.getInternal();
tc.getInternal();
stop = micros();
Serial.print("getInternal:\t");
Serial.println(stop - start);
@ -49,7 +49,7 @@ void setup()
Serial.println(t2, 2);
Serial.println();
}
void loop()
{
// this loop returns multiples of about 73mSec (counter multiples of ~143)
@ -75,10 +75,4 @@ void loop()
Serial.println(t1, 2);
Serial.println();
}

View File

@ -1,7 +1,7 @@
//
// FILE: max31855_demo4.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.00
// VERSION: 0.1.01
// PURPOSE: thermocouple lib demo application
// DATE: 2014-01-02
// URL:
@ -34,20 +34,25 @@ void setup()
start = micros();
float t1 = tc.getTemperature();
double t1 = tc.getTemperature();
stop = micros();
Serial.print("getTemperature:\t");
Serial.println(stop - start);
Serial.println(t1, 2);
Serial.println();
start = micros();
tc.setOffset(2.0);
stop = micros();
Serial.print("setOffset:\t");
Serial.println(stop - start);
start = micros();
tc.getOffset();
stop = micros();
Serial.print("getOffset:\t");
Serial.println(stop - start);
tc.read();
start = micros();
t1 = tc.getTemperature();
@ -59,7 +64,7 @@ void setup()
start = micros();
float t2 = tc.getInternal();
double t2 = tc.getInternal();
stop = micros();
Serial.print("getInternal:\t");
Serial.println(stop - start);

View File

@ -0,0 +1,60 @@
//
// FILE: max31855_demo5.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.00
// PURPOSE: thermocouple lib demo application
// DATE: 2014-01-02
// URL:
//
// 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_demo5: ");
Serial.println(MAX31855_VERSION);
Serial.println();
tc.begin();
tc.read();
double t1 = tc.getTemperature();
Serial.print(" temp before:\t");
Serial.println(t1, 2);
double o = tc.getOffset();
Serial.print("offset before:\t");
Serial.println(o, 2);
tc.setOffset(3.14);
o = tc.getOffset();
Serial.print(" offset after:\t");
Serial.println(o, 2);
tc.read();
double t2 = tc.getTemperature();
Serial.print(" temp after:\t");
Serial.println(t1, 2);
Serial.print(" temp delta:\t");
Serial.println(abs(t1 - t2), 2);
Serial.println("\ndone...");
}
void loop()
{
}