Thermocouple

I'm trying to multiplex some thermocouples into a MAX6675. So far I have one channel connected for testing but I get a -1 reply from the MAX6675.

This is how I have things connected up...

This is my code...

/*
  Testing the Max6675
  03/03/2011
*/

#include <SPI.h>

#define CS_MAX 10 // MAX6675 Chip Select Line
#define EN_ADG 9  // ADG609 Enable Line

//-------------------------
int GetTemperature (void)
{
unsigned int temp_reading;

  // stop any conversion process
  delay(5);
  digitalWrite(CS_MAX,LOW); // Set MAX7765 /CS Low
  delay(5);
  
  // initiate a new conversion
  digitalWrite(CS_MAX,HIGH); // Set MAX7765 /CS High
  delay(250); // wait for conversion to finish..
  
  // read result
  digitalWrite(CS_MAX,LOW); // Set MAX7765 /CS Low
  delay(1);
  
  temp_reading = SPI.transfer(0xff) << 8;  
  temp_reading += SPI.transfer(0xff);  

  digitalWrite(CS_MAX,HIGH); // Set MAX7765 /CS High
  delay(1);
  
  // Bit D2 is normally low and goes high if the thermocouple input is open.
  if(bitRead(temp_reading,2) == 1) // No Connection
    {
      return(-1); // No Connection Error
    }
    else
    {
      return((int)(temp_reading >> 5)); //Convert to Degc
    }
}

//-------------------------
//-------------------------
void setup()
{
  Serial.begin(9600);

  pinMode(CS_MAX,OUTPUT); // MAX6675/6674 /CS Line must be an output for hardware SPI
  digitalWrite(CS_MAX,HIGH); // Set MAX7765 /CS High

  SPI.begin(); // Init SPI
  SPI.setBitOrder(MSBFIRST); // Sets the order of the bits shifted out of and into the SPI bus
  SPI.setDataMode(SPI_MODE1); // Base value of clock is 1, data is captured on clock's falling edge.
  SPI.setClockDivider(SPI_CLOCK_DIV4); // Set SPI data rate to 16mhz/4. IE: 4mhz.
  
  pinMode(EN_ADG,OUTPUT); 
  digitalWrite(EN_ADG,HIGH); // Enable the ADG609 which connects S1A = DA and S1B = DB
}

//-------------------------

void loop()
{
int temperature = 0;

while(1)
  {
    delay(1000);
    temperature = GetTemperature(); 
    if(temperature == -1)
      {
        Serial.print(temperature);
        Serial.println(" No Connection");
      }
      else
      {
        Serial.print(temperature,DEC); 
        Serial.println(" DegC");
      }
  }
}

This is the reply on the serial monitor...

-1 No Connection

I almost forgot the data sheets
MAX6675
ADG609

I'm sorry for the crappy image it was the best I could do with Eagle...
Thanks
John

The 6674/5 require that the - lead of the thermocouple be connected to ground. Otherwise, it's a fault, which is reported by returning a -1.

Why not just use multiple 6675s?

-j

Thermocouples don't like anything between them and the amplifier. I think running them through a MUX is asking for trouble.


Rob

kg4wsv, good catch on the ground but the schematic is wrong. I have the t- connected to ground on the MAX6675. Multiple MAX6675's cost a lot more than one ADG609.

If that is correct why is one just like I'm prototyping available on the other side of the earth?

I guess I don't have a clue what and "old school" thermocouple is compared to the one I purchased???

John

Ok, I understand that using a multiplexer is not the best way. Barring that and the fact that it may not be as accurate as my lab grade thermometer does anyone see why the multiplexer is not passing the thermocouple on to the MAX6675. After further reading of the MAX6675 data sheet if the T- is not connected to ground the only thing this affects is the open thermocouple will not work so a -1 will NOT be returned. So can I assume the MAX6675 "thinks" that there is an open circuit. Is there something in my code that is not switching on the ADG609? Is there some way to see if the ADG609 is being switched on?

Thanks
John

The A0:1 lines appear to be floating, if so what MUX IO is being selected?


Rob

I've not tried with the thermocouple connected directly to the MAX6675 yet, but that seems like a logical step in trouble shooting.

As I understand the data sheet on the ADG609 putting 5v on the EN leg will "connect" the S1A to DA and S1B to DB, putting 5v on combination of A0 and A1 bring the other pairs to DA and DB. Perhaps A0 and A1 "must" be connected and pulled low?

I'm really new at this stuff and really appreciate the help.

Thanks
John

Perhaps A0 and A1 "must" be connected and pulled low?

It's possible that chip has internal pull downs or something, but good practice (and removes one variable) to tie them yourself.


Rob

I'm using the following, not sure about the 0x00 vs. 0xff, but easy to try.

    digitalWrite(_ssPin, LOW);
    tcData = SPI.transfer(0x00) << 8;
    tcData |= SPI.transfer(0x00);
    digitalWrite(_ssPin, HIGH);

Definitely test initially with the TC connected directly to the MAX6675. Theoretically an "ideal" mux would work, but thermocouples deal in microvolts, so a mux would have to pass the signal through pretty darned faithfully. So I'm also dubious, but I'd encourage you to try it since you have the parts. I'd be interested to hear the results. The MAX6675 senses its own temperature to do the cold-junction compensation, so as long as the mux is kept close by, that shouldn't be a huge issue.

Graynomad:
The A0:1 lines appear to be floating, if so what MUX IO is being selected?


Rob

Bingo Rob! You were correct the A0 and A1 lines can not be left floating. I connected them up and set them to low in my setup loop and walla she works...

A big thanks for spotting that.

Onward and forward...

Thanks
John