#include"ntc.h"#include"main.h"staticfloat NTCTAB[70]={2.489,2.580,2.677,2.776,2.880,2.988,3.101,3.219,3.342,3.471,//51~60℃3.601,3.745,3.892,4.045,4.204,4.371,4.546,4.729,4.920,5.120,//50~41℃5.329,5.549,5.778,6.019,6.271,6.534,6.810,7.100,7.405,7.724,//40~31℃8.058,8.409,8.778,9.166,9.572,10.000,10.450,10.921,11.418,11.941,//30~21℃12.491,13.068,13.676,14.317,14.992,15.704,16.452,17.242,18.074,18.953,//20~11℃19.880,20.858,21.892,22.984,24.138,25.357,26.645,28.007,29.448,30.974,//10~1℃32.590,34.298,36.107,38.025,40.057,42.215,44.500,46.924,49.499,52.235//0~-9℃};
uint8 FineTab(float dat)//表中数据从小到大 {
uint8 st,ed,m ;
uint8 i ;
st =0;
ed =70-1;//和元素下标对应
i =0;if(dat >= NTCTAB[ed])return ed ;elseif(dat <= NTCTAB[st])return st ;while(st < ed){
m =(st+ed)/2;if(dat == NTCTAB[m])break;if(dat < NTCTAB[m+1]&& dat > NTCTAB[m]){if(NTCTAB[m+1]-dat < dat-NTCTAB[m]){
m=m+1;break;}break;}if(dat > NTCTAB[m]) st = m ;//ed = m ; else ed = m ;//st = m ; if(i++>71)break;}if(st > ed )return0;return m ;}