What the difference between assigning a parameter with dot
and put as an array to a function block?
here is a simple code as an example.
Timer1(IN:=TRUE,PT:=T#2S);
IF Timer1.Q THEN
i:=i+1;
Timer1.IN:=FALSE;
END_IF
Timer2(IN:=TRUE,PT:=T#2S);
IF Timer2.Q THEN
j:=j+1;
Timer2(IN:=FALSE);
END_IF
It expected that Timer1
be reset by this Timer1.IN:=FALSE;
assignment but nothing happened, although it shows FALSE
in the code as a real-time value!
any help would be appreciated.
There are just two characters which make a huge difference between the outcomes:
()
. The brackets indicate that the function block is called, which means that the implementation part of a function block is executed.In order to illustrate the differences, let me make an example function block to show the differences.
Example
Here I define a function block with a single input
Increment
and a single outputCount
. Every time the function block is called it will run the code in the implementation part. The implementation part will increment the currentCount
byIncrement
.Let me make an instance
counter
of this function block in a programRunner
, so we can see what happens when we call it.If you step through the above code by using a break point you can see what happens at every step of the way.