打印

求教各位

[复制链接]
1226|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
游苛|  楼主 | 2007-3-7 08:47 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
对908QY4编程,能否使用浮点数计算.编程环境是CodeWarrior 5.1

下面是我的部分程序:
{ const float C1=-4.0;        // 
  const float C2=+0.0405;     // 
  const float C3=-0.0000028;  // 
  const float T1=+0.01;       // 
  const float T2=+0.00008;    //     

  float rh=*p_humidity;    // rh:   Humidity [Ticks] 12 Bit 
  float t=*p_temperature; // t:       Temperature [Ticks] 14 Bit
  float rh_lin;            // rh_lin:  Humidity linear
  float rh_true;         // rh_true: Temperature compensated humidity
  float t_C;               // t_C   :  Temperature 

  t_C=t*0.01 - 40;             //clc. temperature from ticks to 
  rh_lin=C3*rh*rh + C2*rh + C1;  //calc. humidity from ticks to [%RH]
  rh_true=(t_C-25)*(T1+T2*rh)+rh_lin;  //calc. temperature compensated humidity [%RH]
  if(rh_true>100)rh_true=100;      //cut if the value is outside of
  if(rh_true<0.1)rh_true=0.1;       //the physical possible range

  *p_temperature=t_C;              //return temperature 
  *p_humidity=rh_true;              //return humidity[%RH]
}

相关帖子

沙发
JerryBJ| | 2007-3-7 18:38 | 只看该作者

可以

在project创建初期,就选择浮点数支持(project wizard的最后一步)。

不过资源耗费很大。

使用特权

评论回复
板凳
游苛|  楼主 | 2007-3-8 09:07 | 只看该作者

Thank you !

Thank you !

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

6

主题

27

帖子

0

粉丝