stm32用外设10k热敏电阻测温度不准确

2019-07-25 11:06发布

short Get_Temprate(void)       
{
        double R_T;
  u16 AVC=3300;
  u16 R=1000;
        u16 k=0;
        u32 adcx;
        short result;
        double temperate;
        adcx=T_Get_Adc_Average(ADC_Channel_1,20);        //取平均值
        temperate=AVC*((float)adcx/1024);                //电压值
        R_T=(AVC-temperate)*(R/temperate);
  if(R_T==RT_50[146])                 
        {
           result=-30+146;
        }
        for(k=0;k<146;k++)
        {
           if(R_T==RT_50[k])
           {
                 result=-30+k;
           }
           else  if ((R_T<RT_50[k])&&(R_T>RT_50[k+1]))
                 {
                 result=-30+k;
                 }
        }

        return result;
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。