Skip to content

Commit 6c78feb

Browse files
committed
+ version 0.1.04
+ float replaced by double to support ARM + updated examples too
1 parent b3c0f3e commit 6c78feb

File tree

8 files changed

+109
-46
lines changed

8 files changed

+109
-46
lines changed

libraries/MAX31855/MAX31855.cpp

Lines changed: 2 additions & 1 deletion
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.03
4+
// VERSION: 0.1.04
55
// PURPOSE: MAX31855 - Thermocouple
66
// DATE: 2014-01-01
77
// URL:
88
//
99
// HISTORY:
10+
// 0.1.04 2015-03-09 replaced float -> double (ARM support)
1011
// 0.1.03 fixed negative temperature
1112
// 0.1.02 added offset
1213
// 0.1.01 refactored speed/performance

libraries/MAX31855/MAX31855.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
#ifndef MAX31855_H
2-
#define MAX31855_H
31
//
42
// FILE: MAX31855.h
53
// AUTHOR: Rob Tillaart
6-
// VERSION: 0.1.03
4+
// VERSION: 0.1.04
75
// PURPOSE: MAX31855 - Thermocouple
86
// DATE: 2014-01-01
97
// URL:
108
//
119
// Released to the public domain
1210
//
11+
#ifndef MAX31855_H
12+
#define MAX31855_H
1313

1414
#if (ARDUINO < 100)
1515
#include "WProgram.h"
1616
#else
1717
#include "Arduino.h"
1818
#endif
1919

20-
#define MAX31855_VERSION "0.1.03"
20+
#define MAX31855_VERSION "0.1.04"
2121

2222
#define STATUS_OK 0x00
2323
#define STATUS_OPEN_CIRCUIT 0x01
@@ -29,22 +29,22 @@ class MAX31855
2929
public:
3030
MAX31855(uint8_t SCLK, uint8_t CS, uint8_t MISO);
3131
void begin();
32+
3233
uint8_t read();
33-
float getInternal(void) { return _internal; };
34-
// Celsius
35-
float getTemperature(void) { return _temperature; };
36-
uint8_t getStatus(void) {return _status; };
3734

38-
void setOffset(float t) { _offset = t; };
39-
float getOffset(float t) { return _offset; };
35+
double getInternal(void) { return _internal; };
36+
double getTemperature(void) { return _temperature; };
37+
uint8_t getStatus(void) { return _status; };
4038

39+
void setOffset(double t) { _offset = t; };
40+
double getOffset() { return _offset; };
4141

4242
private:
43-
uint32_t _read();
44-
float _internal;
45-
float _temperature;
43+
uint32_t _read();
44+
double _internal;
45+
double _temperature;
4646
uint8_t _status;
47-
float _offset;
47+
double _offset;
4848

4949
uint8_t _sclk;
5050
uint8_t _miso;
@@ -53,4 +53,4 @@ class MAX31855
5353

5454
#endif
5555

56-
// END OF FILE
56+
// END OF FILE

libraries/MAX31855/examples/max31855_demo0/max31855_demo0.ino

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
2-
// FILE: max31855_demo.ino
2+
// FILE: max31855_demo0.ino
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.1.01
4+
// VERSION: 0.1.02
55
// PURPOSE: thermocouple lib demo application
66
// DATE: 2014-01-01
77
// URL:
@@ -20,7 +20,7 @@ MAX31855 tc(clPin, csPin, doPin);
2020
void setup()
2121
{
2222
Serial.begin(115200);
23-
Serial.print("Start max31855_demo: ");
23+
Serial.print("Start max31855_demo0: ");
2424
Serial.println(MAX31855_VERSION);
2525
Serial.println();
2626

@@ -33,11 +33,11 @@ void loop()
3333
Serial.print("stat:\t\t");
3434
Serial.println(status);
3535

36-
float internal = tc.getInternal();
36+
double internal = tc.getInternal();
3737
Serial.print("internal:\t");
3838
Serial.println(internal);
3939

40-
float temp = tc.getTemperature();
40+
double temp = tc.getTemperature();
4141
Serial.print("temperature:\t");
4242
Serial.println(temp);
4343
delay(1000);

libraries/MAX31855/examples/max31855_demo1/max31855_demo1.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// FILE: max31855_demo1.ino
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.1.01
4+
// VERSION: 0.1.02
55
// PURPOSE: thermocouple lib demo application
66
// DATE: 2014-01-02
77
// URL:
@@ -20,7 +20,7 @@ MAX31855 tc(clPin, csPin, doPin);
2020
void setup()
2121
{
2222
Serial.begin(115200);
23-
Serial.print("Start max31855_demo: ");
23+
Serial.print("Start max31855_demo1: ");
2424
Serial.println(MAX31855_VERSION);
2525
Serial.println();
2626

@@ -36,7 +36,7 @@ void loop()
3636
Serial.println(status);
3737
}
3838

39-
float temp = tc.getTemperature();
39+
double temp = tc.getTemperature();
4040
int m = temp*10 - 200;
4141
Serial.print(temp);
4242
Serial.print('\t');

libraries/MAX31855/examples/max31855_demo2/max31855_demo2.ino

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// FILE: max31855_demo2.ino
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.1.01
4+
// VERSION: 0.1.02
55
// PURPOSE: thermocouple lib demo application
66
// DATE: 2014-01-02
77
// URL:
@@ -17,25 +17,28 @@ const int clPin = 5;
1717

1818
MAX31855 tc(clPin, csPin, doPin);
1919

20+
double t1, t2;
21+
2022
void setup()
2123
{
2224
Serial.begin(115200);
23-
Serial.print("Start max31855_demo: ");
25+
Serial.print("Start max31855_demo2: ");
2426
Serial.println(MAX31855_VERSION);
2527
Serial.println();
2628

2729
tc.begin();
2830
tc.read();
31+
t1 = tc.getTemperature();
32+
delay(1000);
2933
}
3034

3135
void loop()
3236
{
33-
float t1 = tc.getTemperature();
34-
delay(1000);
3537
tc.read();
36-
float t2 = tc.getTemperature();
38+
t2 = tc.getTemperature();
3739
Serial.print("delta:\t");
3840
Serial.println(t2-t1, 2);
41+
t1 = t2;
3942
delay(1000);
4043
}
4144

libraries/MAX31855/examples/max31855_demo3/max31855_demo3.ino

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// FILE: max31855_demo3.ino
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.1.01
4+
// VERSION: 0.1.02
55
// PURPOSE: thermocouple lib demo application
66
// DATE: 2014-01-02
77
// URL:
@@ -27,19 +27,19 @@ void setup()
2727
tc.begin();
2828

2929
uint32_t start = micros();
30-
for (int i=0; i< 10; i++) tc.read();
30+
tc.read();
3131
uint32_t stop = micros();
32-
Serial.print("10x read:\t");
32+
Serial.print("read:\t");
3333
Serial.println(stop - start);
3434

3535
start = micros();
36-
float t1 = tc.getTemperature();
36+
double t1 = tc.getTemperature();
3737
stop = micros();
3838
Serial.print("getTemperature:\t");
3939
Serial.println(stop - start);
4040

4141
start = micros();
42-
float t2 = tc.getInternal();
42+
tc.getInternal();
4343
stop = micros();
4444
Serial.print("getInternal:\t");
4545
Serial.println(stop - start);
@@ -49,7 +49,7 @@ void setup()
4949
Serial.println(t2, 2);
5050
Serial.println();
5151
}
52-
52+
5353
void loop()
5454
{
5555
// this loop returns multiples of about 73mSec (counter multiples of ~143)
@@ -75,10 +75,4 @@ void loop()
7575
Serial.println(t1, 2);
7676
Serial.println();
7777
}
78-
79-
80-
81-
82-
83-
84-
78+

libraries/MAX31855/examples/max31855_demo4/max31855_demo4.ino

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// FILE: max31855_demo4.ino
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.1.00
4+
// VERSION: 0.1.01
55
// PURPOSE: thermocouple lib demo application
66
// DATE: 2014-01-02
77
// URL:
@@ -34,20 +34,25 @@ void setup()
3434

3535

3636
start = micros();
37-
float t1 = tc.getTemperature();
37+
double t1 = tc.getTemperature();
3838
stop = micros();
3939
Serial.print("getTemperature:\t");
4040
Serial.println(stop - start);
4141
Serial.println(t1, 2);
4242
Serial.println();
4343

44-
4544
start = micros();
4645
tc.setOffset(2.0);
4746
stop = micros();
4847
Serial.print("setOffset:\t");
4948
Serial.println(stop - start);
5049

50+
start = micros();
51+
tc.getOffset();
52+
stop = micros();
53+
Serial.print("getOffset:\t");
54+
Serial.println(stop - start);
55+
5156
tc.read();
5257
start = micros();
5358
t1 = tc.getTemperature();
@@ -59,7 +64,7 @@ void setup()
5964

6065

6166
start = micros();
62-
float t2 = tc.getInternal();
67+
double t2 = tc.getInternal();
6368
stop = micros();
6469
Serial.print("getInternal:\t");
6570
Serial.println(stop - start);
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
//
2+
// FILE: max31855_demo5.ino
3+
// AUTHOR: Rob Tillaart
4+
// VERSION: 0.1.00
5+
// PURPOSE: thermocouple lib demo application
6+
// DATE: 2014-01-02
7+
// URL:
8+
//
9+
// Released to the public domain
10+
//
11+
12+
#include "MAX31855.h"
13+
14+
const int doPin = 7;
15+
const int csPin = 6;
16+
const int clPin = 5;
17+
18+
MAX31855 tc(clPin, csPin, doPin);
19+
20+
void setup()
21+
{
22+
Serial.begin(115200);
23+
Serial.print("Start max31855_demo5: ");
24+
Serial.println(MAX31855_VERSION);
25+
Serial.println();
26+
27+
tc.begin();
28+
tc.read();
29+
double t1 = tc.getTemperature();
30+
Serial.print(" temp before:\t");
31+
Serial.println(t1, 2);
32+
33+
double o = tc.getOffset();
34+
Serial.print("offset before:\t");
35+
Serial.println(o, 2);
36+
37+
tc.setOffset(3.14);
38+
o = tc.getOffset();
39+
Serial.print(" offset after:\t");
40+
Serial.println(o, 2);
41+
42+
tc.read();
43+
double t2 = tc.getTemperature();
44+
Serial.print(" temp after:\t");
45+
Serial.println(t1, 2);
46+
47+
Serial.print(" temp delta:\t");
48+
Serial.println(abs(t1 - t2), 2);
49+
50+
Serial.println("\ndone...");
51+
}
52+
53+
void loop()
54+
{
55+
}
56+
57+
58+
59+
60+

0 commit comments

Comments
 (0)