'********************************************************************** ' '*****____MAX31855 type "K" T/C reader____****** '*****____Walt McDonald 1/13/15_CopyRight_________****** '-----____For use with the MAX31855 break-out board (Adafruit) with on board Voltage Reg. and Vin pin..This replaces the MAX6675 '!!!!!!!---NOTE---USE THE Vin PIN FOR USE WITH A 5volt STAMP, NOT THE 3.3Volt PIN!!!!!!---cs,so, and Clk pins are good for 6.3volts MAX. ' ' {$STAMP BS2p} This code should run on any BS2xx stamp, Change directive to fit your stamp ' {$PBASIC 2.5} ' '**********_This MAX81855/MAX6675(upgrade) works great from 0`C to 1025`C.,With a 1/4% accuracy full scale. <>(0.25%)_******************************* '****************_______It does NOT READ below 0`C._**************************************************************************************** '*****___TESTED___Accuracy check with Fluke 724 Temp. Calibrator...Last Cal. 10/29/14, Good until 10/29/15_********************************* '*****___Added T/C Fault_1/22/15__WMc___ CS PIN 0 ' chip select so PIN 1 ' serial-out/data pin Clk PIN 2 ' clock pin MAX_T VAR Word ' MAX31855 C` result F_temp VAR Word ' Buffer for C` to F` conversion. Setup: HIGH CS ' set to converion mode. MAX6675 PAUSE 250 ' time to start first converion. (250 mS) Main: DO LOW CS ' set the MAX31855 to write mode, Stops all conversions SHIFTIN so, Clk, MSBPOST, [MAX_T\11] ' shift in the data, MSB first on the falling clock pulse\16 bits of data only 11 are needed. HIGH CS ' Restart conversion mode F_temp = (ABS MAX_T) * 9 / 5 + 32 ' Convert C` to F` This is far easier than using C * 1.8 + 32 !!! DEBUG CLS DEBUG BIN ? MAX_T ' Show BIN% DEBUG DEC ? MAX_T ' Show C` DEBUG DEC ? F_temp ' show conversion result PAUSE 1000 ' Allow a second for the MAX31855 to read the T/C and do the conversion. ' This PAUSE value could be less but the flash on the DEBUG screen is annoying. IF F_temp > 3000 THEN GOSUB Fault LOOP ' repeat END Fault: DEBUG CLS, "T/C fault " ' The MAX31855 has a fault bit(2) for this, But the simple "IF-Then" is so much easier to use. PAUSE 5000 ' The fault is either OPEN T/C, OVER TEMP (above 1025`C), or BELOW ZERO C`. RETURN