5. Standard
5.1. 用CASE实现延时顺序执行
CASE index OF
0:
a:=a+1;
TON1(IN:=bDelay , PT:=t#5s , Q=> , ET=> );(*bDelay 为true 5秒后执行10段代码*)
IF ton1.Q THEN
index:=10;
END_IF
10:
b:=b+1;
TON2(IN:=bDelay2 , PT:=t#5s , Q=> , ET=> );(*bDelay2 为true 5秒后执行20段代码*)
IF ton2.Q THEN
index:=20;
END_IF
20:
c:=c+1;
IF c=200 THEN
c:=0;
a:=0;
b:=0;
index:=0;
END_IF
END_CASE
自循环(不用外部触发)
CASE index OF
0:
a:=a+1;
TON1(IN:= , PT:=T#2S , Q=> , ET=> );
ton1.IN:=1;
IF ton1.Q THEN
index:=10;
ton1.IN:=FALSE;
END_IF
10:
b:=b+1;
TON2(IN:=d , PT:=T#2S , Q=> , ET=> );
d:=1;
IF ton2.Q THEN
index:=20;
d:=FALSE;
END_IF
20:
d:=0;a:=0;b:=0;
index:=0;
END_CASE
2020.3.6 余子辰 编辑