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


Browsing this Thread:   1 Anonymous Users






AD轉換問題?
#1
中級會員
中級會員


查看用戶資訊
void init_AD(void)
{
CMCON = 0x07;
ADCON0bits.CHS3 = 0;
ADCON0bits.CHS2 = 0;
ADCON0bits.CHS1 = 0;
ADCON0bits.CHS0 = 0;
ADCON0bits.GO_DONE = 0;
ADCON0bits.ADON = 1;
ADCON1 = 0x0E;
ADCON2bits.ADFM = 0;
ADCON2bits.ACQT2 = 0;
ADCON2bits.ACQT1 = 0;
ADCON2bits.ACQT0 = 0;
ADCON2bits.ADCS2 = 1;
ADCON2bits.ADCS1 = 1;
ADCON2bits.ADCS0 = 1;
}

void main (void)
{
init_AD();

while(1)
{
Delay10TCYx(5);
ConvertADC();
while(BusyADC());
}
}

以上是我寫的一個測試AD轉換的程式....
硬體部分用的是PIC18F6490,用的是內部RC震盪器
線路接法是直接給24Pin(AN0) 一個3V的電壓 有用分壓電路
所以實際進去的電壓 只有3V的一半

然後我使用debug模式
開啟watch視窗檢查ADRESH和ADRESL兩各暫存器
發現我電壓給3V 此時AD取得的電壓為7F 02
因為分壓 所以1/2 得到7F 02這是OK的
不過問題來了....
我把VCC電壓改成2.8V後 的到的值也是7F 02
變成我的考電壓跟實際要測的電壓是一起在動的
有辦法把考電壓固定為3V嘛
這樣才有辦法去比較剩餘的電

只有用一個電源 VDD和VSS 以及 AN0 AD 轉換的電壓都是一樣的

請各位大大指點一下

發表於: 2008/12/9 14:31

Edited by badsan on 2008年12月09日 18:16:04
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... ]

教育訓練中心

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