SFC elements in ST

The following →SFC elements are supported in ST in order to create SFC networks:

Using/Creating SFC networks efficiently and correctly

  • Knowledge about programming step sequences is essential when creating SFC networks.

  • It is possible to create several SFC networks within →programs and →function blocks.

  • The content assist of the ST-editor provides templates to quickly create SFC networks: Press Ctrl+Space and enter the first keyword in lowercase to get the appropriate templates. Example: Enter step to get the template for the step.

  • It is possible to arrange the SFC elements within the ST-code as you want. logi.cals advises you to arrange the SFC elements in an order that makes it easy for you to understand the network.
    See the below example: steps and transitions in turns, finally the actions
    See Evaluating the ST-code including the SFC networks for information on the order how an SFC network is evaluated.

  • According to the →IEC standard, it is not possible to combine these SFC elements with ST statements on the upmost level (e.g. block calls or assignments parallel to steps and transitions). A message will inform you, if the ST-code entered together with the SFC elements is not allowed.

  • Unsafe or unreachable SFC networks or such ones with a deadlock are not detected or prevented by logi.CAD 3.
    Unsafe SFC networks might be caused, if there are more divergences than convergences in the SFC network. Unreachable branches in the SFC network might be caused, if there are different types of a divergence and of a convergence. In case of SFC networks with a deadlock, each SFC network is waiting for an operation of the other SFC network but this operation will never be executed.
    If you require more details on such SFC networks, see the IEC-standard and/or the Technical Report IEC TR 61131-8 (Programmable controllers – Part 8: Guidelines for the application and implementation of programming languages) and search for "unsafe SFC", "unreachable SFC" and "deadly embrace".

Example 1 for a step sequence with SFC elements in ST
PROGRAM SampleSfcCounting1
VAR
cntStep0 : DINT;
cntStep1 : DINT;
END_VAR
INITIAL_STEP step0 :
act0(N);
END_STEP
TRANSITION t0 FROM step0 TO step1
:= cntStep0 MOD 10 = 0;
END_TRANSITION
STEP step1 :
act1(N);
END_STEP
TRANSITION t1 FROM step1 TO step0
:= cntStep1 MOD 10 = 0;
END_TRANSITION
ACTION act0 :
cntStep0 := cntStep0 + 1;
END_ACTION
ACTION act1 :
cntStep1 := cntStep1 + 1;
END_ACTION
END_PROGRAM

The schematic representation of the SFC elements from the example 1:

images/download/attachments/409863194/SFCSequence_EN-version-1-modificationdate-1531293845334-api-v2.png

Knowledge on the evaluation of the ST-code will be required in order to understand all comments for ACTION ... END_ACTION for the following example.

Example 2 for a step sequence with SFC elements in ST
FUNCTION_BLOCK SampleSfcCounting2
 
VAR
cnt1, cnt2, cnt3, cnt4, cnt5, cnt6 : LINT;
END_VAR
 
INITIAL_STEP Step1 :
Action1();
Action2(D, T#5s);
Action3(L, T#5s);
Action4(P0);
Action6(SD, T#15s);
Action7(D, T#10s);
END_STEP
 
TRANSITION FROM Step1 TO Step2
:= Action7;
END_TRANSITION
 
STEP Step2 :
Action2(L, T#5s);
Action3(D, T#5s);
Action5(P1);
END_STEP
 
TRANSITION FROM Step2 TO Step3
:= Step2.T > Time#10s - T#200ms;
END_TRANSITION
 
STEP Step3 :
Action6(R);
END_STEP
 
TRANSITION FROM Step3 TO Step1
:= TRUE;
END_TRANSITION
 
// runs from 0-10
ACTION Action1 :
cnt1 := cnt1 + 1;
END_ACTION
 
// runs from 5-10 sec (while Step1 is active) and 10-15 sec (while Step2 is active)
ACTION Action2 :
cnt2 := cnt2 + 1;
END_ACTION
 
// runs from 0-5 sec and 15-20 sec
ACTION Action3 :
cnt3 := cnt3 + 1;
END_ACTION
 
// runs at the end of Step1
ACTION Action4 :
cnt4 := cnt4 + 1;
END_ACTION
 
// runs at the start of Step2
ACTION Action5 :
cnt5 := cnt5 + 1;
END_ACTION
 
// runs from 15-20 sec (while Step2 is active)
ACTION Action6 :
cnt6 := cnt6 + 2;
END_ACTION
 
// used to signal end of step1 after 10 sec
ACTION Action7 :
END_ACTION
 
END_FUNCTION_BLOCK