Library to support temperature sensor conversions and lookups

Committer:
mahphalke
Date:
Thu Jul 01 13:41:18 2021 +0530
Revision:
4:d8246c20aed2
Parent:
2:bcfa5a2f21c9
Adding equation to calculate 10K 44031 NTC temperature using Beta value

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mahphalke 1:f65f6fadda5d 1 /*!
mahphalke 1:f65f6fadda5d 2 *****************************************************************************
mahphalke 1:f65f6fadda5d 3 @file: thermcouple.cpp
mahphalke 1:f65f6fadda5d 4
mahphalke 1:f65f6fadda5d 5 @brief:
mahphalke 1:f65f6fadda5d 6
mahphalke 1:f65f6fadda5d 7 @details:
mahphalke 1:f65f6fadda5d 8 -----------------------------------------------------------------------------
mahphalke 1:f65f6fadda5d 9 Copyright (c) 2018, 2020 Analog Devices, Inc. All rights reserved.
mahphalke 1:f65f6fadda5d 10
mahphalke 1:f65f6fadda5d 11 This software is proprietary to Analog Devices, Inc. and its licensors.
mahphalke 1:f65f6fadda5d 12 By using this software you agree to the terms of the associated
mahphalke 1:f65f6fadda5d 13 Analog Devices Software License Agreement.
mahphalke 1:f65f6fadda5d 14
mahphalke 1:f65f6fadda5d 15 *****************************************************************************/
mahphalke 1:f65f6fadda5d 16
mahphalke 1:f65f6fadda5d 17 #include <math.h>
mahphalke 1:f65f6fadda5d 18 #include "thermocouple.h"
mahphalke 1:f65f6fadda5d 19
mahphalke 1:f65f6fadda5d 20 // http://srdata.nist.gov/its90/download/allcoeff.tab
mahphalke 1:f65f6fadda5d 21
mahphalke 1:f65f6fadda5d 22 Thermocouple::Thermocouple() {}
mahphalke 1:f65f6fadda5d 23 Thermocouple::~Thermocouple() {}
mahphalke 1:f65f6fadda5d 24
mahphalke 1:f65f6fadda5d 25 float Thermocouple::lookup(const int32_t *lut, float voltage, uint16_t size,
mahphalke 1:f65f6fadda5d 26 int16_t offset)
mahphalke 1:f65f6fadda5d 27 {
mahphalke 1:f65f6fadda5d 28 uint16_t first = 0;
mahphalke 1:f65f6fadda5d 29 uint16_t last = size - 1;
mahphalke 1:f65f6fadda5d 30 uint16_t middle = (first + last) / 2;
mahphalke 1:f65f6fadda5d 31 int32_t integer_voltage = int32_t(voltage*1000);
mahphalke 1:f65f6fadda5d 32 while (first <= last) {
mahphalke 1:f65f6fadda5d 33 if (lut[middle] < integer_voltage)
mahphalke 1:f65f6fadda5d 34 first = middle + 1;
mahphalke 1:f65f6fadda5d 35 else if (lut[middle] == integer_voltage) {
mahphalke 1:f65f6fadda5d 36 return static_cast<float>(middle + offset);
mahphalke 1:f65f6fadda5d 37 } else
mahphalke 1:f65f6fadda5d 38 last = middle - 1;
mahphalke 1:f65f6fadda5d 39
mahphalke 1:f65f6fadda5d 40 middle = (first + last) / 2;
mahphalke 1:f65f6fadda5d 41 }
mahphalke 1:f65f6fadda5d 42 if (first > last)
mahphalke 1:f65f6fadda5d 43 return static_cast<float>(first+offset);
mahphalke 1:f65f6fadda5d 44
mahphalke 1:f65f6fadda5d 45 return 0; // should never get here
mahphalke 1:f65f6fadda5d 46 }
mahphalke 1:f65f6fadda5d 47
mahphalke 1:f65f6fadda5d 48 float Thermocouple::convert(float voltage,
mahphalke 1:f65f6fadda5d 49 const thermocouple_poly_subrange range[], const int n)
mahphalke 1:f65f6fadda5d 50 {
mahphalke 1:f65f6fadda5d 51 int range_id = 0;
mahphalke 1:f65f6fadda5d 52 float temperature=0;
mahphalke 1:f65f6fadda5d 53 for(range_id = 0 ; range_id<n; range_id++) {
mahphalke 1:f65f6fadda5d 54 if(voltage > range[range_id].min_voltage_range
mahphalke 1:f65f6fadda5d 55 && voltage <= range[range_id].max_voltage_range)
mahphalke 1:f65f6fadda5d 56 break;
mahphalke 1:f65f6fadda5d 57 }
mahphalke 1:f65f6fadda5d 58
mahphalke 1:f65f6fadda5d 59 for (int i = 0; i < range[range_id].n; i++) {
mahphalke 1:f65f6fadda5d 60 temperature += (range[range_id].coef[i] * pow(10,
mahphalke 1:f65f6fadda5d 61 range[range_id].power[i])) * pow(voltage, i);
mahphalke 1:f65f6fadda5d 62 }
mahphalke 1:f65f6fadda5d 63 return temperature;
mahphalke 1:f65f6fadda5d 64 }
mahphalke 1:f65f6fadda5d 65
mahphalke 1:f65f6fadda5d 66
mahphalke 1:f65f6fadda5d 67
mahphalke 1:f65f6fadda5d 68
mahphalke 1:f65f6fadda5d 69 const int Thermocouple_Type_B::inv_poly_size = 2;
mahphalke 1:f65f6fadda5d 70 const Thermocouple::thermocouple_poly_subrange Thermocouple_Type_B::inv_poly[2]
mahphalke 1:f65f6fadda5d 71 = {
mahphalke 1:f65f6fadda5d 72 {
mahphalke 1:f65f6fadda5d 73 0.000, 630.615,// characteristic curve for temp range between 0.000, and 630.615,
mahphalke 1:f65f6fadda5d 74 {0.000000000000,-0.246508183460,0.590404211710,-0.132579316360,0.156682919010,-0.169445292400,0.629903470940,},
mahphalke 1:f65f6fadda5d 75 { 0, -3, -5, -8, -11, -14, -18,},
mahphalke 1:f65f6fadda5d 76 7
mahphalke 1:f65f6fadda5d 77 },
mahphalke 1:f65f6fadda5d 78 {
mahphalke 1:f65f6fadda5d 79 630.615, 1820.000,// characteristic curve for temp range between 630.615, and 1820.000,
mahphalke 1:f65f6fadda5d 80 {-0.389381686210,0.285717474700,-0.848851047850,0.157852801640,-0.168353448640,0.111097940130,-0.445154310330,0.989756408210,-0.937913302890,},
mahphalke 1:f65f6fadda5d 81 { 1, -1, -4, -6, -9, -12, -16, -20, -24,},
mahphalke 1:f65f6fadda5d 82 9
mahphalke 1:f65f6fadda5d 83 }
mahphalke 1:f65f6fadda5d 84 };
mahphalke 1:f65f6fadda5d 85
mahphalke 1:f65f6fadda5d 86 float Thermocouple_Type_B::convert_inv(float temp)
mahphalke 1:f65f6fadda5d 87 {
mahphalke 1:f65f6fadda5d 88 return Thermocouple::convert(temp, inv_poly, inv_poly_size);
mahphalke 1:f65f6fadda5d 89 }
mahphalke 1:f65f6fadda5d 90
mahphalke 1:f65f6fadda5d 91 float Thermocouple_Type_B::lookup_inv(float temp)
mahphalke 1:f65f6fadda5d 92 {
mahphalke 1:f65f6fadda5d 93 #ifdef TYPE_B_LUT
mahphalke 1:f65f6fadda5d 94 if((temp+lut_offset)>lut_size)
mahphalke 1:f65f6fadda5d 95 return lut[lut_size-1];
mahphalke 1:f65f6fadda5d 96 else
mahphalke 1:f65f6fadda5d 97 return lut[(uint16_t)temp+lut_offset];
mahphalke 1:f65f6fadda5d 98 #else
mahphalke 1:f65f6fadda5d 99 /* NOT IMPLEMENTED */
mahphalke 1:f65f6fadda5d 100 return 0;
mahphalke 1:f65f6fadda5d 101 #endif
mahphalke 1:f65f6fadda5d 102 }
mahphalke 1:f65f6fadda5d 103 const int Thermocouple_Type_B::poly_size = 2;
mahphalke 1:f65f6fadda5d 104 const Thermocouple::thermocouple_poly_subrange Thermocouple_Type_B::poly[2] = {
mahphalke 1:f65f6fadda5d 105 {
mahphalke 1:f65f6fadda5d 106 0.291, 2.431, // characteristic curve for mV range between 0.291 and 2.431
mahphalke 1:f65f6fadda5d 107 { 9.8423321, 6.9971500, -8.4765304, 1.0052644, -8.3345952, 4.5508542, -1.5523037, 2.9886750, -2.4742860,},
mahphalke 1:f65f6fadda5d 108 { 1, 2, 2, 3, 2, 2, 2, 1, 0,},
mahphalke 1:f65f6fadda5d 109 9
mahphalke 1:f65f6fadda5d 110 },
mahphalke 1:f65f6fadda5d 111 {
mahphalke 1:f65f6fadda5d 112 2.431, 13.820, // characteristic curve for mV range between 2.431 and 13.820
mahphalke 1:f65f6fadda5d 113 { 2.1315071, 2.8510504, -5.2742887, 9.9160804, -1.2965303, 1.1195870, -6.0625199, 1.8661696, -2.4878585,},
mahphalke 1:f65f6fadda5d 114 { 2, 2, 1, 0, 0, -1, -3, -4, -6,},
mahphalke 1:f65f6fadda5d 115 9
mahphalke 1:f65f6fadda5d 116 }
mahphalke 1:f65f6fadda5d 117 };
mahphalke 1:f65f6fadda5d 118
mahphalke 1:f65f6fadda5d 119 Thermocouple_Type_B::~Thermocouple_Type_B()
mahphalke 1:f65f6fadda5d 120 {
mahphalke 1:f65f6fadda5d 121
mahphalke 1:f65f6fadda5d 122 }
mahphalke 1:f65f6fadda5d 123
mahphalke 1:f65f6fadda5d 124 float Thermocouple_Type_B::convert(float voltage)
mahphalke 1:f65f6fadda5d 125 {
mahphalke 1:f65f6fadda5d 126 return Thermocouple::convert(voltage, poly, poly_size);
mahphalke 1:f65f6fadda5d 127 }
mahphalke 1:f65f6fadda5d 128
mahphalke 1:f65f6fadda5d 129 float Thermocouple_Type_B::lookup(float voltage)
mahphalke 1:f65f6fadda5d 130 {
mahphalke 1:f65f6fadda5d 131 #ifdef TYPE_B_LUT
mahphalke 1:f65f6fadda5d 132 return Thermocouple::lookup(lut, voltage, lut_size, lut_offset);
mahphalke 1:f65f6fadda5d 133 #else
mahphalke 1:f65f6fadda5d 134 /* NOT IMPLEMENTED */
mahphalke 1:f65f6fadda5d 135 return 0;
mahphalke 1:f65f6fadda5d 136 #endif
mahphalke 1:f65f6fadda5d 137 }
mahphalke 1:f65f6fadda5d 138 const int Thermocouple_Type_E::inv_poly_size = 2;
mahphalke 1:f65f6fadda5d 139 const Thermocouple::thermocouple_poly_subrange Thermocouple_Type_E::inv_poly[2]
mahphalke 1:f65f6fadda5d 140 = {
mahphalke 1:f65f6fadda5d 141 {
mahphalke 1:f65f6fadda5d 142 -270.000, 0.000,// characteristic curve for temp range between -270.000, and 0.000,
mahphalke 1:f65f6fadda5d 143 {0.000000000000,0.586655087080,0.454109771240,-0.779980486860,-0.258001608430,-0.594525830570,-0.932140586670,-0.102876055340,-0.803701236210,-0.439794973910,-0.164147763550,-0.396736195160,-0.558273287210,-0.346578420130,},
mahphalke 1:f65f6fadda5d 144 { 0, -1, -4, -6, -7, -9, -11, -12, -15, -17, -19, -22, -25, -28,},
mahphalke 1:f65f6fadda5d 145 14
mahphalke 1:f65f6fadda5d 146 },
mahphalke 1:f65f6fadda5d 147 {
mahphalke 1:f65f6fadda5d 148 0.000, 1000.000,// characteristic curve for temp range between 0.000, and 1000.000,
mahphalke 1:f65f6fadda5d 149 {0.000000000000,0.586655087100,0.450322755820,0.289084072120,-0.330568966520,0.650244032700,-0.191974955040,-0.125366004970,0.214892175690,-0.143880417820,0.359608994810,},
mahphalke 1:f65f6fadda5d 150 { 0, -1, -4, -7, -9, -12, -15, -17, -20, -23, -27,},
mahphalke 1:f65f6fadda5d 151 11
mahphalke 1:f65f6fadda5d 152 }
mahphalke 1:f65f6fadda5d 153 };
mahphalke 1:f65f6fadda5d 154
mahphalke 1:f65f6fadda5d 155 float Thermocouple_Type_E::convert_inv(float temp)
mahphalke 1:f65f6fadda5d 156 {
mahphalke 1:f65f6fadda5d 157 return Thermocouple::convert(temp, inv_poly, inv_poly_size);
mahphalke 1:f65f6fadda5d 158 }
mahphalke 1:f65f6fadda5d 159
mahphalke 1:f65f6fadda5d 160 float Thermocouple_Type_E::lookup_inv(float temp)
mahphalke 1:f65f6fadda5d 161 {
mahphalke 1:f65f6fadda5d 162 #ifdef TYPE_E_LUT
mahphalke 1:f65f6fadda5d 163 if((temp+lut_offset)>lut_size)
mahphalke 1:f65f6fadda5d 164 return lut[lut_size-1];
mahphalke 1:f65f6fadda5d 165 else
mahphalke 1:f65f6fadda5d 166 return lut[(uint16_t)temp+lut_offset];
mahphalke 1:f65f6fadda5d 167 #else
mahphalke 1:f65f6fadda5d 168 /* NOT IMPLEMENTED */
mahphalke 1:f65f6fadda5d 169 return 0;
mahphalke 1:f65f6fadda5d 170 #endif
mahphalke 1:f65f6fadda5d 171 }
mahphalke 1:f65f6fadda5d 172 const int Thermocouple_Type_E::poly_size = 2;
mahphalke 1:f65f6fadda5d 173 const Thermocouple::thermocouple_poly_subrange Thermocouple_Type_E::poly[2] = {
mahphalke 1:f65f6fadda5d 174 {
mahphalke 1:f65f6fadda5d 175 -8.825, 0.000, // characteristic curve for mV range between -8.825 and 0.000
mahphalke 1:f65f6fadda5d 176 { 0.0000000, 1.6977288, -4.3514970, -1.5859697, -9.2502871, -2.6084314, -4.1360199, -3.4034030, -1.1564890, 0.0000000,},
mahphalke 1:f65f6fadda5d 177 { 0, 1, -1, -1, -2, -2, -3, -4, -5, 0,},
mahphalke 1:f65f6fadda5d 178 10
mahphalke 1:f65f6fadda5d 179 },
mahphalke 1:f65f6fadda5d 180 {
mahphalke 1:f65f6fadda5d 181 0.000, 76.373, // characteristic curve for mV range between 0.000 and 76.373
mahphalke 1:f65f6fadda5d 182 { 0.0000000, 1.7057035, -2.3301759, 6.5435585, -7.3562749, -1.7896001, 8.4036165, -1.3735879, 1.0629823, -3.2447087,},
mahphalke 1:f65f6fadda5d 183 { 0, 1, -1, -3, -5, -6, -8, -9, -11, -14,},
mahphalke 1:f65f6fadda5d 184 10
mahphalke 1:f65f6fadda5d 185 }
mahphalke 1:f65f6fadda5d 186 };
mahphalke 1:f65f6fadda5d 187
mahphalke 1:f65f6fadda5d 188 Thermocouple_Type_E::~Thermocouple_Type_E()
mahphalke 1:f65f6fadda5d 189 {
mahphalke 1:f65f6fadda5d 190
mahphalke 1:f65f6fadda5d 191 }
mahphalke 1:f65f6fadda5d 192
mahphalke 1:f65f6fadda5d 193 float Thermocouple_Type_E::convert(float voltage)
mahphalke 1:f65f6fadda5d 194 {
mahphalke 1:f65f6fadda5d 195 return Thermocouple::convert(voltage, poly, poly_size);
mahphalke 1:f65f6fadda5d 196 }
mahphalke 1:f65f6fadda5d 197
mahphalke 1:f65f6fadda5d 198 float Thermocouple_Type_E::lookup(float voltage)
mahphalke 1:f65f6fadda5d 199 {
mahphalke 1:f65f6fadda5d 200 #ifdef TYPE_E_LUT
mahphalke 1:f65f6fadda5d 201 return Thermocouple::lookup(lut, voltage, lut_size, lut_offset);
mahphalke 1:f65f6fadda5d 202 #else
mahphalke 1:f65f6fadda5d 203 /* NOT IMPLEMENTED */
mahphalke 1:f65f6fadda5d 204 return 0;
mahphalke 1:f65f6fadda5d 205 #endif
mahphalke 1:f65f6fadda5d 206 }
mahphalke 1:f65f6fadda5d 207 const int Thermocouple_Type_J::inv_poly_size = 2;
mahphalke 1:f65f6fadda5d 208 const Thermocouple::thermocouple_poly_subrange Thermocouple_Type_J::inv_poly[2]
mahphalke 1:f65f6fadda5d 209 = {
mahphalke 1:f65f6fadda5d 210 {
mahphalke 1:f65f6fadda5d 211 -210.000, 760.000,// characteristic curve for temp range between -210.000, and 760.000,
mahphalke 1:f65f6fadda5d 212 {0.000000000000,0.503811878150,0.304758369300,-0.856810657200,0.132281952950,-0.170529583370,0.209480906970,-0.125383953360,0.156317256970,},
mahphalke 1:f65f6fadda5d 213 { 0, -1, -4, -7, -9, -12, -15, -18, -22,},
mahphalke 1:f65f6fadda5d 214 9
mahphalke 1:f65f6fadda5d 215 },
mahphalke 1:f65f6fadda5d 216 {
mahphalke 1:f65f6fadda5d 217 760.000, 1200.000,// characteristic curve for temp range between 760.000, and 1200.000,
mahphalke 1:f65f6fadda5d 218 {0.296456256810,-0.149761277860,0.317871039240,-0.318476867010,0.157208190040,-0.306913690560,},
mahphalke 1:f65f6fadda5d 219 { 3, 1, -2, -5, -8, -12,},
mahphalke 1:f65f6fadda5d 220 6
mahphalke 1:f65f6fadda5d 221 }
mahphalke 1:f65f6fadda5d 222 };
mahphalke 1:f65f6fadda5d 223
mahphalke 1:f65f6fadda5d 224 float Thermocouple_Type_J::convert_inv(float temp)
mahphalke 1:f65f6fadda5d 225 {
mahphalke 1:f65f6fadda5d 226 return Thermocouple::convert(temp, inv_poly, inv_poly_size);
mahphalke 1:f65f6fadda5d 227 }
mahphalke 1:f65f6fadda5d 228
mahphalke 1:f65f6fadda5d 229 float Thermocouple_Type_J::lookup_inv(float temp)
mahphalke 1:f65f6fadda5d 230 {
mahphalke 1:f65f6fadda5d 231 #ifdef TYPE_J_LUT
mahphalke 1:f65f6fadda5d 232 if((temp+lut_offset)>lut_size)
mahphalke 1:f65f6fadda5d 233 return lut[lut_size-1];
mahphalke 1:f65f6fadda5d 234 else
mahphalke 1:f65f6fadda5d 235 return lut[(uint16_t)temp+lut_offset];
mahphalke 1:f65f6fadda5d 236 #else
mahphalke 1:f65f6fadda5d 237 /* NOT IMPLEMENTED */
mahphalke 1:f65f6fadda5d 238 return 0;
mahphalke 1:f65f6fadda5d 239 #endif
mahphalke 1:f65f6fadda5d 240 }
mahphalke 1:f65f6fadda5d 241 const int Thermocouple_Type_J::poly_size = 3;
mahphalke 1:f65f6fadda5d 242 const Thermocouple::thermocouple_poly_subrange Thermocouple_Type_J::poly[3] = {
mahphalke 1:f65f6fadda5d 243 {
mahphalke 1:f65f6fadda5d 244 -8.095, 0.000, // characteristic curve for mV range between -8.095 and 0.000
mahphalke 1:f65f6fadda5d 245 { 0.0000000, 1.9528268, -1.2286185, -1.0752178, -5.9086933, -1.7256713, -2.8131513, -2.3963370, -8.3823321,},
mahphalke 1:f65f6fadda5d 246 { 0, 1, 0, 0, -1, -1, -2, -3, -5,},
mahphalke 1:f65f6fadda5d 247 9
mahphalke 1:f65f6fadda5d 248 },
mahphalke 1:f65f6fadda5d 249 {
mahphalke 1:f65f6fadda5d 250 0.000, 42.919, // characteristic curve for mV range between 0.000 and 42.919
mahphalke 1:f65f6fadda5d 251 { 0.000000, 1.978425, -2.001204, 1.036969, -2.549687, 3.585153, -5.344285, 5.099890, 0.000000,},
mahphalke 1:f65f6fadda5d 252 { 0, 1, -1, -2, -4, -6, -8, -10, 0,},
mahphalke 1:f65f6fadda5d 253 9
mahphalke 1:f65f6fadda5d 254 },
mahphalke 1:f65f6fadda5d 255 {
mahphalke 1:f65f6fadda5d 256 42.919, 69.553, // characteristic curve for mV range between 42.919 and 69.553
mahphalke 1:f65f6fadda5d 257 {-3.11358187, 3.00543684,-9.94773230, 1.70276630,-1.43033468, 4.73886084, 0.00000000, 0.00000000, 0.00000000,},
mahphalke 1:f65f6fadda5d 258 { 3, 2, 0, -1, -3, -6, 0, 0, 0,},
mahphalke 1:f65f6fadda5d 259 9
mahphalke 1:f65f6fadda5d 260 }
mahphalke 1:f65f6fadda5d 261 };
mahphalke 1:f65f6fadda5d 262
mahphalke 1:f65f6fadda5d 263 Thermocouple_Type_J::~Thermocouple_Type_J()
mahphalke 1:f65f6fadda5d 264 {
mahphalke 1:f65f6fadda5d 265
mahphalke 1:f65f6fadda5d 266 }
mahphalke 1:f65f6fadda5d 267
mahphalke 1:f65f6fadda5d 268 float Thermocouple_Type_J::convert(float voltage)
mahphalke 1:f65f6fadda5d 269 {
mahphalke 1:f65f6fadda5d 270 return Thermocouple::convert(voltage, poly, poly_size);
mahphalke 1:f65f6fadda5d 271 }
mahphalke 1:f65f6fadda5d 272
mahphalke 1:f65f6fadda5d 273 float Thermocouple_Type_J::lookup(float voltage)
mahphalke 1:f65f6fadda5d 274 {
mahphalke 1:f65f6fadda5d 275 #ifdef TYPE_J_LUT
mahphalke 1:f65f6fadda5d 276 return Thermocouple::lookup(lut, voltage, lut_size, lut_offset);
mahphalke 1:f65f6fadda5d 277 #else
mahphalke 1:f65f6fadda5d 278 /* NOT IMPLEMENTED */
mahphalke 1:f65f6fadda5d 279 return 0;
mahphalke 1:f65f6fadda5d 280 #endif
mahphalke 1:f65f6fadda5d 281 }
mahphalke 1:f65f6fadda5d 282 const int Thermocouple_Type_K::inv_poly_size = 2;
mahphalke 1:f65f6fadda5d 283 const Thermocouple::thermocouple_poly_subrange Thermocouple_Type_K::inv_poly[2]
mahphalke 1:f65f6fadda5d 284 = {
mahphalke 1:f65f6fadda5d 285 {
mahphalke 1:f65f6fadda5d 286 -270.000, 0.000,// characteristic curve for temp range between -270.000, and 0.000,
mahphalke 1:f65f6fadda5d 287 {0.000000000000,0.394501280250,0.236223735980,-0.328589067840,-0.499048287770,-0.675090591730,-0.574103274280,-0.310888728940,-0.104516093650,-0.198892668780,-0.163226974860,},
mahphalke 1:f65f6fadda5d 288 { 0, -1, -4, -6, -8, -10, -12, -14, -16, -19, -22,},
mahphalke 1:f65f6fadda5d 289 11
mahphalke 1:f65f6fadda5d 290 },
mahphalke 1:f65f6fadda5d 291 {
mahphalke 1:f65f6fadda5d 292 0.000, 1372.000,// characteristic curve for temp range between 0.000, and 1372.000,
mahphalke 1:f65f6fadda5d 293 {-0.176004136860,0.389212049750,0.185587700320,-0.994575928740,0.318409457190,-0.560728448890,0.560750590590,-0.320207200030,0.971511471520,-0.121047212750,},
mahphalke 1:f65f6fadda5d 294 { -1, -1, -4, -7, -9, -12, -15, -18, -22, -25,},
mahphalke 1:f65f6fadda5d 295 10
mahphalke 1:f65f6fadda5d 296 }
mahphalke 1:f65f6fadda5d 297 };
mahphalke 1:f65f6fadda5d 298
mahphalke 1:f65f6fadda5d 299 float Thermocouple_Type_K::convert_inv(float temp)
mahphalke 1:f65f6fadda5d 300 {
mahphalke 1:f65f6fadda5d 301 return Thermocouple::convert(temp, inv_poly, inv_poly_size);
mahphalke 1:f65f6fadda5d 302 }
mahphalke 1:f65f6fadda5d 303
mahphalke 1:f65f6fadda5d 304 float Thermocouple_Type_K::lookup_inv(float temp)
mahphalke 1:f65f6fadda5d 305 {
mahphalke 1:f65f6fadda5d 306 #ifdef TYPE_K_LUT
mahphalke 1:f65f6fadda5d 307 if((temp+lut_offset)>lut_size)
mahphalke 1:f65f6fadda5d 308 return lut[lut_size-1];
mahphalke 1:f65f6fadda5d 309 else
mahphalke 1:f65f6fadda5d 310 return lut[(uint16_t)temp+lut_offset];
mahphalke 1:f65f6fadda5d 311 #else
mahphalke 1:f65f6fadda5d 312 /* NOT IMPLEMENTED */
mahphalke 1:f65f6fadda5d 313 return 0;
mahphalke 1:f65f6fadda5d 314 #endif
mahphalke 1:f65f6fadda5d 315 }
mahphalke 1:f65f6fadda5d 316 const int Thermocouple_Type_K::poly_size = 3;
mahphalke 1:f65f6fadda5d 317 const Thermocouple::thermocouple_poly_subrange Thermocouple_Type_K::poly[3] = {
mahphalke 1:f65f6fadda5d 318 {
mahphalke 1:f65f6fadda5d 319 -5.891, 0.000, // characteristic curve for mV range between -5.891 and 0.000
mahphalke 1:f65f6fadda5d 320 { 0.0000000, 2.5173462, -1.1662878, -1.0833638, -8.9773540, -3.7342377, -8.6632643, -1.0450598, -5.1920577, 0.0000000,},
mahphalke 1:f65f6fadda5d 321 { 0, 1, 0, 0, -1, -1, -2, -2, -4, 0,},
mahphalke 1:f65f6fadda5d 322 10
mahphalke 1:f65f6fadda5d 323 },
mahphalke 1:f65f6fadda5d 324 {
mahphalke 1:f65f6fadda5d 325 0.000, 20.644, // characteristic curve for mV range between 0.000 and 20.644
mahphalke 1:f65f6fadda5d 326 { 0.000000, 2.508355, 7.860106, -2.503131, 8.315270, -1.228034, 9.804036, -4.413030, 1.057734, -1.052755,},
mahphalke 1:f65f6fadda5d 327 { 0, 1, -2, -1, -2, -2, -4, -5, -6, -8,},
mahphalke 1:f65f6fadda5d 328 10
mahphalke 1:f65f6fadda5d 329 },
mahphalke 1:f65f6fadda5d 330 {
mahphalke 1:f65f6fadda5d 331 20.644, 54.886, // characteristic curve for mV range between 20.644 and 54.886
mahphalke 1:f65f6fadda5d 332 { -1.318058, 4.830222, -1.646031, 5.464731, -9.650715, 8.802193, -3.110810, 0.000000, 0.000000, 0.000000,},
mahphalke 1:f65f6fadda5d 333 { 2, 1, 0, -2, -4, -6, -8, 0, 0, 0,},
mahphalke 1:f65f6fadda5d 334 10
mahphalke 1:f65f6fadda5d 335 }
mahphalke 1:f65f6fadda5d 336 };
mahphalke 1:f65f6fadda5d 337
mahphalke 1:f65f6fadda5d 338 Thermocouple_Type_K::~Thermocouple_Type_K()
mahphalke 1:f65f6fadda5d 339 {
mahphalke 1:f65f6fadda5d 340
mahphalke 1:f65f6fadda5d 341 }
mahphalke 1:f65f6fadda5d 342
mahphalke 1:f65f6fadda5d 343 float Thermocouple_Type_K::convert(float voltage)
mahphalke 1:f65f6fadda5d 344 {
mahphalke 1:f65f6fadda5d 345 return Thermocouple::convert(voltage, poly, poly_size);
mahphalke 1:f65f6fadda5d 346 }
mahphalke 1:f65f6fadda5d 347
mahphalke 1:f65f6fadda5d 348 float Thermocouple_Type_K::lookup(float voltage)
mahphalke 1:f65f6fadda5d 349 {
mahphalke 1:f65f6fadda5d 350 #ifdef TYPE_K_LUT
mahphalke 1:f65f6fadda5d 351 return Thermocouple::lookup(lut, voltage, lut_size, lut_offset);
mahphalke 1:f65f6fadda5d 352 #else
mahphalke 1:f65f6fadda5d 353 /* NOT IMPLEMENTED */
mahphalke 1:f65f6fadda5d 354 return 0;
mahphalke 1:f65f6fadda5d 355 #endif
mahphalke 1:f65f6fadda5d 356 }
mahphalke 1:f65f6fadda5d 357 const int Thermocouple_Type_N::inv_poly_size = 2;
mahphalke 1:f65f6fadda5d 358 const Thermocouple::thermocouple_poly_subrange Thermocouple_Type_N::inv_poly[2]
mahphalke 1:f65f6fadda5d 359 = {
mahphalke 1:f65f6fadda5d 360 {
mahphalke 1:f65f6fadda5d 361 -270.000, 0.000,// characteristic curve for temp range between -270.000, and 0.000,
mahphalke 1:f65f6fadda5d 362 {0.000000000000,0.261591059620,0.109574842280,-0.938411115540,-0.464120397590,-0.263033577160,-0.226534380030,-0.760893007910,-0.934196678350,},
mahphalke 1:f65f6fadda5d 363 { 0, -1, -4, -7, -10, -11, -13, -16, -19,},
mahphalke 1:f65f6fadda5d 364 9
mahphalke 1:f65f6fadda5d 365 },
mahphalke 1:f65f6fadda5d 366 {
mahphalke 1:f65f6fadda5d 367 0.000, 1300.000,// characteristic curve for temp range between 0.000, and 1300.000,
mahphalke 1:f65f6fadda5d 368 {0.000000000000,0.259293946010,0.157101418800,0.438256272370,-0.252611697940,0.643118193390,-0.100634715190,0.997453389920,-0.608632456070,0.208492293390,-0.306821961510,},
mahphalke 1:f65f6fadda5d 369 { 0, -1, -4, -7, -9, -12, -14, -18, -21, -24, -28,},
mahphalke 1:f65f6fadda5d 370 11
mahphalke 1:f65f6fadda5d 371 }
mahphalke 1:f65f6fadda5d 372 };
mahphalke 1:f65f6fadda5d 373
mahphalke 1:f65f6fadda5d 374 float Thermocouple_Type_N::convert_inv(float temp)
mahphalke 1:f65f6fadda5d 375 {
mahphalke 1:f65f6fadda5d 376 return Thermocouple::convert(temp, inv_poly, inv_poly_size);
mahphalke 1:f65f6fadda5d 377 }
mahphalke 1:f65f6fadda5d 378
mahphalke 1:f65f6fadda5d 379 float Thermocouple_Type_N::lookup_inv(float temp)
mahphalke 1:f65f6fadda5d 380 {
mahphalke 1:f65f6fadda5d 381 #ifdef TYPE_N_LUT
mahphalke 1:f65f6fadda5d 382 if((temp+lut_offset)>lut_size)
mahphalke 1:f65f6fadda5d 383 return lut[lut_size-1];
mahphalke 1:f65f6fadda5d 384 else
mahphalke 1:f65f6fadda5d 385 return lut[(uint16_t)temp+lut_offset];
mahphalke 1:f65f6fadda5d 386 #else
mahphalke 1:f65f6fadda5d 387 /* NOT IMPLEMENTED */
mahphalke 1:f65f6fadda5d 388 return 0;
mahphalke 1:f65f6fadda5d 389 #endif
mahphalke 1:f65f6fadda5d 390 }
mahphalke 1:f65f6fadda5d 391 const int Thermocouple_Type_N::poly_size = 3;
mahphalke 1:f65f6fadda5d 392 const Thermocouple::thermocouple_poly_subrange Thermocouple_Type_N::poly[3] = {
mahphalke 1:f65f6fadda5d 393 {
mahphalke 1:f65f6fadda5d 394 -3.990, 0.000, // characteristic curve for mV range between -3.990 and 0.000
mahphalke 1:f65f6fadda5d 395 { 0.0000000, 3.8436847, 1.1010485, 5.2229312, 7.2060525, 5.8488586, 2.7754916, 7.7075166, 1.1582665, 7.3138868,},
mahphalke 1:f65f6fadda5d 396 { 0, 1, 0, 0, 0, 0, 0, -1, -1, -3,},
mahphalke 1:f65f6fadda5d 397 10
mahphalke 1:f65f6fadda5d 398 },
mahphalke 1:f65f6fadda5d 399 {
mahphalke 1:f65f6fadda5d 400 0.000, 20.613, // characteristic curve for mV range between 0.000 and 20.613
mahphalke 1:f65f6fadda5d 401 { 0.00000, 3.86896, -1.08267, 4.70205, -2.12169, -1.17272, 5.39280, -7.98156, 0.00000, 0.00000,},
mahphalke 1:f65f6fadda5d 402 { 0, 1, 0, -2, -6, -4, -6, -8, 0, 0,},
mahphalke 1:f65f6fadda5d 403 10
mahphalke 1:f65f6fadda5d 404 },
mahphalke 1:f65f6fadda5d 405 {
mahphalke 1:f65f6fadda5d 406 20.613, 47.513, // characteristic curve for mV range between 20.613 and 47.513
mahphalke 1:f65f6fadda5d 407 { 1.972485, 3.300943, -3.915159, 9.855391, -1.274371, 7.767022, 0.000000, 0.000000, 0.000000, 0.000000,},
mahphalke 1:f65f6fadda5d 408 { 1, 1, -1, -3, -4, -7, 0, 0, 0, 0,},
mahphalke 1:f65f6fadda5d 409 10
mahphalke 1:f65f6fadda5d 410 }
mahphalke 1:f65f6fadda5d 411 };
mahphalke 1:f65f6fadda5d 412
mahphalke 1:f65f6fadda5d 413 Thermocouple_Type_N::~Thermocouple_Type_N()
mahphalke 1:f65f6fadda5d 414 {
mahphalke 1:f65f6fadda5d 415
mahphalke 1:f65f6fadda5d 416 }
mahphalke 1:f65f6fadda5d 417
mahphalke 1:f65f6fadda5d 418 float Thermocouple_Type_N::convert(float voltage)
mahphalke 1:f65f6fadda5d 419 {
mahphalke 1:f65f6fadda5d 420 return Thermocouple::convert(voltage, poly, poly_size);
mahphalke 1:f65f6fadda5d 421 }
mahphalke 1:f65f6fadda5d 422
mahphalke 1:f65f6fadda5d 423 float Thermocouple_Type_N::lookup(float voltage)
mahphalke 1:f65f6fadda5d 424 {
mahphalke 1:f65f6fadda5d 425 #ifdef TYPE_N_LUT
mahphalke 1:f65f6fadda5d 426 return Thermocouple::lookup(lut, voltage, lut_size, lut_offset);
mahphalke 1:f65f6fadda5d 427 #else
mahphalke 1:f65f6fadda5d 428 /* NOT IMPLEMENTED */
mahphalke 1:f65f6fadda5d 429 return 0;
mahphalke 1:f65f6fadda5d 430 #endif
mahphalke 1:f65f6fadda5d 431 }
mahphalke 1:f65f6fadda5d 432 const int Thermocouple_Type_R::inv_poly_size = 3;
mahphalke 1:f65f6fadda5d 433 const Thermocouple::thermocouple_poly_subrange Thermocouple_Type_R::inv_poly[3]
mahphalke 1:f65f6fadda5d 434 = {
mahphalke 1:f65f6fadda5d 435 {
mahphalke 1:f65f6fadda5d 436 -50.000, 1064.180,// characteristic curve for temp range between -50.000, and 1064.180,
mahphalke 1:f65f6fadda5d 437 {0.000000000000,0.528961729765,0.139166589782,-0.238855693017,0.356916001063,-0.462347666298,0.500777441034,-0.373105886191,0.157716482367,-0.281038625251,},
mahphalke 1:f65f6fadda5d 438 { 0, -2, -4, -7, -10, -13, -16, -19, -22, -26,},
mahphalke 1:f65f6fadda5d 439 10
mahphalke 1:f65f6fadda5d 440 },
mahphalke 1:f65f6fadda5d 441 {
mahphalke 1:f65f6fadda5d 442 1064.180, 1664.500,// characteristic curve for temp range between 1064.180, and 1664.500,
mahphalke 1:f65f6fadda5d 443 {0.295157925316,-0.252061251332,0.159564501865,-0.764085947576,0.205305291024,-0.293359668173,},
mahphalke 1:f65f6fadda5d 444 { 1, -2, -4, -8, -11, -15,},
mahphalke 1:f65f6fadda5d 445 6
mahphalke 1:f65f6fadda5d 446 },
mahphalke 1:f65f6fadda5d 447 {
mahphalke 1:f65f6fadda5d 448 1664.500, 1768.100,// characteristic curve for temp range between 1664.500, and 1768.100,
mahphalke 1:f65f6fadda5d 449 {0.152232118209,-0.268819888545,0.171280280471,-0.345895706453,-0.934633971046,},
mahphalke 1:f65f6fadda5d 450 { 3, 0, -3, -7, -14,},
mahphalke 1:f65f6fadda5d 451 5
mahphalke 1:f65f6fadda5d 452 }
mahphalke 1:f65f6fadda5d 453 };
mahphalke 1:f65f6fadda5d 454
mahphalke 1:f65f6fadda5d 455 float Thermocouple_Type_R::convert_inv(float temp)
mahphalke 1:f65f6fadda5d 456 {
mahphalke 1:f65f6fadda5d 457 return Thermocouple::convert(temp, inv_poly, inv_poly_size);
mahphalke 1:f65f6fadda5d 458 }
mahphalke 1:f65f6fadda5d 459
mahphalke 1:f65f6fadda5d 460 float Thermocouple_Type_R::lookup_inv(float temp)
mahphalke 1:f65f6fadda5d 461 {
mahphalke 1:f65f6fadda5d 462 #ifdef TYPE_R_LUT
mahphalke 1:f65f6fadda5d 463 if((temp+lut_offset)>lut_size)
mahphalke 1:f65f6fadda5d 464 return lut[lut_size-1];
mahphalke 1:f65f6fadda5d 465 else
mahphalke 1:f65f6fadda5d 466 return lut[(uint16_t)temp+lut_offset];
mahphalke 1:f65f6fadda5d 467 #else
mahphalke 1:f65f6fadda5d 468 /* NOT IMPLEMENTED */
mahphalke 1:f65f6fadda5d 469 return 0;
mahphalke 1:f65f6fadda5d 470 #endif
mahphalke 1:f65f6fadda5d 471 }
mahphalke 1:f65f6fadda5d 472 const int Thermocouple_Type_R::poly_size = 4;
mahphalke 1:f65f6fadda5d 473 const Thermocouple::thermocouple_poly_subrange Thermocouple_Type_R::poly[4] = {
mahphalke 1:f65f6fadda5d 474 {
mahphalke 1:f65f6fadda5d 475 -0.226, 1.923, // characteristic curve for mV range between -0.226 and 1.923
mahphalke 1:f65f6fadda5d 476 { 0.0000000, 1.8891380, -9.3835290, 1.3068619, -2.2703580, 3.5145659, -3.8953900, 2.8239471, -1.2607281, 3.1353611, -3.3187769,},
mahphalke 1:f65f6fadda5d 477 { 0, 2, 1, 2, 2, 2, 2, 2, 2, 1, 0,},
mahphalke 1:f65f6fadda5d 478 11
mahphalke 1:f65f6fadda5d 479 },
mahphalke 1:f65f6fadda5d 480 {
mahphalke 1:f65f6fadda5d 481 1.923, 13.228, // characteristic curve for mV range between 1.923 and 13.228
mahphalke 1:f65f6fadda5d 482 {1.334584505,1.472644573,-1.844024844,4.031129726,-6.249428360,6.468412046,-4.458750426,1.994710149,-5.313401790,6.481976217,0.000000000,},
mahphalke 1:f65f6fadda5d 483 { 1, 2, 1, 0, -1, -2, -3, -4, -6, -8, 0,},
mahphalke 1:f65f6fadda5d 484 11
mahphalke 1:f65f6fadda5d 485 },
mahphalke 1:f65f6fadda5d 486 {
mahphalke 1:f65f6fadda5d 487 11.361, 19.739, // characteristic curve for mV range between 11.361 and 19.739
mahphalke 1:f65f6fadda5d 488 {-8.199599416,1.553962042,-8.342197663,4.279433549,-1.191577910,1.492290091,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,},
mahphalke 1:f65f6fadda5d 489 { 1, 2, 0, -1, -2, -4, 0, 0, 0, 0, 0,},
mahphalke 1:f65f6fadda5d 490 11
mahphalke 1:f65f6fadda5d 491 },
mahphalke 1:f65f6fadda5d 492 {
mahphalke 1:f65f6fadda5d 493 19.739, 21.103, // characteristic curve for mV range between 19.739 and 21.103
mahphalke 1:f65f6fadda5d 494 {3.406177836,-7.023729171,5.582903813,-1.952394635,2.560740231,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,},
mahphalke 1:f65f6fadda5d 495 { 4, 3, 2, 1, -1, 0, 0, 0, 0, 0, 0,},
mahphalke 1:f65f6fadda5d 496 11
mahphalke 1:f65f6fadda5d 497 }
mahphalke 1:f65f6fadda5d 498 };
mahphalke 1:f65f6fadda5d 499
mahphalke 1:f65f6fadda5d 500 Thermocouple_Type_R::~Thermocouple_Type_R()
mahphalke 1:f65f6fadda5d 501 {
mahphalke 1:f65f6fadda5d 502
mahphalke 1:f65f6fadda5d 503 }
mahphalke 1:f65f6fadda5d 504
mahphalke 1:f65f6fadda5d 505 float Thermocouple_Type_R::convert(float voltage)
mahphalke 1:f65f6fadda5d 506 {
mahphalke 1:f65f6fadda5d 507 return Thermocouple::convert(voltage, poly, poly_size);
mahphalke 1:f65f6fadda5d 508 }
mahphalke 1:f65f6fadda5d 509
mahphalke 1:f65f6fadda5d 510 float Thermocouple_Type_R::lookup(float voltage)
mahphalke 1:f65f6fadda5d 511 {
mahphalke 1:f65f6fadda5d 512 #ifdef TYPE_R_LUT
mahphalke 1:f65f6fadda5d 513 return Thermocouple::lookup(lut, voltage, lut_size, lut_offset);
mahphalke 1:f65f6fadda5d 514 #else
mahphalke 1:f65f6fadda5d 515 /* NOT IMPLEMENTED */
mahphalke 1:f65f6fadda5d 516 return 0;
mahphalke 1:f65f6fadda5d 517 #endif
mahphalke 1:f65f6fadda5d 518 }
mahphalke 1:f65f6fadda5d 519 const int Thermocouple_Type_S::inv_poly_size = 3;
mahphalke 1:f65f6fadda5d 520 const Thermocouple::thermocouple_poly_subrange Thermocouple_Type_S::inv_poly[3]
mahphalke 1:f65f6fadda5d 521 = {
mahphalke 1:f65f6fadda5d 522 {
mahphalke 1:f65f6fadda5d 523 -50.000, 1064.180,// characteristic curve for temp range between -50.000, and 1064.180,
mahphalke 1:f65f6fadda5d 524 {0.000000000000,0.540313308631,0.125934289740,-0.232477968689,0.322028823036,-0.331465196389,0.255744251786,-0.125068871393,0.271443176145,},
mahphalke 1:f65f6fadda5d 525 { 0, -2, -4, -7, -10, -13, -16, -19, -23,},
mahphalke 1:f65f6fadda5d 526 9
mahphalke 1:f65f6fadda5d 527 },
mahphalke 1:f65f6fadda5d 528 {
mahphalke 1:f65f6fadda5d 529 1064.180, 1664.500,// characteristic curve for temp range between 1064.180, and 1664.500,
mahphalke 1:f65f6fadda5d 530 {0.132900444085,0.334509311344,0.654805192818,-0.164856259209,0.129989605174,},
mahphalke 1:f65f6fadda5d 531 { 1, -2, -5, -8, -13,},
mahphalke 1:f65f6fadda5d 532 5
mahphalke 1:f65f6fadda5d 533 },
mahphalke 1:f65f6fadda5d 534 {
mahphalke 1:f65f6fadda5d 535 1664.500, 1768.100,// characteristic curve for temp range between 1664.500, and 1768.100,
mahphalke 1:f65f6fadda5d 536 {0.146628232636,-0.258430516752,0.163693574641,-0.330439046987,-0.943223690612,},
mahphalke 1:f65f6fadda5d 537 { 3, 0, -3, -7, -14,},
mahphalke 1:f65f6fadda5d 538 5
mahphalke 1:f65f6fadda5d 539 }
mahphalke 1:f65f6fadda5d 540 };
mahphalke 1:f65f6fadda5d 541
mahphalke 1:f65f6fadda5d 542 float Thermocouple_Type_S::convert_inv(float temp)
mahphalke 1:f65f6fadda5d 543 {
mahphalke 1:f65f6fadda5d 544 return Thermocouple::convert(temp, inv_poly, inv_poly_size);
mahphalke 1:f65f6fadda5d 545 }
mahphalke 1:f65f6fadda5d 546
mahphalke 1:f65f6fadda5d 547 float Thermocouple_Type_S::lookup_inv(float temp)
mahphalke 1:f65f6fadda5d 548 {
mahphalke 1:f65f6fadda5d 549 #ifdef TYPE_S_LUT
mahphalke 1:f65f6fadda5d 550 if((temp+lut_offset)>lut_size)
mahphalke 1:f65f6fadda5d 551 return lut[lut_size-1];
mahphalke 1:f65f6fadda5d 552 else
mahphalke 1:f65f6fadda5d 553 return lut[(uint16_t)temp+lut_offset];
mahphalke 1:f65f6fadda5d 554 #else
mahphalke 1:f65f6fadda5d 555 /* NOT IMPLEMENTED */
mahphalke 1:f65f6fadda5d 556 return 0;
mahphalke 1:f65f6fadda5d 557 #endif
mahphalke 1:f65f6fadda5d 558 }
mahphalke 1:f65f6fadda5d 559 const int Thermocouple_Type_S::poly_size = 4;
mahphalke 1:f65f6fadda5d 560 const Thermocouple::thermocouple_poly_subrange Thermocouple_Type_S::poly[4] = {
mahphalke 1:f65f6fadda5d 561 {
mahphalke 1:f65f6fadda5d 562 -0.235, 1.874, // characteristic curve for mV range between -0.235 and 1.874
mahphalke 1:f65f6fadda5d 563 { 0.00000000, 1.84949460,-8.00504062, 1.02237430,-1.52248592, 1.88821343,-1.59085941, 8.23027880,-2.34181944, 2.79786260,},
mahphalke 1:f65f6fadda5d 564 { 0, 2, 1, 2, 2, 2, 2, 1, 1, 0,},
mahphalke 1:f65f6fadda5d 565 10
mahphalke 1:f65f6fadda5d 566 },
mahphalke 1:f65f6fadda5d 567 {
mahphalke 1:f65f6fadda5d 568 1.874, 11.950, // characteristic curve for mV range between 1.874 and 11.950
mahphalke 1:f65f6fadda5d 569 {1.291507177,1.466298863,-1.534713402,3.145945973,-4.163257839,3.187963771,-1.291637500,2.183475087,-1.447379511,8.211272125,},
mahphalke 1:f65f6fadda5d 570 { 1, 2, 1, 0, -1, -2, -3, -5, -7, -9,},
mahphalke 1:f65f6fadda5d 571 10
mahphalke 1:f65f6fadda5d 572 },
mahphalke 1:f65f6fadda5d 573 {
mahphalke 1:f65f6fadda5d 574 10.332, 17.536, // characteristic curve for mV range between 10.332 and 17.536
mahphalke 1:f65f6fadda5d 575 {-8.087801117,1.621573104,-8.536869453,4.719686976,-1.441693666,2.081618890,0.000000000,0.000000000,0.000000000,0.000000000,},
mahphalke 1:f65f6fadda5d 576 { 1, 2, 0, -1, -2, -4, 0, 0, 0, 0,},
mahphalke 1:f65f6fadda5d 577 10
mahphalke 1:f65f6fadda5d 578 },
mahphalke 1:f65f6fadda5d 579 {
mahphalke 1:f65f6fadda5d 580 17.536, 18.693, // characteristic curve for mV range between 17.536 and 18.693
mahphalke 1:f65f6fadda5d 581 {5.333875126,-1.235892298,1.092657613,-4.265693686,6.247205420,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,},
mahphalke 1:f65f6fadda5d 582 { 4, 4, 3, 1, -1, 0, 0, 0, 0, 0,},
mahphalke 1:f65f6fadda5d 583 10
mahphalke 1:f65f6fadda5d 584 }
mahphalke 1:f65f6fadda5d 585 };
mahphalke 1:f65f6fadda5d 586
mahphalke 1:f65f6fadda5d 587 Thermocouple_Type_S::~Thermocouple_Type_S()
mahphalke 1:f65f6fadda5d 588 {
mahphalke 1:f65f6fadda5d 589
mahphalke 1:f65f6fadda5d 590 }
mahphalke 1:f65f6fadda5d 591
mahphalke 1:f65f6fadda5d 592 float Thermocouple_Type_S::convert(float voltage)
mahphalke 1:f65f6fadda5d 593 {
mahphalke 1:f65f6fadda5d 594 return Thermocouple::convert(voltage, poly, poly_size);
mahphalke 1:f65f6fadda5d 595 }
mahphalke 1:f65f6fadda5d 596
mahphalke 1:f65f6fadda5d 597 float Thermocouple_Type_S::lookup(float voltage)
mahphalke 1:f65f6fadda5d 598 {
mahphalke 1:f65f6fadda5d 599 #ifdef TYPE_S_LUT
mahphalke 1:f65f6fadda5d 600 return Thermocouple::lookup(lut, voltage, lut_size, lut_offset);
mahphalke 1:f65f6fadda5d 601 #else
mahphalke 1:f65f6fadda5d 602 /* NOT IMPLEMENTED */
mahphalke 1:f65f6fadda5d 603 return 0;
mahphalke 1:f65f6fadda5d 604 #endif
mahphalke 1:f65f6fadda5d 605 }
mahphalke 1:f65f6fadda5d 606 const int Thermocouple_Type_T::inv_poly_size = 2;
mahphalke 1:f65f6fadda5d 607 const Thermocouple::thermocouple_poly_subrange Thermocouple_Type_T::inv_poly[2]
mahphalke 1:f65f6fadda5d 608 = {
mahphalke 1:f65f6fadda5d 609 {
mahphalke 1:f65f6fadda5d 610 -270.000, 0.000,// characteristic curve for temp range between -270.000, and 0.000,
mahphalke 1:f65f6fadda5d 611 {0.000000000000,0.387481063640,0.441944343470,0.118443231050,0.200329735540,0.901380195590,0.226511565930,0.360711542050,0.384939398830,0.282135219250,0.142515947790,0.487686622860,0.107955392700,0.139450270620,0.797951539270,},
mahphalke 1:f65f6fadda5d 612 { 0, -1, -4, -6, -7, -9, -10, -12, -14, -16, -18, -21, -23, -26, -30,},
mahphalke 1:f65f6fadda5d 613 15
mahphalke 1:f65f6fadda5d 614 },
mahphalke 1:f65f6fadda5d 615 {
mahphalke 1:f65f6fadda5d 616 0.000, 400.000,// characteristic curve for temp range between 0.000, and 400.000,
mahphalke 1:f65f6fadda5d 617 {0.000000000000,0.387481063640,0.332922278800,0.206182434040,-0.218822568460,0.109968809280,-0.308157587720,0.454791352900,-0.275129016730,},
mahphalke 1:f65f6fadda5d 618 { 0, -1, -4, -6, -8, -10, -13, -16, -19,},
mahphalke 1:f65f6fadda5d 619 9
mahphalke 1:f65f6fadda5d 620 }
mahphalke 1:f65f6fadda5d 621 };
mahphalke 1:f65f6fadda5d 622
mahphalke 1:f65f6fadda5d 623 float Thermocouple_Type_T::convert_inv(float temp)
mahphalke 1:f65f6fadda5d 624 {
mahphalke 1:f65f6fadda5d 625 return Thermocouple::convert(temp, inv_poly, inv_poly_size);
mahphalke 1:f65f6fadda5d 626 }
mahphalke 1:f65f6fadda5d 627
mahphalke 1:f65f6fadda5d 628 float Thermocouple_Type_T::lookup_inv(float temp)
mahphalke 1:f65f6fadda5d 629 {
mahphalke 1:f65f6fadda5d 630 #ifdef TYPE_T_LUT
mahphalke 1:f65f6fadda5d 631 if((temp+lut_offset)>lut_size)
mahphalke 1:f65f6fadda5d 632 return lut[lut_size-1];
mahphalke 1:f65f6fadda5d 633 else
mahphalke 1:f65f6fadda5d 634 return lut[(uint16_t)temp+lut_offset];
mahphalke 1:f65f6fadda5d 635 #else
mahphalke 1:f65f6fadda5d 636 /* NOT IMPLEMENTED */
mahphalke 1:f65f6fadda5d 637 return 0;
mahphalke 1:f65f6fadda5d 638 #endif
mahphalke 1:f65f6fadda5d 639 }
mahphalke 1:f65f6fadda5d 640 const int Thermocouple_Type_T::poly_size = 2;
mahphalke 1:f65f6fadda5d 641 const Thermocouple::thermocouple_poly_subrange Thermocouple_Type_T::poly[2] = {
mahphalke 1:f65f6fadda5d 642 {
mahphalke 1:f65f6fadda5d 643 -5.603, 0.000, // characteristic curve for mV range between -5.603 and 0.000
mahphalke 1:f65f6fadda5d 644 { 0.0000000, 2.5949192, -2.1316967, 7.9018692, 4.2527777, 1.3304473, 2.0241446, 1.2668171,},
mahphalke 1:f65f6fadda5d 645 { 0, 1, -1, -1, -1, -1, -2, -3,},
mahphalke 1:f65f6fadda5d 646 8
mahphalke 1:f65f6fadda5d 647 },
mahphalke 1:f65f6fadda5d 648 {
mahphalke 1:f65f6fadda5d 649 0.000, 20.872, // characteristic curve for mV range between 0.000 and 20.872
mahphalke 1:f65f6fadda5d 650 { 0.000000, 2.592800, -7.602961, 4.637791, -2.165394, 6.048144, -7.293422, 0.000000,},
mahphalke 1:f65f6fadda5d 651 { 0, 1, -1, -2, -3, -5, -7, 0,},
mahphalke 1:f65f6fadda5d 652 8
mahphalke 1:f65f6fadda5d 653 }
mahphalke 1:f65f6fadda5d 654 };
mahphalke 1:f65f6fadda5d 655
mahphalke 1:f65f6fadda5d 656 Thermocouple_Type_T::~Thermocouple_Type_T()
mahphalke 1:f65f6fadda5d 657 {
mahphalke 1:f65f6fadda5d 658
mahphalke 1:f65f6fadda5d 659 }
mahphalke 1:f65f6fadda5d 660
mahphalke 1:f65f6fadda5d 661 float Thermocouple_Type_T::convert(float voltage)
mahphalke 1:f65f6fadda5d 662 {
mahphalke 1:f65f6fadda5d 663 return Thermocouple::convert(voltage, poly, poly_size);
mahphalke 1:f65f6fadda5d 664 }
mahphalke 1:f65f6fadda5d 665
mahphalke 1:f65f6fadda5d 666 float Thermocouple_Type_T::lookup(float voltage)
mahphalke 1:f65f6fadda5d 667 {
mahphalke 1:f65f6fadda5d 668 #ifdef TYPE_T_LUT
mahphalke 1:f65f6fadda5d 669 return Thermocouple::lookup(lut, voltage, lut_size, lut_offset);
mahphalke 1:f65f6fadda5d 670 #else
mahphalke 1:f65f6fadda5d 671 /* NOT IMPLEMENTED */
mahphalke 1:f65f6fadda5d 672 return 0;
mahphalke 1:f65f6fadda5d 673 #endif
mahphalke 1:f65f6fadda5d 674 }