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.
ptc_ky81_110.cpp
00001 /*! 00002 ***************************************************************************** 00003 @file: ptc_ky81_110.cpp 00004 00005 @brief: This file contains functionality for PTC KY81/110 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 "thermistor.h" 00018 #include "ptc_ky81_110.h" 00019 00020 #ifdef DEFINE_LOOKUP_TABLES 00021 /* PTC look-up table. Values are resistance in ohm for temperature 00022 * range from -10 to 80C with +/-1C tolerance. 00023 * @note This table is derived based on the look-up table specified 00024 * in the datasheet of KY81/110 part. The linear interpolation 00025 * has been used to obtain 1C step size. 00026 **/ 00027 const uint32_t ptc_ky81_110::lut[] = { 00028 747, 753, 760, 767, 774, 781, 787, 794, 801, 808, 815, 822, 829, 836, 00029 843, 850, 857, 864, 871, 878, 886, 893, 901, 908, 916, 923, 931, 938, 00030 946, 953, 961, 968, 976, 984, 992, 1000, 1008, 1016, 1024, 1032, 1040, 00031 1048, 1056, 1064, 1072, 1081, 1089, 1097, 1105, 1113, 1122, 1130, 1139, 00032 1148, 1156, 1165, 1174, 1182, 1191, 1200, 1209, 1218, 1227, 1236, 1245, 00033 1254, 1263, 1272, 1281, 1290, 1299, 1308, 1317, 1326, 1336, 1345, 1354, 00034 1364, 1373, 1382, 1392, 1401, 1411, 1421, 1431, 1441, 1450, 1460, 1470, 00035 1480, 1490 00036 }; 00037 #endif 00038 00039 00040 /*! 00041 * @brief This is a constructor for ptc_ky81_110 class 00042 * @return none 00043 */ 00044 ptc_ky81_110::ptc_ky81_110() 00045 { 00046 temperature_coeff = 0.79; /* Temperature coefficient for KY81/110 */ 00047 00048 #ifdef DEFINE_LOOKUP_TABLES 00049 ptc_ky81_110::lut_offset = -10; /* Min temperature obtained through LUT */ 00050 ptc_ky81_110::lut_size = 90; /* Temperature range defined in LUT 00051 [lut_offset : lut_size - lut_offset] */ 00052 #endif 00053 } 00054 00055 00056 /*! 00057 * @brief Convert the thermistor resistance into equivalent temperature 00058 * @param resistance[in] - thermistor resistance 00059 * @return Thermistor temperature value 00060 * @note Resistance at room temperature is 1000 ohms (1K) 00061 */ 00062 float ptc_ky81_110::convert(const float resistance) 00063 { 00064 return (((resistance - 1000) / 1000) * (100.0 / temperature_coeff)) + 25.0; 00065 } 00066 00067 00068 #ifdef DEFINE_LOOKUP_TABLES 00069 /*! 00070 * @brief Convert the thermistor resistance into equivalent temperature using 00071 * lookup table for KY81/110 NTC 00072 * @param resistance[in] - thermistor resistance 00073 * @return Thermistor temperature value 00074 */ 00075 float ptc_ky81_110::lookup(const float resistance) 00076 { 00077 return thermistor::lookup(lut, resistance, lut_size, lut_offset); 00078 } 00079 #endif
Generated on Thu Jul 21 2022 10:03:15 by
1.7.2