MAX31855 Internal Negative values

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Vdrela
 
Posts: 8
Joined: Sun Jun 01, 2014 9:49 am

MAX31855 Internal Negative values

Post by Vdrela »

Hi,

I've bought a MAX31855 thermocoupler amplifier and I can't seem to get any negative values from the internal temperature.

When I put it in the freezer the temperature readings continuously decrease from i.e. 25ºC to 0ºC, and then it doesn't go into negative values, it returns -127, which is the error value. Furthermore it then decreases to -126, -125 and then I stopped at -124. I cannot make any sense from these values.

Does the internal temperature not support negative values?
If it does support am I doing something wrong? I'm using your libraries and tutorials: " int temperature1 = thermocouple.readInternal();" and then converting the integer to char[]": sprintf(temperature1char,"%i", temperature1)".

I must add that I am not using the actual thermocoupler with the MAX31855, but considering that the internal temperature is working for positive temperatures without the thermocouple I'm assuming that is not the problem. I have used the thermocoupler (external temperature) in the past and the readings were fine, it supported negative values. But these test were in a different MAX31855 board.

I hope you can give me some directions or suggestions. Thanks in advance.

User avatar
Franklin97355
 
Posts: 23910
Joined: Mon Apr 21, 2008 2:33 pm

Re: MAX31855 Internal Negative values

Post by Franklin97355 »

Sounds (reads) like your code is returning a byte value (0 - 127) and once the value reaches 0 it will roll over to -127. Post the code you are using to test with. Please use

Code: Select all

 tags when posting code.

User avatar
Vdrela
 
Posts: 8
Joined: Sun Jun 01, 2014 9:49 am

Re: MAX31855 Internal Negative values

Post by Vdrela »

Thank you for the quick reply. Here is the code:

Code: Select all


#define THERMO_DO   2
#define THERMO_CS   4
#define THERMO_CLK  6

// MAX31855 (Thermo) Libraries
#include <Adafruit_MAX31855.h>
Adafruit_MAX31855 thermocouple(THERMO_CLK, THERMO_CS, THERMO_DO);
int temperature1 = 0;

void THERMO_get_values()
{
  int temperature2=0;
  temperature1 = thermocouple.readInternal();
  temperature2 = thermocouple.readCelsius();
   
  if (temperature1 == -127) 
  {
    Serial.println("Faulty Thermocoupler");
    //NOTE: ADD WARNING    
  } 
  else
  {
    char thermostring[80];
    sprintf(thermostring,",%i,%i", temperature1, temperature2);
    strcat(datastring,thermostring);
  }  
}
I'm actually concatenating the thermostring with a datastring, that I am saving on an SDCard:

The output was as below:

Code: Select all

25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -127, -126, -125, -124

User avatar
Vdrela
 
Posts: 8
Joined: Sun Jun 01, 2014 9:49 am

Re: MAX31855 Internal Negative values

Post by Vdrela »

Hi,

Has anyone been able to replicate the behavior or has understood the potential cause of the problem?

Thanks

User avatar
Franklin97355
 
Posts: 23910
Joined: Mon Apr 21, 2008 2:33 pm

Re: MAX31855 Internal Negative values

Post by Franklin97355 »

What micro are you running this on? The code you included is not a complete Arduino program. Also you should format your output so you can tell temp1 from temp2.

User avatar
Vdrela
 
Posts: 8
Joined: Sun Jun 01, 2014 9:49 am

Re: MAX31855 Internal Negative values

Post by Vdrela »

I am running it on Arduino Uno R3.
I've added the complete code. There is no change from the previous code regarding the reading of the temperature, I've only included the SDCard code that stores the values (because when I put it in the freezer I can't keep the serial cable connected). Alternatively the SDCard code can be replaced by a Serial.print.

I can only foresee the following possibilities:

1. I shouldn't be using integer to read temperature, instead I should be using some other data type. (I would be surprised because it works for positive values)
2. There is some problem with the library, namely with function readInternal();
3. The sensor does not work without the thermocouple. (I would be surprised because it works for positive values)
4. The sensor is faulty.
5. I am biased by my own code and I'm not able to see an obvious mistake I've made somewhere.

Code: Select all

 /*
      P2 - THERMOCOUPLE (DO)
      P4 - THERMOCOUPLE (CS)
      P6 - THERMOCOUPLE (CLK)
      P10 - SD CARD (SDCS)
      P11 - SD CARD (MOSI)
      P12 - SD CARD (MISO)
      P13 - SD CARD (SLK)
 */

#define THERMO_DO   2
#define THERMO_CS   4
#define THERMO_CLK  6

char datastring[128];

// MAX31855 (Thermo) Libraries
#include <Adafruit_MAX31855.h>
Adafruit_MAX31855 thermocouple(THERMO_CLK, THERMO_CS, THERMO_DO);

//SD CARD
#include <SdFat.h>
#include <SdFatUtil.h>
SdFat sd;
SdFile newDataFile;

void setup()
{
  Serial.begin(9600);
  
  SDCARD_setup();
}

void loop()
{ 
  
  THERMO_get_values();
 
  SDCARD_write();
}

void THERMO_get_values()
{
  int temperature1 = 0;  
  int temperature2 = 0;
  temperature1 = thermocouple.readInternal();
  temperature2 = thermocouple.readCelsius();
   
  sprintf(datastring,"%i,%i", temperature1, temperature2);
}

void SDCARD_setup()
{ 
  // make sure that the default chip select pin is set to
  // output, even if you don't use it:
  pinMode(10, OUTPUT);
  
  // see if the card is present and can be initialized:
  if (!sd.begin(10, SPI_FULL_SPEED)) 
  {
    //NOTE: DEFINE WARNING
    Serial.println("SDCARD Setup Error");
  }
}

void SDCARD_write()
{
  char fileName[13] = "file.txt";
  if (!newDataFile.open(fileName, O_RDWR | O_APPEND))
  {    
    //NOTE: DEFINE WARNING
    Serial.println("SDCARD Write Error");  
  }
  else
  {
    //Write to SD Card
    newDataFile.println(datastring);
    newDataFile.close();
  }  
}

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: MAX31855 Internal Negative values

Post by adafruit_support_mike »

The MAX31855 has internal cold-point compensation, but that still gets combined with whatever signal the chip sees on its input pins.

If you leave the inputs floating, there's no telling what values you'll read. The Seebeck effect is measured in microvolts per degree C, so even extremely small parasitic effects will be picked up by the sensor amplifer.. microcurrents flowing across the surface of the PCB through fingerprints or condensation on the board, intermetallic effects, nano- or picocurrents due to thermal stress in the chip, everyday leakage currents within the chip, etc.

Bottom line though, floating the inputs mean you're getting the internal cold point compensation added to a completely unknown value that may or may not be changing over time.

User avatar
Vdrela
 
Posts: 8
Joined: Sun Jun 01, 2014 9:49 am

Re: MAX31855 Internal Negative values

Post by Vdrela »

Thanks Mike for the thorough reply.

What you said seems to make sense, however, isn't it weird that below 0° the temperature readings change to -127 and start increasing sequencially and timely as if the sensor did seem to capture the temperature variation?

What I mean is that the values I got were ... 1, 0, -127, -126, -125... so it seems more than a coincidence that the cold-point compensation on itself is returnin these values... it seems that the microvoltage being returned continues to reflect the changes in temperature below 0° but somehow they are translated incorrectly into integers. Furthermore, isn't it weird that only precisely below 0° my readings are incorrect? Does the compensation only kick below zero degrees?

Anyway, I must be able to read negative temperatures, and I must be confortable with my test results before releasing it. What do you recommend? Should I try to minimize interference and retest? Should I use a different MAX sensor? Should I test with a thermocoupler attached? I guess that if the problem is indeed mechanical I will eventually get different results, but if I still get the same results then it must mean that something must be wrong with the library or my code.

Thanks

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: MAX31855 Internal Negative values

Post by adafruit_support_mike »

Use a thermocouple and move the MAX31855 out of the freezer.

The Seebeck effect generates voltage along the temperature gradient in a wire. Electrons in the hot end move faster than electrons in the cold end, so the cold end basically pushes against the hot end, slowing the electrons down. That push appears as a voltage between the hot and cold ends of the wire.

You can't measure the voltage difference between the hot and cold ends of a wire without putting another wire into the same hot/cold conditions though, and the Seebeck effect will work in the second wire too. If you use two identical wires, the Seebeck voltage in one will cancel the Seebeck voltage in the other and you won't be able to measure any voltage difference between the hot and cold ends.

The amount of voltage gradient you get depends on the kind of metal you use though, so a thermocouple puts two different wires in parallel. You can measure the difference between the Seebeck voltages of the two wires at the same end, taking any thermal effects out of the reading.

You need that gradient for it to work though. If the hot end and the cold end are the same temperature, you don't get any Seebeck voltage.

If you don't want to use a thermocouple, use a single-point temperature sensor like a TMP36 (https://www.adafruit.com/products/165) or the reverse leakage current through a diode.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”