unsigned long adc_temp1, adc_temp2, adc_temp3, adc_temp4;
adc_temp1 = 0; //±»²âµç×è¸ß¶Ë¼ÆÊýÖµ
adc_temp1 = adc_value1;
adc_temp1 = adc_temp1 << 8;
adc_temp1 |= adc_value2;
adc_temp4 = 0; //±»²âµç×èµÍ¶Ë¼ÆÊýÖµ(½Ï´ó)
adc_temp4 = adc_value3;
adc_temp4 = adc_temp3 << 8;
adc_temp4 |= adc_value4;
if(adc_temp4 > 0x4BC0)
adc_temp4 = 0x4BC0;
adc_temp2 = (2*adc_temp4 - adc_temp1)*1250/511 - 47437; //¸Ä
SendData(0x23); //adc_temp3±»²âµç×èÖµ£¬ÒÑ·Å´ó100±¶
SendData(adc_temp2 >> 8);
SendData(adc_temp2);
----------------------------------------------------------------------------------------
01 2B 2B 4B 6A 23 4F B3 45 6A BE 67 00 B2 | 串口发送上来的数,adc_temp1 = 0x2b, adc_temp2 = 0x2b, adc_temp3 = 0x4b, adc_temp4 = 0x6a, adc_temp2 = 0x4fb3;
可我按以上参数算出来adc_temp2 = (((0x4b6a * 2) - 0x2b2b) * 1250 / 511) - 47437 = 0x4e0e;
相差很大啊。
编译环境用的uv5.
|