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