Closed line branch

A closed line branch is only available in LD. It contains a start point and an end point. It is used to implement parallel evaluation of logical elements.

Inserting a closed line branch:

Closed line branch at a contact

If you have marked one or more contacts and you execute an Insert Contact Parallel command, a parallel branch with a simple vertical line is inserted. In this type of branch, the signal flow passes through both branches. It is an OR construct for the two branches.

Closed line branch on a function block

If you have marked a function block and you execute an "Insert contact parallel" command, a parallel branch with a double vertical line is inserted. This indicates that short-circuit evaluation (SCE) is implemented. SCE allows the execution of a function block with a Boolean output to be bypassed if a certain condition is TRUE. The condition can be represented in the LD editor through a branch that is arranged parallel with the function block branch. The short-circuit condition is defined through one or several contacts in this branch, which are connected in parallel or sequentially.

Functioning:

First, the branches which do not contain the function block are considered. If TwinCAT determines the value TRUE for one of these branches, the function block is not called in the parallel branch. In this case, the value that is applied to the input of the function block is immediately transferred to the output. If TwinCAT determines FALSE for the short-circuit evaluation condition, the function block is called and the Boolean result of its processing is passed on. If all branches contain function blocks, they are processed from top to bottom, and their outputs are linked with logical OR operations. If there are no branches with function blocks, normal OR operations are performed.

Example:

The function block instance fbTimer (TON) has a Boolean input and a Boolean output. The execution of fbTimer is omitted if TRUE is determined for the condition in the parallel line branch. The condition value results from the OR and AND operations, which link the contacts bCond1, bCond2 and bCond3.

fbTimer is executed if the conditional value from the link of the contacts bCond1, bCond2 and bCond3 is FALSE.

Closed line branch 1:

(1) Connections shown with a double vertical line indicate a construct that is subject to short-circuit evaluation.

(2) Connections shown with a single vertical line indicate an OR construct.

The LD example introduced above is shown as ST code below. bIN and bOUT are the Boolean values at the input (split point) and output (reunite point) of the parallel line branch.

bIN := bVar1 AND bVar2;

IF ((bIN AND bCond1) AND (bCond2 OR bCond3)) THEN
    bOUT := bIN;
ELSE
    fbTimer(IN := bIN, PT := {p 10}t#2s);
    tElapsed := fbTimer.ET;
    bOUT := fbTimer.Q;
END_IF

bRes := bOUT AND bVar3;