Declan wrote:SUCCESS
I had destroyed my MAX31855 device.
D'oh. That's no fun. At least you figured out the problem and MAX31855s aren't terribly expensive.
Running your code, I get:
Code: Select all
Corrected Temp = 25.19125
Raw Temp = 25.50000
Internal temp = 27.81250
Corrected Temp = 25.19125
Raw Temp = 25.50000
Internal temp = 27.81250
Corrected Temp = 25.19125
Raw Temp = 25.50000
Internal temp = 27.81250
Corrected Temp = 25.19125
Raw Temp = 25.50000
Internal temp = 27.81250
Corrected Temp = 25.19125
Raw Temp = 25.50000
Internal temp = 27.81250
The Gefran controller gives me 25.191C
Outstanding!
Many thanks for all your assistance.
My pleasure. Glad to be of assistance.
I hope the code is reasonably self-explanatory and can be easily adapted to your needs.
Now, for the next challenge - how do I read the fault TC Open, TC to VCC, TC to GND
I'm not 100% sure. My code just follows Adafruit's example code and prints an error if there's any fault (if there's a fault, rawTemp = NAN, so it's easy to detect). I didn't care particularly about identifying any specific fault condition.
The Adafruit MAX31855 library (Adafruit_MAX31855.cpp, line 91 on my system) checks for errors in the "double Adafruit_MAX31855::readCelsius(void)" function thusly:
Code: Select all
if (v & 0x7) {
// uh oh, a serious problem!
return NAN;
}
"v" is the string of 32 bits read out from the MAX31855. It does a bitwise AND check (&) against the three fault bits. If any of them are 1, it returns NAN as the temperature to indicate a fault.
You could easily split that into three checks, one for each condition:
Code: Select all
if (v & 0x1) {
// TC is open
return 10000;
} else if (v & 0x2) {
// TC is shorted to ground
return 20000;
} else if (v & 0x4) {
// TC is shorted to VCC
return 30000;
}
In this example I return impossibly high temperatures to indicate an error condition: for open circuit, it returns 10000, for grounded it returns 20000, for shorted to VCC it returns 30000. You'd need to have your code check for such raw temperatures to detect the error before proceeding.
There's probably other ways to do such checks that are more elegant and "done right", particularly if you intend to use it in some sort of non-hobbyist control system where failure would result in Bad Things(tm). This idea was just a quick, untested hack that occurred to me. I won't be liable if you blow up whatever it is that you're working with. :)
Good luck!