Mahesh Phalke / tempsensors_prv
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers thermocouple.h Source File

thermocouple.h

Go to the documentation of this file.
00001 /*!
00002  *****************************************************************************
00003   @file:  thermocouple.h
00004 
00005   @brief:
00006 
00007   @details:
00008  -----------------------------------------------------------------------------
00009  Copyright (c) 2018, 2020 Analog Devices, Inc.  All rights reserved.
00010 
00011  This software is proprietary to Analog Devices, Inc. and its licensors.
00012  By using this software you agree to the terms of the associated
00013  Analog Devices Software License Agreement.
00014 
00015 *****************************************************************************/
00016 
00017 #include "stdint.h"
00018 
00019 #ifndef _THERMOCOUPLE_H_
00020 #define _THERMOCOUPLE_H_
00021 
00022 #define DEFINE_LOOKUP_TABLES
00023 #ifdef DEFINE_LOOKUP_TABLES
00024 #define TYPE_B_LUT
00025 #define TYPE_E_LUT
00026 #define TYPE_J_LUT
00027 #define TYPE_K_LUT
00028 #define TYPE_N_LUT
00029 #define TYPE_R_LUT
00030 #define TYPE_S_LUT
00031 #define TYPE_T_LUT
00032 #endif
00033 
00034 class Thermocouple
00035 {
00036 private:
00037 
00038 public:
00039     typedef struct {
00040         float min_voltage_range;
00041         float max_voltage_range;
00042         float coef[16];
00043         float power[16];
00044         int n;
00045     } thermocouple_poly_subrange;
00046     Thermocouple();
00047     virtual ~Thermocouple();
00048     static float convert(float voltage, const thermocouple_poly_subrange range[],
00049                  const int n);
00050     static float lookup(const int32_t *lut, float voltage,uint16_t size,
00051                 int16_t offset);
00052     virtual float convert(float voltage) = 0;
00053     virtual float convert_inv(float temp) = 0;
00054     virtual float lookup(float voltage) = 0;
00055     virtual float lookup_inv(float temp) = 0;
00056 
00057 };
00058 
00059 
00060 
00061 
00062 class Thermocouple_Type_B : public Thermocouple
00063 {
00064 public:
00065     ~Thermocouple_Type_B();
00066     static const thermocouple_poly_subrange inv_poly[2];
00067     static const int inv_poly_size;
00068     float convert_inv(float temp);
00069 
00070     static const thermocouple_poly_subrange poly[2];
00071     static const int poly_size;
00072     float convert(float voltage);
00073 #ifdef TYPE_B_LUT
00074     static const int32_t lut[];
00075     static const int16_t lut_offset;
00076     static const uint16_t lut_size;
00077     float lookup(float voltage);
00078     float lookup_inv(float temp);
00079 #endif
00080 };
00081 
00082 
00083 class Thermocouple_Type_E : public Thermocouple
00084 {
00085 public:
00086     ~Thermocouple_Type_E();
00087     static const thermocouple_poly_subrange inv_poly[2];
00088     static const int inv_poly_size;
00089     float convert_inv(float temp);
00090 
00091     static const thermocouple_poly_subrange poly[2];
00092     static const int poly_size;
00093     float convert(float voltage);
00094 #ifdef TYPE_E_LUT
00095     static const int32_t lut[];
00096     static const int16_t lut_offset;
00097     static const uint16_t lut_size;
00098     float lookup(float voltage);
00099     float lookup_inv(float temp);
00100 #endif
00101 };
00102 
00103 
00104 class Thermocouple_Type_J : public Thermocouple
00105 {
00106 public:
00107     ~Thermocouple_Type_J();
00108     static const thermocouple_poly_subrange inv_poly[2];
00109     static const int inv_poly_size;
00110     float convert_inv(float temp);
00111 
00112     static const thermocouple_poly_subrange poly[3];
00113     static const int poly_size;
00114     float convert(float voltage);
00115 #ifdef TYPE_J_LUT
00116     static const int32_t lut[];
00117     static const int16_t lut_offset;
00118     static const uint16_t lut_size;
00119     float lookup(float voltage);
00120     float lookup_inv(float temp);
00121 #endif
00122 };
00123 
00124 
00125 class Thermocouple_Type_K : public Thermocouple
00126 {
00127 public:
00128     ~Thermocouple_Type_K();
00129     static const thermocouple_poly_subrange inv_poly[2];
00130     static const int inv_poly_size;
00131     float convert_inv(float temp);
00132 
00133     static const thermocouple_poly_subrange poly[3];
00134     static const int poly_size;
00135     float convert(float voltage);
00136 #ifdef TYPE_K_LUT
00137     static const int32_t lut[];
00138     static const int16_t lut_offset;
00139     static const uint16_t lut_size;
00140     float lookup(float voltage);
00141     float lookup_inv(float temp);
00142 #endif
00143 };
00144 
00145 
00146 class Thermocouple_Type_N : public Thermocouple
00147 {
00148 public:
00149     ~Thermocouple_Type_N();
00150     static const thermocouple_poly_subrange inv_poly[2];
00151     static const int inv_poly_size;
00152     float convert_inv(float temp);
00153 
00154     static const thermocouple_poly_subrange poly[3];
00155     static const int poly_size;
00156     float convert(float voltage);
00157 #ifdef TYPE_N_LUT
00158     static const int32_t lut[];
00159     static const int16_t lut_offset;
00160     static const uint16_t lut_size;
00161     float lookup(float voltage);
00162     float lookup_inv(float temp);
00163 #endif
00164 };
00165 
00166 
00167 class Thermocouple_Type_R : public Thermocouple
00168 {
00169 public:
00170     ~Thermocouple_Type_R();
00171     static const thermocouple_poly_subrange inv_poly[3];
00172     static const int inv_poly_size;
00173     float convert_inv(float temp);
00174 
00175     static const thermocouple_poly_subrange poly[4];
00176     static const int poly_size;
00177     float convert(float voltage);
00178 #ifdef TYPE_R_LUT
00179     static const int32_t lut[];
00180     static const int16_t lut_offset;
00181     static const uint16_t lut_size;
00182     float lookup(float voltage);
00183     float lookup_inv(float temp);
00184 #endif
00185 };
00186 
00187 
00188 class Thermocouple_Type_S : public Thermocouple
00189 {
00190 public:
00191     ~Thermocouple_Type_S();
00192     static const thermocouple_poly_subrange inv_poly[3];
00193     static const int inv_poly_size;
00194     float convert_inv(float temp);
00195 
00196     static const thermocouple_poly_subrange poly[4];
00197     static const int poly_size;
00198     float convert(float voltage);
00199 #ifdef TYPE_S_LUT
00200     static const int32_t lut[];
00201     static const int16_t lut_offset;
00202     static const uint16_t lut_size;
00203     float lookup(float voltage);
00204     float lookup_inv(float temp);
00205 #endif
00206 };
00207 
00208 
00209 class Thermocouple_Type_T : public Thermocouple
00210 {
00211 public:
00212     ~Thermocouple_Type_T();
00213     static const thermocouple_poly_subrange inv_poly[2];
00214     static const int inv_poly_size;
00215     float convert_inv(float temp);
00216 
00217     static const thermocouple_poly_subrange poly[2];
00218     static const int poly_size;
00219     float convert(float voltage);
00220 #ifdef TYPE_T_LUT
00221     static const int32_t lut[];
00222     static const int16_t lut_offset;
00223     static const uint16_t lut_size;
00224     float lookup(float voltage);
00225     float lookup_inv(float temp);
00226 #endif
00227 };
00228 
00229 #endif