Re: AD轉換
|
||||
---|---|---|---|---|
中級會員
|
你可以改寫成
if(ADCValue1 > (90 << 2)) 或是 if(ADCValue1 > (90*4)) 或是 if(ADCValue1 > 360) 其實AD轉換出來的是10bit所以是0~1023 但是put_Num_LCD()這個副程式只能顯示三位數的數字 所以顯示的時候強迫把AD 10bit的解析度降成8bit了
發表於: 2010/2/2 14:55
|
|||
|
Re: AD轉換
|
||||
---|---|---|---|---|
新會員
|
應該是這樣,請問要怎麼更改程式才可以讓LCD顯示90時做切換動作呢?
發表於: 2010/2/2 13:43
|
|||
|
Re: AD轉換
|
||||
---|---|---|---|---|
中級會員
|
因為LCM秀出來的值是ADCValue1 >> 2
所以你設定的if(ADCValue1>90)會讓RE0 = 0 就上面的程式是看到LCM顯示22以下的時候LED1就會亮,並不會在90的時候做切換 不知道你的問題是不是在這裡?還是我會錯意
發表於: 2010/2/2 10:58
|
|||
|
Re: AD轉換
|
||||
---|---|---|---|---|
中級會員
|
先確定RE0是否設為輸出腳,不然會量不到信號
發表於: 2010/2/2 9:17
|
|||
|
Re: AD轉換
|
||||
---|---|---|---|---|
新會員
|
測試時,LCD上的數值會隨著感測器變化而產生不同的數值,BUFFER內應該是有值的吧?
發表於: 2010/1/29 22:24
|
|||
|
Re: AD轉換
|
||||
---|---|---|---|---|
版主
|
dsPIC30F Peripheral Libraries User's Guide 裡面就有完整的說明。
3.7 ReadADC10 Function Prototype : unsigned int ReadADC10(unsigned char bufIndex); Include : adc10.h Description : This function reads the ADC Buffer register which contains the conversion value. Arguments : bufIndex - The ADC buffer number which is to be read. Return Value: None Remarks: This function returns the contents of the ADC Buffer register. You should provide a value between ‘0’ to ‘15’ to ensure a correct read of the ADCBUF0 to ADCBUFF. Source File: ReadADC10.c Code Example : unsigned int result; result = ReadADC10(3);
發表於: 2010/1/29 15:24
|
|||
|
AD轉換
|
||||
---|---|---|---|---|
新會員
|
使用的是APP020的模擬板,修改dsPIC數位訊號控制器原理與應用的範例程式11-4
想請問ADCValue1 = ReadADC10(0) ;中的ADCValue1是什麼樣的形態? 因為想將轉換出來的數值做程式判別,希望在讀出來的數值大於90與小於90時,可以改變模擬板上LED狀態。 目前無法達成,想請教是哪出了問題? void Show_ADC(void) { // unsigned int ADCValue1,ADCValue2; int Loop ; ADCValue1 = 0; // clear ADCValue ADCValue2 = 0; ADCON1bits.SAMP = 1; // start sampling for ( Loop = 0 ; Loop < 100 ; Loop ++ ) ; // ADCON1bits.SAMP = 0; // stop sampling while (BusyADC10()); // conversion done? ADCValue1 = ReadADC10(0) ; //------------------------------------------------------------------------------- if(ADCValue1>90) { LATEbits.LATE0 = 0; } else { LATEbits.LATE0 = 1; } //------------------------------------------------------------------------------- setcurLCD(4,1) ; // Set LCD cursor put_Num_LCD( ADCValue1 >> 2 ) ; // 將類比轉換結果以十進位數字顯示至液晶顯示器 ADCValue2 = ReadADC10(1) ; setcurLCD(12,1) ; // Set LCD cursor put_Num_LCD( ADCValue2 >> 2 ) ; // 將類比轉換結果以十進位數字顯示至液晶顯示器 }
發表於: 2010/1/29 14:08
|
|||
|