威纶通官方论坛

加入宏指令,PLC运行变慢

[复制链接]
发表于 2012-8-14 17:10:55 | 显示全部楼层 |阅读模式
macro_command main()
bool a[499]
GetData(a[3], "MITSUBISHI FX2n", M, 31, 1)
GetData(a[5], "MITSUBISHI FX2n", M, 315, 1)
GetData(a[8], "MITSUBISHI FX2n", M, 314, 1)
GetData(a[9], "MITSUBISHI FX2n", M, 416, 1)
GetData(a[11], "MITSUBISHI FX2n", M, 66, 1)
GetData(a[12], "MITSUBISHI FX2n", M, 20, 1)
GetData(a[13], "MITSUBISHI FX2n", M, 13, 1)
GetData(a[14], "MITSUBISHI FX2n", M, 190, 1)
GetData(a[15], "MITSUBISHI FX2n", M, 124, 1)
GetData(a[20], "MITSUBISHI FX2n", M, 132, 1)
GetData(a[21], "MITSUBISHI FX2n", M, 117, 1)
GetData(a[22], "MITSUBISHI FX2n", M, 120, 1)
GetData(a[25], "MITSUBISHI FX2n", M, 24, 1)
GetData(a[40], "MITSUBISHI FX2n", M, 86, 1)
GetData(a[41], "MITSUBISHI FX2n", M, 87, 1)
GetData(a[42], "MITSUBISHI FX2n", M, 88, 1)
GetData(a[43], "MITSUBISHI FX2n", M, 89, 1)
GetData(a[44], "MITSUBISHI FX2n", M, 90, 1)
GetData(a[45], "MITSUBISHI FX2n", M, 91, 1)
GetData(a[47], "MITSUBISHI FX2n", M, 92, 1)
GetData(a[49], "MITSUBISHI FX2n", M, 93, 1)
GetData(a[46], "MITSUBISHI FX2n", M, 94, 1)
GetData(a[52], "MITSUBISHI FX2n", M, 95, 1)
GetData(a[48], "MITSUBISHI FX2n", M, 96, 1)
GetData(a[53], "MITSUBISHI FX2n", M, 97, 1)
GetData(a[50], "MITSUBISHI FX2n", M, 98, 1)
GetData(a[51], "MITSUBISHI FX2n", M, 99, 1)
if  a[5]==true  or   a[3]==true  then
a[4]  =true
else
a[4]=false
end   if
if  a[8]==true or  a[9]==true   then
a[10]=true
else
a[10]=false

end  if
if  a[11]==true  and   a[12]==true  then
a[16]=true
else
a[16]=false
end  if
if  a[14]==true   and   a[15]==false  then
a[17]=true
else
a[17]=false
end   if
if   a[16]==true   or   a[17]==true   or  a[13]==true  then
a[18]=true
else
a[18]=false
end   if
if  a[20]==true  and  a[14]==false  and  a[21]==false  and   a[22]==false  then
a[23]=true
else
a[23]=false
end  if
if  a[14]==true   and   a[11]  ==false  then
a[26]=true
else
a[26]=false
end  if
if  a[25]==true  or  a[26]==true  then
a[27]=true
else
a[27]=false
end  if
SetData(a[27], "MITSUBISHI FX2n", M, 110, 1)
if  a[14]==true   then
a[30]=true
else
a[30]=false
end   if
if a[40]==true  then
a[60]=true
else
a[60]=false
end  if
if  a[41]==true then
a[61]=true
else
a[61]=false
end  if
if a[42]==true  then
a[62]=true
else
a[62]=false
end  if
if  a[43]==true then
a[63]=true
else
a[63]=false
end  if
if a[44]==true then
a[64]=true
else
a[64]=false
end  if
if a[45]==true  then
a[65]=true
else
a[65]=false
end  if
if  a[47]==true then
a[66]=true
else
a[66]=false
end  if
if a[49]==true  then
a[67]=true
else
a[67]=false
end  if
if a[46]==true then
a[68]=true
else
a[68]=false
end  if
if  a[52]==true then
a [69]=true
else
a[69]=false
end  if
if  a[48]==true  then
a[70]=true
else
a[70]=false
end  if
if  a[53]==true  then
a[71]=true
else
a[71]=false
end  if
if a[50]==true  then
a[72]=true
else
a[72]=false
end  if
if  a[51]==true  then
a[72]=true
else
a[72]=false
end  if
if  a[21]==true  then
a[90]=true
else
a[90]=false
end  if
if  a[22]==true   then
a[91]=true
else
a[91]=false
end  if

SetData(a[60], "MITSUBISHI FX2n", M, 179, 1)
SetData(a[61], "MITSUBISHI FX2n", M, 194, 1)
SetData(a[62], "MITSUBISHI FX2n", M, 192, 1)
SetData(a[63], "MITSUBISHI FX2n", M, 180, 1)
SetData(a[64], "MITSUBISHI FX2n", M, 181, 1)
SetData(a[65], "MITSUBISHI FX2n", M, 187, 1)
SetData(a[30], "MITSUBISHI FX2n", M, 76, 1)
SetData(a[4], "MITSUBISHI FX2n", M, 239, 1)
SetData(a[10], "MITSUBISHI FX2n", M, 223, 1)
SetData(a[18], "MITSUBISHI FX2n", M, 51, 1)
SetData(a[23], "MITSUBISHI FX2n", M, 35, 1)
SetData(a[90], "MITSUBISHI FX2n", M, 37, 1)
SetData(a[91], "MITSUBISHI FX2n", M, 39, 1)
SetData(a[66], "MITSUBISHI FX2n", M, 184, 1)
SetData(a[67], "MITSUBISHI FX2n", M, 183, 1)
SetData(a[68], "MITSUBISHI FX2n", M, 189, 1)
SetData(a[69], "MITSUBISHI FX2n", M, 182, 1)
SetData(a[70], "MITSUBISHI FX2n", M, 186, 1)
SetData(a[71], "MITSUBISHI FX2n", M, 185, 1)
SetData(a[72], "MITSUBISHI FX2n", M, 188, 1)
SetData(a[73], "MITSUBISHI FX2n", M, 178, 1)
end macro_command
加入以上指令后,PLC的输入输出反应速度变慢,是何原因?在PLC中,例如:M87接通或闭合,要几秒钟,M194才会相应动作,有时候,M194根本不动作,为什么?M31接通,M239迟迟不接通,M31断开,按道理M239要断开,但是M239还是接通,不知道啥原因?
发表于 2012-8-17 09:47:09 | 显示全部楼层
判断语句太多,造成宏的处理需要一定时间,建议采用连续的地址做读取;另宏指令的执行方式也会影响宏指令执行速度的快慢;
楼上很多语句采用PLC控制继电器通断很容易实现;
您需要登录后才可以发帖 登录 | 注册

本版积分规则

回复帖子

Archiver|小黑屋|威纶通官网 ( 粤ICP备06054553号 )

GMT+8, 2024-11-24 07:10

Powered by Discuz! X3.4

© 2001-2023 Comsenz Inc.

快速回复 返回顶部 返回列表