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@1:851dbb04c1e5, 2021-03-19 (annotated)
- Committer:
- mahphalke 
- Date:
- Fri Mar 19 12:27:14 2021 +0530
- Revision:
- 1:851dbb04c1e5
- Parent:
- 0:854742598c2c
Copyright updates
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| mahphalke | 0:854742598c2c | 1 | /*! | 
| mahphalke | 0:854742598c2c | 2 | ***************************************************************************** | 
| mahphalke | 0:854742598c2c | 3 | @file: ntc_10k_44031.cpp | 
| mahphalke | 0:854742598c2c | 4 | |
| mahphalke | 0:854742598c2c | 5 | @brief: This file contains functionality for 10K NTC 44021 model | 
| mahphalke | 0:854742598c2c | 6 | |
| mahphalke | 0:854742598c2c | 7 | @details: | 
| mahphalke | 0:854742598c2c | 8 | ----------------------------------------------------------------------------- | 
| mahphalke | 1:851dbb04c1e5 | 9 | Copyright (c) 2021 Analog Devices, Inc. All rights reserved. | 
| mahphalke | 0:854742598c2c | 10 | |
| mahphalke | 0:854742598c2c | 11 | This software is proprietary to Analog Devices, Inc. and its licensors. | 
| mahphalke | 0:854742598c2c | 12 | By using this software you agree to the terms of the associated | 
| mahphalke | 0:854742598c2c | 13 | Analog Devices Software License Agreement. | 
| mahphalke | 0:854742598c2c | 14 | |
| mahphalke | 0:854742598c2c | 15 | *****************************************************************************/ | 
| mahphalke | 0:854742598c2c | 16 | |
| mahphalke | 0:854742598c2c | 17 | #include <math.h> | 
| mahphalke | 0:854742598c2c | 18 | #include "thermistor.h" | 
| mahphalke | 0:854742598c2c | 19 | #include "ntc_10k_44031.h" | 
| mahphalke | 0:854742598c2c | 20 | |
| mahphalke | 0:854742598c2c | 21 | #ifdef DEFINE_LOOKUP_TABLES | 
| mahphalke | 0:854742598c2c | 22 | /* 10K NTC look-up table. Values are resistance in ohm for temperature | 
| mahphalke | 0:854742598c2c | 23 | * range from -10 to 80C with +/-1C tolerance. | 
| mahphalke | 0:854742598c2c | 24 | * @note This function uses Steinhart-Hart equation for deriving look-up table. | 
| mahphalke | 0:854742598c2c | 25 | **/ | 
| mahphalke | 0:854742598c2c | 26 | const uint32_t ntc_10k_44031rc::lut[] = { | 
| mahphalke | 0:854742598c2c | 27 | 47561, 45285, 43131, 41091, 39158, 37327, 35591, 33946, 32385, | 
| mahphalke | 0:854742598c2c | 28 | 30905, 29500, 28166, 26900, 25697, 24555, 23470, 22438, 21457, | 
| mahphalke | 0:854742598c2c | 29 | 20524, 19637, 18792, 17989, 17224, 16495, 15801, 15140, 14510, | 
| mahphalke | 0:854742598c2c | 30 | 13910, 13337, 12791, 12271, 11774, 11299, 10847, 10414, 10002, | 
| mahphalke | 0:854742598c2c | 31 | 9607, 9231, 8870, 8526, 8197, 7882, 7581, 7293, 7018, | 
| mahphalke | 0:854742598c2c | 32 | 6754, 6501, 6259, 6028, 5806, 5593, 5389, 5194, 5006, | 
| mahphalke | 0:854742598c2c | 33 | 4827, 4654, 4489, 4331, 4178, 4032, 3892, 3757, 3628, | 
| mahphalke | 0:854742598c2c | 34 | 3503, 3384, 3269, 3159, 3053, 2951, 2852, 2758, 2667, | 
| mahphalke | 0:854742598c2c | 35 | 2580, 2496, 2415, 2337, 2262, 2189, 2120, 2053, 1988, | 
| mahphalke | 0:854742598c2c | 36 | 1926, 1866, 1808, 1752, 1698, 1646, 1596, 1548, 1501, | 
| mahphalke | 0:854742598c2c | 37 | 1456 | 
| mahphalke | 0:854742598c2c | 38 | }; | 
| mahphalke | 0:854742598c2c | 39 | #endif | 
| mahphalke | 0:854742598c2c | 40 | |
| mahphalke | 0:854742598c2c | 41 | |
| mahphalke | 0:854742598c2c | 42 | /*! | 
| mahphalke | 0:854742598c2c | 43 | * @brief This is a constructor for ntc_10k_44031rc class | 
| mahphalke | 0:854742598c2c | 44 | * @return none | 
| mahphalke | 0:854742598c2c | 45 | */ | 
| mahphalke | 0:854742598c2c | 46 | ntc_10k_44031rc::ntc_10k_44031rc() | 
| mahphalke | 0:854742598c2c | 47 | { | 
| mahphalke | 0:854742598c2c | 48 | /* Coefficients of Steinhart-Hart equation for 10K NTC to convert | 
| mahphalke | 0:854742598c2c | 49 | * NTC resistance into equivalent temperature */ | 
| mahphalke | 0:854742598c2c | 50 | ntc_10k_44031rc::coeff_A = 1.032*pow(10, -3); | 
| mahphalke | 0:854742598c2c | 51 | ntc_10k_44031rc::coeff_B = 2.387*pow(10, -4); | 
| mahphalke | 0:854742598c2c | 52 | ntc_10k_44031rc::coeff_C = 1.580*pow(10, -7); | 
| mahphalke | 0:854742598c2c | 53 | |
| mahphalke | 0:854742598c2c | 54 | #ifdef DEFINE_LOOKUP_TABLES | 
| mahphalke | 0:854742598c2c | 55 | ntc_10k_44031rc::lut_offset = -10; /* Min temperature obtained through LUT */ | 
| mahphalke | 0:854742598c2c | 56 | ntc_10k_44031rc::lut_size = 90; /* Temperature range defined in LUT | 
| mahphalke | 0:854742598c2c | 57 | [lut_offset : lut_size - lut_offset] */ | 
| mahphalke | 0:854742598c2c | 58 | #endif | 
| mahphalke | 0:854742598c2c | 59 | } | 
| mahphalke | 0:854742598c2c | 60 | |
| mahphalke | 0:854742598c2c | 61 | |
| mahphalke | 0:854742598c2c | 62 | /*! | 
| mahphalke | 0:854742598c2c | 63 | * @brief Convert the thermistor resistance into equivalent temperature using | 
| mahphalke | 0:854742598c2c | 64 | * Steinhart-Hart equation for 10K 44031 NTC | 
| mahphalke | 0:854742598c2c | 65 | * @param resistance[in] - thermistor resistance | 
| mahphalke | 0:854742598c2c | 66 | * @return Thermistor temperature value | 
| mahphalke | 0:854742598c2c | 67 | */ | 
| mahphalke | 0:854742598c2c | 68 | float ntc_10k_44031rc::convert(const float resistance) | 
| mahphalke | 0:854742598c2c | 69 | { | 
| mahphalke | 0:854742598c2c | 70 | return thermistor::convert(resistance, coeff_A, coeff_B, coeff_C); | 
| mahphalke | 0:854742598c2c | 71 | } | 
| mahphalke | 0:854742598c2c | 72 | |
| mahphalke | 0:854742598c2c | 73 | |
| mahphalke | 0:854742598c2c | 74 | #ifdef DEFINE_LOOKUP_TABLES | 
| mahphalke | 0:854742598c2c | 75 | /*! | 
| mahphalke | 0:854742598c2c | 76 | * @brief Convert the thermistor resistance into equivalent temperature using | 
| mahphalke | 0:854742598c2c | 77 | * lookup table for 10K 44031 NTC | 
| mahphalke | 0:854742598c2c | 78 | * @param resistance[in] - thermistor resistance | 
| mahphalke | 0:854742598c2c | 79 | * @return Thermistor temperature value | 
| mahphalke | 0:854742598c2c | 80 | */ | 
| mahphalke | 0:854742598c2c | 81 | float ntc_10k_44031rc::lookup(const float resistance) | 
| mahphalke | 0:854742598c2c | 82 | { | 
| mahphalke | 0:854742598c2c | 83 | return thermistor::lookup(lut, resistance, lut_size, lut_offset); | 
| mahphalke | 0:854742598c2c | 84 | } | 
| mahphalke | 0:854742598c2c | 85 | #endif |