@@ -85,48 +85,48 @@ double MAX31855Class::polynomial(double value, int tableEntries, coefftable cons
85
85
return NAN;
86
86
}
87
87
88
- double MAX31855Class::coldTempTomv (int type, double temp) {
88
+ double MAX31855Class::coldTempTomv (double temp) {
89
89
coefftable const (*table);
90
90
int tableEntries;
91
91
double voltage;
92
92
93
- switch (type ) {
94
- case PROBE_J :
93
+ switch (_current_probe_type ) {
94
+ case PROBE_TC_J :
95
95
table = CoeffJ;
96
96
tableEntries = sizeof (CoeffJ) / sizeof (coefftable);
97
- break ;
98
- case PROBE_K :
97
+ break ;
98
+ case PROBE_TC_K :
99
99
table = CoeffK;
100
100
tableEntries = sizeof (CoeffK) / sizeof (coefftable);
101
101
break ;
102
102
}
103
103
voltage = polynomial (temp, tableEntries, table);
104
104
// special case... for K probes in temperature range 0-1372 we need
105
105
// to add an extra term
106
- if (type == PROBE_K && temp > 0 ) {
106
+ if (_current_probe_type == PROBE_TC_K && temp> 0 ) {
107
107
voltage += 0.118597600000E+00 * exp (-0.118343200000E-03 * pow (temp - 0.126968600000E+03 , 2 ));
108
108
}
109
109
return voltage;
110
110
}
111
111
112
- double MAX31855Class::mvtoTemp (int type, double voltage) {
112
+ double MAX31855Class::mvtoTemp (double voltage) {
113
113
coefftable const (*table);
114
114
int tableEntries;
115
115
116
- switch (type ) {
117
- case PROBE_J :
116
+ switch (_current_probe_type ) {
117
+ case PROBE_TC_J :
118
118
table = InvCoeffJ;
119
119
tableEntries = sizeof (InvCoeffJ) / sizeof (coefftable);
120
120
break ;
121
- case PROBE_K :
121
+ case PROBE_TC_K :
122
122
table = InvCoeffK;
123
123
tableEntries = sizeof (InvCoeffJ) / sizeof (coefftable);
124
124
break ;
125
125
}
126
126
return polynomial (voltage, tableEntries, table);
127
127
}
128
128
129
- float MAX31855Class::readTemperature ( int type ) {
129
+ float MAX31855Class::readTCTemperature ( ) {
130
130
uint32_t rawword;
131
131
int32_t measuredTempInt;
132
132
int32_t measuredColdInt;
@@ -177,14 +177,15 @@ float MAX31855Class::readTemperature(int type) {
177
177
// this way we calculate the voltage we would have measured if cold junction
178
178
// was at 0 degrees celsius
179
179
180
- measuredVolt = coldTempTomv (type, measuredCold - _coldOffset) + (measuredTemp - measuredCold) * 0 .041276f ;
180
+ measuredVolt = coldTempTomv (measuredCold - _coldOffset) + (measuredTemp - measuredCold) * 0 .041276f ;
181
181
182
182
// finally from the cold junction compensated voltage we calculate the temperature
183
183
// using NIST polynomial approximation for the thermocouple type we are using
184
- return mvtoTemp (type, measuredVolt);
184
+ return mvtoTemp (measuredVolt);
185
185
}
186
186
187
- float MAX31855Class::readReferenceTemperature (int type) {
187
+ float MAX31855Class::readReferenceTemperature () {
188
+ // TODO. Actually use TC _current_probe_type and _coldOffset
188
189
uint32_t rawword;
189
190
float ref;
190
191
@@ -211,3 +212,7 @@ void MAX31855Class::setColdOffset(float offset) {
211
212
_coldOffset = offset;
212
213
}
213
214
215
+
216
+ void MAX31855Class::setTCType (uint8_t type) {
217
+ _current_probe_type = type;
218
+ }
0 commit comments