Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of MAX31856_example_program by
Diff: MAX31856.cpp
- Revision:
- 8:8723d0006097
- Parent:
- 7:2e45068189b1
- Child:
- 9:2d284cc2f65c
--- a/MAX31856.cpp Mon Jul 31 18:46:49 2017 +0000
+++ b/MAX31856.cpp Tue Aug 01 03:29:15 2017 +0000
@@ -3,6 +3,7 @@
#define LOG(args...) printf(args)
+//*****************************************************************************
MAX31856::MAX31856(SPI& _spi, PinName _ncs, uint8_t _type, uint8_t _fltr, uint8_t _samples, uint8_t _conversion_mode) : spi(_spi), ncs(_ncs), samples(_samples) {
spi.format(8,3); //configure the correct SPI mode to beable to program the registers intially correctly
setThermocoupleType(_type);
@@ -14,27 +15,44 @@
//*****************************************************************************
float MAX31856::readTC()
-{
+{
+ //Check and see if the MAX31856 is set to conversion mode ALWAYS ON
+ if (conversion_mode==0) { //means that the conversion mode is normally off
+ setOneShotMode(CR0_1_SHOT_MODE_ONE_CONVERSION); // turn on the one shot mode for singular conversion
+ thermocouple_conversion_count=0; //reset the conversion count back to zero to make sure minimum conversion time reflects one shot mode requirements
+ }
+
+ //calculate minimum wait time for conversions
+ calculateDelayTime();
+
+ //initialize other info for the read functionality
int32_t temp;
uint8_t buf_read[3], buf_write[3]={ADDRESS_LTCBH_READ,ADDRESS_LTCBM_READ,ADDRESS_LTCBL_READ};
-// uint32_t time = us_ticker_read();
-// uint32_t duration = time - lastReadTime;
-// if (duration > 200000) { // more than 250ms
- for(int i=0; i<3; i++) {
- spiEnable();
- buf_read[i]=spi.write(buf_write[i]);
- buf_read[i]=spi.write(buf_write[i]);
- spiDisable();
- }
-
- //Convert the registers contents into the correct value
- temp =((buf_read[0] & 0xFF) << 11); //Shift Byte 2 into place
- temp|=((buf_read[1] & 0xFF) << 3); //Shift Byte 1 into place
- temp|=((buf_read[2] & 0xFF) >> 5); //Shift Byte 0 into place
- float val=(temp/128.0f); //Divide the binary string by 2 to the 7th power
- return val;
-// }
+ bool read_thermocouple_temp=checkFaultsThermocoupleConnection(); //check and see if there are any faults that prohibit a normal read of the register
+
+ if(read_thermocouple_temp){ //no faults with connection are present so continue on with normal read of temperature
+ uint32_t time = us_ticker_read();
+ uint32_t duration = time - lastReadTime;
+ if (duration > conversion_time) { // more than current conversion time
+ for(int i=0; i<3; i++) {
+ spiEnable();
+ buf_read[i]=spi.write(buf_write[i]);
+ buf_read[i]=spi.write(buf_write[i]);
+ spiDisable();
+ }
+
+ //Convert the registers contents into the correct value
+ temp =((buf_read[0] & 0xFF) << 11); //Shift Byte 2 into place
+ temp|=((buf_read[1] & 0xFF) << 3); //Shift Byte 1 into place
+ temp|=((buf_read[2] & 0xFF) >> 5); //Shift Byte 0 into place
+ float val=(temp/128.0f); //Divide the binary string by 2 to the 7th power
+ return val;
+ }
+ }
+ checkFaultsThermocoupleThresholds(); //print any faults to the terminal
+
+ thermocouple_conversion_count++; //iterate the conversion count to speed up time in between future converions in always on mode
}
@@ -56,9 +74,113 @@
temp|=((int32_t)(buf_read[2] >> 2)); //Shift the LSB into place
float val=((float)(temp/64.0)); //Divide the binary string by 2 to the 6th power
+ checkFaultsColdJunctionThresholds(); //print any faults to the terminal
+
return val;
}
+//*****************************************************************************
+uint8_t MAX31856::checkFaultsThermocoupleThresholds()
+{
+ uint8_t fault_byte=registerReadByte(ADDRESS_SR_READ); //Read contents of fault status register
+ uint8_t temp[2], return_int;
+ for(int i=0; i<2; i++)
+ temp[i]=fault_byte;
+
+ //Check if any of the faults for thermocouple connection are triggered
+ if ((fault_byte&0x4C)==0) //means no fault is detected for thermocouple thresholds
+ return_int=0;
+ else {
+ if ((fault_byte&0x40)==0) { //check if normal operation of thermocouple is true
+ if (temp[0]&0x08) {
+ LOG("FAULT! Thermocouple temp is higher than the threshold that is set!\r\n");
+ return_int=1;
+ }
+ else if (temp[1]&0x04) {
+ LOG("FAULT! Thermocouple temp is lower than the threshold that is set!\r\n");
+ return_int=2;
+ }
+ }
+ else { //Thermocouples is operating outside of normal range
+ LOG("FAULT! Thermocouple temperature is out of range for specific type of thermocouple!\r\n");
+ if (temp[0]&0x08) {
+ LOG("FAULT! Thermocouple temp is higher than the threshold that is set!\r\n");
+ return_int=4;
+ }
+ else if (temp[1]&0x04) {
+ LOG("FAULT! Thermocouple temp is lower than the threshold that is set!\r\n");
+ return_int=5;
+ }
+ else //no other faults are flagged besides unnatural operation
+ return_int=3;
+ }
+ }
+ return return_int;
+}
+
+//*****************************************************************************
+uint8_t MAX31856::checkFaultsColdJunctionThresholds()
+{
+ uint8_t fault_byte=registerReadByte(ADDRESS_SR_READ); //Read contents of fault status register
+ uint8_t temp[2], return_int;
+ for(int i=0; i<2; i++)
+ temp[i]=fault_byte;
+
+ //Check if any of the faults for thermocouple connection are triggered
+ if ((fault_byte&0xB0)==0) //means no fault is detected for cold junction thresholds
+ return_int=0;
+ else {
+ if ((fault_byte&0x80)==0) { //check if normal operation of cold junction is true
+ if (temp[0]&0x20) {
+ LOG("FAULT! Cold Junction temp is higher than the threshold that is set!\r\n");
+ return_int=1;
+ }
+ else if (temp[1]&0x10) {
+ LOG("FAULT! Cold Junction temp is lower than the threshold that is set!\r\n");
+ return_int=2;
+ }
+ }
+ else { //Cold Junction is operating outside of normal range
+ LOG("FAULT! Cold Junction temperature is out of range for specific type of thermocouple!\r\n");
+ if (temp[0]&0x20) {
+ LOG("FAULT! Cold Junction temp is higher than the threshold that is set!\r\n");
+ return_int=4;
+ }
+ else if (temp[1]&0x10) {
+ LOG("FAULT! Cold Junction temp is lower than the threshold that is set!\r\n");
+ return_int=5;
+ }
+ else //no other faults are flagged besides unnatural operation
+ return_int=3;
+ }
+ }
+ return return_int;
+}
+
+//*****************************************************************************
+bool MAX31856::checkFaultsThermocoupleConnection()
+{
+ uint8_t fault_byte=registerReadByte(ADDRESS_SR_READ); //Read contents of fault status register
+ uint8_t temp[2];
+ for(int i=0; i<2; i++)
+ temp[i]=fault_byte;
+
+ //Check if any of the faults for thermocouple connection are triggered
+ if (fault_byte==0) //means no fault is detected
+ return_val=1;
+ else{
+ if (temp[0]&0x02) {
+ LOG("Overvotage/Undervoltage Fault triggered! Input voltage is negative or the voltage is greater than Vdd! Please check thermocouple connection!\r\n");
+ return_val=0;
+ }
+ if (temp[1]&0x01) {
+ LOG("Open circuit fault detected! Please check thermocouple connection!\r\n");
+ return_val=0;
+ }
+ }
+ return return_val;
+}
+
//Register:CR0 Bits: 7
//*****************************************************************************
@@ -319,7 +441,6 @@
{
if(enable)
val=0;
- ;
if (val==MASK_CJ_FAULT_THRESHOLD_HIGH) { //Cold Junction High Threshold Fault Mask
return_val=registerReadWriteByte(ADDRESS_MASK_READ, ADDRESS_MASK_WRITE, MASK_CLEAR_BITS_5, val);
LOG("Register containing\t\tsetFaultMasks\t\twas programmed with the parameter\t\tMASK_CJ_FAULT_THRESHOLD_HIGH\r\n");
@@ -352,91 +473,99 @@
}
-//Register:MASK Bits: 5:0
+////Register:MASK Bits: 5:0
+////******************************************************************************
+//float MAX31856::setFaultThresholds(uint8_t val, bool enable_mask, float temperature)
+//{
+// float return_val;
+// uint8_t temp_val;
+// if(enable_mask) {
+// temp_val=0;
+// }
+// else {
+// temp_val=val;
+// }
+// if (val==MASK_CJ_FAULT_THRESHOLD_HIGH) { //Cold Junction High Threshold Fault Mask
+// return_val=registerReadWriteByte(ADDRESS_MASK_READ, ADDRESS_MASK_WRITE, MASK_CLEAR_BITS_5, temp_val);
+//
+// int8_t temperature_byte=temperature;
+//
+// if (temperature_byte>CJ_MAX_VAL_FAULT)
+// temperature_byte=CJ_MAX_VAL_FAULT;
+// else if (temperature_byte<=0 || temperature_byte>=CJ_MIN_VAL_FAULT)
+// temperature_byte=twosComplimentToSigned8(temperature_byte); //Convert the 2's compliment int into a signed value
+// else if (temperature_byte<CJ_MIN_VAL_FAULT)
+// temperature_byte=twosComplimentToSigned8(CJ_MIN_VAL_FAULT); //Convert the 2's compliment int into a signed value
+// //else the data is within range, no more manipulation of data is needed
+// return_val=registerWriteByte(ADDRESS_CJHF_WRITE, temperature_byte);
+// }
+// else if (val==MASK_CJ_FAULT_THRESHOLD_LOW) { //Cold Junction Low Threshold Fault Mask
+// return_val=registerReadWriteByte(ADDRESS_MASK_READ, ADDRESS_MASK_WRITE, MASK_CLEAR_BITS_4, temp_val);
+//
+// int8_t temperature_byte=temperature;
+//
+// if (temperature_byte>CJ_MAX_VAL_FAULT)
+// temperature_byte=CJ_MAX_VAL_FAULT;
+// else if (temperature_byte<=0 || temperature_byte>=CJ_MIN_VAL_FAULT)
+// temperature_byte=twosComplimentToSigned8(temperature_byte); //Convert the 2's compliment int into a signed value
+// else if (temperature_byte<CJ_MIN_VAL_FAULT)
+// temperature_byte=twosComplimentToSigned8(CJ_MIN_VAL_FAULT); //Convert the 2's compliment int into a signed value
+// //else the data is within range, no more manipulation of data is needed
+//
+// return_val=registerWriteByte(ADDRESS_CJLF_WRITE, temperature_byte);
+// }
+// else if (val==MASK_TC_FAULT_THRESHOLD_HIGH) { //Thermocouple High Threshold Fault Mask
+// return_val=registerReadWriteByte(ADDRESS_MASK_READ, ADDRESS_MASK_WRITE, MASK_CLEAR_BITS_3, temp_val);
+//
+// if (temperature) {
+// int8_t temperature_byte[2];
+// int16_t temperature_multi_byte =(int16_t)(temperature*4.0);
+// if (temperature_multi_byte>(TC_MAX_VAL_FAULT*4.0f))
+// temperature_multi_byte=TC_MAX_VAL_FAULT*4.0f;
+// else if (temperature_multi_byte<=0 || temperature_multi_byte>=(TC_MIN_VAL_FAULT*4.0f))
+// temperature_multi_byte=twosComplimentToSigned16(temperature_multi_byte); //Convert the 2's compliment int into a signed value
+// else if (temperature_multi_byte<(TC_MIN_VAL_FAULT*4.0f))
+// temperature_multi_byte=twosComplimentToSigned16(TC_MIN_VAL_FAULT*4.0f); //Convert the 2's compliment int into a signed value
+//
+// //now split up the 32bit int into two bytes to program the registers with
+// temperature_byte[0]=((uint8_t)((temperature_multi_byte)&(0xFF00) >> 8));
+// temperature_byte[1]=((uint8_t)((temperature_multi_byte)&(0x00FF)));
+//
+// return_val=registerWriteByte(ADDRESS_LTHFTH_WRITE, temperature_byte[0]);
+// return_val=registerWriteByte(ADDRESS_LTHFTL_WRITE, temperature_byte[1]);
+//
+// return_val=temperature;
+// }
+//// else {
+//// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////return_val="WHATEVER IS IN THE REGISTERS WHEN YOU SET THE FLAG JUST INCASE YOU NEED TO SEE WHAT IS INSISIDE THE REGISTER";
+//// }
+// }
+// else if (val==MASK_TC_FAULT_THRESHOLD_LOW) //Thermocouple Low Threshold Fault Mask
+// return_val=registerReadWriteByte(ADDRESS_MASK_READ, ADDRESS_MASK_WRITE, MASK_CLEAR_BITS_2, temp_val);
+// else if (val==MASK_OVER_UNDER_VOLT_FAULT) //Over-Voltage/Under-Voltage Input Fault Mask
+// return_val=registerReadWriteByte(ADDRESS_MASK_READ, ADDRESS_MASK_WRITE, MASK_CLEAR_BITS_1, temp_val);
+// else if (val==MASK_OPEN_CIRCUIT_FAULT) //Thermocouple Open-Circuit Fault Mask
+// return_val=registerReadWriteByte(ADDRESS_MASK_READ, ADDRESS_MASK_WRITE, MASK_CLEAR_BITS_0, temp_val);
+// else {
+// LOG("Incorrect parameter selected for MASK Register. Default value not changed.\r\nPlease see MAX31856.h for list of valid parameters. \r\n");
+// return_val=0; //returns a 0 to flag that the parameter wasn't programmed due to wrong parameter in function call
+// }
+// return return_val;
+//}
+
//******************************************************************************
-float MAX31856::setFaultThresholds(uint8_t val, bool enable_mask, float temperature)
+bool MAX31856::coldJunctionOffset(float temperature)
{
- float return_val;
- uint8_t temp_val;
- if(enable_mask) {
- temp_val=0;
- }
- else {
- temp_val=val;
- }
- if (val==MASK_CJ_FAULT_THRESHOLD_HIGH) { //Cold Junction High Threshold Fault Mask
- return_val=registerReadWriteByte(ADDRESS_MASK_READ, ADDRESS_MASK_WRITE, MASK_CLEAR_BITS_5, temp_val);
-
- int8_t temperature_byte=temperature;
-
- if (temperature_byte>CJ_MAX_VAL_FAULT)
- temperature_byte=CJ_MAX_VAL_FAULT;
- else if (temperature_byte<=0 || temperature_byte>=CJ_MIN_VAL_FAULT)
- temperature_byte=twosComplimentToSigned8(temperature_byte); //Convert the 2's compliment int into a signed value
- else if (temperature_byte<CJ_MIN_VAL_FAULT)
- temperature_byte=twosComplimentToSigned8(CJ_MIN_VAL_FAULT); //Convert the 2's compliment int into a signed value
- //else the data is within range, no more manipulation of data is needed
- return_val=registerWriteByte(ADDRESS_CJHF_WRITE, temperature_byte);
+ if (temperature > 7.9375 || temperature < -8.0) {
+ LOG("Input value to offest the cold junction point is non valid. enter in value in range -8 to +7.9375\r\n");
+ return_val = 0;
}
- else if (val==MASK_CJ_FAULT_THRESHOLD_LOW) { //Cold Junction Low Threshold Fault Mask
- return_val=registerReadWriteByte(ADDRESS_MASK_READ, ADDRESS_MASK_WRITE, MASK_CLEAR_BITS_4, temp_val);
-
- int8_t temperature_byte=temperature;
-
- if (temperature_byte>CJ_MAX_VAL_FAULT)
- temperature_byte=CJ_MAX_VAL_FAULT;
- else if (temperature_byte<=0 || temperature_byte>=CJ_MIN_VAL_FAULT)
- temperature_byte=twosComplimentToSigned8(temperature_byte); //Convert the 2's compliment int into a signed value
- else if (temperature_byte<CJ_MIN_VAL_FAULT)
- temperature_byte=twosComplimentToSigned8(CJ_MIN_VAL_FAULT); //Convert the 2's compliment int into a signed value
- //else the data is within range, no more manipulation of data is needed
-
- return_val=registerWriteByte(ADDRESS_CJLF_WRITE, temperature_byte);
- }
- else if (val==MASK_TC_FAULT_THRESHOLD_HIGH) { //Thermocouple High Threshold Fault Mask
- return_val=registerReadWriteByte(ADDRESS_MASK_READ, ADDRESS_MASK_WRITE, MASK_CLEAR_BITS_3, temp_val);
-
- if (temperature) {
- int8_t temperature_byte[2];
- int16_t temperature_multi_byte =(int16_t)(temperature*4.0);
- if (temperature_multi_byte>(TC_MAX_VAL_FAULT*4.0f))
- temperature_multi_byte=TC_MAX_VAL_FAULT*4.0f;
- else if (temperature_multi_byte<=0 || temperature_multi_byte>=(TC_MIN_VAL_FAULT*4.0f))
- temperature_multi_byte=twosComplimentToSigned16(temperature_multi_byte); //Convert the 2's compliment int into a signed value
- else if (temperature_multi_byte<(TC_MIN_VAL_FAULT*4.0f))
- temperature_multi_byte=twosComplimentToSigned16(TC_MIN_VAL_FAULT*4.0f); //Convert the 2's compliment int into a signed value
-
- //now split up the 32bit int into two bytes to program the registers with
- temperature_byte[0]=((uint8_t)((temperature_multi_byte)&(0xFF00) >> 8));
- temperature_byte[1]=((uint8_t)((temperature_multi_byte)&(0x00FF)));
-
- return_val=registerWriteByte(ADDRESS_LTHFTH_WRITE, temperature_byte[0]);
- return_val=registerWriteByte(ADDRESS_LTHFTL_WRITE, temperature_byte[1]);
-
- return_val=temperature;
- }
-// else {
-// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////return_val="WHATEVER IS IN THE REGISTERS WHEN YOU SET THE FLAG JUST INCASE YOU NEED TO SEE WHAT IS INSISIDE THE REGISTER";
-// }
- }
- else if (val==MASK_TC_FAULT_THRESHOLD_LOW) //Thermocouple Low Threshold Fault Mask
- return_val=registerReadWriteByte(ADDRESS_MASK_READ, ADDRESS_MASK_WRITE, MASK_CLEAR_BITS_2, temp_val);
- else if (val==MASK_OVER_UNDER_VOLT_FAULT) //Over-Voltage/Under-Voltage Input Fault Mask
- return_val=registerReadWriteByte(ADDRESS_MASK_READ, ADDRESS_MASK_WRITE, MASK_CLEAR_BITS_1, temp_val);
- else if (val==MASK_OPEN_CIRCUIT_FAULT) //Thermocouple Open-Circuit Fault Mask
- return_val=registerReadWriteByte(ADDRESS_MASK_READ, ADDRESS_MASK_WRITE, MASK_CLEAR_BITS_0, temp_val);
- else {
- LOG("Incorrect parameter selected for MASK Register. Default value not changed.\r\nPlease see MAX31856.h for list of valid parameters. \r\n");
- return_val=0; //returns a 0 to flag that the parameter wasn't programmed due to wrong parameter in function call
- }
+ int8_t temp_val=temperature*16.0f; //normalize the value to get rid of decimal and shorten it to size of register
+ return_val=registerWriteByte(ADDRESS_CJTO_WRITE, temp_val); //write the byte to cold junction offset register
return return_val;
}
-
-
-
-
//The following functions are for internal library use only
//******************************************************************************
void MAX31856::spiEnable()
@@ -491,34 +620,22 @@
return true;
}
-
//******************************************************************************
-int8_t MAX31856::twosComplimentToSigned8(int8_t temp)
+uint8_t MAX31856::registerReadByte(uint8_t read_address)
{
- temp=(~(temp)+1); //Take two's complement of the negative number
- temp|=(int8_t)(0x80UL); //And convert it into 7-bit val with msb as sign bit
- return temp;
-}
-
-//******************************************************************************
-int16_t MAX31856::twosComplimentToSigned16(int16_t temp)
-{
- temp=(~(temp)+1); //Take two's complement of the negative number
- temp|=(int16_t)(0x8000UL); //And convert it into 15-bit val with msb as sign bit
- return temp;
+ uint8_t buf_read, buf_write=read_address;
+ spiEnable();
+ buf_read=spi.write(buf_write);
+ buf_read=spi.write(buf_write);
+ spiDisable();
+ return buf_read;
}
-//******************************************************************************
-MAX31856::~MAX31856(void)
-{
- //empty block
-}
-//bool MAX31856::checkForFaults() {
-//
-//}
+
+
@@ -535,23 +652,36 @@
*/
+//******************************************************************************
+void MAX31856::calculateDelayTime() {
+ uint32_t temp_int;
+
+ if (conversion_mode==0 || thermocouple_conversion_count==0) {
+ if (filter_mode==0) //60Hz
+ temp_int=82+(samples-1)*33.33f;
+ else //50Hz
+ temp_int=98+(samples-1)*40.00f;
+ }
+ else {
+ if (filter_mode==0) //60Hz
+ temp_int=82+(samples-1)*16.67f;
+ else //50Hz
+ temp_int=98+(samples-1)*20.00f;
+ }
+
+ if (cold_junction_enabled==0) //cold junction is disabled enabling 25 millisecond faster conversion times
+ temp_int=temp_int-25;
+ conversion_time=1000*temp_int; //set private member conversion time to calculated minimum wait time in microseconds
+ return;
+}
-//uint32_t MAX31856::calculateDelayTime() {
-// uint32_t delayTime;
-//
-// if (auto_convert_mode==1 && samples==1) { //single conversion
-// if (filter_mode==0) //60Hz
-// delayTime=82+(samples-1)*33.33f;
-// if (filter_mode==1) //50Hz
-// delayTime=98+(samples-1)*40.00f;
-// }
-// else if (auto_convert_mode==1 && samples>1) { //single conversion
-// if (filter_mode==0) //60Hz
-// delayTime=82+(samples-1)*33.33f;
-// if (filter_mode==1) //50Hz
-// delayTime=98+(samples-1)*40.00f;
-// }
-//
+//*****************************************************************************
+MAX31856::~MAX31856(void)
+{
+ //empty block
+}
+
+
//
//
//
@@ -559,3 +689,80 @@
//auto 60 143
//1shot 50 98
//1shot 60 82
+
+
+//*****************************************************************************
+//EXTRA
+//*****************************************************************************
+//bool MAX31856::checkFaultsAll()
+//{
+// uint8_t temp[9];
+// uint8_t buf_read, buf_write=ADDRESS_SR_READ;
+//
+// spiEnable();
+// buf_read=spi.write(buf_write);
+// buf_read=spi.write(buf_write);
+// spiDisable();
+// for(int i=0; i<9; i++)
+// temp[i]=buf_read;
+//
+// //Check if any of the faults are triggered
+// if ((temp[0]&0xFF)==0) //means no fault is detected
+// return_val=1;
+// else{
+// if (temp[0]&0x80) {
+// LOG("Cold Junction out of range fault is triggered! ");
+// return_val=0;
+// }
+// if (temp[1]&0x40) {
+// LOG("Thermocouple out of range fault is triggered! ");
+// return_val=0;
+// }
+// if (temp[2]&0x20) {
+// LOG("Temperature is higher than the threshold that is set!\r\n");
+// return_val=0;
+// }
+// if (temp[3]&0x10) {
+// LOG("Temperature is lower than the threshold that is set!\r\n");
+// return_val=0;
+// }
+// if (temp[4]&0x08) {
+// LOG("Temperature is higher than the threshold that is set!\r\n");
+// return_val=0;
+// }
+// if (temp[5]&0x04) {
+// LOG("Temperature is lower than the threshold that is set!\r\n");
+// return_val=0;
+// }
+// if (temp[6]&0x02) {
+// LOG("Overvotage/Undervoltage Fault triggered! Input voltage is negative or the voltage is greater than Vdd! Please check thermocouple connection!\r\n");
+// return_val=0;
+// }
+// if (temp[7]&0x01) {
+// LOG("Open circuit fault detected! Please check thermocouple connection!\r\n");
+// return_val=0;
+// }
+// }
+// return return_val;
+//}
+
+
+
+////******************************************************************************
+//int8_t MAX31856::twosComplimentToSigned8(int8_t temp)
+//{
+// temp=(~(temp)+1); //Take two's complement of the negative number
+// temp|=(int8_t)(0x80UL); //And convert it into 7-bit val with msb as sign bit
+// return temp;
+//}
+
+
+
+////******************************************************************************
+//int16_t MAX31856::twosComplimentToSigned16(int16_t temp)
+//{
+// temp=(~(temp)+1); //Take two's complement of the negative number
+// temp|=(int16_t)(0x8000UL); //And convert it into 15-bit val with msb as sign bit
+// return temp;
+//}
+
