From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
08-02-2012 02:48 PM
I have it sending data now. I had to chenge retval to max_retval in the print statement
/*********************************************************************************
** MAX31855 Cold-Junction Compensated Thermocouple-to-Digital Converter
*********************************************************************************/
case 0xFD: // Init
MAX31855_Init(command[2], command[3], command[4]);
Serial.write('0');
break;
case 0xFE: // Read Raw Data
// Read raw data here.
max_retVal = MAX31855_readData();
Serial.write( (max_retVal >> 24) );
Serial.write( (max_retVal >> 16 & 0xFF) );
Serial.write( (max_retVal >> 8 & 0xFF) );
Serial.write( (max_retVal & 0xFF) );
break;
Also it reads on the hi to low transition so I fixed that in the code as well.
// MAX31855 Functions
void MAX31855_Init(unsigned char SO, unsigned char CS, unsigned char SCK)
{
max_so = SO;
max_cs = CS;
max_sck = SCK;
// MAX31855 data output pin
pinMode(max_so, INPUT);
// MAX31855 chip select input pin
pinMode(max_cs, OUTPUT);
// MAX31855 clock input pin
pinMode(max_sck, OUTPUT);
// Default output pins state
digitalWrite(max_cs, HIGH);
digitalWrite(max_sck, HIGH);
}
unsigned long MAX31855_readData()
{
int bitCount;
unsigned long data;
// Clear data
data = 0;
// Select the MAX31855 chip
digitalWrite(max_cs, LOW);
// Shift in 32-bit of data
for (bitCount = 31; bitCount >= 0; bitCount--)
{
digitalWrite(max_sck, LOW);
// If data bit is high
if (digitalRead(max_so))
{
// Need to type cast data type to unsigned long, else compiler will
// truncate to 16-bit
data |= ((unsigned long)1 << bitCount);
}
digitalWrite(max_sck, HIGH);
}
// Deselect MAX31855 chip
digitalWrite(max_cs, HIGH);
return(data);
}
08-02-2012 04:32 PM
ug this took a while to figure out... but it works now
08-02-2012 06:59 PM
ok i've been tinkering a bit have a look at this I'm working on the error bits next
08-02-2012 07:03 PM
LeXLuther422 wrote:
ug this took a while to figure out... but it works now
Why didn't you use my VIs? They should work with your fixed version of the firmware. It's much much simpler.
The max_retVal was my fault but the second thing you mention surprises me because I took it directly from the library. I'll update the library later tonight.
08-02-2012 07:04 PM
if you look i need to reorginize the bytes middle two for temp outside two for cjc
08-02-2012 07:11 PM
In the library, I have one for the thermocouple temperature already. I will create VIs for everything else shortly but didn't have the time (at the time) and would like to get the critical parts tested and working.
08-02-2012 07:44 PM
With this setup it is doing everything even the errors
08-02-2012 11:50 PM
This is what I ended up making my display look like
08-03-2012 01:56 AM
Please excuse that my feedback took a whole day, but it was only now that I had to build the actual circuit arround the MAX31855, and than checked everything twice and threefold to make sure that the reson for your program always returning 0°C was somewhere in the code, and not in my circuit - so that I don't "blame" your program by mistake; that would be paltry.
I'm afraid my contribution isn't nearly as profound as LexLuther's: there are no "errors" in the example VI, but it just reads in 0s...
I don't know how to help you any better - just tell me, please.
Thanks again for the great help!
08-03-2012 02:04 AM
this is the base file I used and the vi's I used are available above in another post of mine.
EDIT: let me know if you want my latest vi with the display as picturd above.