Skip to content

Commit f534edf

Browse files
committed
Adding type T TC probe type
1 parent 91f1d8b commit f534edf

File tree

2 files changed

+39
-9
lines changed

2 files changed

+39
-9
lines changed

src/utility/THERMOCOUPLE/MAX31855.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
const double MAX31855Class::Jm210_760[];
44
const double MAX31855Class::J760_1200[];
5+
56
const double MAX31855Class::Km270_0[];
67
const double MAX31855Class::K0_1372[];
78

9+
const double MAX31855Class::Tm270_0[];
10+
const double MAX31855Class::T0_400[];
11+
812
const double MAX31855Class::InvJ_neg[];
913
const double MAX31855Class::InvJ0_760[];
1014
const double MAX31855Class::InvJ760_1200[];
@@ -13,11 +17,16 @@ const double MAX31855Class::InvK_neg[];
1317
const double MAX31855Class::InvK0_500[];
1418
const double MAX31855Class::InvK500_1372[];
1519

20+
const double MAX31855Class::InvT_m200_0[];
21+
const double MAX31855Class::InvT0_400[];
22+
1623
const MAX31855Class::coefftable MAX31855Class::CoeffJ[];
1724
const MAX31855Class::coefftable MAX31855Class::CoeffK[];
25+
const MAX31855Class::coefftable MAX31855Class::CoeffT[];
1826

1927
const MAX31855Class::coefftable MAX31855Class::InvCoeffJ[];
2028
const MAX31855Class::coefftable MAX31855Class::InvCoeffK[];
29+
const MAX31855Class::coefftable MAX31855Class::InvCoeffT[];
2130

2231
MAX31855Class::MAX31855Class(PinName cs, SPIClass& spi) : _cs(cs), _spi(&spi), _spiSettings(4000000, MSBFIRST, SPI_MODE0), _coldOffset(2.10f) {
2332
}

src/utility/THERMOCOUPLE/MAX31855.h

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88

99
#define PROBE_TC_K 0
1010
#define PROBE_TC_J 1
11+
#define PROBE_TC_T 2
1112

1213
#define PROBE_K PROBE_TC_K
1314
#define PROBE_J PROBE_TC_J
15+
#define PROBE_T PROBE_TC_T
1416

1517
class MAX31855Class {
1618
public:
@@ -36,9 +38,13 @@ class MAX31855Class {
3638
static constexpr double Jm210_760[] = { 0.000000000000E+00, 0.503811878150E-01, 0.304758369300E-04, -0.856810657200E-07, 0.132281952950E-09, -0.170529583370E-12, 0.209480906970E-15, -0.125383953360E-18, 0.156317256970E-22 };
3739
static constexpr double J760_1200[] = { 0.296456256810E+03, -0.149761277860E+01, 0.317871039240E-02, -0.318476867010E-05, 0.157208190040E-08, -0.306913690560E-12 };
3840

39-
static constexpr double Km270_0[] = { 0.000000000000E+00, 0.394501280250E-01, 0.236223735980E-04, -0.328589067840E-06, -0.499048287770E-08, -0.675090591730E-10, -0.574103274280E-12, -0.310888728940E-14, -0.104516093650E-16, -0.198892668780E-19,-0.163226974860E-22 };
41+
static constexpr double Km270_0[] = { 0.000000000000E+00, 0.394501280250E-01, 0.236223735980E-04, -0.328589067840E-06, -0.499048287770E-08, -0.675090591730E-10, -0.574103274280E-12, -0.310888728940E-14, -0.104516093650E-16, -0.198892668780E-19, -0.163226974860E-22 };
4042
static constexpr double K0_1372[] = { -0.176004136860E-01, 0.389212049750E-01, 0.185587700320E-04, -0.994575928740E-07, 0.318409457190E-09, -0.560728448890E-12, 0.560750590590E-15, -0.320207200030E-18, 0.971511471520E-22, -0.121047212750E-25 };
4143

44+
static constexpr double Tm270_0[] = { 0.000000000000E+00, 0.387481063640E-01, 0.441944343470E-04, 0.118443231050E-06, 0.200329735540E-07, 0.901380195590E-09, 0.226511565930E-10, 0.360711542050E-12, 0.384939398830E-14, 0.282135219250E-16, 0.142515947790E-18, 0.487686622860E-21, 0.107955392700E-23, 0.139450270620E-26, 0.797951539270E-30 };
45+
static constexpr double T0_400[] = { 0.000000000000E+00, 0.387481063640E-01, 0.332922278800E-04, 0.206182434040E-06, -0.218822568460E-08, 0.109968809280E-10, -0.308157587720E-13, 0.454791352900E-16, -0.275129016730E-19 };
46+
47+
// NIST inverse coefficient tables
4248
static constexpr double InvJ_neg[] = { 0.0000000E+00, 1.9528268E+01, -1.2286185E+00, -1.0752178E+00, -5.9086933E-01, -1.7256713E-01, -2.8131513E-02, -2.3963370E-03, -8.3823321E-05};
4349
static constexpr double InvJ0_760[] = { 0.000000E+00, 1.978425E+01, -2.001204E-01, 1.036969E-02, -2.549687E-04, 3.585153E-06, -5.344285E-08, 5.099890E-10 };
4450
static constexpr double InvJ760_1200[] = { -3.11358187E+03, 3.00543684E+02, -9.94773230E+00, 1.70276630E-01, -1.43033468E-03, 4.73886084E-06 };
@@ -47,38 +53,53 @@ class MAX31855Class {
4753
static constexpr double InvK0_500[] = { 0.000000E+00, 2.508355E+01, 7.860106E-02, -2.503131E-01, 8.315270E-02, -1.228034E-02, 9.804036E-04, -4.413030E-05, 1.057734E-06, -1.052755E-08 };
4854
static constexpr double InvK500_1372[] = { -1.318058E+02, 4.830222E+01, -1.646031E+00, 5.464731E-02, -9.650715E-04, 8.802193E-06, -3.110810E-08 };
4955

56+
static constexpr double InvT_m200_0[] = { 0.0000000E+00, 2.5949192E+01, -2.1316967E-01, 7.9018692E-01, 4.2527777E-01, 1.3304473E-01, 2.0241446E-02, 1.2668171E-03 };
57+
static constexpr double InvT0_400[] = { 0.000000E+00, 2.592800E+01, -7.602961E-01, 4.637791E-02, -2.165394E-03, 6.048144E-05, -7.293422E-07, 0.000000E+00 };
58+
5059
typedef struct {
5160
int size;
5261
double max;
5362
const double *coeffs;
5463
} coefftable;
5564

56-
static constexpr coefftable CoeffJ []= {
57-
{0, -210, NULL},
65+
static constexpr coefftable CoeffJ[] = {
66+
{0, -210.0f, NULL},
5867
{sizeof(Jm210_760) / sizeof(double), 760.0f, &Jm210_760[0]},
5968
{sizeof(J760_1200) / sizeof(double), 1200.0f, &J760_1200[0]}
6069
};
6170

62-
static constexpr coefftable CoeffK []= {
63-
{0, -270, NULL},
71+
static constexpr coefftable CoeffK[] = {
72+
{0, -270.0f, NULL},
6473
{sizeof(Km270_0) / sizeof(double), 0.0f, &Km270_0[0]},
6574
{sizeof(K0_1372) / sizeof(double), 1372.0f, &K0_1372[0]}
6675
};
6776

68-
static constexpr coefftable InvCoeffJ []= {
69-
{0, -0.895, NULL},
77+
static constexpr coefftable CoeffT []= {
78+
{0,-270, NULL},
79+
{sizeof(Tm270_0) / sizeof(double), 0.0f, &Tm270_0[0]},
80+
{sizeof(T0_400) / sizeof(double), 400.0f, &T0_400[0]}
81+
};
82+
83+
static constexpr coefftable InvCoeffJ[] = {
84+
{0, -0.895f, NULL},
7085
{sizeof(InvJ_neg) / sizeof(double), 0.0f, &InvJ_neg[0]},
7186
{sizeof(InvJ0_760) / sizeof(double), 42.919f, &InvJ0_760[0]},
7287
{sizeof(InvJ760_1200) / sizeof(double), 69.533f, &InvJ760_1200[0]}
7388
};
7489

75-
static constexpr coefftable InvCoeffK []= {
76-
{0, -5.891, NULL},
90+
static constexpr coefftable InvCoeffK[] = {
91+
{0, -5.891f, NULL},
7792
{sizeof(InvK_neg) / sizeof(double), 0.0f, &InvK_neg[0]},
7893
{sizeof(InvK0_500) / sizeof(double), 20.644f, &InvK0_500[0]},
7994
{sizeof(InvK500_1372) / sizeof(double), 54.886f, &InvK500_1372[0]},
8095
};
8196

97+
static constexpr coefftable InvCoeffT []= {
98+
{0, -5.603f, NULL},
99+
{sizeof(InvT_m200_0) / sizeof(double), 0.0f, &InvT_m200_0[0]},
100+
{sizeof(InvT0_400) / sizeof(double), 20.872f, &InvT0_400[0]},
101+
};
102+
82103
double mvtoTemp(double voltage);
83104
double coldTempTomv(double temp);
84105
double polynomial(double value, int tableEntries, coefftable const (*table));

0 commit comments

Comments
 (0)