• slider image 442
  • slider image 497
  • slider image 498
  • slider image 499
  • slider image 500
  • slider image 502
:::


Browsing this Thread:   1 Anonymous Users






Re: VB傳ASCII CODE 傳至 P30F4011
#2
中級會員
中級會員


查看用戶資訊
利用COM Port來控制,首先自己要先定義控制的命令/訊息格式,在此先假設您對串列傳輸已經有基本的認知,只是不知道dsPIC如何撰寫
直接貼上我目前用的程式一小段,這是用來改變PID的控制參數及轉速命令,建議您看看dsPIC的周邊課程資料
// ***********************************************************************
void __attribute__((__interrupt__)) _U1TXInterrupt(void)
{
IFS0bits.U1TXIF = 0; // clear interrupt flag
return;
}


void __attribute__((__interrupt__)) _U1RXInterrupt(void)
{
IFS0bits.U1RXIF = 0; // clear interrupt flag
Rec_temp = U1RXREG; // 4個字元進來中斷一次,第一字元放temp
if (Rec_temp == 0x02) // 判斷命令為何
{
RXPtr = &InData1[0]; // point to first char in string
*RXPtr=Rec_temp;
*RXPtr++;
for (Rec_Count=1;Rec_Count<=3;Rec_Count++)
{
*RXPtr = U1RXREG;
*RXPtr++;
}

SpeedSet=((unsigned int)InData1[1] << 8) + (unsigned int)InData1[2];
if (SpeedSet < 2000) //UART歸零時硬體電路設計還有初始值
SpeedSet = 2000;

}
else if (Rec_temp == 0x03) // 判斷Kp命令為何
{
RXPtr = &InData2[0]; // point to first char in string
*RXPtr=Rec_temp;
*RXPtr++;
for (Rec_Count=1;Rec_Count<=3;Rec_Count++)
{
*RXPtr = U1RXREG;
*RXPtr++;
}

Kp=((unsigned int)InData2[1] << 8) + (unsigned int)InData2[2];

}
else if (Rec_temp == 0x04) // 判斷Ki命令為何
{
RXPtr = &InData3[0]; // point to first char in string
*RXPtr=Rec_temp;
*RXPtr++;
for (Rec_Count=1;Rec_Count<=3;Rec_Count++)
{
*RXPtr = U1RXREG;
*RXPtr++;
}

Ki=((unsigned int)InData3[1] << 8) + (unsigned int)InData3[2];

}
else
{ //清除空間
U1RXREG;
U1RXREG;
U1RXREG;
}


return;
}

發表於: 2007/3/17 13:07
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


VB傳ASCII CODE 傳至 P30F4011
#1
新會員
新會員


查看用戶資訊
動作:
VB輸入ASCII P30F4011 利用LED顯示
例如 我傳U字元 ASII=01010101 LED八顆就亮哪幾個



VB已成功輸出ASCII CODE
問題是PF4011 語法如何寫 最好為C語言





發表於: 2007/3/16 17:10
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... ]

教育訓練中心

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