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.
ntc_10k_44031.cpp
00001 /*! 00002 ***************************************************************************** 00003 @file: ntc_10k_44031.cpp 00004 00005 @brief: This file contains functionality for 10K NTC 44021 model 00006 00007 @details: 00008 ----------------------------------------------------------------------------- 00009 Copyright (c) 2021 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 <math.h> 00018 #include "thermistor.h" 00019 #include "ntc_10k_44031.h" 00020 00021 /* Convert the temperature using Beta factor specified for 44031 10K NTC */ 00022 //#define NTC_10K_44031_CONVERT_USING_BETA_VALUE 00023 00024 #if defined(NTC_10K_44031_CONVERT_USING_BETA_VALUE) 00025 #define NTC_10K_44031_RESISTANCE_AT_25C 10000 // 10K 00026 #define NTC_10K_44031_ROOM_TEMP_IN_KELVIN 298.15 00027 #define NTC_10K_44031_BETA_VALUE 3694 00028 #endif 00029 00030 #ifdef DEFINE_LOOKUP_TABLES 00031 /* 10K NTC look-up table. Values are resistance in ohm for temperature 00032 * range from -10 to 80C with +/-1C tolerance. 00033 * @note This function uses Steinhart-Hart equation for deriving look-up table. 00034 **/ 00035 const uint32_t ntc_10k_44031rc::lut[] = { 00036 47561, 45285, 43131, 41091, 39158, 37327, 35591, 33946, 32385, 00037 30905, 29500, 28166, 26900, 25697, 24555, 23470, 22438, 21457, 00038 20524, 19637, 18792, 17989, 17224, 16495, 15801, 15140, 14510, 00039 13910, 13337, 12791, 12271, 11774, 11299, 10847, 10414, 10002, 00040 9607, 9231, 8870, 8526, 8197, 7882, 7581, 7293, 7018, 00041 6754, 6501, 6259, 6028, 5806, 5593, 5389, 5194, 5006, 00042 4827, 4654, 4489, 4331, 4178, 4032, 3892, 3757, 3628, 00043 3503, 3384, 3269, 3159, 3053, 2951, 2852, 2758, 2667, 00044 2580, 2496, 2415, 2337, 2262, 2189, 2120, 2053, 1988, 00045 1926, 1866, 1808, 1752, 1698, 1646, 1596, 1548, 1501, 00046 1456 00047 }; 00048 #endif 00049 00050 00051 /*! 00052 * @brief This is a constructor for ntc_10k_44031rc class 00053 * @return none 00054 */ 00055 ntc_10k_44031rc::ntc_10k_44031rc() 00056 { 00057 /* Coefficients of Steinhart-Hart equation for 10K NTC to convert 00058 * NTC resistance into equivalent temperature */ 00059 ntc_10k_44031rc::coeff_A = 1.032*pow(10, -3); 00060 ntc_10k_44031rc::coeff_B = 2.387*pow(10, -4); 00061 ntc_10k_44031rc::coeff_C = 1.580*pow(10, -7); 00062 00063 #ifdef DEFINE_LOOKUP_TABLES 00064 ntc_10k_44031rc::lut_offset = -10; /* Min temperature obtained through LUT */ 00065 ntc_10k_44031rc::lut_size = 90; /* Temperature range defined in LUT 00066 [lut_offset : lut_size - lut_offset] */ 00067 #endif 00068 } 00069 00070 00071 /*! 00072 * @brief Convert the thermistor resistance into equivalent temperature using 00073 * Steinhart-Hart equation Or Beta value for 10K 44031 NTC 00074 * @param resistance[in] - thermistor resistance 00075 * @return Thermistor temperature value in Celcius 00076 */ 00077 float ntc_10k_44031rc::convert(const float resistance) 00078 { 00079 #if defined(NTC_10K_44031_CONVERT_USING_BETA_VALUE) 00080 float temperature; 00081 temperature = (1 / ((log(resistance / NTC_10K_44031_RESISTANCE_AT_25C) / 00082 NTC_10K_44031_BETA_VALUE) + (1 / NTC_10K_44031_ROOM_TEMP_IN_KELVIN))) - 273.15; 00083 return temperature; 00084 #else 00085 return thermistor::convert(resistance, coeff_A, coeff_B, coeff_C); 00086 #endif 00087 } 00088 00089 00090 #ifdef DEFINE_LOOKUP_TABLES 00091 /*! 00092 * @brief Convert the thermistor resistance into equivalent temperature using 00093 * lookup table for 10K 44031 NTC 00094 * @param resistance[in] - thermistor resistance 00095 * @return Thermistor temperature value 00096 */ 00097 float ntc_10k_44031rc::lookup(const float resistance) 00098 { 00099 return thermistor::lookup(lut, resistance, lut_size, lut_offset); 00100 } 00101 #endif
Generated on Thu Jul 21 2022 10:03:15 by
1.7.2