Using Arduino Due with MAX31855 thermocouple amplifier

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
sungsuk
 
Posts: 8
Joined: Fri Aug 30, 2013 5:03 pm

Using Arduino Due with MAX31855 thermocouple amplifier

Post by sungsuk »

Hi, I am having a hard time using MAX31855 thermocouple amplifier with Arduino Due for school project. I just need serial data outputs(temperatures) and it doesn't matter if I uses normal digital pins or SPI pins. Since I am an mechanical engineering student, I have limited experience with programming.
I know libraries of MAX31855 (https://github.com/adafruit/Adafruit-MAX31855-library) are based on AVR like for Mega and Uno so they are not working with Due which uses ARM.
I have been trying to modify the following codes but all of them didn't work.

1. http://forum.arduino.cc//index.php?PHPS ... c=150629.0
This guy uses SD card and it doesn't shoots outputs.

2. http://forum.arduino.cc//index.php?PHPS ... c=150351.0
The first two codes look OK for me but it just shoots 0 after three loops. Also, the first output that he got (1000000010000000100000001) looks like digital output data which are not converted to decimal numbers.
The last code didn't work at all.

I know converting AVR based libraries to ARM based libraries is very challenging. Is there any way that I can run MAX31855 with Due?
Thank you.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Using Arduino Due with MAX31855 thermocouple amplifier

Post by adafruit_support_rick »

We are working on porting our libraries to the Due, but we haven't done the MAX31855 yet. We have no ETA. Sorry.

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

Re: Using Arduino Due with MAX31855 thermocouple amplifier

Post by Franklin97355 »

Page 8 through 10 of this document http://www.adafruit.com/datasheets/MAX31855.pdf should give you the information to get the raw data from the MAX31855 and then you can manipulate it as necessary for your project.

sungsuk
 
Posts: 8
Joined: Fri Aug 30, 2013 5:03 pm

Re: Using Arduino Due with MAX31855 thermocouple amplifier

Post by sungsuk »

Thank you for fast reply. I inseted "Serial.println(data.bit8);" in the setup and got outputs as following.

1000000010000000100000001
1
1
1
1
1000000010000000100000001
1
1
1
1
1000000010000000100000001

and when I changed the temperature(touching thermocouple), I got like this

0
0
0
0
0
0
0
0

Since the binary numbers stay same, I guess the raw data does not represent the temperature. How do you think?

Code: Select all

#include <SPI.h>

union FourByte{
    unsigned long bit32;
    unsigned int bit16[2];
    unsigned char bit8[4];
};

int SlavePin1 = 10; //Thermocouple #1
long unsigned data;

void setup() {
  Serial.begin(9600);
  pinMode(SlavePin1, OUTPUT);
  digitalWrite(SlavePin1, HIGH); //Disable SS
  SPI.begin(SlavePin1);                // Setup SPI to use pin 4 as CS.
  SPI.setBitOrder(MSBFIRST);
  SPI.setDataMode(SlavePin1,1);        // Use SPI Mode 1 (CPOL = 0, CPHA = 1)
  SPI.setClockDivider(SlavePin1, 21);  // Set SPI Clock divider to 21.(4MHz)
  
}

unsigned long transfer(unsigned long value){
  FourByte data = {value};
  for(byte i = 0; i < 4; i++){
    data.bit8[i] = SPI.transfer(SlavePin1, data.bit8[i]);
     Serial.println(data.bit8[i]);
    delay(1);
  }
  return data.bit32;
}

void loop() {
  digitalWrite(SlavePin1, LOW);
  unsigned long someValue = 0xFFFFFFFEUL; //No MOSI on MAX31855, dosent matter what is sent.
  data = transfer(someValue);
  Serial.println(data, BIN);
  
  digitalWrite(SlavePin1, HIGH);
  delay(1000);
}

User avatar
federico.belfi
 
Posts: 1
Joined: Tue Dec 10, 2013 4:44 pm

Re: Using Arduino Due with MAX31855 thermocouple amplifier

Post by federico.belfi »

Hello,
still no news about? I have two thermocouple and i must read to do a PID controller. Using an Arduino DUE :D

Thank you for the help.

Bye

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Using Arduino Due with MAX31855 thermocouple amplifier

Post by adafruit_support_rick »

Try the attached version of the library and see if it works for you:
Attachments
Adafruit_MAX31855_Due.zip
(8.8 KiB) Downloaded 129 times

User avatar
Blake_80486
 
Posts: 1
Joined: Mon Apr 13, 2015 10:27 am

Re: Using Arduino Due with MAX31855 thermocouple amplifier

Post by Blake_80486 »

I played with this for a while trying to get it to work, but this is what I ended up using.

Code: Select all

#include <SPI.h>

const int slaveSelectPin = 52;

void setup() {
  Serial.begin(9600);
  SPI.begin(slaveSelectPin);
}

void loop() {
  byte data1 = SPI.transfer(slaveSelectPin, 0, SPI_CONTINUE);
  byte data2 = SPI.transfer(slaveSelectPin, 0, SPI_CONTINUE);
  byte data3 = SPI.transfer(slaveSelectPin, 0, SPI_CONTINUE);
  byte data4 = SPI.transfer(slaveSelectPin, 0, SPI_LAST);
  
  word temp1 = word(data1, data2);
  word temp2 = word(data3, data4);
  
  bool ned = false;
  if (temp1 &0x8000){
    ned = true;
  }
  
  if (temp1 & 0x1)
  {
    Serial.println("Thermocouple error!");
    if (temp2 & 0x1)
    Serial.println("Open circuit");
    if (temp2 & 0x2)
    Serial.println("VCC Short");
    if (temp2 & 0x4)
    Serial.println("GND Short");
  }
  
  temp1 &= 0x7FFC;
  temp1 >>= 2;
  double celcius = temp1;
  
  double temp = celcius / 4;

  Serial.println(temp, 2);
  
  delay(500);    
}
I thought it best to put this hear as this is the page Google kept bringing me to when I was trying to fix my issues.

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

Re: Using Arduino Due with MAX31855 thermocouple amplifier

Post by Franklin97355 »

Blake, thanks for posting your findings.

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

Return to “Arduino”