|
|||||||||||
| 技術交流 | 電路欣賞 | 工控天地 | 數字廣電 | 通信技術 | 電源技術 | 測控之家 | EMC技術 | ARM技術 | EDA技術 | PCB技術 | 嵌入式系統(tǒng) 驅動編程 | 集成電路 | 器件替換 | 模擬技術 | 新手園地 | 單 片 機 | DSP技術 | MCU技術 | IC 設計 | IC 產業(yè) | CAN-bus/DeviceNe |
求教各位 |
| 作者:游苛 欄目:單片機 |
對908QY4編程,能否使用浮點數計算.編程環(huán)境是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] } |
| 2樓: | >>參與討論 |
| 作者: JerryBJ 于 2007/3/7 18:38:00 發(fā)布:
可以 在project創(chuàng)建初期,就選擇浮點數支持(project wizard的最后一步)。 不過資源耗費很大。 |
|
| 3樓: | >>參與討論 |
| 作者: 游苛 于 2007/3/8 9:07:00 發(fā)布:
Thank you ! Thank you ! |
|
|
|
| 免費注冊為維庫電子開發(fā)網會員,參與電子工程師社區(qū)討論,點此進入 |
Copyright © 1998-2006 m.58mhw.cn 浙ICP證030469號 |