diff --git a/include/mcc134.h b/include/mcc134.h index df0852f..abb7baf 100644 --- a/include/mcc134.h +++ b/include/mcc134.h @@ -49,6 +49,8 @@ enum TcTypes TC_TYPE_B = 6, /// N type TC_TYPE_N = 7, + /// C type + TC_TYPE_C = 8, /// Input disabled TC_DISABLED = 0xFF }; diff --git a/lib/mcc134.c b/lib/mcc134.c index 205bfda..8883ebe 100644 --- a/lib/mcc134.c +++ b/lib/mcc134.c @@ -972,7 +972,7 @@ int mcc134_tc_type_write(uint8_t address, uint8_t channel, uint8_t type) if (!_check_addr(address) || (channel >= NUM_TC_CHANNELS) || - ((type > TC_TYPE_N) && (type != TC_DISABLED))) + ((type > TC_TYPE_C) && (type != TC_DISABLED))) { return RESULT_BAD_PARAMETER; } diff --git a/lib/nist.c b/lib/nist.c index da89996..46cbe91 100644 --- a/lib/nist.c +++ b/lib/nist.c @@ -4,6 +4,8 @@ * brief This file contains NIST thermocouple linearization functions. * * date 1 Feb 2018 +* +* 14 Jun 2024 Added C Type TC (Ovidio Y. Pena Rodriguez) */ #include #include "nist.h" @@ -12,7 +14,7 @@ // // The following types are supported: // -// J, K, R, S, T, N, E, B +// J, K, R, S, T, N, E, B, C enum tcTypes { TC_TYPE_J = 0, @@ -22,7 +24,8 @@ enum tcTypes TC_TYPE_R, TC_TYPE_S, TC_TYPE_B, - TC_TYPE_N + TC_TYPE_N, + TC_TYPE_C }; @@ -641,10 +644,66 @@ const NIST_Reverse_type TypeBReverseTable = TypeBReverse }; +// **************************************************************************** +// Type C data + +const double TypeCTable0[] = +{ + 0.0000000E+00, + 7.4411468E+01, + -4.5680255E+00, + 6.0972079E-01, + -5.5888380E-02, + 2.9645590E-03, + -6.5745000E-05 +}; + +const double TypeCTable1[] = +{ + 4.1102500E+02, + -6.1463789E+01, + 1.4651879E+01, + -9.9683382E-01, + 3.7141869E-02, + -7.0836000E-04, + 5.5012700E-06 +}; + +const NIST_Table_type TypeCTables[] = +{ + { + 7, + 0.0, + TypeCTable0 + }, + { + 7, + 11.3, + TypeCTable1 + } +}; + +const double TypeCReverse[] = +{ + 0.00000E00, + 1.33300E-02, + 1.25261E-05, + -1.08382E-08, + 3.70800E-12, + -4.64562E-16, + -1.35135E-20 +}; + +const NIST_Reverse_type TypeCReverseTable = +{ + 7, // nCoefficients + TypeCReverse +}; + // **************************************************************************** -const Thermocouple_Data_type ThermocoupleData[8] = +const Thermocouple_Data_type ThermocoupleData[9] = { { 3, // nTables @@ -685,6 +744,11 @@ const Thermocouple_Data_type ThermocoupleData[8] = 3, // nTables &TypeNReverseTable, // Reverse Table TypeNTables // Tables + }, + { + 2, // nTables + &TypeCReverseTable, // Reverse Table + TypeCTables // Tables } }; @@ -696,9 +760,9 @@ double NISTCalcVoltage(unsigned int type, double temp) double fTemp; double fExtra = 0.0; - if (type > TC_TYPE_N) + if (type > TC_TYPE_C) { - type = TC_TYPE_N; + type = TC_TYPE_C; } // select appropriate NIST table data @@ -740,9 +804,9 @@ double NISTCalcTemperature(unsigned int type, double voltage) double fVoltage; double fResult; - if (type > TC_TYPE_N) + if (type > TC_TYPE_C) { - type = TC_TYPE_N; + type = TC_TYPE_C; } // determine which temp range table to use with the threshold V