51+HD7279+ADS1110+PT100的测温系统(程序)(17)

发布时间:2021-06-05

51+HD7279+ADS1110+PT100的测温系统,通过与标准温度计对比拟合,精度能达到0.5度

W_B1byte_high /*= TMR_H*/ = ads1110ReceiveByte();

sendAck();

W_B1byte_low /*= TMR_L*/ = ads1110ReceiveByte();

sendAck();

temp = ads1110ReceiveByte();

ads1110Stop();

W_B1_word = (W_B1byte_high << 8)+ W_B1byte_low;

if (W_B1_word > 0x7fff)

W_B1_word = 0;

return W_B1_word;

}

else

return 0x0000;

}

/*******************************************************************************

名称: 取AD结果函数

功能: 它是16位AD转换,连续去制25次,去掉3最大值和3个最小值,剩下19个取平均值

返回: 平均取值

********************************************************************************/

uint get_ad_result()

{

uchar i,j;

uint temp;

nTmp = 0;

for(i = 0; i < 25; i++) // 连续取值25次

{

AD_Result[i] = RD_ADS();

delay1ms(10);

}

for(i = 1; i< 25; i++) // 插入法对取的25个值进行排序

{

temp = AD_Result[i]; //store the original sorted array in temp

for(j=i ; j>0 && temp < AD_Result[j-1] ; j--) //compare the new array with temp

{

AD_Result[j] = AD_Result[j-1]; //all larger elements are moved one pot to the right }

精彩图片

热门精选

大家正在看