Thermocouple Amplifier MAX31855

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

Moderators: adafruit_support_bill, adafruit

Thermocouple Amplifier MAX31855

Postby kenton86 » Fri Jun 01, 2012 1:52 pm

Just received one of the new MAX31855 thermocouple breakout boards and the Adafruit K-type thermocouple. I'm having a few problems.

Using the 31855 example libraries on GitHub (serialthermocouple sketch), the temperature readings are incorrect and thermocouple polarity is backwards from the silksreen.

1) The polarity of the thermocouple is backwards. I applied heat and the temp went down. So I swapped the leads.
2) Temp readings are off. It's 26°C in my room (from a calibrated thermometer). The TC is reading 2.5-4.5°C at ambient
3) When I place a hot air gun over the TC, it heats up correctly (now that the leads are swapped)
4) When I place the hot air gun over the breakout board, the internal Temp goes negative.

I think something is wrong with the binary to decimal conversion that's giving me the false reading. Perhaps during the update from the 6675 to the 31855 the binary conversion changed and the sketch wasn't updated? I think the new one uses two's complement to spit out the temp data.

Screenshot of the serial window is here:
https://plus.google.com/photos/11079350 ... 9385416561
kenton86
 
Posts: 14
Joined: Thu Nov 10, 2011 5:05 pm

Re: Thermocouple Amplifier MAX31855

Postby adafruit_support_bill » Fri Jun 01, 2012 3:44 pm

We have seen some thermocouples with reversed color coding. I'll get one of the new amps and check the output.
User avatar
adafruit_support_bill
 
Posts: 16644
Joined: Sat Feb 07, 2009 9:11 am

Re: Thermocouple Amplifier MAX31855

Postby ribo » Sun Jun 03, 2012 1:07 am

If I'm using the MAX31855 directly on the arduino pins 7-2, how do I set pins 4,3,2 to GND, 3Vo, Vin respectively?
The example sketch doesn't handle anything other than the DO, CS, CLK.
ribo
 
Posts: 19
Joined: Thu Mar 15, 2012 12:16 am

Re: Thermocouple Amplifier MAX31855

Postby ribo » Sun Jun 03, 2012 1:32 pm

ribo wrote:If I'm using the MAX31855 directly on the arduino pins 7-2, how do I set pins 4,3,2 to GND, 3Vo, Vin respectively?
The example sketch doesn't handle anything other than the DO, CS, CLK.


Got it working by looking at the sketch for the older MAX6675. The example for the MAX31855 should be updated to include the Vin and GND pin setup. Also due to the six pins on the 31855 I think you have to shift the pin numbers higher, using pins 7-2. Is the 3V input optional for systems that do not run at 5V (3 OR 5V supply required)?

PIN sketch lines to add to MAX31855 example:
int thermoDO = 5;
int thermoCS = 6;
int thermoCLK = 7;
int VinPin = 2;
int gndPin = 4;

and in the setup:
pinMode(VinPin, OUTPUT); digitalWrite(VinPin, HIGH);
pinMode(gndPin, OUTPUT); digitalWrite(gndPin, LOW);

-ribo
ribo
 
Posts: 19
Joined: Thu Mar 15, 2012 12:16 am

Re: Thermocouple Amplifier MAX31855

Postby adafruit_support_bill » Sun Jun 03, 2012 3:43 pm

Is the 3V input optional for systems that do not run at 5V

The 3v is an output from the on-board 3.3v regulator. You can set the corresponding Arduino pin mode to INPUT (the default mode), or remove that pin from the header.
User avatar
adafruit_support_bill
 
Posts: 16644
Joined: Sat Feb 07, 2009 9:11 am

Re: Thermocouple Amplifier MAX31855

Postby kenton86 » Sun Jun 03, 2012 3:55 pm

I just put the MAX31855 breakout in the breadboard and jumpered to the pins.. ribo are you getting correct temperature data? I think the mask in the Adafruit_Max31855.cpp is incorrect for the 32 bit signal coming from the chip, which screws up the math.
kenton86
 
Posts: 14
Joined: Thu Nov 10, 2011 5:05 pm

Re: Thermocouple Amplifier MAX31855

Postby ribo » Sun Jun 03, 2012 10:04 pm

Temp coefficient is definitely off. I just tested the following:
ice bath:
-509C
-885.1F
boiling water (~300ft above sea level):
96.0C
204.3F
ribo
 
Posts: 19
Joined: Thu Mar 15, 2012 12:16 am

Re: Thermocouple Amplifier MAX31855

Postby kenton86 » Sun Jun 03, 2012 10:43 pm

The readInternal seems to work correctly- I'm getting believable ambient temps there.

Here's the relevant code from Arduino_MAX31855.cpp:
Code: Select all
double Adafruit_MAX31855::readCelsius(void) {

  uint32_t v;

  v = spiread32();

  //Serial.print("0x"); Serial.println(v, HEX);

  float internal = (v >> 4) & 0x1FF;
  internal *= 0.0625;
  if ((v >> 4) & 0x200)
    internal *= -1;
  //Serial.print("Internal Temp: "); Serial.println(internal);
  if (v & 0x7) {
    // uh oh, a serious problem!
    return NAN;
  }

  v >>= 18;
  //Serial.println(v, HEX);

  double temp = v & 0x7FF;
  if (v & 0x800) temp *= -1;
  temp *= 0.25;
  return temp;
}


I un-commented the //Serial.print("0x"); Serial.println(v, HEX);) to see what raw data the breakout board was giving me
(I actually changed it to Serial.println(v, BIN); to line it up with the MAX31855 datasheet).
I only see 24 bits instead of the 32 that I expect from the data sheet... Any idea why?
kenton86
 
Posts: 14
Joined: Thu Nov 10, 2011 5:05 pm

Re: Thermocouple Amplifier MAX31855

Postby kenton86 » Mon Jun 04, 2012 7:56 pm

I think the code in the Adafruit_MAX31855.cpp is incorrect for negative temperatures (but I am a novice in bitwise math so I could just be an idiot).
The datasheet says the temperature is written using two's complement, but the method in the .cpp file seems to be one's complement:
Lines 68-74:
Code: Select all
   v >>= 18;
  //Serial.println(v, HEX);

  double temp = v & 0x7FF;
  if (v & 0x800) temp *= -1;
  temp *= 0.25;
  return temp;


Here's what I think is happening.
1) v starts out as a 32 bit number from the MAX31855, it then gets bit shifted to lose the first 18 bits, leaving the 14 bits containing the thermocouple temp.
2) temp is masked to get rid of the sign bit which is the most significant bit. However, with 14 bits I think the mask should be 0x1FFF instead of 0x7FF.
3) if you mask v with 0x800 and it's positive, it means the most significant bit was a 1, hence the sign should be negative and temp should now be =-1 (since this is 14 bit instead of 12 bit, i think this should be 0x2000, not 0x800).
4) each bit left is = .25C, so math is done.

The problem here is two's complement makes -.25°C=1111 1111 1111 11. If you go through this method than you would end up with -8191°C instead of -.25°C.

Someone told me that Arduino already does two's complement natively but I think that might only be when using an int? I couldn't get the two's complement to work, and I'm too much of a novice to figure this out, so can somebody please double check the math in Arduino_MAX31855.cpp?

Thanks.
I currently get readings of 89°C in boiling water (I'm basically sea level)
Ambient reading is 6°C when it is about 26°C in my office.
Ice water plunges my reading to very negative values.
Yes I've soldered everything correctly and triple checked my connections.
kenton86
 
Posts: 14
Joined: Thu Nov 10, 2011 5:05 pm

Re: Thermocouple Amplifier MAX31855

Postby adafruit » Tue Jun 05, 2012 9:02 am

Hmm, sounds like there is some mathematical problems in the library - we'll try to take a look at it soon and rewrite it. ETA is by thursday unless something goes terribly wrong :)
User avatar
adafruit
 
Posts: 10552
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: Thermocouple Amplifier MAX31855

Postby kenton86 » Tue Jun 05, 2012 6:03 pm

Great. Thanks for looking into it.
I'm more versed in Propeller than Arduino and got the temperature probe to output correct negative temperatures using two's complement.

The second problem with the current breakout board is the temps are all a bit low. From my calculations I'm getting about a 7°C offset from actual vs measured temps. I measured from 0-150°C by taping the thermocouple to the analog Tell-Tru thermometer located inside a lab oven. It's not quite linear but is within ±3°C of a 7 degree offset.

In order to rule out the thermocouple itself, I stole a K-type thermocouple from my Makerbot and got the same readings.
kenton86
 
Posts: 14
Joined: Thu Nov 10, 2011 5:05 pm

Re: Thermocouple Amplifier MAX31855

Postby adafruit » Fri Jun 08, 2012 5:44 pm

OK try the most recent library.
we fixed the math (we believe), although we also find that this thermocouple amp has a bit of an offset, it could be from arduino noise sneaking in. we will investigate some more!
User avatar
adafruit
 
Posts: 10552
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: Thermocouple Amplifier MAX31855

Postby ribo » Sat Jun 09, 2012 7:09 pm

No dice on my hardware...
Still seeing very large (-) values for an ice bath.
Around -3600F
ribo
 
Posts: 19
Joined: Thu Mar 15, 2012 12:16 am

Re: Thermocouple Amplifier MAX31855

Postby adafruit » Sun Jun 10, 2012 10:02 am

can you uncomment the Serial.print's in the library .c files and recompile, upload and copy & paste here the output?
User avatar
adafruit
 
Posts: 10552
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: Thermocouple Amplifier MAX31855

Postby craftycoder » Mon Jun 11, 2012 12:52 pm

The had this issue as well. The less important issue is that the calculations in the Adafruit library are off when the chip receives useless readings. Those negative readings are useless ones so who cares they are "correct". The necessary part is a 10000pF cap across thermocouple pins. If that cap is missing your board isn't going to work. The new version of the breakout on Adafruit has two caps now so I assume they read the datasheet and it takes care of this issue and as well as the issues this 3.3V new chip has with talking to a 5V UNO (those new resistors are a giveaway). If you are using the old board with the new chip you need a cap or you are in trouble. Slide a 10000pF aka 0.01uF cap across the thermocouple pins to verify that it doesn't fix your problem.

Image
craftycoder
 
Posts: 1
Joined: Mon Jun 11, 2012 12:33 pm

Next

Return to Other Arduino products from Adafruit

Who is online

Users browsing this forum: franklin97355 and 3 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [114]

Raspberry Pi[82]
 
FLORA[24]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[12]
Arduino[60]
 
NETduino[14]
 
BeagleBone[23]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[39]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[9]


 
Breakout Boards[35]
LCDs & Displays[49]
Components & Parts[70]
Batteries & Power[54]
EL Wire/Tape/Panel[52]
LEDs[112]
 
Wireless[16]
Cables[66]
 
Lasers[6]
Sensors/Parts[147]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[70]
 
iDevices[13]
Tools[71]
 
Wearables[41]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[25]


 
Stickers[41]
 
Skill badges[55]
 
Books[26]
 
Circuit Playground[7]
 
Gift Certificates[4]