precision-converters-firmware
thermocouple.h
Go to the documentation of this file.
1 
17 #include "stdint.h"
18 
19 #ifndef _THERMOCOUPLE_H_
20 #define _THERMOCOUPLE_H_
21 
22 #define DEFINE_LOOKUP_TABLES
23 #ifdef DEFINE_LOOKUP_TABLES
24 #define TYPE_B_LUT
25 #define TYPE_E_LUT
26 #define TYPE_J_LUT
27 #define TYPE_K_LUT
28 #define TYPE_N_LUT
29 #define TYPE_R_LUT
30 #define TYPE_S_LUT
31 #define TYPE_T_LUT
32 #endif
33 
35 {
36 private:
37 
38 public:
39  typedef struct {
42  float coef[16];
43  float power[16];
44  int n;
47  virtual ~Thermocouple();
48  static float convert(float voltage, const thermocouple_poly_subrange range[],
49  const int n);
50  static float lookup(const int32_t *lut, float voltage,uint16_t size,
51  int16_t offset);
52  virtual float convert(float voltage) = 0;
53  virtual float convert_inv(float temp) = 0;
54  virtual float lookup(float voltage) = 0;
55  virtual float lookup_inv(float temp) = 0;
56 
57 };
58 
59 
60 
61 
63 {
64 public:
67  static const int inv_poly_size;
68  float convert_inv(float temp);
69 
71  static const int poly_size;
72  float convert(float voltage);
73 #ifdef TYPE_B_LUT
74  static const int32_t lut[];
75  static const int16_t lut_offset;
76  static const uint16_t lut_size;
77  float lookup(float voltage);
78  float lookup_inv(float temp);
79 #endif
80 };
81 
82 
84 {
85 public:
88  static const int inv_poly_size;
89  float convert_inv(float temp);
90 
92  static const int poly_size;
93  float convert(float voltage);
94 #ifdef TYPE_E_LUT
95  static const int32_t lut[];
96  static const int16_t lut_offset;
97  static const uint16_t lut_size;
98  float lookup(float voltage);
99  float lookup_inv(float temp);
100 #endif
101 };
102 
103 
105 {
106 public:
109  static const int inv_poly_size;
110  float convert_inv(float temp);
111 
113  static const int poly_size;
114  float convert(float voltage);
115 #ifdef TYPE_J_LUT
116  static const int32_t lut[];
117  static const int16_t lut_offset;
118  static const uint16_t lut_size;
119  float lookup(float voltage);
120  float lookup_inv(float temp);
121 #endif
122 };
123 
124 
126 {
127 public:
130  static const int inv_poly_size;
131  float convert_inv(float temp);
132 
134  static const int poly_size;
135  float convert(float voltage);
136 #ifdef TYPE_K_LUT
137  static const int32_t lut[];
138  static const int16_t lut_offset;
139  static const uint16_t lut_size;
140  float lookup(float voltage);
141  float lookup_inv(float temp);
142 #endif
143 };
144 
145 
147 {
148 public:
151  static const int inv_poly_size;
152  float convert_inv(float temp);
153 
155  static const int poly_size;
156  float convert(float voltage);
157 #ifdef TYPE_N_LUT
158  static const int32_t lut[];
159  static const int16_t lut_offset;
160  static const uint16_t lut_size;
161  float lookup(float voltage);
162  float lookup_inv(float temp);
163 #endif
164 };
165 
166 
168 {
169 public:
172  static const int inv_poly_size;
173  float convert_inv(float temp);
174 
176  static const int poly_size;
177  float convert(float voltage);
178 #ifdef TYPE_R_LUT
179  static const int32_t lut[];
180  static const int16_t lut_offset;
181  static const uint16_t lut_size;
182  float lookup(float voltage);
183  float lookup_inv(float temp);
184 #endif
185 };
186 
187 
189 {
190 public:
193  static const int inv_poly_size;
194  float convert_inv(float temp);
195 
197  static const int poly_size;
198  float convert(float voltage);
199 #ifdef TYPE_S_LUT
200  static const int32_t lut[];
201  static const int16_t lut_offset;
202  static const uint16_t lut_size;
203  float lookup(float voltage);
204  float lookup_inv(float temp);
205 #endif
206 };
207 
208 
210 {
211 public:
214  static const int inv_poly_size;
215  float convert_inv(float temp);
216 
218  static const int poly_size;
219  float convert(float voltage);
220 #ifdef TYPE_T_LUT
221  static const int32_t lut[];
222  static const int16_t lut_offset;
223  static const uint16_t lut_size;
224  float lookup(float voltage);
225  float lookup_inv(float temp);
226 #endif
227 };
228 
229 #endif
Definition: thermocouple.h:63
float convert(float voltage)
static const thermocouple_poly_subrange inv_poly[2]
Definition: thermocouple.h:66
float convert_inv(float temp)
static const int inv_poly_size
Definition: thermocouple.h:67
static const uint16_t lut_size
Definition: thermocouple.h:76
static const int poly_size
Definition: thermocouple.h:71
float lookup_inv(float temp)
static const thermocouple_poly_subrange poly[2]
Definition: thermocouple.h:70
float lookup(float voltage)
static const int32_t lut[]
Definition: thermocouple.h:74
static const int16_t lut_offset
Definition: thermocouple.h:75
Definition: thermocouple.h:84
static const int poly_size
Definition: thermocouple.h:92
float convert(float voltage)
float lookup_inv(float temp)
static const thermocouple_poly_subrange inv_poly[2]
Definition: thermocouple.h:87
float lookup(float voltage)
float convert_inv(float temp)
static const uint16_t lut_size
Definition: thermocouple.h:97
static const thermocouple_poly_subrange poly[2]
Definition: thermocouple.h:91
static const int inv_poly_size
Definition: thermocouple.h:88
static const int32_t lut[]
Definition: thermocouple.h:95
static const int16_t lut_offset
Definition: thermocouple.h:96
Definition: thermocouple.h:105
static const thermocouple_poly_subrange poly[3]
Definition: thermocouple.h:112
static const int32_t lut[]
Definition: thermocouple.h:116
static const uint16_t lut_size
Definition: thermocouple.h:118
static const int poly_size
Definition: thermocouple.h:113
float lookup(float voltage)
float lookup_inv(float temp)
static const thermocouple_poly_subrange inv_poly[2]
Definition: thermocouple.h:108
static const int inv_poly_size
Definition: thermocouple.h:109
float convert(float voltage)
float convert_inv(float temp)
static const int16_t lut_offset
Definition: thermocouple.h:117
Definition: thermocouple.h:126
float convert(float voltage)
static const thermocouple_poly_subrange poly[3]
Definition: thermocouple.h:133
static const uint16_t lut_size
Definition: thermocouple.h:139
float lookup_inv(float temp)
static const int inv_poly_size
Definition: thermocouple.h:130
float lookup(float voltage)
static const int32_t lut[]
Definition: thermocouple.h:137
float convert_inv(float temp)
static const int16_t lut_offset
Definition: thermocouple.h:138
static const int poly_size
Definition: thermocouple.h:134
static const thermocouple_poly_subrange inv_poly[2]
Definition: thermocouple.h:129
Definition: thermocouple.h:147
float convert(float voltage)
static const thermocouple_poly_subrange poly[3]
Definition: thermocouple.h:154
static const int inv_poly_size
Definition: thermocouple.h:151
float lookup(float voltage)
static const int32_t lut[]
Definition: thermocouple.h:158
static const int16_t lut_offset
Definition: thermocouple.h:159
float lookup_inv(float temp)
static const thermocouple_poly_subrange inv_poly[2]
Definition: thermocouple.h:150
static const uint16_t lut_size
Definition: thermocouple.h:160
static const int poly_size
Definition: thermocouple.h:155
float convert_inv(float temp)
Definition: thermocouple.h:168
static const int16_t lut_offset
Definition: thermocouple.h:180
static const thermocouple_poly_subrange inv_poly[3]
Definition: thermocouple.h:171
static const int poly_size
Definition: thermocouple.h:176
float convert_inv(float temp)
static const thermocouple_poly_subrange poly[4]
Definition: thermocouple.h:175
float lookup(float voltage)
static const uint16_t lut_size
Definition: thermocouple.h:181
static const int inv_poly_size
Definition: thermocouple.h:172
float convert(float voltage)
static const int32_t lut[]
Definition: thermocouple.h:179
float lookup_inv(float temp)
Definition: thermocouple.h:189
static const int poly_size
Definition: thermocouple.h:197
float convert(float voltage)
static const int16_t lut_offset
Definition: thermocouple.h:201
static const thermocouple_poly_subrange inv_poly[3]
Definition: thermocouple.h:192
float lookup(float voltage)
static const int32_t lut[]
Definition: thermocouple.h:200
static const int inv_poly_size
Definition: thermocouple.h:193
float convert_inv(float temp)
static const thermocouple_poly_subrange poly[4]
Definition: thermocouple.h:196
float lookup_inv(float temp)
static const uint16_t lut_size
Definition: thermocouple.h:202
Definition: thermocouple.h:210
float convert(float voltage)
static const int16_t lut_offset
Definition: thermocouple.h:222
static const int inv_poly_size
Definition: thermocouple.h:214
static const int32_t lut[]
Definition: thermocouple.h:221
static const uint16_t lut_size
Definition: thermocouple.h:223
float convert_inv(float temp)
float lookup(float voltage)
static const thermocouple_poly_subrange inv_poly[2]
Definition: thermocouple.h:213
float lookup_inv(float temp)
static const int poly_size
Definition: thermocouple.h:218
static const thermocouple_poly_subrange poly[2]
Definition: thermocouple.h:217
Definition: thermocouple.h:35
virtual float lookup_inv(float temp)=0
virtual float convert_inv(float temp)=0
static float lookup(const int32_t *lut, float voltage, uint16_t size, int16_t offset)
static float convert(float voltage, const thermocouple_poly_subrange range[], const int n)
virtual ~Thermocouple()
virtual float lookup(float voltage)=0
virtual float convert(float voltage)=0
Definition: thermocouple.h:39
float max_voltage_range
Definition: thermocouple.h:41
int n
Definition: thermocouple.h:44
float min_voltage_range
Definition: thermocouple.h:40