• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
:::


Browsing this Thread:   1 Anonymous Users






Re: 溫度sensor 程式原理
#3
新會員
新會員


查看用戶資訊
謝謝~我懂了

發表於: 2008/11/13 16:38
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 溫度sensor 程式原理
#2
資深會員
資深會員


查看用戶資訊
tc77 一次丟 16bit ,只有前 13bit 有用。

每個 單位 = 0.0625 ℃

所以,假設你收到 05FF -------------->你到底看不看得懂這代表幾度?

191 *0.0625 = 11.9375

191/16 = 11

1910/16= 119

0.0625 = 1/16

所以你的兩個問題
一是 *10 / 16

二是 bcd 轉換

發表於: 2008/11/13 15:06
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


溫度sensor 程式原理
#1
新會員
新會員


查看用戶資訊
usbCDC範例程式有溫度sensor 程式轉換ASCLL的程式


void UpdateCelsiusASCII(void)
{
WORD temp;
byte i;

temp._word = temperature._word >> 3;

if(temp.HighB.b4 == 0)
{
temp.HighB._byte &= 0b00011111;
tempString[0] = '+';
}
else
{
temp.HighB._byte |= 0b11100000;
tempString[0] = '-';
temp._word = temp._word ^ 0xFFFF; // Negate
temp._word++;
}//end if

temp._word = (temp._word*10U) >> 4; // Turn into celsius xx.x

/* Populate string */
for(i=4;i>0;i--)
{
tempString[i] = (((char)(temp._word % 10)) & 0x0F) | 0x30;
temp._word /= 10;
}//end for

/* Turn leading zeros into spaces */
if(tempString[1] == '0')
{
tempString[1] = ' ';
if(tempString[2] == '0')
tempString[2] = ' ';
}//end if

/* Adjust decimal digit */
tempString[5] = tempString[4];
tempString[4]='.';
tempString[6]=0x00 ; // Null-Terminated

}//end UpdateCelsiusASCII
==================================
其中temp._word = (temp._word*10U) >> 4;這行是幹麻呢?


for(i=4;i>0;i--)
{
tempString[i] = (((char)(temp._word % 10)) & 0x0F) | 0x30;
temp._word /= 10;
}//end for

這for迴圈又做了什麼事


這兩個地方我看了很久不知道是怎麼轉換的有誰知道呢?我有看了TC77的data,0.0625度c為000FH

發表於: 2008/11/13 13:22
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------