对908QY4编程,能否使用浮点数计算.编程环境是CodeWarrior 5.1<br /><br />下面是我的部分程序:<br />{ const float C1=-4.0; // <br /> const float C2=+0.0405; // <br /> const float C3=-0.0000028; // <br /> const float T1=+0.01; // <br /> const float T2=+0.00008; // <br /><br /> float rh=*p_humidity; // rh: Humidity [Ticks] 12 Bit <br /> float t=*p_temperature; // t: Temperature [Ticks] 14 Bit<br /> float rh_lin; // rh_lin: Humidity linear<br /> float rh_true; // rh_true: Temperature compensated humidity<br /> float t_C; // t_C : Temperature <br /><br /> t_C=t*0.01 - 40; //clc. temperature from ticks to <br /> rh_lin=C3*rh*rh + C2*rh + C1; //calc. humidity from ticks to [%RH]<br /> rh_true=(t_C-25)*(T1+T2*rh)+rh_lin; //calc. temperature compensated humidity [%RH]<br /> if(rh_true>100)rh_true=100; //cut if the value is outside of<br /> if(rh_true<0.1)rh_true=0.1; //the physical possible range<br /><br /> *p_temperature=t_C; //return temperature <br /> *p_humidity=rh_true; //return humidity[%RH]<br />} |
|