哪位大神可以帮忙看看如下宏指令怎么写,非常感谢:
一个威纶通触摸屏带两个PLC,完全一样的PLC,PLC程序都是一样的。我的项目是20工位的,每个工位的动作一样的,就是20个步进电机,我现在用XD5-60T10来做,2个PLC,这样就可以控制20个电机了,因为每个工位动作一样的 ,所以我一个PLC就控制10个电机,这样另外一个PLC我的程序就不用做了,一样的程序就好,原本的输出传输我是一下子传输10个工位的,现在我想改一下,工位可以任意选择个数,选择好工位之后,再传输数据,我原来是这样的:
macro_command main()
bool mov=0,b=1,c=0
int i1=0,i2=0,i3=0,i4=0,i5=0,i6=0,i7=0
float f1=0,f2=0,f3=0,f4=0,f5=0,f6=0,f7=0,f8=0
GetData(mov, "Local HMI", LB, 205, 1)//读取HMI---LB205当前值
if mov==1 then
GetData(i1, "Local HMI", RW, 0, 1) //读取当前值
GetData(i2, "Local HMI", RW, 2, 1)
GetData(i3, "Local HMI", RW, 12, 1)
GetData(i4, "Local HMI", RW, 22, 1)
GetData(i5, "Local HMI", RW, 24, 1)
GetData(i6, "Local HMI", RW, 26, 1)
GetData(i7, "Local HMI", RW, 28, 1)
GetData(f1, "Local HMI", RW, 4, 1)
GetData(f2, "Local HMI", RW, 6, 1)
GetData(f3, "Local HMI", RW, 8, 1)
GetData(f4, "Local HMI", RW, 10, 1)
GetData(f5, "Local HMI", RW, 14, 1)
GetData(f6, "Local HMI", RW, 16, 1)
GetData(f7, "Local HMI", RW, 18, 1)
GetData(f8, "Local HMI", RW, 20, 1)
SetData(i1, "XINJE XD Series", HD, 2030, 1)
SetData(i1, "XINJE XD Series-B", HD, 2030, 1)
SetData(i2, "XINJE XD Series", HD, 2032, 1)
SetData(i2, "XINJE XD Series-B", HD, 2032, 1)
SetData(i3, "XINJE XD Series", HD, 2034, 1)
SetData(i3, "XINJE XD Series-B", HD, 2034, 1)
SetData(i4, "XINJE XD Series", HD, 2020, 1)
SetData(i4, "XINJE XD Series-B", HD, 2020, 1)
SetData(i5, "XINJE XD Series", HD, 2022, 1)
SetData(i5, "XINJE XD Series-B", HD, 2022, 1)
SetData(i6, "XINJE XD Series", HD, 2024, 1)
SetData(i6, "XINJE XD Series-B", HD, 2024, 1)
SetData(i7, "XINJE XD Series", HD, 2026, 1)
SetData(i7, "XINJE XD Series-B", HD, 2026, 1)
SetData(f1, "XINJE XD Series", HD, 2012, 1)
SetData(f1, "XINJE XD Series-B", HD, 2012, 1)
SetData(f2, "XINJE XD Series", HD, 2050, 1)
SetData(f2, "XINJE XD Series-B", HD, 2050, 1)
SetData(f3, "XINJE XD Series", HD, 2042, 1)
SetData(f3, "XINJE XD Series-B", HD, 2042, 1)
SetData(f4, "XINJE XD Series", HD, 2040, 1)
SetData(f4, "XINJE XD Series-B", HD, 2040, 1)
SetData(f5, "XINJE XD Series", HD, 2014, 1)
SetData(f5, "XINJE XD Series-B", HD, 2014, 1)
SetData(f6, "XINJE XD Series", HD, 2052, 1)
SetData(f6, "XINJE XD Series-B", HD, 2052, 1)
SetData(f7, "XINJE XD Series", HD, 2046, 1)
SetData(f7, "XINJE XD Series-B", HD, 2046, 1)
SetData(f8, "XINJE XD Series", HD, 2044, 1)
SetData(f8, "XINJE XD Series-B", HD, 2044, 1)
SetData(b, "XINJE XD Series", M, 90, 1)
SetData(b, "XINJE XD Series-B", M, 90, 1)
SetData(b, "Local HMI", LB, 10, 1)
SetData(c, "Local HMI", LB, 205, 1)
else
SetData(c, "XINJE XD Series", M, 90, 1)
SetData(c, "XINJE XD Series-B", M, 90, 1)
end if
end macro_command
GetData(mov, "Local HMI", LB, 205, 1)//读取HMI---LB205当前值
if mov==1 then
GetData(i1, "Local HMI", RW, 0, 1) //读取当前值
SetData(i1, "XINJE XD Series", HD, 2030, 1)
SetData(i1, "XINJE XD Series-B", HD, 2030, 1)
比如这里,我是当MOV=1的时候,RW-0的输出数传到XINJE XD Series", HD, 2030和XINJE XD Series-B", HD, 2030,,就是传输到两个PLC里面的HD2030,但是现在我需要加选择工位,假设我的1#工位选择按钮是LB-300, 11#工位选择按钮是LB-311,还有一个按钮是全部选择LB-400,当LB300=1或者LB400=1,那就传输RW0的数据到XINJE XD Series", HD, 2030,当LB-300和LB-400都等0,就不传输。当LB-311=1或者LB400=1,那就传输RW0的数据到XINJE XD Series-B", HD, 2030,当两个都不按下的时候,就不传输过去。
我现在是这样的:j1 quanxuan前面定义过
GetData(mov, "Local HMI", LB, 205, 1)//读取HMI---LB205当前值
if mov==1 and j1==1 or quanxuan=1 then
GetData(i1, "Local HMI", RW, 0, 1) //读取当前值
SetData(i1, "XINJE XD Series", HD, 2030, 1)
else 主要是这里我该怎么写?
就是说,如果MOV=1 j1=1 quanxuan=1 我就传输数据,否则怎么样??????????? 难道我要传个 “0”给他吗?
|