Testing my MAX31855 I seem to have come up with a problem, when putting the device into a cold environment like say a freezer or outside (I’m in Canada) where the temperature should read a negative value, the thermocouple temperature goes negative, but once the internal temperature goes below zero we get big positive temperatures. So for example when doing a test from room temperature to negative temperatures we see both the thermocouple and internal temperatures drop down nicely, but once we get to zero the internal temperature goes crazy. Looking at the data returned from the MAX31855 we see values like
11111111111011000111111010000000
so the sign bit for the thermocouple indicates a negative value, but the sign bit for the internal temperature still reads positive, hence why we get temps like 126.5 C which is clearly wrong.
So for example during the cooling the last 3 internal temps that make sense are:
Are we correct to be looking at bit 15 for the sign of the internal temp as I’m think bit 14 looks like it could be the sign bit as 15 doesn’t change or is there possible another problem?
The MAX31855 chip is stamped
M31855K
1506A2
+224AB
@ Duke Nukem - I don’t have a chip, but I am trying to make sense of the data you show. No matter which way I read it, it shows one of the reserved (always 0) bits flipping. Am I reading the spec wrong, because to my reading, you shouldn’t get this output at all?
I suspect there’s something wrong with the representation or the reading of the data. From the datasheet, the bit progression for internal temperature is
0.0000 = 0000 0000 0000
-0.0625 = 1111 1111 1111
I doubt something so fundamental is wrong here, so it has to be how the data is read/interpreted
The problem turns out to be I’m an idiot and a left over from my Unix days where the rule was if thou doest, thou must undoest.
UInt32 data = 0;
_cs.Write(false); //set chip select to low to use chip
Thread.Sleep(1);
for (var i = 31; i >= 0; i--)
{
_clk.Write(true);
Thread.Sleep(1);
if (_miso.Read())
data |= (uint)(1 << i);
_clk.Write(false);
Thread.Sleep(1);
}
//_clk.Write(true); <-- bad line which screwed up the next data retrieval, interesting
//Thread.Sleep(1);
_cs.Write(true); //set cs to high as we are finished with it
Thread.Sleep(1);
Thanks @ mcalsyn for making me think about the data retrieval, rather then just about the data as I made some changes to experiment with hooking up multiple chips. So data all good now, now to work on supporting multiple max31855 chips.
Multiple max31855 chip support working, so now back to testing and once I’m a happy camper, time to post code. Thanks for your help, eyes and motivation.