dingzyi
级别: 家园常客
精华主题: 0
发帖数量: 691 个
工控威望: 844 点
下载积分: 9348 分
在线时间: 463(小时)
注册时间: 2011-05-29
最后登录: 2024-12-22
查看dingzyi的 主题 / 回贴
楼主  发表于: 2015-07-15 21:00
宏指令1

macro_command main()
short count,Realcount,i,baseaddress,getaddress,baseadd2,getadd2,on,baseadd3,getadd3,view,PLCAddr
int tempdata,realdata
unsigned char RealName[8]

//view=34
i=0
count=0
//temp baseaddr
baseaddress=910
// realdata baseaddr
Realcount=0
//PLC Addr
PLCAddr=2000
//SetData(view, "Local HMI", LW, 0, 1)
for i=0 to 7 step 1
RealName=''
next i
//获取当前配方序号
GetData(count, "Local HMI", RW, 900, 1)
//设置载入当前配方序号
SetData(count, "Local HMI", RW, 900, 1)
//获取实际数据基地址
getaddress= baseaddress+100*count
//获取实际数据点数及配方名称
GetData(Realcount, "Local HMI", RW, getaddress-9, 1)
GetData(RealName[0], "Local HMI", RW,getaddress-8, 8)
//设置实际数据点数及配方名称
SetData(Realcount, "Local HMI", RW, 901, 1)
SetData(RealName[0], "Local HMI", RW, 902, 8)
DELAY(5)
//load other configure data for  XYZW
for i=0 to 60 step 2
     GetData(realdata, "Local HMI", RW,getaddress+i, 1)
     SetData(realdata, "Local HMI", RW,baseaddress+i, 1)  
next i
DELAY(1000)
//send data to PLC
SetData(Realcount, "DELTA DVP", D, 200, 1)
SetData(count, "DELTA DVP", D, 214, 1)
SetData(RealName[0], "DELTA DVP", D, 216, 8)
for i=0 to 60 step 2
     GetData(realdata, "Local HMI", RW,baseaddress+i, 1)
     SetData(realdata, "DELTA DVP", D, PLCAddr+i, 1)  
next i
DELAY(500)
//send exit cmd
on=1
SetData(on, "DELTA DVP", M, 1001, 1)


//view=0
//SetData(view, "Local HMI", LW, 0, 1)
//on=1
//SetData(on, "Local HMI", RW_Bit, 0, 1)
//SetData(on, "Local HMI", LB, 2, 1)

end macro_command




第二个宏指令
macro_command main()
short count,Realcount,i,number
short baseaddress,getaddress,view
int realdata,PLCAddr
unsigned char RealName[8]
i=0
count=0
baseaddress=910
Realcount=0
PLCAddr=2000
view=20
SetData(view, "Local HMI", LW, 10000, 1)
for i=0 to 7 step 1
RealName=''
next i
//view=35
//SetData(view, "Local HMI", LW, 0, 1)
//获取PLC中实际配方数据,配方号,配方点数,配方名称
//GetData(number, "DELTA DVP", D, 200, 1)
//GetData(Realcount, "DELTA DVP", D, 214, 1)
//GetData(RealName[0], "DELTA DVP", D, 216, 8)
//保存至HMI中临时配方号,配方点数,配方名称
//SetData(number, "Local HMI", RW, 900, 1)
//SetData(Realcount, "Local HMI", RW, 901, 1)
//SetData(RealName[0], "Local HMI", RW, 902, 8)
//保存至XYZ数据至临时区域中
for i=0 to 60 step 2
     GetData(realdata, "DELTA DVP", D, PLCAddr+i, 1)
     SetData(realdata, "Local HMI", RW,baseaddress+i, 1)  
next i
DELAY(500)

//保存临时数据至配方区域中
//***
GetData(number, "Local HMI", RW, 900, 1)
GetData(Realcount, "Local HMI", RW, 901, 1)
GetData(RealName[0], "Local HMI", RW, 902, 8)
SetData(number, "Local HMI", RW, baseaddress-10+100*number, 1)
SetData(Realcount, "Local HMI", RW, baseaddress-10+100*number+1, 1)
SetData(RealName[0], "Local HMI", RW, baseaddress-10+100*number+2, 8)
for i=0 to 60 step 2
     GetData(realdata, "Local HMI", RW, baseaddress+i, 1)
     SetData(realdata, "Local HMI", RW, baseaddress+100*number+i, 1)  
next i
DELAY(500)
view=0
SetData(view, "Local HMI", LW, 10000, 1)

end macro_command
看看这两个宏指令,大家给点意见
plc
忍缘善
独自漂泊
级别: 论坛先锋

精华主题: 0
发帖数量: 892 个
工控威望: 1807 点
下载积分: 20025 分
在线时间: 3999(小时)
注册时间: 2010-12-17
最后登录: 2024-12-23
查看忍缘善的 主题 / 回贴
1楼  发表于: 2015-07-15 21:20
学习啦。谢谢!
独自漂泊
34551842
一直在努力,还需更努力……
级别: 略有小成
精华主题: 0
发帖数量: 173 个
工控威望: 314 点
下载积分: 17007 分
在线时间: 451(小时)
注册时间: 2014-04-03
最后登录: 2024-12-23
查看34551842的 主题 / 回贴
2楼  发表于: 2015-07-15 21:33
表示一点也看不懂,还是感谢分享!!!!!!!!!!
彭万生
级别: 工控侠客
精华主题: 0
发帖数量: 1890 个
工控威望: 2102 点
下载积分: 131755 分
在线时间: 1278(小时)
注册时间: 2013-08-04
最后登录: 2024-04-17
查看彭万生的 主题 / 回贴
3楼  发表于: 2015-07-15 21:38
基本也看不懂