本帖最后由 新新科技 于 2021-3-15 08:23 編輯
我這里有個將NTC電阻阻值轉換成溫度的C51函數,從網上下載的,經測試,可以用,如果需要,你可以搬去用一下#include "math.h"
const float Rp=10000.0; //10K
const float T2 = (273.15+25.0);//T2
const float Bx = 3950.0;//B
const float Ka = 273.15;
float Get_Temp(void)
{
float Rt;
float temp;
Rt = Get_TempResistor();
//like this R=5000, T2=273.15+25,B=3470, RT=5000*EXP(3470*(1/T1-1/(273.15+25)),
temp = Rt/Rp;
temp = log(temp);//ln(Rt/Rp)
temp/=Bx;//ln(Rt/Rp)/B
temp+=(1/T2);
temp = 1/(temp);
temp-=Ka;
return temp;
}
|