/** * @file ALGO_Temperature_ATY.c * * @param Project ALGO_Algorithm_ATY_LIB * * @author ATY * * @copyright * - Copyright 2017 - 2023 MZ-ATY * - This code follows: * - MZ-ATY Various Contents Joint Statement - * * https://mengze.top/MZ-ATY_VCJS * - CC 4.0 BY-NC-SA - * * https://creativecommons.org/licenses/by-nc-sa/4.0/ * - Your use will be deemed to have accepted the terms of this statement. * * @brief Familiar functions of NTC or others temperature calc * * @version * - 1_01_230107 > ATY * -# Preliminary version, first Release ******************************************************************************** */ #ifndef __ALGO_Temperature_ATY_C #define __ALGO_Temperature_ATY_C #include "ALGO_Temperature_ATY.h" /******************************* For user *************************************/ /******************************************************************************/ /** * @brief Calculate temperature from ntc resistance * @param Rntc Current NTC resistance value * @param R25 NTC standard resistance value at 25C * @param B B value of NTC * @return Current temperature in Celsius * @note T25: Kelvin temperature at 25C = 298.15 = ALGO_TEMP_CtoT(25) * R25: NTC standard resistance value at 25C like 10K,5K,100K... * B: B value of NTC like 3435,3950... * Rntc: Current NTC resistance value * Tn: Actual Kelvin temperature(Cn = Tn-273.15) * B = (lnR25 - lnRntc)/(1/T25 - 1/Tn) */ float ALGO_ResToKelvinTemp(float Rntc, float R25, float B) { float Tn = 0.0; float Cn = 0.0; float temp_f[2]; temp_f[0] = (ALGO_MATH_LogLn(R25) - ALGO_MATH_LogLn(Rntc)) / B; temp_f[1] = (1 / ALGO_TEMP_CtoT(25)) - temp_f[0]; Tn = 1 / temp_f[1]; Cn = ALGO_TEMP_TtoC(Tn); return Cn; } // resultTemp = ALGO_ResToKelvinTemp(ALGO_VoltageToResDown(resultTemp, vref_t, 10), 1, 3200); #endif /* __ALGO_Temperature_ATY_C */ /******************************** End Of File *********************************/