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
MAX6675ADG609I'm sorry for the crappy image it was the best I could do with Eagle...
Thanks
John