Browsing this Thread:
1 Anonymous Users
|
AD轉換問題?
|
|
中級會員
Joined
: 2007/12/26 17:11 最後登入時間
: 2009/6/16 14:53
Group:
註冊會員
Level : 6 HP : 0 / 128 MP : 17 / 6283 EXP : 12
|
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
|
|
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.