• slider image 442
  • slider image 492
  • slider image 493
  • slider image 494
  • slider image 495
  • slider image 496
:::


Browsing this Thread:   1 Anonymous Users






Re: 在範例程式觸控面板控制
#5
版主
版主


查看用戶資訊
電阻式觸控螢幕轉換後只有 X & Y 兩軸的電壓值而已,平面座標只要兩點就可以了。

發表於: 2008/10/6 17:18
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 在範例程式觸控面板控制
#4
新會員
新會員


查看用戶資訊
請問一下..觸碰面板不是有X- X+ Y- Y+四個訊號嗎
依這範例只有2個訊號..這樣是為什麼??

發表於: 2008/10/3 13:38
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 在範例程式觸控面板控制
#3
新會員
新會員


查看用戶資訊
我把下面的這個範例用PIC18F8722來製作..裡面的ADCFlag不知道是代表什麼意思?我用C18編譯器...請指導一下!!

#include <pic.h>

#define XYSel RA1
#define DIR_XYSel TRISA1
#define X 1
#define Y 0

static bit ADCFlag;
static unsigned char IntCnt,TimerCnt = 158;

void Init(void);
void delay(void);
void delay30us(void);
void delay_charge(void);
void delay_discharge(void);
unsigned long multiplication(unsigned short a,unsigned short b);

/********************************************/
/* 中斷副程式 */
/*PIC只有一個中斷向量位址,也就是只有一個中斷*/
/*副程式,所以可用中斷旗標的檢查來達到多個中 */
/*斷源的目的,在此僅檢查計時中斷. */
/********************************************/
static void interrupt isr(void)
{
if(T0IF){
if(IntCnt == 1){
IntCnt = 0;
ADCFlag = 1;
TMR0 = TimerCnt;
T0IF = 0;
}
else{
TMR0 = TimerCnt;
T0IF = 0;
IntCnt++;

}
}
}

/********************************************/
/* 主程式 */
/********************************************/
void main(void)
{
unsigned short X_pos,Y_pos;
unsigned short Xpos[12],Ypos[12];
unsigned char cnt;
unsigned long x_mul,y_mul;

Init(); // 執行初始設定.

// Status initializing.
RB0 = 1; // 動作時亮燈.
RB2 = 0; // 未觸碰熄燈.
X_pos = 0x0000; // X座標初值為0.
Y_pos = 0x0000; // Y座標初值為0.
XYSel = X; // 初始為X軸.
RB1 = 1; // 開始放電.
ADCFlag = 0; // ADC轉換旗標.
IntCnt = 0; // 中斷次數計數器.
TMR0 = TimerCnt; // 設定初值.


// Main loop.
while(1){

while(!ADCFlag) continue;
ADCFlag = 0;

// Get X coordinate.
delay_discharge();
delay_discharge(); // 放電延遲.
RB1 = 0; // 停止放電.
delay_charge(); // 充電延遲.
for(cnt=0;cnt<12;cnt++){
delay30us(); // CPU要求的延遲.
ADGO = 1; // 開始轉換.
while(ADGO); // 等待轉換完畢.
Xpos[cnt] = ADRESH << 8;
Xpos[cnt] |= ADRESL;
}
XYSel = Y; // 切至Y軸.
RB1 = 1; // 開始放電.

// Get Y coordinate.
delay_discharge();
delay_discharge(); // 放電延遲.
RB1 = 0; // 停止放電.
delay_charge(); // 充電延遲.
for(cnt=0;cnt<12;cnt++){
delay30us(); // CPU要求的延遲.
ADGO = 1; // 開始轉換.
while(ADGO); // 等待轉換完畢.
Ypos[cnt] = ADRESH << 8;
Ypos[cnt] |= ADRESL;
}
XYSel = X; // 切至X軸.
RB1 = 1; // 開始放電.

// Filtering.
if(Xpos[0] == Xpos[1]||Xpos[0] == Xpos[2]||Xpos[1] == Xpos[2]){
if( Ypos[0] == Ypos[1]||Ypos[0] == Ypos[2]||Ypos[1] == Ypos[2]){
if(Xpos[0] == Xpos[1]) X_pos = Xpos[0];
else if(Xpos[1] == Xpos[2]) X_pos = Xpos[1];
else X_pos = Xpos[2];
if(Ypos[0] == Ypos[1]) Y_pos = Ypos[0];
else if(Ypos[1] == Ypos[2]) Y_pos = Ypos[1];
else Y_pos = Ypos[2];
}
else continue;
}
else continue;

////////////////////////////////////////////////////////
// UART(RS232) Transmission
if(X_pos > 928) X_pos = 928;
if(Y_pos > 840) Y_pos = 840;
if(X_pos < 110 || Y_pos < 190){
RB2 = 0;
}
else{
X_pos -= 190;
x_mul = multiplication(X_pos,200);
X_pos = x_mul >> 8;
Y_pos -= 80; // Torlerance adjust.
y_mul = multiplication(Y_pos,92);
Y_pos = y_mul >> 8;
Y_pos -= 25; // Torlerance adjust.
while(TRMT == 0);
TXREG = X_pos >> 8;
while(TRMT == 0);
TXREG = X_pos;
while(TRMT == 0);
TXREG = Y_pos >> 8;
while(TRMT == 0);
TXREG = Y_pos;
RB2 = 1;
}
}
}

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


Re: 在範例程式觸控面板控制
#2
版主
版主


查看用戶資訊
從字面上看起來應該是 AD 轉換完成後的通知旗號,告訴主程式 AD 已經在 Background 下轉換完成。

我還再猜你是指哪一個程式,太多的範例不見得每一個我都知道...

發表於: 2008/2/27 11:07
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


在範例程式觸控面板控制
#1
新會員
新會員


查看用戶資訊
在範例程式中ADCFlag是代表什麼意思呢?
請指導..謝謝

發表於: 2008/2/26 17:59
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... ]

教育訓練中心

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