283596603
盟主
級(jí)別: 略有小成
精華主題: 0
發(fā)帖數(shù)量: 138 個(gè)
工控威望: 275 點(diǎn)
下載積分: 1075 分
在線時(shí)間: 111(小時(shí))
注冊(cè)時(shí)間: 2010-06-15
最后登錄: 2024-07-24
查看283596603的 主題 / 回貼
樓主  發(fā)表于: 2023-02-04 15:53
第一次做一個(gè)倍福的項(xiàng)目,開始說只要寫PLC,客戶自己開發(fā)上位機(jī),寫到后來客戶又要求加觸摸屏,于是就記錄下這次實(shí)踐的過程。。。
連接PLC與觸摸屏還算順利,按倍福的那個(gè)文檔設(shè)置基本就可以了,這里主要說一點(diǎn),由于我是使用電腦WIN10運(yùn)行的TwinCAT3,直接連接觸摸屏,
在添加觸摸屏Route時(shí)不要按文檔的復(fù)制,粘貼,而要設(shè)置好網(wǎng)絡(luò)后,使用Route Editer添加,能添加上基本就可以連接上;
下面來到觸摸屏開發(fā)配方地方,以前連接其它PLC都是使用【資料傳輸】元件觸發(fā)傳輸配方到PLC,但是由于PLC程序已經(jīng)寫好,PLC內(nèi)與配方關(guān)
聯(lián)的變量是結(jié)構(gòu)體數(shù)組的形式,鏈接的又是標(biāo)簽非物理地址(鏈接驅(qū)動(dòng):Beckhoff TwinCAT PLC - Free Tag Names),按以前的辦法只能傳輸首
變量,威綸通技術(shù)支持說是可以的,試了很久沒成功,遂放棄。后想到了用宏指令一個(gè)個(gè)賦值傳輸?shù)牟坏靡艳k法;附上簡(jiǎn)單的宏指令,只保留了
時(shí)間一項(xiàng),其它類似:
macro_command main()    
//獲取選擇的配方ID
    short selID
    GetData(selID, "Local HMI", RECIPE, "Recip1.Selection")
//名稱
    char SRcpName[20]
    int i
    for i=0 to 19 step 1
        SRcpName=''
    next i
    StringGet(SRcpName[0], "Local HMI", RECIPE, "Recip1.RecipeName")
    StringSet(SRcpName[0], "Beckhoff TwinCAT PLC - Free Tag Names", "PM1.I_arrStepValue_G[1].sRcpName", 20)
    
//*****************步序***********
//時(shí)間    
    short iTime
    RecipeGetData(iTime, "Recip1.1Time", selID)
    SetData(iTime, "Beckhoff TwinCAT PLC - Free Tag Names", "PM1.I_arrStepValue_G[1].iStepTime", 1)
    RecipeGetData(iTime, "Recip1.2Time", selID)
    SetData(iTime, "Beckhoff TwinCAT PLC - Free Tag Names", "PM1.I_arrStepValue_G[2].iStepTime", 1)
    RecipeGetData(iTime, "Recip1.3Time", selID)
    SetData(iTime, "Beckhoff TwinCAT PLC - Free Tag Names", "PM1.I_arrStepValue_G[3].iStepTime", 1)
    RecipeGetData(iTime, "Recip1.4Time", selID)
    SetData(iTime, "Beckhoff TwinCAT PLC - Free Tag Names", "PM1.I_arrStepValue_G[4].iStepTime", 1)
    RecipeGetData(iTime, "Recip1.5Time", selID)
    SetData(iTime, "Beckhoff TwinCAT PLC - Free Tag Names", "PM1.I_arrStepValue_G[5].iStepTime", 1)
    RecipeGetData(iTime, "Recip1.6Time", selID)
    SetData(iTime, "Beckhoff TwinCAT PLC - Free Tag Names", "PM1.I_arrStepValue_G[6].iStepTime", 1)
    RecipeGetData(iTime, "Recip1.7Time", selID)
    SetData(iTime, "Beckhoff TwinCAT PLC - Free Tag Names", "PM1.I_arrStepValue_G[7].iStepTime", 1)
end macro_command
HMI

Route
  
[ 此帖被283596603在2023-02-04 16:11重新編輯 ]