• 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






Re: A/D轉換後的問題?16f877a
#7
新會員
新會員


查看用戶資訊
後來ADRESH改成ADRESL就可以了


謝謝

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


Re: A/D轉換後的問題?16f877a
#6
資深會員
資深會員


查看用戶資訊
個人覺得 A/D線路 規劃可能有問題.

可以貼硬體 A/D部分 的線路看看嗎?

硬體就像骨骼肌肉,軟體像神經網路.相互協調.

發表於: 2009/11/19 0:57
少年不知愁滋味,老來方知路難行。
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: A/D轉換後的問題?16f877a
#5
新會員
新會員


查看用戶資訊
程式要怎改連續累加?

能大概說明一下?謝謝

發表於: 2009/11/18 23:53
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: A/D轉換後的問題?16f877a
#4
資深會員
資深會員


查看用戶資訊
設迴圈 , 連續累加 16 or 32 or 64 or 128 or 256 讀值後 , 取平均值 ( 右移 )(或以累加值 ) 作判斷

發表於: 2009/11/18 23:27
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: A/D轉換後的問題?16f877a
#3
新會員
新會員


查看用戶資訊
那如果硬體固定了.有其他改法嗎?

我們要用可變電阻 因阻值不同顯示不同的數值

可是老師給的難題是電阻變化非常微小 所以不知道該如何是好...

發表於: 2009/11/18 23:17
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: A/D轉換後的問題?16f877a
#2
資深會員
資深會員


查看用戶資訊
動態範圍太小 , ((79-77) * 4 / 1024 ) * 5v = 0.039v , 容易誤判
建議由硬體將這範圍拉大 , 再交由 MCU 判斷

A/D 周邊設定沒什麼問題 , 但主迴圈速度太快 , 如果是由人眼判斷,可能無法察覺

CMCON 設定式 多了一個 0 ( 應無大礙 )

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


A/D轉換後的問題?16f877a
#1
新會員
新會員


查看用戶資訊
因為用的測試板可變電阻變化較大.但是裝在實體上後

實體的電阻變化只有一點點值都卡在0X77左右

有可能把0X77這個值再分出來很多段嗎?

或是要更改程式?

程式如下面:

#include <pic.h>
#include "cnfig877a.h"


void Init_IO(void);
void Init_Adc( void );

void A2D( unsigned char );
void Init_System(void);



__CONFIG ( XT_OSC & BODEN_OFF & WDT_OFF & CP_OFF & LVP_OFF & DEBUG_ON );


const char RBarray[ ]={0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f};

unsigned int AD_Temp;

union {
int AD_10bit;
struct {
char AD_LSB;
char AD_MSB;
}AD_Byte;
}AD_Int;


void Init_IO(void)
{
ADCON1=0b00000110;
}

/*****************************************
Initialize A/D & Comparator Module
******************************************/
void Init_Adc( void )
{
CMCON=0b000000111;
ADCON1=0b00001110;
ADFM=0;
ADCON0=0b10000001;
}
/***********************************
Convert A/D Channel
************************************/
void A2D( unsigned char channel )
{
unsigned char temp;

temp = channel << 3;



ADCON0 &= 0b11000111;
ADCON0 |= temp;

ADGO = 1;
while (ADGO) ;
AD_Int.AD_Byte.AD_MSB=ADRESH;
AD_Int.AD_Byte.AD_LSB=ADRESL;
}
//***************************************
//* Program Main ( ) *
//***************************************
void main(void)
{
Init_IO();
Init_Adc();
Init_System();

while(1)
{
A2D(0); // Get 10-bit A/D result from CH0
if ( ADRESH>= 0x79)
{
PORTB=RBarray[3];
}
else if ( ADRESH>= 0x78 )
{
PORTB=RBarray[2];
}
else if ( ADRESH>= 0x77 )
{
PORTB=RBarray[1];
}
else
{
PORTB=RBarray[0];
}
}
}
/*****************************
INITIALIZE SYSTEM
*****************************/
void Init_System(void)
{
PORTB = 0x00;
TRISB = 0x00;
};

發表於: 2009/11/18 0:00
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... ]

教育訓練中心

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