283596603
盟主
级别: 略有小成
精华主题: 0
发帖数量: 138 个
工控威望: 275 点
下载积分: 1075 分
在线时间: 110(小时)
注册时间: 2010-06-15
最后登录: 2024-04-15
查看283596603的 主题 / 回贴
楼主  发表于: 2023-02-04 15:53
第一次做一个倍福的项目,开始说只要写PLC,客户自己开发上位机,写到后来客户又要求加触摸屏,于是就记录下这次实践的过程。。。
连接PLC与触摸屏还算顺利,按倍福的那个文档设置基本就可以了,这里主要说一点,由于我是使用电脑WIN10运行的TwinCAT3,直接连接触摸屏,
在添加触摸屏Route时不要按文档的复制,粘贴,而要设置好网络后,使用Route Editer添加,能添加上基本就可以连接上;
下面来到触摸屏开发配方地方,以前连接其它PLC都是使用【资料传输】元件触发传输配方到PLC,但是由于PLC程序已经写好,PLC内与配方关
联的变量是结构体数组的形式,链接的又是标签非物理地址(链接驱动:Beckhoff TwinCAT PLC - Free Tag Names),按以前的办法只能传输首
变量,威纶通技术支持说是可以的,试了很久没成功,遂放弃。后想到了用宏指令一个个赋值传输的不得已办法;附上简单的宏指令,只保留了
时间一项,其它类似:
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)
    
//*****************步序***********
//时间    
    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重新编辑 ]