PLC:如果然后在功能块内

时间:2015-12-22 10:22:31

标签: plc

我正在尝试通过编程博世/力士乐MLC来学习。我写了这个序列,但我不确定是否有更好的方法来做事。

伪代码看起来像这样:

wRunningCount=300
wStandstillCount=150
wCount
zeroSpeed
IF zeroSpeed THEN
    wCount=wStandstillCount
ELSE
    wCount=wRunningCount
FI

但我想将此功能转移到功能块中。 (已经有一个将收到wCount的TON)

现在我有:

                  __MOVE____
       zeroSpeed-|EN    ENO|-
wStandStillCount-|_________|-wCount


                  __MOVE___
      zeroSpeed-o|EN    ENO|-
   wRunningCount-|_________|-wCount

有没有更好的方法呢?

3 个答案:

答案 0 :(得分:1)

取决于您想要初始化变量的方式,您可以执行此操作

enter image description here

否则没有更好的方法可以做到这一点,那么你现在就是。

答案 1 :(得分:0)

为什么你不能在ST中使用ton块?其余代码看起来很不错。

TON_0(启用:= TRUE,PT:= T#1s);

如果TON_0.Q那么//如果计时器完成

//do stuff

TON_0(enable:=FALSE); //reset timer

END_IF

答案 2 :(得分:0)

大多数61131实现都会有一个" SEL"块应该做得相当好......

            __SEL__
zerospeed  |G     Q|wCount
           |       |
wrunning   |IN0    |
           |       |
wstandstill|IN1    |
           |_______|