• slider image 514
  • slider image 516
  • slider image 517
  • slider image 518
  • slider image 519
:::


Browsing this Thread:   1 Anonymous Users






Re: ADC轉換基本的問題
#9
新會員
新會員


查看用戶資訊
不過我還是覺得我的可變電阻沒啥作用耶
AD1PCFGLbits.PCFG5=0;
設定成這樣不就是來源是類比的AN5輸入嗎?

這樣的話電壓應該是會跟著可變電阻的改變而改變呀?

可是我怎麼覺得我的可變電阻怎麼調都沒效果

我看不出來程式哪裡有出問題?
是有少設定什麼嗎?還是?

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


Re: ADC轉換基本的問題
#8
資深會員
資深會員


查看用戶資訊
如果ADC的操作範圍是0~3.3V的話,3.3/1024=3.2mv,一般透過可變電阻進ADC的跳動本來就燒大。10的跳動幅度也不過30mv,這樣算正常的吧?

一般操作範圍在0~3.3V的話,典型會有約1.5LSB的跳動。0~5V約1LSB跳動。不過這是指輸入信號良好的狀況。

發表於: 2008/7/15 16:33
不要問我哪裡來,我只是個流浪天涯的工程師
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: ADC轉換基本的問題
#7
新會員
新會員


查看用戶資訊
喔喔~
不過我跳動的範圍很大~~

而且ADCBUF0這裡的數值會跑到10多..
不過版子上的電壓不是只有3.3V嗎?
怎麼會跑到10多?..

發表於: 2008/7/15 16:08
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: ADC轉換基本的問題
#6
版主
版主


查看用戶資訊
AD 值會跳動是很正常的,因為 Digital 的環境下有太多的干擾,不過這種因雜訊所引起的跳動僅限於 Bit0 & Bit1 兩個LSB的跳動,如果是很多位元同時跳動時程式就有問題了。

發表於: 2008/7/15 16:04
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: ADC轉換基本的問題
#5
新會員
新會員


查看用戶資訊
謝謝大大耐心回覆
小弟我今天又從看了講義從打了一次
我用的是手動轉換,手動取樣

打出來的程式如下
#define _dsPIC33FJ256GP710_
#include <p33FJ256GP710.h>

int main(void)
{
AD1CON1bits.ADON=1;
AD1PCFGLbits.PCFG5=0;
AD1CON1bits.FORM=0;
AD1CON1bits.SSRC=0;
AD1CON1bits.ASAM=0;
TRISA=0;
AD1CON2bits.BUFM=0;
while (1)
{
AD1CON1bits.SAMP=1;
DelayX1ms(800);
AD1CON1bits.SAMP=0;
while(!AD1CON1bits.DONE);
PORTA=ADCBUF0;
}
}

void DelayX1ms(unsigned int count)
{
unsigned int i,j;
for(i=0;i<count;i++)
for(j=0;j<114;j++);
}


不過現在有一個問題
就是ADCBUF0這個站存器的數值會一直跳動
我都還沒開始轉動可變電阻他就一直跳動~
不知道是什麼原因?
請問大大知道嗎?

發表於: 2008/7/15 15:51

Edited by iceborns on 2008年07月15日 16:07:12
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: ADC轉換基本的問題
#4
版主
版主


查看用戶資訊
ADC 轉換沒有說一定要使用中斷方式處理,但考慮系統的架構最好將 AD 的轉換交由中斷去處理。這樣主程式比較單純。

VCFG<2:0>: Converter Voltage Reference Configuration bits
AD1PCFGH: ADC1 Port Configuration Register High

VCFG 是選擇參考電壓源,與選擇哪幾找要做 AD 輸入無關。
AD1PCFGH & AD1PCFGL 則是選擇哪幾支 I/O 腳位要當作 AD 的輸入。

發表於: 2008/7/14 15:56
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: ADC轉換基本的問題
#3
新會員
新會員


查看用戶資訊
請問一下我的程式需要用到中斷嗎~?

還有輸入是要用
這個AD1CON2bits.VCFG=0;
還是AD1PCFGL = 0xFFDF;
?
我手邊是已經有書本了~~
不過看了很久還是好難了解...
快昏了...

發表於: 2008/7/14 14:54
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: ADC轉換基本的問題
#2
版主
版主


查看用戶資訊
看了你的程式個人認為你對 ADC 的 Module 的工作原理與使用方式還不是很清楚。建議先讀一下 dsPIC30F Peripheral Module 裡的 10-bit ADC 講義與練習。在左邊下載中心可以找到。
另外,Microchip 也也ㄧ些範例在這裡參考看看:
http://www.microchip.com/stellent/idc ... e=SS_GET_PAGE&nodeId=2622


底下是我寫的 dsPIC33F128MC506 for 10-bit ADC 的程式,使用中斷方式讀取AD
AD1PCFGL 0xFFDF;        // AN5 is ADC input
:
:
void ADC_Initial(void)
{

     
AD1PCFGL 0xFFDF;                // AN5 is Analog , others are Digital;
     
AD1CON1 0x0446;                // 0b0000 0000 0100 0110 
                    // Auto convert using TMR3 as trigger source
                    // A/D Sample Auto-Start
     
AD1CON2 0x0000;                // ADCON2 = 0000 0000 0000 0000
                    // Don't scan inputs , SMPi = 00 ( Interrupt for each sample/convert )
     
AD1CSSL 0x0000;                // no scan input selected .......
     
AD1CON3 0x1F3F;                // TAD = 8 Tcy , SAMC = 15 TAD 
    
AD1CHS0 0x0005;                // ADCHS = 0b 00000000 00000101
    
AD1CON4 0x0000;

    
IFS0bits.AD1IF ;
    
IEC0bits.AD1IE ;            // Enable AD interrupt
    
IPC3bits.AD1IP ;            // Set Priority to 7     >> highest !!
 
     
AD1CON1bits.ADON 1;            // turn ADC ON
}

void __attribute__((interruptno_auto_psv)) _ADC1Interrupt(void)
{

        
IFS0bits.AD1IF ;
        
MyADC ADC1BUF0 ;
}

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


ADC轉換基本的問題
#1
新會員
新會員


查看用戶資訊
#define _dsPIC33FJ256GP710_
#include <p33FJ256GP710.h> 

void main ()
{
    while (
1)
    {
        
AD1CON1bits.ADON=0;
        
AD1CON2bits.VCFG=0;
        
AD1CSSLbits.CSS0=1;
        
AD1CHS0bits.CH0SA=0;
        
AD1CON1bits.FORM=0;
        
AD1CON2bits.CHPS=0;
        
TRISA=0;
        
void main1 ()
        {
            
DelayX1ms(800);
            
AD1CON1bits.ADON=1;
            
AD1CON1bits.SAMP=0;
            
PORTA=AD1CSSH;
        }
    }
}
        

void DelayX1ms(unsigned int count)
{
    
unsigned int i,j;
    for(
i=0;i<count;i++)
    for(
j=0;j<114;j++);
}



這是我打的程式
主要的功能就是用版子上的電源,在調整可調電阻VR調整電壓輸出
用LED的亮燈來表示電壓大小

不過好像怎麼打都打不出來
想請問大大我的設定方面有錯誤嗎
還有PORTA要等於什麼才能表是轉換完的數值?
是AD1CSSH這個數值嗎?
拜託大大給我點方向了~~謝謝

發表於: 2008/7/13 21:59

Edited by Ryang on 2008年07月14日 11:33:28
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... ]

教育訓練中心

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