y4620148
級(jí)別: 探索解密
精華主題: 0
發(fā)帖數(shù)量: 53 個(gè)
工控威望: 120 點(diǎn)
下載積分: 420 分
在線(xiàn)時(shí)間: 8(小時(shí))
注冊(cè)時(shí)間: 2020-11-07
最后登錄: 2022-03-22
查看y4620148的 主題 / 回貼
樓主  發(fā)表于: 2022-03-15 14:25

就不知道程序改怎么寫(xiě)了,問(wèn)問(wèn)大佬們。

I0.0輸入的時(shí)候,LB0指示燈亮

I0.1有信號(hào),I0.2沒(méi)信號(hào),等待3S采集Q0.3,Q0.3有信號(hào),LB1亮.

這個(gè)程序需要怎么寫(xiě),這個(gè)延遲函數(shù)感覺(jué)放不進(jìn)去啊


macro_command main()
bool i00,i01,i02,q03
GetData(i00, "Siemens S7-200 PPI", I, 0.0, 1)
GetData(i01, "Siemens S7-200 PPI", I, 0.1, 1)
GetData(i02, "Siemens S7-200 PPI", I, 0.2, 1)
GetData(q03, "Siemens S7-200 PPI", Q, 0.3, 1)
if i00==1 then
SetData(i00, "Local HMI", LB, 0, 1)
else if i00==0 then
SetData(i00, "Local HMI", LB, 0, 1)
end if

if i01==1 and i02==0 and DELAY(3000) q03==1 then
SetData(i01, "Local HMI", LB, 1, 1)
else if i01==0 then
SetData(i01, "Local HMI", LB, 1, 1)
end if
wwjfsk
級(jí)別: 探索解密
精華主題: 0
發(fā)帖數(shù)量: 71 個(gè)
工控威望: 188 點(diǎn)
下載積分: 928 分
在線(xiàn)時(shí)間: 424(小時(shí))
注冊(cè)時(shí)間: 2014-04-20
最后登錄: 2024-09-22
查看wwjfsk的 主題 / 回貼
1樓  發(fā)表于: 2022-03-18 09:57
DELAY 不能放在條件上吧
macro_command main()
bool i[4],q03,off=false
GetData(i[3], "Siemens S7-200 PPI", I, 0.0, 3)
SetData(i[0], "Local HMI", LB, 0, 1)
if i[1]==1 and i[2]==0  then
DELAY(3000)
GetData(q03, "Siemens S7-200 PPI", Q, 0.3, 1)
if q03==1 then
SetData(i[1], "Local HMI", LB, 1, 1)
else
SetData(i[2], "Local HMI", LB, 1, 1)
end if
else
SetData(off, "Local HMI", LB, 1, 1)
end if
end macro_command