Library for the MAX31856 Precision Thermocouple to Digital Converter with Linearization
Dependents: MAX31856_example_program
Fork of MAX31856 by
MAX31856.cpp@1:a1bbb5c254f2, 2017-09-14 (annotated)
- Committer:
- DevinAlexander
- Date:
- Thu Sep 14 18:08:20 2017 +0000
- Revision:
- 1:a1bbb5c254f2
- Parent:
- 0:b714c6a7c969
Final first revision
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
DevinAlexander | 1:a1bbb5c254f2 | 1 | /******************************************************************//** |
DevinAlexander | 1:a1bbb5c254f2 | 2 | * @file MAX31856.cpp |
DevinAlexander | 1:a1bbb5c254f2 | 3 | * |
DevinAlexander | 1:a1bbb5c254f2 | 4 | * @author Devin Alexander |
DevinAlexander | 1:a1bbb5c254f2 | 5 | * |
DevinAlexander | 1:a1bbb5c254f2 | 6 | * @version 1.0 |
DevinAlexander | 1:a1bbb5c254f2 | 7 | * |
DevinAlexander | 1:a1bbb5c254f2 | 8 | * Started: SEPTEMBER 14th 2017 |
DevinAlexander | 1:a1bbb5c254f2 | 9 | * |
DevinAlexander | 1:a1bbb5c254f2 | 10 | * Updated: |
DevinAlexander | 1:a1bbb5c254f2 | 11 | * |
DevinAlexander | 1:a1bbb5c254f2 | 12 | * @brief Source file for MAX3185 class |
DevinAlexander | 1:a1bbb5c254f2 | 13 | * |
DevinAlexander | 1:a1bbb5c254f2 | 14 | *********************************************************************** |
DevinAlexander | 1:a1bbb5c254f2 | 15 | * |
DevinAlexander | 1:a1bbb5c254f2 | 16 | * @copyright |
DevinAlexander | 1:a1bbb5c254f2 | 17 | * Copyright (C) 2015 Maxim Integrated Products, Inc., All Rights Reserved. |
DevinAlexander | 1:a1bbb5c254f2 | 18 | * |
DevinAlexander | 1:a1bbb5c254f2 | 19 | * Permission is hereby granted, free of charge, to any person obtaining a |
DevinAlexander | 1:a1bbb5c254f2 | 20 | * copy of this software and associated documentation files (the "Software"), |
DevinAlexander | 1:a1bbb5c254f2 | 21 | * to deal in the Software without restriction, including without limitation |
DevinAlexander | 1:a1bbb5c254f2 | 22 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
DevinAlexander | 1:a1bbb5c254f2 | 23 | * and/or sell copies of the Software, and to permit persons to whom the |
DevinAlexander | 1:a1bbb5c254f2 | 24 | * Software is furnished to do so, subject to the following conditions: |
DevinAlexander | 1:a1bbb5c254f2 | 25 | * |
DevinAlexander | 1:a1bbb5c254f2 | 26 | * The above copyright notice and this permission notice shall be included |
DevinAlexander | 1:a1bbb5c254f2 | 27 | * in all copies or substantial portions of the Software. |
DevinAlexander | 1:a1bbb5c254f2 | 28 | * |
DevinAlexander | 1:a1bbb5c254f2 | 29 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
DevinAlexander | 1:a1bbb5c254f2 | 30 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
DevinAlexander | 1:a1bbb5c254f2 | 31 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
DevinAlexander | 1:a1bbb5c254f2 | 32 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
DevinAlexander | 1:a1bbb5c254f2 | 33 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
DevinAlexander | 1:a1bbb5c254f2 | 34 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
DevinAlexander | 1:a1bbb5c254f2 | 35 | * OTHER DEALINGS IN THE SOFTWARE. |
DevinAlexander | 1:a1bbb5c254f2 | 36 | * |
DevinAlexander | 1:a1bbb5c254f2 | 37 | * Except as contained in this notice, the name of Maxim Integrated |
DevinAlexander | 1:a1bbb5c254f2 | 38 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
DevinAlexander | 1:a1bbb5c254f2 | 39 | * Products, Inc. Branding Policy. |
DevinAlexander | 1:a1bbb5c254f2 | 40 | * |
DevinAlexander | 1:a1bbb5c254f2 | 41 | * The mere transfer of this software does not imply any licenses |
DevinAlexander | 1:a1bbb5c254f2 | 42 | * of trade secrets, proprietary technology, copyrights, patents, |
DevinAlexander | 1:a1bbb5c254f2 | 43 | * trademarks, maskwork rights, or any other form of intellectual |
DevinAlexander | 1:a1bbb5c254f2 | 44 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
DevinAlexander | 1:a1bbb5c254f2 | 45 | * ownership rights. |
DevinAlexander | 1:a1bbb5c254f2 | 46 | **********************************************************************/ |
DevinAlexander | 1:a1bbb5c254f2 | 47 | |
DevinAlexander | 0:b714c6a7c969 | 48 | #include <mbed.h> |
DevinAlexander | 0:b714c6a7c969 | 49 | #include "MAX31856.h" |
DevinAlexander | 0:b714c6a7c969 | 50 | |
DevinAlexander | 0:b714c6a7c969 | 51 | #define LOG(args...) printf(args) |
DevinAlexander | 0:b714c6a7c969 | 52 | |
DevinAlexander | 0:b714c6a7c969 | 53 | //***************************************************************************** |
DevinAlexander | 0:b714c6a7c969 | 54 | 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) { |
DevinAlexander | 0:b714c6a7c969 | 55 | spi.format(8,3); //configure the correct SPI mode to beable to program the registers intially correctly |
DevinAlexander | 0:b714c6a7c969 | 56 | setThermocoupleType(_type); |
DevinAlexander | 0:b714c6a7c969 | 57 | setEmiFilterFreq(_fltr); |
DevinAlexander | 0:b714c6a7c969 | 58 | setNumSamplesAvg(_samples); |
DevinAlexander | 0:b714c6a7c969 | 59 | setConversionMode(_conversion_mode); |
DevinAlexander | 0:b714c6a7c969 | 60 | } |
DevinAlexander | 0:b714c6a7c969 | 61 | |
DevinAlexander | 0:b714c6a7c969 | 62 | |
DevinAlexander | 0:b714c6a7c969 | 63 | //***************************************************************************** |
DevinAlexander | 0:b714c6a7c969 | 64 | float MAX31856::readTC() |
DevinAlexander | 0:b714c6a7c969 | 65 | { |
DevinAlexander | 0:b714c6a7c969 | 66 | //Check and see if the MAX31856 is set to conversion mode ALWAYS ON |
DevinAlexander | 0:b714c6a7c969 | 67 | if (conversion_mode==0) { //means that the conversion mode is normally off |
DevinAlexander | 0:b714c6a7c969 | 68 | setOneShotMode(CR0_1_SHOT_MODE_ONE_CONVERSION); // turn on the one shot mode for singular conversion |
DevinAlexander | 0:b714c6a7c969 | 69 | thermocouple_conversion_count=0; //reset the conversion count back to zero to make sure minimum conversion time reflects one shot mode requirements |
DevinAlexander | 0:b714c6a7c969 | 70 | } |
DevinAlexander | 0:b714c6a7c969 | 71 | |
DevinAlexander | 0:b714c6a7c969 | 72 | //calculate minimum wait time for conversions |
DevinAlexander | 0:b714c6a7c969 | 73 | calculateDelayTime(); |
DevinAlexander | 0:b714c6a7c969 | 74 | |
DevinAlexander | 0:b714c6a7c969 | 75 | //initialize other info for the read functionality |
DevinAlexander | 0:b714c6a7c969 | 76 | int32_t temp; |
DevinAlexander | 0:b714c6a7c969 | 77 | uint8_t buf_read[3], buf_write[3]={ADDRESS_LTCBH_READ,ADDRESS_LTCBM_READ,ADDRESS_LTCBL_READ}; |
DevinAlexander | 0:b714c6a7c969 | 78 | |
DevinAlexander | 0:b714c6a7c969 | 79 | bool read_thermocouple_temp=checkFaultsThermocoupleConnection(); //check and see if there are any faults that prohibit a normal read of the register |
DevinAlexander | 0:b714c6a7c969 | 80 | |
DevinAlexander | 0:b714c6a7c969 | 81 | if(read_thermocouple_temp){ //no faults with connection are present so continue on with normal read of temperature |
DevinAlexander | 0:b714c6a7c969 | 82 | uint32_t time = us_ticker_read(); |
DevinAlexander | 0:b714c6a7c969 | 83 | uint32_t duration = time - lastReadTime; |
DevinAlexander | 0:b714c6a7c969 | 84 | if (duration > conversion_time) { // more than current conversion time |
DevinAlexander | 0:b714c6a7c969 | 85 | for(int i=0; i<3; i++) { |
DevinAlexander | 0:b714c6a7c969 | 86 | spiEnable(); |
DevinAlexander | 0:b714c6a7c969 | 87 | buf_read[i]=spi.write(buf_write[i]); |
DevinAlexander | 0:b714c6a7c969 | 88 | buf_read[i]=spi.write(buf_write[i]); |
DevinAlexander | 0:b714c6a7c969 | 89 | spiDisable(); |
DevinAlexander | 0:b714c6a7c969 | 90 | } |
DevinAlexander | 0:b714c6a7c969 | 91 | |
DevinAlexander | 0:b714c6a7c969 | 92 | //Convert the registers contents into the correct value |
DevinAlexander | 0:b714c6a7c969 | 93 | temp =((buf_read[0] & 0xFF) << 11); //Shift Byte 2 into place |
DevinAlexander | 0:b714c6a7c969 | 94 | temp|=((buf_read[1] & 0xFF) << 3); //Shift Byte 1 into place |
DevinAlexander | 0:b714c6a7c969 | 95 | temp|=((buf_read[2] & 0xFF) >> 5); //Shift Byte 0 into place |
DevinAlexander | 0:b714c6a7c969 | 96 | float val=(temp/128.0f); //Divide the binary string by 2 to the 7th power |
DevinAlexander | 0:b714c6a7c969 | 97 | return val; |
DevinAlexander | 0:b714c6a7c969 | 98 | } |
DevinAlexander | 0:b714c6a7c969 | 99 | } |
DevinAlexander | 0:b714c6a7c969 | 100 | thermocouple_conversion_count++; //iterate the conversion count to speed up time in between future converions in always on mode |
DevinAlexander | 0:b714c6a7c969 | 101 | |
DevinAlexander | 0:b714c6a7c969 | 102 | checkFaultsThermocoupleThresholds(); //print any faults to the terminal |
DevinAlexander | 0:b714c6a7c969 | 103 | return 0; |
DevinAlexander | 0:b714c6a7c969 | 104 | } |
DevinAlexander | 0:b714c6a7c969 | 105 | |
DevinAlexander | 0:b714c6a7c969 | 106 | |
DevinAlexander | 0:b714c6a7c969 | 107 | //***************************************************************************** |
DevinAlexander | 0:b714c6a7c969 | 108 | float MAX31856::readCJ() |
DevinAlexander | 0:b714c6a7c969 | 109 | { |
DevinAlexander | 0:b714c6a7c969 | 110 | int32_t temp; |
DevinAlexander | 0:b714c6a7c969 | 111 | uint8_t buf_read[3], buf_write=ADDRESS_CJTH_READ; |
DevinAlexander | 0:b714c6a7c969 | 112 | |
DevinAlexander | 0:b714c6a7c969 | 113 | spiEnable(); |
DevinAlexander | 0:b714c6a7c969 | 114 | for(int i=0; i<3; i++) |
DevinAlexander | 0:b714c6a7c969 | 115 | { |
DevinAlexander | 0:b714c6a7c969 | 116 | buf_read[i]=spi.write(buf_write); |
DevinAlexander | 0:b714c6a7c969 | 117 | } |
DevinAlexander | 0:b714c6a7c969 | 118 | spiDisable(); |
DevinAlexander | 0:b714c6a7c969 | 119 | |
DevinAlexander | 0:b714c6a7c969 | 120 | //Convert the registers contents into the correct value |
DevinAlexander | 0:b714c6a7c969 | 121 | temp =((int32_t)(buf_read[1] << 6)); //Shift the MSB into place |
DevinAlexander | 0:b714c6a7c969 | 122 | temp|=((int32_t)(buf_read[2] >> 2)); //Shift the LSB into place |
DevinAlexander | 0:b714c6a7c969 | 123 | float val=((float)(temp/64.0)); //Divide the binary string by 2 to the 6th power |
DevinAlexander | 0:b714c6a7c969 | 124 | |
DevinAlexander | 0:b714c6a7c969 | 125 | checkFaultsColdJunctionThresholds(); //print any faults to the terminal |
DevinAlexander | 0:b714c6a7c969 | 126 | |
DevinAlexander | 0:b714c6a7c969 | 127 | return val; |
DevinAlexander | 0:b714c6a7c969 | 128 | } |
DevinAlexander | 0:b714c6a7c969 | 129 | |
DevinAlexander | 0:b714c6a7c969 | 130 | //***************************************************************************** |
DevinAlexander | 0:b714c6a7c969 | 131 | uint8_t MAX31856::checkFaultsThermocoupleThresholds() |
DevinAlexander | 0:b714c6a7c969 | 132 | { |
DevinAlexander | 0:b714c6a7c969 | 133 | uint8_t fault_byte=registerReadByte(ADDRESS_SR_READ); //Read contents of fault status register |
DevinAlexander | 0:b714c6a7c969 | 134 | uint8_t temp[2], return_int; |
DevinAlexander | 0:b714c6a7c969 | 135 | for(int i=0; i<2; i++) |
DevinAlexander | 0:b714c6a7c969 | 136 | temp[i]=fault_byte; |
DevinAlexander | 0:b714c6a7c969 | 137 | |
DevinAlexander | 0:b714c6a7c969 | 138 | //Check if any of the faults for thermocouple connection are triggered |
DevinAlexander | 0:b714c6a7c969 | 139 | if ((fault_byte&0x4C)==0) //means no fault is detected for thermocouple thresholds |
DevinAlexander | 0:b714c6a7c969 | 140 | return_int=0; |
DevinAlexander | 0:b714c6a7c969 | 141 | else { |
DevinAlexander | 0:b714c6a7c969 | 142 | if ((fault_byte&0x40)==0) { //check if normal operation of thermocouple is true |
DevinAlexander | 0:b714c6a7c969 | 143 | if (temp[0]&0x08) { |
DevinAlexander | 0:b714c6a7c969 | 144 | LOG("FAULT! Thermocouple temp is higher than the threshold that is set!\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 145 | return_int=1; |
DevinAlexander | 0:b714c6a7c969 | 146 | } |
DevinAlexander | 0:b714c6a7c969 | 147 | else if (temp[1]&0x04) { |
DevinAlexander | 0:b714c6a7c969 | 148 | LOG("FAULT! Thermocouple temp is lower than the threshold that is set!\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 149 | return_int=2; |
DevinAlexander | 0:b714c6a7c969 | 150 | } |
DevinAlexander | 0:b714c6a7c969 | 151 | } |
DevinAlexander | 0:b714c6a7c969 | 152 | else { //Thermocouples is operating outside of normal range |
DevinAlexander | 0:b714c6a7c969 | 153 | LOG("FAULT! Thermocouple temperature is out of range for specific type of thermocouple!\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 154 | if (temp[0]&0x08) { |
DevinAlexander | 0:b714c6a7c969 | 155 | LOG("FAULT! Thermocouple temp is higher than the threshold that is set!\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 156 | return_int=4; |
DevinAlexander | 0:b714c6a7c969 | 157 | } |
DevinAlexander | 0:b714c6a7c969 | 158 | else if (temp[1]&0x04) { |
DevinAlexander | 0:b714c6a7c969 | 159 | LOG("FAULT! Thermocouple temp is lower than the threshold that is set!\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 160 | return_int=5; |
DevinAlexander | 0:b714c6a7c969 | 161 | } |
DevinAlexander | 0:b714c6a7c969 | 162 | else //no other faults are flagged besides unnatural operation |
DevinAlexander | 0:b714c6a7c969 | 163 | return_int=3; |
DevinAlexander | 0:b714c6a7c969 | 164 | } |
DevinAlexander | 0:b714c6a7c969 | 165 | } |
DevinAlexander | 0:b714c6a7c969 | 166 | return return_int; |
DevinAlexander | 0:b714c6a7c969 | 167 | } |
DevinAlexander | 0:b714c6a7c969 | 168 | |
DevinAlexander | 0:b714c6a7c969 | 169 | //***************************************************************************** |
DevinAlexander | 0:b714c6a7c969 | 170 | uint8_t MAX31856::checkFaultsColdJunctionThresholds() |
DevinAlexander | 0:b714c6a7c969 | 171 | { |
DevinAlexander | 0:b714c6a7c969 | 172 | uint8_t fault_byte=registerReadByte(ADDRESS_SR_READ); //Read contents of fault status register |
DevinAlexander | 0:b714c6a7c969 | 173 | uint8_t temp[2], return_int; |
DevinAlexander | 0:b714c6a7c969 | 174 | for(int i=0; i<2; i++) |
DevinAlexander | 0:b714c6a7c969 | 175 | temp[i]=fault_byte; |
DevinAlexander | 0:b714c6a7c969 | 176 | |
DevinAlexander | 0:b714c6a7c969 | 177 | //Check if any of the faults for thermocouple connection are triggered |
DevinAlexander | 0:b714c6a7c969 | 178 | if ((fault_byte&0xB0)==0) //means no fault is detected for cold junction thresholds |
DevinAlexander | 0:b714c6a7c969 | 179 | return_int=0; |
DevinAlexander | 0:b714c6a7c969 | 180 | else { |
DevinAlexander | 0:b714c6a7c969 | 181 | if ((fault_byte&0x80)==0) { //check if normal operation of cold junction is true |
DevinAlexander | 0:b714c6a7c969 | 182 | if (temp[0]&0x20) { |
DevinAlexander | 0:b714c6a7c969 | 183 | LOG("FAULT! Cold Junction temp is higher than the threshold that is set!\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 184 | return_int=1; |
DevinAlexander | 0:b714c6a7c969 | 185 | } |
DevinAlexander | 0:b714c6a7c969 | 186 | else if (temp[1]&0x10) { |
DevinAlexander | 0:b714c6a7c969 | 187 | LOG("FAULT! Cold Junction temp is lower than the threshold that is set!\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 188 | return_int=2; |
DevinAlexander | 0:b714c6a7c969 | 189 | } |
DevinAlexander | 0:b714c6a7c969 | 190 | } |
DevinAlexander | 0:b714c6a7c969 | 191 | else { //Cold Junction is operating outside of normal range |
DevinAlexander | 0:b714c6a7c969 | 192 | LOG("FAULT! Cold Junction temperature is out of range for specific type of thermocouple!\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 193 | if (temp[0]&0x20) { |
DevinAlexander | 0:b714c6a7c969 | 194 | LOG("FAULT! Cold Junction temp is higher than the threshold that is set!\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 195 | return_int=4; |
DevinAlexander | 0:b714c6a7c969 | 196 | } |
DevinAlexander | 0:b714c6a7c969 | 197 | else if (temp[1]&0x10) { |
DevinAlexander | 0:b714c6a7c969 | 198 | LOG("FAULT! Cold Junction temp is lower than the threshold that is set!\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 199 | return_int=5; |
DevinAlexander | 0:b714c6a7c969 | 200 | } |
DevinAlexander | 0:b714c6a7c969 | 201 | else //no other faults are flagged besides unnatural operation |
DevinAlexander | 0:b714c6a7c969 | 202 | return_int=3; |
DevinAlexander | 0:b714c6a7c969 | 203 | } |
DevinAlexander | 0:b714c6a7c969 | 204 | } |
DevinAlexander | 0:b714c6a7c969 | 205 | return return_int; |
DevinAlexander | 0:b714c6a7c969 | 206 | } |
DevinAlexander | 0:b714c6a7c969 | 207 | |
DevinAlexander | 0:b714c6a7c969 | 208 | //***************************************************************************** |
DevinAlexander | 0:b714c6a7c969 | 209 | bool MAX31856::checkFaultsThermocoupleConnection() |
DevinAlexander | 0:b714c6a7c969 | 210 | { |
DevinAlexander | 0:b714c6a7c969 | 211 | uint8_t fault_byte=registerReadByte(ADDRESS_SR_READ); //Read contents of fault status register |
DevinAlexander | 0:b714c6a7c969 | 212 | uint8_t temp[2]; |
DevinAlexander | 0:b714c6a7c969 | 213 | for(int i=0; i<2; i++) |
DevinAlexander | 0:b714c6a7c969 | 214 | temp[i]=fault_byte; |
DevinAlexander | 0:b714c6a7c969 | 215 | |
DevinAlexander | 0:b714c6a7c969 | 216 | //Check if any of the faults for thermocouple connection are triggered |
DevinAlexander | 0:b714c6a7c969 | 217 | if (fault_byte==0) //means no fault is detected |
DevinAlexander | 0:b714c6a7c969 | 218 | return_val=1; |
DevinAlexander | 0:b714c6a7c969 | 219 | else{ |
DevinAlexander | 0:b714c6a7c969 | 220 | if (temp[0]&0x02) { |
DevinAlexander | 0:b714c6a7c969 | 221 | LOG("Overvotage/Undervoltage Fault triggered! Input voltage is negative or the voltage is greater than Vdd! Please check thermocouple connection!\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 222 | return_val=0; |
DevinAlexander | 0:b714c6a7c969 | 223 | } |
DevinAlexander | 0:b714c6a7c969 | 224 | if (temp[1]&0x01) { |
DevinAlexander | 0:b714c6a7c969 | 225 | LOG("Open circuit fault detected! Please check thermocouple connection!\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 226 | return_val=0; |
DevinAlexander | 0:b714c6a7c969 | 227 | } |
DevinAlexander | 0:b714c6a7c969 | 228 | } |
DevinAlexander | 0:b714c6a7c969 | 229 | return return_val; |
DevinAlexander | 0:b714c6a7c969 | 230 | } |
DevinAlexander | 0:b714c6a7c969 | 231 | |
DevinAlexander | 0:b714c6a7c969 | 232 | |
DevinAlexander | 0:b714c6a7c969 | 233 | //Register:CR0 Bits: 7 |
DevinAlexander | 0:b714c6a7c969 | 234 | //***************************************************************************** |
DevinAlexander | 0:b714c6a7c969 | 235 | bool MAX31856::setConversionMode(uint8_t val) |
DevinAlexander | 0:b714c6a7c969 | 236 | { |
DevinAlexander | 0:b714c6a7c969 | 237 | if (val==CR0_CONV_MODE_NORMALLY_OFF) { |
DevinAlexander | 0:b714c6a7c969 | 238 | return_val=registerReadWriteByte(ADDRESS_CR0_READ, ADDRESS_CR0_WRITE, CR0_CLEAR_BITS_7, val); |
DevinAlexander | 0:b714c6a7c969 | 239 | conversion_mode=0; |
DevinAlexander | 0:b714c6a7c969 | 240 | LOG("Register containing\t\tsetConversionMode\t\twas programmed with the parameter\t\tCR0_CONV_MODE_NORMALLY_OFF\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 241 | } |
DevinAlexander | 0:b714c6a7c969 | 242 | else if (val==CR0_CONV_MODE_NORMALLY_ON) { |
DevinAlexander | 0:b714c6a7c969 | 243 | return_val=registerReadWriteByte(ADDRESS_CR0_READ, ADDRESS_CR0_WRITE, CR0_CLEAR_BITS_7, val); |
DevinAlexander | 0:b714c6a7c969 | 244 | conversion_mode=1; |
DevinAlexander | 0:b714c6a7c969 | 245 | LOG("Register containing\t\tsetConversionMode\t\twas programmed with the parameter\t\tCR0_CONV_MODE_NORMALLY_ON\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 246 | } |
DevinAlexander | 0:b714c6a7c969 | 247 | else { |
DevinAlexander | 0:b714c6a7c969 | 248 | LOG("Incorrect parameter selected for Control Register 0 (CR0) bit 7. Default value not changed.\r\nPlease see MAX31856.h for list of valid parameters. \r\n"); |
DevinAlexander | 0:b714c6a7c969 | 249 | return_val=0; //returns a 0 to flag that the parameter wasn't programmed due to wrong parameter in function call |
DevinAlexander | 0:b714c6a7c969 | 250 | } |
DevinAlexander | 0:b714c6a7c969 | 251 | return return_val; |
DevinAlexander | 0:b714c6a7c969 | 252 | } |
DevinAlexander | 0:b714c6a7c969 | 253 | |
DevinAlexander | 0:b714c6a7c969 | 254 | |
DevinAlexander | 0:b714c6a7c969 | 255 | //Register:CR0 Bits: 6 |
DevinAlexander | 0:b714c6a7c969 | 256 | //***************************************************************************** |
DevinAlexander | 0:b714c6a7c969 | 257 | bool MAX31856::setOneShotMode(uint8_t val) |
DevinAlexander | 0:b714c6a7c969 | 258 | { |
DevinAlexander | 0:b714c6a7c969 | 259 | if (val==CR0_1_SHOT_MODE_NO_CONVERSION) |
DevinAlexander | 0:b714c6a7c969 | 260 | return_val=registerReadWriteByte(ADDRESS_CR0_READ, ADDRESS_CR0_WRITE, CR0_CLEAR_BITS_6, val); |
DevinAlexander | 0:b714c6a7c969 | 261 | else if (val==CR0_1_SHOT_MODE_ONE_CONVERSION) |
DevinAlexander | 0:b714c6a7c969 | 262 | return_val=registerReadWriteByte(ADDRESS_CR0_READ, ADDRESS_CR0_WRITE, CR0_CLEAR_BITS_6, val); |
DevinAlexander | 0:b714c6a7c969 | 263 | else { |
DevinAlexander | 0:b714c6a7c969 | 264 | LOG("Incorrect parameter selected for Control Register 0 (CR0) bit 6. Default value not changed.\r\nPlease see MAX31856.h for list of valid parameters. \r\n"); |
DevinAlexander | 0:b714c6a7c969 | 265 | return_val=0; //returns a 0 to flag that the parameter wasn't programmed due to wrong parameter in function call |
DevinAlexander | 0:b714c6a7c969 | 266 | } |
DevinAlexander | 0:b714c6a7c969 | 267 | return return_val; |
DevinAlexander | 0:b714c6a7c969 | 268 | } |
DevinAlexander | 0:b714c6a7c969 | 269 | |
DevinAlexander | 0:b714c6a7c969 | 270 | |
DevinAlexander | 0:b714c6a7c969 | 271 | //Register:CR0 Bits: 5:4 |
DevinAlexander | 0:b714c6a7c969 | 272 | //***************************************************************************** |
DevinAlexander | 0:b714c6a7c969 | 273 | bool MAX31856::setOpenCircuitFaultDetection(uint8_t val) |
DevinAlexander | 0:b714c6a7c969 | 274 | { |
DevinAlexander | 0:b714c6a7c969 | 275 | if (val==CR0_OC_DETECT_DISABLED) { |
DevinAlexander | 0:b714c6a7c969 | 276 | return_val=registerReadWriteByte(ADDRESS_CR0_READ, ADDRESS_CR0_WRITE, CR0_CLEAR_BITS_5_4, val); |
DevinAlexander | 0:b714c6a7c969 | 277 | LOG("Register containing\t\tsetOpenCircuitFaultDetection\t\twas programmed with the parameter\t\tCR0_OC_DETECT_DISABLED\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 278 | } |
DevinAlexander | 0:b714c6a7c969 | 279 | else if (val==CR0_OC_DETECT_ENABLED_R_LESS_5k) { |
DevinAlexander | 0:b714c6a7c969 | 280 | return_val=registerReadWriteByte(ADDRESS_CR0_READ, ADDRESS_CR0_WRITE, CR0_CLEAR_BITS_5_4, val); |
DevinAlexander | 0:b714c6a7c969 | 281 | LOG("Register containing\t\tsetOpenCircuitFaultDetection\t\twas programmed with the parameter\t\tCR0_OC_DETECT_ENABLED_R_LESS_5k\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 282 | } |
DevinAlexander | 0:b714c6a7c969 | 283 | else if (val==CR0_OC_DETECT_ENABLED_TC_LESS_2ms) { |
DevinAlexander | 0:b714c6a7c969 | 284 | return_val=registerReadWriteByte(ADDRESS_CR0_READ, ADDRESS_CR0_WRITE, CR0_CLEAR_BITS_5_4, val); |
DevinAlexander | 0:b714c6a7c969 | 285 | LOG("Register containing\t\tsetOpenCircuitFaultDetection\t\twas programmed with the parameter\t\tCR0_OC_DETECT_ENABLED_TC_LESS_2ms\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 286 | } |
DevinAlexander | 0:b714c6a7c969 | 287 | else if (val==CR0_OC_DETECT_ENABLED_TC_MORE_2ms) { |
DevinAlexander | 0:b714c6a7c969 | 288 | return_val=registerReadWriteByte(ADDRESS_CR0_READ, ADDRESS_CR0_WRITE, CR0_CLEAR_BITS_5_4, val); |
DevinAlexander | 0:b714c6a7c969 | 289 | LOG("Register containing\t\tsetOpenCircuitFaultDetection\t\twas programmed with the parameter\t\tCR0_OC_DETECT_ENABLED_TC_MORE_2ms\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 290 | } |
DevinAlexander | 0:b714c6a7c969 | 291 | else { |
DevinAlexander | 0:b714c6a7c969 | 292 | LOG("Incorrect parameter selected for Control Register 0 (CR0) bits 5:4. Default value not changed.\r\nPlease see MAX31856.h for list of valid parameters. \r\n"); |
DevinAlexander | 0:b714c6a7c969 | 293 | return_val=0; //returns a 0 to flag that the parameter wasn't programmed due to wrong parameter in function call |
DevinAlexander | 0:b714c6a7c969 | 294 | } |
DevinAlexander | 0:b714c6a7c969 | 295 | return return_val; |
DevinAlexander | 0:b714c6a7c969 | 296 | } |
DevinAlexander | 0:b714c6a7c969 | 297 | |
DevinAlexander | 0:b714c6a7c969 | 298 | |
DevinAlexander | 0:b714c6a7c969 | 299 | //Register:CR0 Bits: 3 |
DevinAlexander | 0:b714c6a7c969 | 300 | //***************************************************************************** |
DevinAlexander | 0:b714c6a7c969 | 301 | bool MAX31856::setColdJunctionDisable(uint8_t val) |
DevinAlexander | 0:b714c6a7c969 | 302 | { |
DevinAlexander | 0:b714c6a7c969 | 303 | if (val==CR0_COLD_JUNC_ENABLE) { |
DevinAlexander | 0:b714c6a7c969 | 304 | return_val=registerReadWriteByte(ADDRESS_CR0_READ, ADDRESS_CR0_WRITE, CR0_CLEAR_BITS_3, val); |
DevinAlexander | 0:b714c6a7c969 | 305 | cold_junction_enabled=1; |
DevinAlexander | 0:b714c6a7c969 | 306 | LOG("Register containing\t\tsetColdJunctionDisable\t\twas programmed with the parameter\t\tCR0_COLD_JUNC_ENABLE\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 307 | } |
DevinAlexander | 0:b714c6a7c969 | 308 | else if (val==CR0_COLD_JUNC_DISABLE) { |
DevinAlexander | 0:b714c6a7c969 | 309 | return_val=registerReadWriteByte(ADDRESS_CR0_READ, ADDRESS_CR0_WRITE, CR0_CLEAR_BITS_3, val); |
DevinAlexander | 0:b714c6a7c969 | 310 | cold_junction_enabled=0; |
DevinAlexander | 0:b714c6a7c969 | 311 | LOG("Register containing\t\tsetColdJunctionDisable\t\twas programmed with the parameter\t\tCR0_COLD_JUNC_DISABLE\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 312 | } |
DevinAlexander | 0:b714c6a7c969 | 313 | else { |
DevinAlexander | 0:b714c6a7c969 | 314 | LOG("Incorrect parameter selected for Control Register 0 (CR0) bit 3. Default value not changed.\r\nPlease see MAX31856.h for list of valid parameters. \r\n"); |
DevinAlexander | 0:b714c6a7c969 | 315 | return_val=0; //returns a 0 to flag that the parameter wasn't programmed due to wrong parameter in function call |
DevinAlexander | 0:b714c6a7c969 | 316 | } |
DevinAlexander | 0:b714c6a7c969 | 317 | return return_val; |
DevinAlexander | 0:b714c6a7c969 | 318 | } |
DevinAlexander | 0:b714c6a7c969 | 319 | |
DevinAlexander | 0:b714c6a7c969 | 320 | |
DevinAlexander | 0:b714c6a7c969 | 321 | //Register:CR0 Bits: 2 |
DevinAlexander | 0:b714c6a7c969 | 322 | //***************************************************************************** |
DevinAlexander | 0:b714c6a7c969 | 323 | bool MAX31856::setFaultMode(uint8_t val) |
DevinAlexander | 0:b714c6a7c969 | 324 | { |
DevinAlexander | 0:b714c6a7c969 | 325 | if (val==CR0_FAULT_MODE_COMPARATOR) { |
DevinAlexander | 0:b714c6a7c969 | 326 | return_val=registerReadWriteByte(ADDRESS_CR0_READ, ADDRESS_CR0_WRITE, CR0_CLEAR_BITS_2, val); |
DevinAlexander | 0:b714c6a7c969 | 327 | LOG("Register containing\t\tsetFaultMode\t\twas programmed with the parameter\t\tCR0_FAULT_MODE_COMPARATOR\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 328 | } |
DevinAlexander | 0:b714c6a7c969 | 329 | else if (val==CR0_FAULT_MODE_INTERUPT) { |
DevinAlexander | 0:b714c6a7c969 | 330 | return_val=registerReadWriteByte(ADDRESS_CR0_READ, ADDRESS_CR0_WRITE, CR0_CLEAR_BITS_2, val); |
DevinAlexander | 0:b714c6a7c969 | 331 | LOG("Register containing\t\tsetFaultMode\t\twas programmed with the parameter\t\tCR0_FAULT_MODE_INTERUPT\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 332 | } |
DevinAlexander | 0:b714c6a7c969 | 333 | else { |
DevinAlexander | 0:b714c6a7c969 | 334 | LOG("Incorrect parameter selected for Control Register 0 (CR0) bit 2. Default value not changed.\r\nPlease see MAX31856.h for list of valid parameters. \r\n"); |
DevinAlexander | 0:b714c6a7c969 | 335 | return_val=0; //returns a 0 to flag that the parameter wasn't programmed due to wrong parameter in function call |
DevinAlexander | 0:b714c6a7c969 | 336 | } |
DevinAlexander | 0:b714c6a7c969 | 337 | return return_val; |
DevinAlexander | 0:b714c6a7c969 | 338 | } |
DevinAlexander | 0:b714c6a7c969 | 339 | |
DevinAlexander | 0:b714c6a7c969 | 340 | |
DevinAlexander | 0:b714c6a7c969 | 341 | //Register:CR0 Bits: 1 |
DevinAlexander | 0:b714c6a7c969 | 342 | //***************************************************************************** |
DevinAlexander | 0:b714c6a7c969 | 343 | bool MAX31856::setFaultStatusClear(uint8_t val) |
DevinAlexander | 0:b714c6a7c969 | 344 | { |
DevinAlexander | 0:b714c6a7c969 | 345 | if (val==CR0_FAULTCLR_DEFAULT_VAL) { |
DevinAlexander | 0:b714c6a7c969 | 346 | return_val=registerReadWriteByte(ADDRESS_CR0_READ, ADDRESS_CR0_WRITE, CR0_CLEAR_BITS_1, val); |
DevinAlexander | 0:b714c6a7c969 | 347 | LOG("Register containing\t\tsetFaultStatusClear\t\twas programmed with the parameter\t\tCR0_FAULTCLR_DEFAULT_VAL\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 348 | } |
DevinAlexander | 0:b714c6a7c969 | 349 | else if (val==CR0_FAULTCLR_RETURN_FAULTS_TO_ZERO) { |
DevinAlexander | 0:b714c6a7c969 | 350 | return_val=registerReadWriteByte(ADDRESS_CR0_READ, ADDRESS_CR0_WRITE, CR0_CLEAR_BITS_1, val); |
DevinAlexander | 0:b714c6a7c969 | 351 | LOG("Register containing\t\tsetFaultStatusClear\t\twas programmed with the parameter\t\tCR0_FAULTCLR_RETURN_FAULTS_TO_ZERO\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 352 | } |
DevinAlexander | 0:b714c6a7c969 | 353 | else { |
DevinAlexander | 0:b714c6a7c969 | 354 | LOG("Incorrect parameter selected for Control Register 0 (CR0) bit 1. Default value not changed.\r\nPlease see MAX31856.h for list of valid parameters. \r\n"); |
DevinAlexander | 0:b714c6a7c969 | 355 | return_val=0; //returns a 0 to flag that the parameter wasn't programmed due to wrong parameter in function call |
DevinAlexander | 0:b714c6a7c969 | 356 | } |
DevinAlexander | 0:b714c6a7c969 | 357 | return return_val; |
DevinAlexander | 0:b714c6a7c969 | 358 | } |
DevinAlexander | 0:b714c6a7c969 | 359 | |
DevinAlexander | 0:b714c6a7c969 | 360 | |
DevinAlexander | 0:b714c6a7c969 | 361 | //Register:CR0 Bits: 0 |
DevinAlexander | 0:b714c6a7c969 | 362 | //***************************************************************************** |
DevinAlexander | 0:b714c6a7c969 | 363 | bool MAX31856::setEmiFilterFreq(uint8_t val) |
DevinAlexander | 0:b714c6a7c969 | 364 | { |
DevinAlexander | 0:b714c6a7c969 | 365 | if (val==CR0_FILTER_OUT_60Hz) { |
DevinAlexander | 0:b714c6a7c969 | 366 | return_val=registerReadWriteByte(ADDRESS_CR0_READ, ADDRESS_CR0_WRITE, CR0_CLEAR_BITS_0, val); |
DevinAlexander | 0:b714c6a7c969 | 367 | filter_mode=0; |
DevinAlexander | 0:b714c6a7c969 | 368 | LOG("Register containing\t\tsetEmiFilterFreq\t\twas programmed with the parameter\t\tCR0_FILTER_OUT_60Hz\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 369 | } |
DevinAlexander | 0:b714c6a7c969 | 370 | else if (val==CR0_FILTER_OUT_50Hz) { |
DevinAlexander | 0:b714c6a7c969 | 371 | return_val=registerReadWriteByte(ADDRESS_CR0_READ, ADDRESS_CR0_WRITE, CR0_CLEAR_BITS_0, val); |
DevinAlexander | 0:b714c6a7c969 | 372 | filter_mode=1; |
DevinAlexander | 0:b714c6a7c969 | 373 | LOG("Register containing\t\tsetEmiFilterFreq\t\twas programmed with the parameter\t\tCR0_FILTER_OUT_50Hz\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 374 | } |
DevinAlexander | 0:b714c6a7c969 | 375 | else { |
DevinAlexander | 0:b714c6a7c969 | 376 | LOG("Incorrect parameter selected for Control Register 0 (CR0) bit 0. Default value not changed.\r\nPlease see MAX31856.h for list of valid parameters. \r\n"); |
DevinAlexander | 0:b714c6a7c969 | 377 | return_val=0; //returns a 0 to flag that the parameter wasn't programmed due to wrong parameter in function call |
DevinAlexander | 0:b714c6a7c969 | 378 | } |
DevinAlexander | 0:b714c6a7c969 | 379 | return return_val; |
DevinAlexander | 0:b714c6a7c969 | 380 | } |
DevinAlexander | 0:b714c6a7c969 | 381 | |
DevinAlexander | 0:b714c6a7c969 | 382 | |
DevinAlexander | 0:b714c6a7c969 | 383 | //Register:CR1 Bits: 6:4 |
DevinAlexander | 0:b714c6a7c969 | 384 | //***************************************************************************** |
DevinAlexander | 0:b714c6a7c969 | 385 | bool MAX31856::setNumSamplesAvg(uint8_t val) |
DevinAlexander | 0:b714c6a7c969 | 386 | { |
DevinAlexander | 0:b714c6a7c969 | 387 | if (val==CR1_AVG_TC_SAMPLES_1) { |
DevinAlexander | 0:b714c6a7c969 | 388 | return_val=registerReadWriteByte(ADDRESS_CR1_READ, ADDRESS_CR1_WRITE, CR1_CLEAR_BITS_6_4, val); |
DevinAlexander | 0:b714c6a7c969 | 389 | samples=1; |
DevinAlexander | 0:b714c6a7c969 | 390 | LOG("Register containing\t\tsetNumSamplesAvg\t\twas programmed with the parameter\t\tCR1_AVG_TC_SAMPLES_1\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 391 | } |
DevinAlexander | 0:b714c6a7c969 | 392 | else if (val==CR1_AVG_TC_SAMPLES_2) { |
DevinAlexander | 0:b714c6a7c969 | 393 | return_val=registerReadWriteByte(ADDRESS_CR1_READ, ADDRESS_CR1_WRITE, CR1_CLEAR_BITS_6_4, val); |
DevinAlexander | 0:b714c6a7c969 | 394 | samples=2; |
DevinAlexander | 0:b714c6a7c969 | 395 | LOG("Register containing\t\tsetNumSamplesAvg\t\twas programmed with the parameter\t\tCR1_AVG_TC_SAMPLES_2\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 396 | } |
DevinAlexander | 0:b714c6a7c969 | 397 | else if (val==CR1_AVG_TC_SAMPLES_4) { |
DevinAlexander | 0:b714c6a7c969 | 398 | return_val=registerReadWriteByte(ADDRESS_CR1_READ, ADDRESS_CR1_WRITE, CR1_CLEAR_BITS_6_4, val); |
DevinAlexander | 0:b714c6a7c969 | 399 | samples=4; |
DevinAlexander | 0:b714c6a7c969 | 400 | LOG("Register containing\t\tsetNumSamplesAvg\t\twas programmed with the parameter\t\tCR1_AVG_TC_SAMPLES_4\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 401 | } |
DevinAlexander | 0:b714c6a7c969 | 402 | else if (val==CR1_AVG_TC_SAMPLES_8) { |
DevinAlexander | 0:b714c6a7c969 | 403 | return_val=registerReadWriteByte(ADDRESS_CR1_READ, ADDRESS_CR1_WRITE, CR1_CLEAR_BITS_6_4, val); |
DevinAlexander | 0:b714c6a7c969 | 404 | samples=8; |
DevinAlexander | 0:b714c6a7c969 | 405 | LOG("Register containing\t\tsetNumSamplesAvg\t\twas programmed with the parameter\t\tCR1_AVG_TC_SAMPLES_8\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 406 | } |
DevinAlexander | 0:b714c6a7c969 | 407 | else if (val==CR1_AVG_TC_SAMPLES_16) { |
DevinAlexander | 0:b714c6a7c969 | 408 | return_val=registerReadWriteByte(ADDRESS_CR1_READ, ADDRESS_CR1_WRITE, CR1_CLEAR_BITS_6_4, val); |
DevinAlexander | 0:b714c6a7c969 | 409 | samples=16; |
DevinAlexander | 0:b714c6a7c969 | 410 | LOG("Register containing\t\tsetNumSamplesAvg\t\twas programmed with the parameter\t\tCR1_AVG_TC_SAMPLES_16\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 411 | } |
DevinAlexander | 0:b714c6a7c969 | 412 | else { |
DevinAlexander | 0:b714c6a7c969 | 413 | LOG("Incorrect parameter selected for Control Register 1 (CR1) bits 6:4. Default value not changed.\r\nPlease see MAX31856.h for list of valid parameters. \r\n"); |
DevinAlexander | 0:b714c6a7c969 | 414 | return_val=0; //returns a 0 to flag that the parameter wasn't programmed due to wrong parameter in function call |
DevinAlexander | 0:b714c6a7c969 | 415 | } |
DevinAlexander | 0:b714c6a7c969 | 416 | return return_val; |
DevinAlexander | 0:b714c6a7c969 | 417 | } |
DevinAlexander | 0:b714c6a7c969 | 418 | |
DevinAlexander | 0:b714c6a7c969 | 419 | |
DevinAlexander | 0:b714c6a7c969 | 420 | //Register:CR1 Bits: 3:0 |
DevinAlexander | 0:b714c6a7c969 | 421 | //***************************************************************************** |
DevinAlexander | 0:b714c6a7c969 | 422 | bool MAX31856::setThermocoupleType(uint8_t val) |
DevinAlexander | 0:b714c6a7c969 | 423 | { |
DevinAlexander | 0:b714c6a7c969 | 424 | if (val==CR1_TC_TYPE_B) { |
DevinAlexander | 0:b714c6a7c969 | 425 | return_val=registerReadWriteByte(ADDRESS_CR1_READ, ADDRESS_CR1_WRITE, CR1_CLEAR_BITS_3_0, val); |
DevinAlexander | 0:b714c6a7c969 | 426 | voltage_mode=false; |
DevinAlexander | 0:b714c6a7c969 | 427 | LOG("Register containing\t\tsetThermocoupleType\t\twas programmed with the parameter\t\tCR1_TC_TYPE_B\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 428 | } |
DevinAlexander | 0:b714c6a7c969 | 429 | else if (val==CR1_TC_TYPE_E) { |
DevinAlexander | 0:b714c6a7c969 | 430 | return_val=registerReadWriteByte(ADDRESS_CR1_READ, ADDRESS_CR1_WRITE, CR1_CLEAR_BITS_3_0, val); |
DevinAlexander | 0:b714c6a7c969 | 431 | voltage_mode=false; |
DevinAlexander | 0:b714c6a7c969 | 432 | LOG("Register containing\t\tsetThermocoupleType\t\twas programmed with the parameter\t\tCR1_TC_TYPE_E\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 433 | } |
DevinAlexander | 0:b714c6a7c969 | 434 | else if (val==CR1_TC_TYPE_J) { |
DevinAlexander | 0:b714c6a7c969 | 435 | return_val=registerReadWriteByte(ADDRESS_CR1_READ, ADDRESS_CR1_WRITE, CR1_CLEAR_BITS_3_0, val); |
DevinAlexander | 0:b714c6a7c969 | 436 | voltage_mode=false; |
DevinAlexander | 0:b714c6a7c969 | 437 | LOG("Register containing\t\tsetThermocoupleType\t\twas programmed with the parameter\t\tCR1_TC_TYPE_J\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 438 | } |
DevinAlexander | 0:b714c6a7c969 | 439 | else if (val==CR1_TC_TYPE_K) { |
DevinAlexander | 0:b714c6a7c969 | 440 | return_val=registerReadWriteByte(ADDRESS_CR1_READ, ADDRESS_CR1_WRITE, CR1_CLEAR_BITS_3_0, val); |
DevinAlexander | 0:b714c6a7c969 | 441 | voltage_mode=false; |
DevinAlexander | 0:b714c6a7c969 | 442 | LOG("Register containing\t\tsetThermocoupleType\t\twas programmed with the parameter\t\tCR1_TC_TYPE_K\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 443 | } |
DevinAlexander | 0:b714c6a7c969 | 444 | else if (val==CR1_TC_TYPE_N) { |
DevinAlexander | 0:b714c6a7c969 | 445 | return_val=registerReadWriteByte(ADDRESS_CR1_READ, ADDRESS_CR1_WRITE, CR1_CLEAR_BITS_3_0, val); |
DevinAlexander | 0:b714c6a7c969 | 446 | voltage_mode=false; |
DevinAlexander | 0:b714c6a7c969 | 447 | LOG("Register containing\t\tsetThermocoupleType\t\twas programmed with the parameter\t\tCR1_TC_TYPE_N\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 448 | } |
DevinAlexander | 0:b714c6a7c969 | 449 | else if (val==CR1_TC_TYPE_R) { |
DevinAlexander | 0:b714c6a7c969 | 450 | return_val=registerReadWriteByte(ADDRESS_CR1_READ, ADDRESS_CR1_WRITE, CR1_CLEAR_BITS_3_0, val); |
DevinAlexander | 0:b714c6a7c969 | 451 | voltage_mode=false; |
DevinAlexander | 0:b714c6a7c969 | 452 | LOG("Register containing\t\tsetThermocoupleType\t\twas programmed with the parameter\t\tCR1_TC_TYPE_R\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 453 | } |
DevinAlexander | 0:b714c6a7c969 | 454 | else if (val==CR1_TC_TYPE_S) { |
DevinAlexander | 0:b714c6a7c969 | 455 | return_val=registerReadWriteByte(ADDRESS_CR1_READ, ADDRESS_CR1_WRITE, CR1_CLEAR_BITS_3_0, val); |
DevinAlexander | 0:b714c6a7c969 | 456 | voltage_mode=false; |
DevinAlexander | 0:b714c6a7c969 | 457 | LOG("Register containing\t\tsetThermocoupleType\t\twas programmed with the parameter\t\tCR1_TC_TYPE_S\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 458 | } |
DevinAlexander | 0:b714c6a7c969 | 459 | else if (val==CR1_TC_TYPE_T) { |
DevinAlexander | 0:b714c6a7c969 | 460 | return_val=registerReadWriteByte(ADDRESS_CR1_READ, ADDRESS_CR1_WRITE, CR1_CLEAR_BITS_3_0, val); |
DevinAlexander | 0:b714c6a7c969 | 461 | voltage_mode=false; |
DevinAlexander | 0:b714c6a7c969 | 462 | LOG("Register containing\t\tsetThermocoupleType\t\twas programmed with the parameter\t\tCR1_TC_TYPE_T\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 463 | } |
DevinAlexander | 0:b714c6a7c969 | 464 | else if (val==CR1_TC_TYPE_VOLT_MODE_GAIN_8) { |
DevinAlexander | 0:b714c6a7c969 | 465 | return_val=registerReadWriteByte(ADDRESS_CR1_READ, ADDRESS_CR1_WRITE, CR1_CLEAR_BITS_3_0, val); |
DevinAlexander | 0:b714c6a7c969 | 466 | voltage_mode=true; |
DevinAlexander | 0:b714c6a7c969 | 467 | LOG("Register containing\t\tsetThermocoupleType\t\twas programmed with the parameter\t\tCR1_TC_TYPE_VOLT_MODE_GAIN_8\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 468 | } |
DevinAlexander | 0:b714c6a7c969 | 469 | else if (val==CR1_TC_TYPE_VOLT_MODE_GAIN_32) { |
DevinAlexander | 0:b714c6a7c969 | 470 | return_val=registerReadWriteByte(ADDRESS_CR1_READ, ADDRESS_CR1_WRITE, CR1_CLEAR_BITS_3_0, val); |
DevinAlexander | 0:b714c6a7c969 | 471 | voltage_mode=true; |
DevinAlexander | 0:b714c6a7c969 | 472 | LOG("Register containing\t\tsetThermocoupleType\t\twas programmed with the parameter\t\tCR1_TC_TYPE_VOLT_MODE_GAIN_32\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 473 | } |
DevinAlexander | 0:b714c6a7c969 | 474 | else { |
DevinAlexander | 0:b714c6a7c969 | 475 | LOG("Incorrect parameter selected for Control Register 1 (CR1) bits 3:0. Default value not changed.\r\nPlease see MAX31856.h for list of valid parameters. \r\n"); |
DevinAlexander | 0:b714c6a7c969 | 476 | return_val=0; //returns a 0 to flag that the parameter wasn't programmed due to wrong parameter in function call |
DevinAlexander | 0:b714c6a7c969 | 477 | } |
DevinAlexander | 0:b714c6a7c969 | 478 | return return_val; |
DevinAlexander | 0:b714c6a7c969 | 479 | } |
DevinAlexander | 0:b714c6a7c969 | 480 | |
DevinAlexander | 0:b714c6a7c969 | 481 | |
DevinAlexander | 0:b714c6a7c969 | 482 | //Register:MASK Bits: 5:0 |
DevinAlexander | 0:b714c6a7c969 | 483 | //***************************************************************************** |
DevinAlexander | 0:b714c6a7c969 | 484 | bool MAX31856::setFaultMasks(uint8_t val, bool enable) |
DevinAlexander | 0:b714c6a7c969 | 485 | { |
DevinAlexander | 0:b714c6a7c969 | 486 | if(enable) |
DevinAlexander | 0:b714c6a7c969 | 487 | val=0; |
DevinAlexander | 0:b714c6a7c969 | 488 | if (val==MASK_CJ_FAULT_THRESHOLD_HIGH) { //Cold Junction High Threshold Fault Mask |
DevinAlexander | 0:b714c6a7c969 | 489 | return_val=registerReadWriteByte(ADDRESS_MASK_READ, ADDRESS_MASK_WRITE, MASK_CLEAR_BITS_5, val); |
DevinAlexander | 0:b714c6a7c969 | 490 | LOG("Register containing\t\tsetFaultMasks\t\twas programmed with the parameter\t\tMASK_CJ_FAULT_THRESHOLD_HIGH\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 491 | } |
DevinAlexander | 0:b714c6a7c969 | 492 | else if (val==MASK_CJ_FAULT_THRESHOLD_LOW) { //Cold Junction Low Threshold Fault Mask |
DevinAlexander | 0:b714c6a7c969 | 493 | return_val=registerReadWriteByte(ADDRESS_MASK_READ, ADDRESS_MASK_WRITE, MASK_CLEAR_BITS_4, val); |
DevinAlexander | 0:b714c6a7c969 | 494 | LOG("Register containing\t\tsetFaultMasks\t\twas programmed with the parameter\t\tMASK_CJ_FAULT_THRESHOLD_LOW\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 495 | } |
DevinAlexander | 0:b714c6a7c969 | 496 | else if (val==MASK_TC_FAULT_THRESHOLD_HIGH) { //Thermocouple High Threshold Fault Mask |
DevinAlexander | 0:b714c6a7c969 | 497 | return_val=registerReadWriteByte(ADDRESS_MASK_READ, ADDRESS_MASK_WRITE, MASK_CLEAR_BITS_3, val); |
DevinAlexander | 0:b714c6a7c969 | 498 | LOG("Register containing\t\tsetFaultMasks\t\twas programmed with the parameter\t\tMASK_TC_FAULT_THRESHOLD_HIGH\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 499 | } |
DevinAlexander | 0:b714c6a7c969 | 500 | else if (val==MASK_TC_FAULT_THRESHOLD_LOW) { //Thermocouple Low Threshold Fault Mask |
DevinAlexander | 0:b714c6a7c969 | 501 | return_val=registerReadWriteByte(ADDRESS_MASK_READ, ADDRESS_MASK_WRITE, MASK_CLEAR_BITS_2, val); |
DevinAlexander | 0:b714c6a7c969 | 502 | LOG("Register containing\t\tsetFaultMasks\t\twas programmed with the parameter\t\tMASK_TC_FAULT_THRESHOLD_LOW\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 503 | } |
DevinAlexander | 0:b714c6a7c969 | 504 | else if (val==MASK_OVER_UNDER_VOLT_FAULT) { //Over-Voltage/Under-Voltage Input Fault Mask |
DevinAlexander | 0:b714c6a7c969 | 505 | return_val=registerReadWriteByte(ADDRESS_MASK_READ, ADDRESS_MASK_WRITE, MASK_CLEAR_BITS_1, val); |
DevinAlexander | 0:b714c6a7c969 | 506 | LOG("Register containing\t\tsetFaultMasks\t\twas programmed with the parameter\t\tMASK_OVER_UNDER_VOLT_FAULT\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 507 | } |
DevinAlexander | 0:b714c6a7c969 | 508 | else if (val==MASK_OPEN_CIRCUIT_FAULT) { //Thermocouple Open-Circuit Fault Mask |
DevinAlexander | 0:b714c6a7c969 | 509 | return_val=registerReadWriteByte(ADDRESS_MASK_READ, ADDRESS_MASK_WRITE, MASK_CLEAR_BITS_0, val); |
DevinAlexander | 0:b714c6a7c969 | 510 | LOG("Register containing\t\tsetFaultMasks\t\twas programmed with the parameter\t\tMASK_OPEN_CIRCUIT_FAULT\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 511 | } |
DevinAlexander | 0:b714c6a7c969 | 512 | else { |
DevinAlexander | 0:b714c6a7c969 | 513 | LOG("Incorrect parameter selected for Mask Register bits 5:0. Default value not changed.\r\nPlease see MAX31856.h for list of valid parameters. \r\n"); |
DevinAlexander | 0:b714c6a7c969 | 514 | return_val=0; //returns a 0 to flag that the parameter wasn't programmed due to wrong parameter in function call |
DevinAlexander | 0:b714c6a7c969 | 515 | } |
DevinAlexander | 0:b714c6a7c969 | 516 | return return_val; |
DevinAlexander | 0:b714c6a7c969 | 517 | } |
DevinAlexander | 0:b714c6a7c969 | 518 | |
DevinAlexander | 0:b714c6a7c969 | 519 | |
DevinAlexander | 0:b714c6a7c969 | 520 | //Register:MASK Bits: 5:0 |
DevinAlexander | 0:b714c6a7c969 | 521 | //****************************************************************************** |
DevinAlexander | 0:b714c6a7c969 | 522 | bool MAX31856::setFaultThresholds(uint8_t val, float temperature) |
DevinAlexander | 0:b714c6a7c969 | 523 | { |
DevinAlexander | 0:b714c6a7c969 | 524 | if (val==MASK_CJ_FAULT_THRESHOLD_HIGH) { //Cold Junction High Threshold Fault Mask |
DevinAlexander | 0:b714c6a7c969 | 525 | int8_t temperature_byte=temperature; |
DevinAlexander | 0:b714c6a7c969 | 526 | return_val=registerWriteByte(ADDRESS_CJHF_WRITE, temperature_byte); |
DevinAlexander | 0:b714c6a7c969 | 527 | } |
DevinAlexander | 0:b714c6a7c969 | 528 | else if (val==MASK_CJ_FAULT_THRESHOLD_LOW) { //Cold Junction Low Threshold Fault Mask |
DevinAlexander | 0:b714c6a7c969 | 529 | int8_t temperature_byte=temperature; |
DevinAlexander | 0:b714c6a7c969 | 530 | return_val=registerWriteByte(ADDRESS_CJLF_WRITE, temperature_byte); |
DevinAlexander | 0:b714c6a7c969 | 531 | } |
DevinAlexander | 0:b714c6a7c969 | 532 | else if (val==MASK_TC_FAULT_THRESHOLD_HIGH) { //Thermocouple High Threshold Fault Mask |
DevinAlexander | 0:b714c6a7c969 | 533 | int8_t temperature_byte[2]; |
DevinAlexander | 0:b714c6a7c969 | 534 | int16_t temperature_multi_byte =temperature*4.0; |
DevinAlexander | 0:b714c6a7c969 | 535 | //now split up the 16bit int into two bytes to program the registers with |
DevinAlexander | 0:b714c6a7c969 | 536 | temperature_byte[0]=((uint8_t)((temperature_multi_byte)&(0xFF00) >> 8)); |
DevinAlexander | 0:b714c6a7c969 | 537 | temperature_byte[1]=((uint8_t)((temperature_multi_byte)&(0x00FF))); |
DevinAlexander | 0:b714c6a7c969 | 538 | |
DevinAlexander | 0:b714c6a7c969 | 539 | return_val=registerWriteByte(ADDRESS_LTHFTH_WRITE, temperature_byte[0]); |
DevinAlexander | 0:b714c6a7c969 | 540 | return_val=registerWriteByte(ADDRESS_LTHFTL_WRITE, temperature_byte[1]); |
DevinAlexander | 0:b714c6a7c969 | 541 | } |
DevinAlexander | 0:b714c6a7c969 | 542 | else if (val==MASK_TC_FAULT_THRESHOLD_LOW) { //Thermocouple LOW Threshold Fault Mask |
DevinAlexander | 0:b714c6a7c969 | 543 | int8_t temperature_byte[2]; |
DevinAlexander | 0:b714c6a7c969 | 544 | int16_t temperature_multi_byte =temperature*4.0; |
DevinAlexander | 0:b714c6a7c969 | 545 | //now split up the 16bit int into two bytes to program the registers with |
DevinAlexander | 0:b714c6a7c969 | 546 | temperature_byte[0]=((uint8_t)((temperature_multi_byte)&(0xFF00) >> 8)); |
DevinAlexander | 0:b714c6a7c969 | 547 | temperature_byte[1]=((uint8_t)((temperature_multi_byte)&(0x00FF))); |
DevinAlexander | 0:b714c6a7c969 | 548 | |
DevinAlexander | 0:b714c6a7c969 | 549 | return_val=registerWriteByte(ADDRESS_LTHFTH_WRITE, temperature_byte[0]); |
DevinAlexander | 0:b714c6a7c969 | 550 | return_val=registerWriteByte(ADDRESS_LTHFTL_WRITE, temperature_byte[1]); |
DevinAlexander | 0:b714c6a7c969 | 551 | } |
DevinAlexander | 0:b714c6a7c969 | 552 | else |
DevinAlexander | 0:b714c6a7c969 | 553 | LOG("Please select correct threshold register to program with the correct value!\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 554 | return return_val; |
DevinAlexander | 0:b714c6a7c969 | 555 | } |
DevinAlexander | 0:b714c6a7c969 | 556 | |
DevinAlexander | 0:b714c6a7c969 | 557 | //****************************************************************************** |
DevinAlexander | 0:b714c6a7c969 | 558 | bool MAX31856::coldJunctionOffset(float temperature) |
DevinAlexander | 0:b714c6a7c969 | 559 | { |
DevinAlexander | 0:b714c6a7c969 | 560 | if (temperature > 7.9375 || temperature < -8.0) { |
DevinAlexander | 0:b714c6a7c969 | 561 | LOG("Input value to offest the cold junction point is non valid. enter in value in range -8 to +7.9375\r\n"); |
DevinAlexander | 0:b714c6a7c969 | 562 | return_val = 0; |
DevinAlexander | 0:b714c6a7c969 | 563 | } |
DevinAlexander | 0:b714c6a7c969 | 564 | int8_t temp_val=temperature*16.0f; //normalize the value to get rid of decimal and shorten it to size of register |
DevinAlexander | 0:b714c6a7c969 | 565 | return_val=registerWriteByte(ADDRESS_CJTO_WRITE, temp_val); //write the byte to cold junction offset register |
DevinAlexander | 0:b714c6a7c969 | 566 | return return_val; |
DevinAlexander | 0:b714c6a7c969 | 567 | } |
DevinAlexander | 0:b714c6a7c969 | 568 | |
DevinAlexander | 0:b714c6a7c969 | 569 | |
DevinAlexander | 0:b714c6a7c969 | 570 | //The following functions are for internal library use only |
DevinAlexander | 0:b714c6a7c969 | 571 | //****************************************************************************** |
DevinAlexander | 0:b714c6a7c969 | 572 | void MAX31856::spiEnable() |
DevinAlexander | 0:b714c6a7c969 | 573 | { |
DevinAlexander | 0:b714c6a7c969 | 574 | ncs=0; //Set CS low to start transmission (interrupts conversion) |
DevinAlexander | 0:b714c6a7c969 | 575 | return; |
DevinAlexander | 0:b714c6a7c969 | 576 | } |
DevinAlexander | 0:b714c6a7c969 | 577 | |
DevinAlexander | 0:b714c6a7c969 | 578 | |
DevinAlexander | 0:b714c6a7c969 | 579 | //****************************************************************************** |
DevinAlexander | 0:b714c6a7c969 | 580 | void MAX31856::spiDisable() |
DevinAlexander | 0:b714c6a7c969 | 581 | { |
DevinAlexander | 0:b714c6a7c969 | 582 | ncs=1; //Set CS high to stop transmission (restarts conversion) |
DevinAlexander | 0:b714c6a7c969 | 583 | return; |
DevinAlexander | 0:b714c6a7c969 | 584 | } |
DevinAlexander | 0:b714c6a7c969 | 585 | |
DevinAlexander | 0:b714c6a7c969 | 586 | |
DevinAlexander | 0:b714c6a7c969 | 587 | //****************************************************************************** |
DevinAlexander | 0:b714c6a7c969 | 588 | bool MAX31856::registerReadWriteByte(uint8_t read_address, uint8_t write_address, int clear_bits, uint8_t val) |
DevinAlexander | 0:b714c6a7c969 | 589 | { |
DevinAlexander | 0:b714c6a7c969 | 590 | uint8_t buf_read[2]; |
DevinAlexander | 0:b714c6a7c969 | 591 | |
DevinAlexander | 0:b714c6a7c969 | 592 | //Read the current contents of a register |
DevinAlexander | 0:b714c6a7c969 | 593 | spiEnable(); |
DevinAlexander | 0:b714c6a7c969 | 594 | for(int i=0; i<2; i++) { |
DevinAlexander | 0:b714c6a7c969 | 595 | buf_read[i]=spi.write(read_address); |
DevinAlexander | 0:b714c6a7c969 | 596 | } |
DevinAlexander | 0:b714c6a7c969 | 597 | spiDisable(); |
DevinAlexander | 0:b714c6a7c969 | 598 | |
DevinAlexander | 0:b714c6a7c969 | 599 | //Modify contents pulled from the register |
DevinAlexander | 0:b714c6a7c969 | 600 | buf_read[1]&=clear_bits; //Clear the contents of bits of parameter you are trying to clear for later or equal operation |
DevinAlexander | 0:b714c6a7c969 | 601 | buf_read[1]|=val; //Bitwise OR the input parameter with cleaned buf_read[1] to create new byte |
DevinAlexander | 0:b714c6a7c969 | 602 | val=buf_read[1]; |
DevinAlexander | 0:b714c6a7c969 | 603 | |
DevinAlexander | 0:b714c6a7c969 | 604 | //Write the updated byte to the register |
DevinAlexander | 0:b714c6a7c969 | 605 | spiEnable(); |
DevinAlexander | 0:b714c6a7c969 | 606 | buf_read[0]=spi.write(write_address); |
DevinAlexander | 0:b714c6a7c969 | 607 | buf_read[1]=spi.write(val); |
DevinAlexander | 0:b714c6a7c969 | 608 | spiDisable(); |
DevinAlexander | 0:b714c6a7c969 | 609 | return 1; |
DevinAlexander | 0:b714c6a7c969 | 610 | } |
DevinAlexander | 0:b714c6a7c969 | 611 | |
DevinAlexander | 0:b714c6a7c969 | 612 | |
DevinAlexander | 0:b714c6a7c969 | 613 | //****************************************************************************** |
DevinAlexander | 0:b714c6a7c969 | 614 | bool MAX31856::registerWriteByte(uint8_t write_address, uint8_t val) |
DevinAlexander | 0:b714c6a7c969 | 615 | { |
DevinAlexander | 0:b714c6a7c969 | 616 | //Write the updated byte to the register |
DevinAlexander | 0:b714c6a7c969 | 617 | spiEnable(); |
DevinAlexander | 0:b714c6a7c969 | 618 | spi.write(write_address); |
DevinAlexander | 0:b714c6a7c969 | 619 | spi.write(val); |
DevinAlexander | 0:b714c6a7c969 | 620 | spiDisable(); |
DevinAlexander | 0:b714c6a7c969 | 621 | return true; |
DevinAlexander | 0:b714c6a7c969 | 622 | } |
DevinAlexander | 0:b714c6a7c969 | 623 | |
DevinAlexander | 0:b714c6a7c969 | 624 | //****************************************************************************** |
DevinAlexander | 0:b714c6a7c969 | 625 | uint8_t MAX31856::registerReadByte(uint8_t read_address) |
DevinAlexander | 0:b714c6a7c969 | 626 | { |
DevinAlexander | 0:b714c6a7c969 | 627 | uint8_t buf_read, buf_write=read_address; |
DevinAlexander | 0:b714c6a7c969 | 628 | spiEnable(); |
DevinAlexander | 0:b714c6a7c969 | 629 | buf_read=spi.write(buf_write); |
DevinAlexander | 0:b714c6a7c969 | 630 | buf_read=spi.write(buf_write); |
DevinAlexander | 0:b714c6a7c969 | 631 | spiDisable(); |
DevinAlexander | 0:b714c6a7c969 | 632 | return buf_read; |
DevinAlexander | 0:b714c6a7c969 | 633 | } |
DevinAlexander | 0:b714c6a7c969 | 634 | |
DevinAlexander | 0:b714c6a7c969 | 635 | //****************************************************************************** |
DevinAlexander | 0:b714c6a7c969 | 636 | void MAX31856::calculateDelayTime() { |
DevinAlexander | 0:b714c6a7c969 | 637 | uint32_t temp_int; |
DevinAlexander | 0:b714c6a7c969 | 638 | |
DevinAlexander | 0:b714c6a7c969 | 639 | if (conversion_mode==0 || thermocouple_conversion_count==0) { |
DevinAlexander | 0:b714c6a7c969 | 640 | if (filter_mode==0) //60Hz |
DevinAlexander | 0:b714c6a7c969 | 641 | temp_int=82+(samples-1)*33.33f; |
DevinAlexander | 0:b714c6a7c969 | 642 | else //50Hz |
DevinAlexander | 0:b714c6a7c969 | 643 | temp_int=98+(samples-1)*40.00f; |
DevinAlexander | 0:b714c6a7c969 | 644 | } |
DevinAlexander | 0:b714c6a7c969 | 645 | else { |
DevinAlexander | 0:b714c6a7c969 | 646 | if (filter_mode==0) //60Hz |
DevinAlexander | 0:b714c6a7c969 | 647 | temp_int=82+(samples-1)*16.67f; |
DevinAlexander | 0:b714c6a7c969 | 648 | else //50Hz |
DevinAlexander | 0:b714c6a7c969 | 649 | temp_int=98+(samples-1)*20.00f; |
DevinAlexander | 0:b714c6a7c969 | 650 | } |
DevinAlexander | 0:b714c6a7c969 | 651 | |
DevinAlexander | 0:b714c6a7c969 | 652 | if (cold_junction_enabled==0) //cold junction is disabled enabling 25 millisecond faster conversion times |
DevinAlexander | 0:b714c6a7c969 | 653 | temp_int=temp_int-25; |
DevinAlexander | 0:b714c6a7c969 | 654 | conversion_time=1000*temp_int; //set private member conversion time to calculated minimum wait time in microseconds |
DevinAlexander | 0:b714c6a7c969 | 655 | return; |
DevinAlexander | 0:b714c6a7c969 | 656 | } |
DevinAlexander | 0:b714c6a7c969 | 657 | |
DevinAlexander | 0:b714c6a7c969 | 658 | //***************************************************************************** |
DevinAlexander | 0:b714c6a7c969 | 659 | MAX31856::~MAX31856(void) |
DevinAlexander | 0:b714c6a7c969 | 660 | { |
DevinAlexander | 0:b714c6a7c969 | 661 | //empty block |
DevinAlexander | 0:b714c6a7c969 | 662 | } |
DevinAlexander | 0:b714c6a7c969 | 663 |