软件篇PT100、NTC等温度传感器阻值-温度换算模块
资源内容介绍
软件篇PT100、NTC等温度传感器阻值-温度换算模块 /********************************************************************************** 文 件 名:Rtd_Driver.c**------文件信息-----------------------------------------* 程序功能: 温度传感器采集模块**------版本历史-----------------------------------------* 创 建 人: 剑胆琴心* 创建时间: 2024.08.28* 版 本: V1.00* 修 改 人:* 修改时间: * 修改说明:*********************************************************************************/#define Rtd_Driver_GLOBALS/********************************************************************************** 包含文件*********************************************************************************/#include "Include_All.h"float Res2Temp(float RES){ int end = RES_MAX - 1; int front = 0; int half = 0; float temp; if((RES <= RTD_RES_TAB[0]) && (RES >= RTD_RES_TAB[RES_MAX - 1])) { for(half = RES_MAX / 2; end - front !=1;) { if (RES > RTD_RES_TAB[half]) { end = half; half = (end + front) / 2; } else if (RES < RTD_RES_TAB[half]) { front = half; half = (front + end) / 2; } else { front = half; end = half; break; } } if(front == end) { temp = front; } else { temp = (RTD_RES_TAB[front] - RES) / (RTD_RES_TAB[front] - RTD_RES_TAB[end]) * RTD_TEMP_STEP + front; } } else { temp =-100; } return temp;}/********************************************************************************** 文件结束*********************************************************************************/