0% found this document useful (0 votes)
5 views23 pages

TC3 Engineering PLC Editors SFC Editor

The SFC Editor is a graphical tool for programming Sequential Function Charts (SFC) in the IEC 61131-3 language, allowing users to define the sequence of actions in a program through steps and transitions. It includes features for editing properties, inserting elements, and managing actions associated with steps, while also allowing for the import of TwinCAT 2.x projects. The document provides detailed instructions on using the editor, including cursor positions, element properties, and editing commands.

Uploaded by

fasp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views23 pages

TC3 Engineering PLC Editors SFC Editor

The SFC Editor is a graphical tool for programming Sequential Function Charts (SFC) in the IEC 61131-3 language, allowing users to define the sequence of actions in a program through steps and transitions. It includes features for editing properties, inserting elements, and managing actions associated with steps, while also allowing for the import of TwinCAT 2.x projects. The document provides detailed instructions on using the editor, including cursor positions, element properties, and editing commands.

Uploaded by

fasp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

SFC Editor http://infosys.beckhoff.com/content/1033/tc3_plc_intro/90071993907...

PLC

SFC Editor
The SFC Editor is available for programming objects in the IEC 61131-3 programming language “SFC - Sequential Function
Chart ”. The language is to be chosen when adding a new POU object to the project via the 'Add Object' command.
The SFC Editor is a graphical editor. General settings concerning behaviour and display are done in the SFC editor options
dialog.
The SFC editor is available in the lower part of the window which opens when you edit a SFC POU object. In its upper part this
window contains the Declaration Editor.

The elements used in a SFC diagram by default are available in the "SFC" menu, which by default is available as soon as the
SFC Editor is active. They are to be arranged in a sequence resp. in parallel sequences of steps which are connected by
transitions. See also: “Working in the SFC Editor ”
The properties of steps can be edited in a separate Properties box. The minimum and maximum time of activity can be defined
for each step.
Implicit variables can be accessed for controlling the processing of a SFC (for example step status, timeout analyzation, reset
etc.).
The commands for working in the SFC Editor can be called from the context menu or from the "SFC" menu which by default is
available as soon as the SFC Editor is active.
Comparison to the TwinCAT 2.x PLC Control SFC Editor:
▪ Basically the same functionality is available, TwinCAT 2.x PLC Control SFC projects can be imported.

▪ Editing is made more comfortable by the fact that each particular element can be selected and arranged individually. During
editing the syntax of the SFC not necessarily must be matched. Syntax errors will not be checked until a precompile run
(build).

▪ Macros can be used for structuring purposes.

Additional information

• SFC - Sequential Function Chart

• Cursor Positions in SFC

• Working in the SFC Editor

• SFC Element - Properties

• SFC Elements / Toolbox

• Qualifier for actions in SFC

• Implicit variables - SFC flags

• Sequence of processing in SFC

• SFC Editor in online mode

1 of 1 13/09/2016 9:43
SFC - Sequential Function Chart http://infosys.beckhoff.com/content/1033/tc3_plc_intro/136046219.ht...

PLC

SFC - Sequential Function Chart


The Sequential Function Chart (SFC) is a graphically oriented language which allows to describe the chronological order of
particular actions within a program. These actions are available as separate programming objects, written in any available
programming language. In a SFC they get assigned to "step" elements and the sequence of processing is controlled by
transition elements. For a detailed description on how the steps will be processed in online mode see “Sequence of processing
in SFC ”
For information on how to use the SFC Editor in TwinCAT 3 PLC see “SFC Editor ”

1 of 1 13/09/2016 9:50
Cursor Positions in SFC http://infosys.beckhoff.com/content/1033/tc3_plc_intro/136047755.ht...

PLC

Cursor Positions in SFC


A possible cursor position in a SFC diagram in the SFC Editor is indicated per default by a grey shadow when moving with the
cursor over the elements.
There are two categories of cursor positions: Texts and element bodies. See the possible positions indicated by a grey shaded
area as shown in the following pictures:
1. Texts

When you click on a text cursor position, the string will get editable:

2. Element bodies

When you click on a shadowed area, the element will get selected. It gets a dotted frame and is displayed red-shaded (for
multiple selection see “Working in the SFC Editor ”):

1 of 1 13/09/2016 9:51
Working in the SFC Editor http://infosys.beckhoff.com/content/1033/tc3_plc_intro/136049291.ht...

PLC

Working in the SFC Editor


By default a new SFC POU contains an init step and a subsequent transition. For how to add further elements, how to arrange
and edit the elements see the following information:
▪ Possible cursor positions: see “Cursor Positions in SFC ”.

▪ Navigating: Jumping to the next resp. previous element in the chart is possible by using the arrow keys.

Insert elements
The particular SFC elements can be inserted via the respective commands which by default are available in the "SFC" menu.
See “SFC Editor commands ” for details. A double-click on an already inserted step, transition or action element, which does not
yet reference a project object, will open a dialog for assigning one.

Select elements
An element resp. text field might be selected by a mouse-click on a possible cursor position. The selection might also always be
given to an adjacent element by using the arrow keys. The element will change color to red, for examples see “Cursor Positions
in SFC ”.
In contrast to TwinCAT 2.x PLC Control steps and transitions can be selected and thus also moved (cut, copy, paste) or deleted
separately!
Multiple selection is possible by the following:
▪ Keep the [ Shift ] -key pressed and subsequently click on the particular elements to be selected.

▪ Press the left mouse-key and draw a rectangle (dotted line) around the elements to be selected.

▪ Use command Select All , by default from the Edit menu.

Edit texts
By a mouse-click on a text-cursor-position at once the edit field opens, where you can edit the text. If a text area has been
selected via the arrow keys, the edit field must be opened explicitly by using the [ Space ] -bar.

Edit associated actions


A doubleclick on an step (entry, active or exit) or transition action association opens the associated action in the corresponding
editor. For example perform a doubleclick on the transition element or on the triangle indicating an exit action in a step element.

Cut, Copy, Paste elements


Select the element(s) and use command “Cut”, “Copy ” resp. “Paste” (by default from the Edit menu) or the corresponding keys.
Notice the following behavior which is different to TwinCAT 2.x PLC Control :
▪ When you paste one or several cut or copied element(s), the content of the clipboard will be inserted before the currently
selected position. If nothing is currently selected, the element(s) will be appended at the end of the currently loaded chart.

▪ If you paste a branch while the currently selected element is also a branch, the pasted branch elements will be inserted left
to the existing ones.

▪ If you paste an action (list) at a currently selected step, the actions will be added at the beginning of the action list of the
step resp. an action list for the step will be created.

▪ Incompatible elements when cutting/copying: If an associated action (list) and additionally an element, which is not the step
to which the action (list) belongs, are selected, a message box will appear: "The current selection contains incompatible
elements. No data will be filed to the clipboard." The selection will not be stored and you cannot paste or copy it somewhere
else!

▪ Incompatible elements when pasting: If you try to paste an action (list) while the currently selected element is not a step or
another association, an error box will appear: "The current clipboard content can not be pasted at the current selection." If
you try to paste an element like a step, branch or transition when currently an associated action (list) is selected the same
message box will appear.

Delete elements

1 of 2 13/09/2016 9:51
Working in the SFC Editor http://infosys.beckhoff.com/content/1033/tc3_plc_intro/136049291.ht...

Select the element(s) and use command Delete or the [ Del ] -key. Notice the following:
▪ Deleting a step also deletes the associated action list.

▪ Deleting the init step automatically sets the following step to be the initial one, that is option 'Initial step' will be activated in
the properties of this step.

▪ Deleting the horizontal line preceding a branched area will delete all branches.

▪ Deleting all particular elements of a branch will delete the branch.

2 of 2 13/09/2016 9:51
SFC Element - Properties http://infosys.beckhoff.com/content/1033/tc3_plc_intro/136050827.ht...

PLC

SFC Element - Properties


The properties of a SFC element can be viewed and edited in the "Element properties" window. This window can be opened via
command ' Element Properties', which by default is part of the 'View' menu.
It depends on the currently selected element which properties are displayed. The properties are grouped and the particular
group sections can be opened or closed by using the plus- resp. minus signs.
Notice that in the 'View' tab of the SFC-Editor otions you can configure whether the particular types of properties should be
displayed next to an element in the SFC chart.
See in the following all possible properties:
Common:

Name Element name, by default "<element><running number>" , for example step name
"Step0", "Step1", branch name "branch0" etc.

Comment Element comment, text string, for example "Reset the counter". Linebreaks can be
inserted via [ Ctrl ] + [ Enter ] .

Symbol For each SFC element implicitly a flag is created, named like the element. Perform a
double-click on the value field, resp. select the value field and use the [ Space ] -key
in order to open a selection list from which you can choose one of the following
access options:
None: The symbol will be exported to the symbol configuration, but it won't be
accessible in the PLC.
Read: The symbol will be exported to the symbol configuration and it will be readable
in the PLC.
Write: The symbol will be exported to the symbol configuration and it will be written
in the PLC.
Read/Write : Combination of Read and Write. By default nothing is entered here,
which means, that the symbol not at all is exported to the symbol configuration.

Specific:

Initial step This option always is activated in the properties of the current initial step (init step).
By default it is activated for the first step in a SFC and deactivated for other steps.
Notice that if you activate this option for another step, you must deactivate it in the
previous init step in order to avoid a compiler error. In this context also notice
command 'Init Step.

Times: Note: Notice the possibility to detect timeouts in steps by the implicit variable
SFCError flag.

Minimal active Minimum length of time the processing of this step should take; permissible values:
time according to IEC-syntax (for example t#8s) or TIME variable; default: t#0s.

Maximal active Maximum length of time the processing of this step should take; permissible values:
time according to IEC-syntax (for example t#8s) or TIME variable; default: t#0s

Actions: Define here the actions to be performed when the step is active. Notice the
description of the “Sequence of processing in SFC ” for details.

Step entry This action will be executed after the step has got active.).

Step active This action will be executed when the step is active and possible entry actions have
been already processed.

Step exit This action will be executed in the subsequent cycle after a step has been
deactivated. ("exit action").

Notice the possibility of getting information on step/action status resp. timeouts etc. via the
appropriate “Implicit variables - SFC flags ”.

Note

1 of 1 13/09/2016 9:51
SFC Elements / Toolbox http://infosys.beckhoff.com/content/1033/tc3_plc_intro/90071993907...

PLC

SFC Elements / Toolbox


The graphic elements usable for programming in the SFC editor window currently can be inserted by using the insert
commands, by default available in the SFC menu.
The SFC Toolbox currently is not yet implemented.
See also the help page on: Working in the SFC Editor.
The following elements Step, Transition, Action, Branch (Alternative), Branch (Parallel), Jump, Macro are available and
described in the “SFC Elements / Toolbox ”

Step-Transition
Steps and transitions are basically inserted in combination, via a command.
A step is represented by a box primarily containing an automatically generated step name. It is connected to the preceding and
subsequent transition by a line. The box frame of the first step within a SFC, the init step, is double-lined. The transition is
represented by a small rectangle. After inserting primarily it has a default name: Trans<n>, whereby n is a running number.
Example for step and subsequent transition:

Example for initial step and subsequent transition:

A step is represented by a box containing the step name and being connected to the preceding and subsequent transitions by a
line.
The step and transition names can be edited inline.

Step names must be unique in the scope of the parent POU. Notice this especially when using
actions programmed in SFC.

Note

The box frame of the init step is double-lined.


Notice that each step - by command ' Init step' or by activating the respective step property - can be transformed to an init step
, that is to that step, which will be executed first when the IL-POU is called.
Each step is defined by the step porperties.

In contrast to TwinCAT 2.x PLC Control there is only one type of steps, the IEC conforming steps. I

Note

After inserting a step, the action(s) to be performed when the step is active (processed) are to be associated; see below for
further information.
Regard the following on transitions:
A transition must provide the condition on which the subsequent step shall get active as soon as the condition value is TRUE.
So a transition condition must have the value TRUE or FALSE. It can be defined in the following two ways:
1. Directly ("inline condition"): Replace the default transition name by either a boolean variable, a boolean address, a boolean
constant or an instruction having a boolean result (e.g. (i<100) AND b). It is not possible here to specifiy programs, function
blocks or assignments!
2. Using a separate transition or property object ("multi-use condition"): Replace the default transition name by the name

1 of 8 13/09/2016 9:56
SFC Elements / Toolbox http://infosys.beckhoff.com/content/1033/tc3_plc_intro/90071993907...

of a transition or property object, available in the project (this allows multiple use of transitions. The object like an inline transition
can contain a boolean variable, address, constant or instruction, but also multiple statements with arbitrary code.

Notice: It is the user's responsibility to assign the desired expression to a transition variable, if a
transition produces multiple statements!

Note

The actions to be performed when the step is active (processed) are to be associated (see below, action).
Steps and transitions are basically inserted in combination via command ' Insert step/transition (after)
A transition is represented by a small rectangle box connected to the preceding and subsequent steps by a line. It provides the
condition on which the following step will get active (as soon as the condition is TRUE).
The transition name resp. the transition condition is displayed right to the box.
By default automatically a transition "trans<n>" is inserted, whereby n is a running number.
This default name can be selected and modified: A valid name is either

- the name of a transition object ( ) available in the POUs tree (this allows multiple use of transitions; see for example "t1"
in the left column)
or
- a valid conditional expression.(for example "a AND b", "TRUE" )

Transitions which consist of a transition or a property object are indicated by a small triangle in the
upper right corner of the rectangle.

Note

2 of 8 13/09/2016 9:56
SFC Elements / Toolbox http://infosys.beckhoff.com/content/1033/tc3_plc_intro/90071993907...

Examples of transition

3 of 8 13/09/2016 9:56
SFC Elements / Toolbox http://infosys.beckhoff.com/content/1033/tc3_plc_intro/90071993907...

In contrast to TwinCAT PLC Control


... a transition condition is handled like a method call; It will be entered according to the
Syntax:
<transition name>:=<transition condition>;
(for example" trans1:= a=100")
or just
<transition condition>;
(for example "a=100")
In online mode the subsequent step can only get active if the preceding transition has become TRUE.

Action
An action can contain a series of instructions written in one of the valid programming languages. It is assigned to a step and in
online mode it will be processed according to the defined sequence of processing .

Each action to be used in SFC steps must be available as a valid POU within the SFC POU resp. the project ( ).

4 of 8 13/09/2016 9:56
SFC Elements / Toolbox http://infosys.beckhoff.com/content/1033/tc3_plc_intro/90071993907...

Step names must be unique in the scope of the parent POU. An action may not contain a step
having the same name like the step to which it is assigned to.

Note

There are the following types of actions:


1. IEC conforming step action ("IEC action"):
This is an action according to standard IEC61131-3 which will be processed according to its qualifier when the step has got
active and a second time when it has got deactivated. In case of assigning multiple actions to a step (action list) the actions will
be executed from up to down.
▪ Different qualifiers can be used for IEC step actions in contrast to a "normal" step action.

▪ A further difference to the "normal" step actions is that each IEC step action is provided with a control flag, which allows to
make sure that - even if the action is called also by another step - the action will get executed always only once at a time.
This is not guaranteed with the normal step actions.

▪ An IEC step action is represented by a bipartite box, connected to the right of a step via a connection line. In the left part it
shows the action qualifier, in the right part the action name. Both can be edited inline.

▪ IEC step actions get associated to a step via the ' Insert action association after ) command. One or multiple actions can be
associated to a step. The position of the new action depends on the current cursor position and the command. The actions
must be available in the project and be inserted with a unique action name (for example plc_prg.a1).

Each action box in the first column shows the qualifier and in the second the action name.
2. IEC-extending step actions:
These are actions extending the IEC standard : The actions must be available as objects below the SFC object. The action
names must be unique.
- "step entry" action (step activated):
This type of step action will be processed as soon as the step has become active and before the "step active" action.
The action is associated to a step via an entry in the "step entry" field of the step properties. It is represented by an "E" in the
lower left corner of the respective step box.
- "step active" action (step action):
This type of step action will be processed when the step has become active and after a possible "step entry" action of this step
has been processed. However in contrast to an IEC step action (see above) it is not executed once more when it gets
deactivated and it cannot get assigned qualifiers.
The action is associated to a step via an entry in the "step active" field of the step properties. It is represented by a small triangle
in the upper right corner of the respective step box.
- "step exit" action (step deactivated): :
An exit action will be executed once when the step has got deactivated. Notice however that this execution will not be done in
the same, but at the beginning of the subsequent cycle.
The action is associated to a step via an entry in the "step exit" field of the step properties. It is represented by an "X" in the
lower right corner of the respective step box.

5 of 8 13/09/2016 9:56
SFC Elements / Toolbox http://infosys.beckhoff.com/content/1033/tc3_plc_intro/90071993907...

The "Step active", "Step Entry" and "Step Exit" actions are defined in the step properties.
Example: Difference between IEC matching / extending step actions
The main difference between step actions and IEC actions with qualifier N is the following: The IEC action is at least executed
twice: First time when the step is active, second time when the step gets deactivated. See the following example:

Action Action_AS1 is associated to step AS1 as a step action (left), resp. as an IEC action with qualifier N (right). Due to the fact
that in both cases two transitions are used, it will take two PLC cycles each before the init step is reached again. Let us assume
that a variable iCounter gets incremented in Action_AS1. After a re-activation of step Init, iCounter in the left example will have
value 1. In the right one however it will have value 2, because the IEC action - due to the deactivation of AS1 - has been
executed twice.
Branches
A sequential function chart can diverge, that is the processing line can be branched into two or several further lines
("branches"). Parallel branches will be processed parallel (both at a time), in case of alternative branches only one will be
processed depending on the preceding transition condition. Each branching within a chart is preceded by a horizontal double
(parallel) or simple (alternative) line and also terminated by such a line or by a jump.

Parallel branch

A parallel branch must begin and end with a step. Parallel branches can contain alternative branches or other parallel
branches.
The horizontal lines before and after the branched area are double-lines.
Processing in online mode: If the preceding transition (t2 in the example shown on the left) is TRUE, the first steps of all parallel
branches will become active (Step11 and Step21). The particular branches will be processed parallel to one another before the
subsequent transition (t3) will be noticed.
A parallel branch is inserted via command ' “Insert branch right ” when a step is currently selected.
Notice that parallel and alternative branches can be transformed to each other by the commands “Parallel” resp. “Alternative”.
This might be useful during programming.

6 of 8 13/09/2016 9:56
SFC Elements / Toolbox http://infosys.beckhoff.com/content/1033/tc3_plc_intro/90071993907...

Automatically a branch label is added at the horizontal line preceding the branching which is named "Branch<n> whereby n is a
running number starting with "0". This label can be specified when defining a jump target.

Alternative branch

The horizontal lines before and after the branched area are simple lines.
An alternative branch must begin and end with a transition. Alternative branches can contain parallel branches and other
alternative branches.
If the step which precedes the alternative beginning line is active, then the first transition of each alternative branch will be
evaluated from left to right. The first transition from the left whose transition condition has value TRUE, will be opened and the
following steps will be activated.
Alternative branches are inserted via command 'Insert branch (right)' when a transition is currently selected.
The horizontal lines before and after the branched area are simple lines.
Notice that parallel and alternative branches can be transformed to each other by the commands Parallel resp. Alternative. This
might be useful during programming.

Jump

A jump is represented by a vertical connection line plus a horizontal arrow and the name of the jump target.
A jump defines the next step to be processed as soon as the preceding transition is TRUE. Jumps might be needed because the
processing lines must not cross or lead upward.
Besides the default jump at the end of the chart a jump may only be used at the end of a branch. It gets inserted via command
'Insert jump (after)' when the last transition of the branch is selected.
The target of the jump is specified by the associated text string which can be edited inline. It can be a step name or the label of
a parallel branch.

Macro
Main SFC editor view:

7 of 8 13/09/2016 9:56
SFC Elements / Toolbox http://infosys.beckhoff.com/content/1033/tc3_plc_intro/90071993907...

Macro editor view for Macro1:

A macro is represented by a bold-framed box containing the macro name.


It includes a part of the SFC chart, which thus is not directly visible in the main editor view.
The process flow is not influenced by using macros, it is just a way to "hide" some parts of the program, for example in order to
simplify the display.
A macro box is inserted by command 'Insert macro (after)'. The macro name can be edited inline.
To open the macro editor, perform a double-click on the macro box or use command 'Zoom in to macro'. You can edit here just
as in the main editor view and enter the desired section of the SFC chart. To get out use 'Zoom out of macro'.
The title line of the macro editor always shows the path of the macro within the current SFC Example:

8 of 8 13/09/2016 9:56
Qualifier for actions in SFC http://infosys.beckhoff.com/content/1033/tc3_plc_intro/136053899.ht...

PLC

Qualifier for actions in SFC


In order to configure in which way the actions should be associated to the IEC steps, some qualifiers are available, which have
to be inserted in the qualifier field of an action element.
These qualifiers are handled by the SFCActionControl function block of the System Library, which is automatically included in all
projects.
The available qualifiers:

N Non-stored The action is active as long as the


step is active.

R0 overriding Reset The action gets deactivated.

S0 Set (Stored) The action will be started when the


step becomes active and will be
continued after the step is
deactivated, until the action gets
reset.

L time Limited The action will be started when the


step becomes active and it will
continue until the step goes inactive
or a set time has passed.

D time Delayed A delay timer will be started when the


step becomes active. If the step is still
active after the time delay, the action
will start and continue until it gets
deactivated

P Pulse The action will be started when the


step becomes active/deactive and will
be executed once.

SD Stored and time Delayed The action will be started after the set
time delay and it will continue until it
gets reset.

DS Delayed and Stored If the step is still active after the


specified time delay, the action will
start and it will continue until it gets
reset

SL Stored and time limited The action will be started when the
step becomes active and it will
continue for the specified time or until
a reset.

The qualifiers L, D, SD, DS and SL need a time value in the TIME constant format.

When an IEC action has been deactivated it will be executed once more. This means that each
action at least is executed twice.

Note

1 of 1 13/09/2016 9:52
Implicit variables - SFC flags http://infosys.beckhoff.com/content/1033/tc3_plc_intro/90071993907...

PLC

Implicit variables - SFC flags


Each SFC step and IEC action provides implicitly generated variables for watching the status of steps and IEC actions during
runtime. Also variables can be defined for watching and controlling the execution of a SFC (timeouts, reset, tip mode). These
variables also might be generated implicitly by the SFC object.
Basically for each step and each IEC action an implicit variable is generated. A structure instance, named like the element, for
example "step1" for a step with step name "step1".
Notice the possibility, to define in the element properties, whether for this flag a symbol definition should be exported to the
symbol configuration and how this symbol should be accessible in the PLC.
The data types for those implicit variables are defined in the System library. This library will automatically be included in the
project.

Step and Action status and Step time


Basically for each step and each IEC-action an implicit structure variable of type SFCStepType resp. SFCActionType is
created. The structure components (flags) describe the status of a step resp. action or the currently processed time of an active
step.
The syntax for the implicitly done variable declaration is:
<stepname>: SFCStepType; bzw. _<actionname>:SFCActionType;

In contrast to TwinCAT 2.x PLC Control implicit variables for actions always are preceded by an
underscore.

Note

The following boolean flags for step or action states are available:
For Steps:
<stepname>.x shows the current activation status.
<stepname>._x: shows the activation status for the next cycle.
If <stepname>.x = TRUE, the step will be executed in the current cycle.
If <stepname>._x = TRUE and <stepname>.x = FALSE, the step will be executed in the following cycle, that is <stepname>._x
gets copied to <stepname>.x at the beginning of a cycle.
For actions:
_<actionname>.x is TRUE, if the action is executed
_<actionname>.x is TRUE, if the action is active
Symbol generation:

The flags described above might be used to force a certain status value for a step, that is for setting
an step active, but be aware that this will effect uncontrolled states within the SFC !

Note

Time via TIME variables:


The flag "t" gives the current time span which has passed since the step had got active; this is only for steps, no matter whether
there is a minimum time configured in the step attributes or not (see also below: SFCError
For steps: <stepname>.t (<stepname>._t not usable for external purposes)
For actions: the implicit time variables are not used.
Control of SFC execution (timeouts, reset, tip mode):
Some implicitly available variables, also named SFC flags, (see table below) can be used to control the operation of an SFC, for
example for indicating time overflows or enabling tip mode for switching transitions.
In order to be able to access these flags and to get them work, they must be declared and activated. This is to be done in the
SFC Settings dialog which is a subdialog of the object properties dialog. Manual declaration, as it was needed in TwinCAT 2.x
PLC Control, is only necessary to enable write access from another POU (see below, Accessing flags ). In this case however
regard the following:

1 of 5 13/09/2016 9:52
Implicit variables - SFC flags http://infosys.beckhoff.com/content/1033/tc3_plc_intro/90071993907...

If you declare the flag globally, you must deactivate the "Declare" option in the SFC Settings dialog in order not to get a
implicitly declared local flag, which then would be used instead of the global one ! Keep in mind, that the SFC Settings for a SFC
POU initially are determined by the definitions currently set in the SFC options dialog.
Notice that a declaration of a flag variable solely done via the SFC Settings dialog will only be visible in the online view of the
SFC POU !
Example of the use of SFCError:
There is a SFC POU named "sfc1" containing a step "s2" which has time limits defined in its step attributes. See the attributes
displayed below in figure "Online view of SFC sfc1".
If for any reason the step s2 stays active for a longer time than allowed by its time properties (time overflow), a SFC flag will be
set which might be read by the application.
In order to allow this access, declare the flag in the SFC Settings dialog. For this purpose select sfc1 and choose command
'Properties' from the context menu. Open subdialog 'SFC Settings' and there, on tab 'Flags', set a checkmark each in column
'Declare' and 'Use' for flag "SFCError". (Solely declaring would make the variable visible in the online view of the sfc1 declaration
part, but it would be without function.)

SFC Settings

Now you can read SFCError within the SFC, for example in an action, via "SFCError", or from another POU via "sfc1.SFCError".
Accessing SFCError:

2 of 5 13/09/2016 9:52
Implicit variables - SFC flags http://infosys.beckhoff.com/content/1033/tc3_plc_intro/90071993907...

SFCError will get TRUE as soon as a timeout within sfc2 occurs.


The following implicit variables (flags) can be used. For this purpose they must be declared and activated in the SFC Settings:

SFCInit: BOOL; If this variable gets TRUE, the sequential function chart will be set back to the Init
stepInit step. All steps and actions and other SFC flags will be reset (initialization).
The Init step will remain active, but not be executed as long as the variable is TRUE.
SFCInit must be set back to FALSE in order to get back to normal processing.

SFCReset: BOOL; This variable behaves similarly to SFCInit. Unlike the latter however, further
processing takes place after the initialization of the Init step. Thus in this case for
example a reset to FALSE of the SFCReset flag could be done in the Init step.

SFCError: BOOL; As soon as any timeout occurs at one of the steps in the SFC, this variable will get
TRUE. Precondition: SFCEnableLimit must be TRUE. Notice that any further timeout
can not be registered before a reset of SFCError. SFCError must be defined, if you
want to use the other time-controlling flags (SFCErrorStep, SFCErrorPOU,
SFCQuitError).

SFCEnableLimit: BOOL; This variable can be used for the explicit activation (TRUE) and deactivation (FALSE)
of the time control in steps via SFCError. This means, that If this variable is declared
and activated ( SFC Settings) then it must be set TRUE in order to get SFCError
working. Otherwise any timeouts of the steps will not be registered. The usage might
be reasonable during start-ups or at manual operation. If the variable is not defined,
SFCError will work automatically. Of course as a precondition SFCError must be
defined!

SFCErrorStep: STRING; This variable stores the name of a step at which a timeout was registered by
SFCError. timeout. Precondition: SFCError must be defined!

SFCErrorPOU: STRING; This variable stores the name of the SFC POU in which a timeout has occurred.
Precondition: SFCError must be defined!

SFCQuitError: BOOL; As long as this variable is TRUE, the execution of the SFC diagram is stopped and
variable SFCError will be reset. As soon as the variable has been reset to FALSE, all
current time states in the active steps will be reset. Precondition: SFCError must be
defined!

SFCPause: BOOL; As long as this variable is TRUE, the execution of the SFC diagram is stopped.

SFCTrans: BOOL; This variable gets TRUE, as soon as a transition is actuated.

SFCCurrentStep: STRING; This variable stores the name of the currently active step, independently of the time
monitoring. In case of simultaneous sequences the name of the outer right step will
be registered.

3 of 5 13/09/2016 9:52
Implicit variables - SFC flags http://infosys.beckhoff.com/content/1033/tc3_plc_intro/90071993907...

SFCTip, SFCTipMode: BOOL; This variables allow using the inching mode within the current chart. When this mode
has been switched on by SFCTipMode=TRUE, you can only skip to the next step by
setting SFCTip=TRUE (rising edge). As long as SFCTipMode is set to FALSE, it is
possible to skip by the transitions.
Example of some SFC error flags in online mode of the editor:
A timeout has been detected in step 's1' in SFC object 'POU' by flag SFCError

Accessing flags
For enabling access on the flags for the control of SFC execution (timeouts, reset, tip mode), the flag variables must be declared
and activated as described above ( Control of SFC execution).
Syntax for accessing:
... from an action or transition within the SFC POU: <stepname>.<flag> resp. _<actionname>.<flag>
Example:

status:=step1._x;
checkerror:=SFCerror;
... from another POU: <SFC POU>.<stepname>.<flag> resp. <SFC POU>_<actionname>.<flag>
Example:

status:=SFC_prog.step1._x;
checkerror:=SFC_prog.SFCerror;
Regard that in case of write access from another POU the implicit variable additionally must be declared explicitly as a
VAR_INPUT variable of the SFC POU or globally for example in a GVL.
Example:
Local declaration:

PROGRAM SFC_prog
VAR_INPUT
SFCinit:BOOL;
END_VAR
or Global declaration in a GVL:

VAR_GLOBAL
SFCinit:BOOL;
END_VAR
Accessing the flag in PLC_PRG:

PROGRAM PLC_PRG
VAR
setinit: BOOL;
END_VAR

4 of 5 13/09/2016 9:52
Implicit variables - SFC flags http://infosys.beckhoff.com/content/1033/tc3_plc_intro/90071993907...

SFC_prog.SFCinit:=setinit; //Write Access on SFCinit in SFC_prog

5 of 5 13/09/2016 9:52
Sequence of processing in SFC http://infosys.beckhoff.com/content/1033/tc3_plc_intro/136056971.ht...

PLC

Sequence of processing in SFC


In online mode the particular action types will be processed according a defined sequence, see the table below.
Following terms are used:
▪ Active step: A step, whose step action is being executed, is called "active". In Online mode active steps are filled with blue
color.

▪ Initial step: In the first cycle after a SFC POU has been called, the initial step automatically gets active and the associated
step action is executed.

▪ IEC actions are executed at least twice: The first time when they have got active, the second time - in the following cycle -
when they have been deactivated.

▪ Alternative Branches: If the step preceding the horizontal start line of alternative branches is active, then the first transition
of each particular branch will be evaluated from left to right. The first transition from the left whose transition condition has
value TRUE will be searched and the respective branch will be executed, that is the subsequent step within this branch will
get active.

▪ Parallel Branches: If the double-line at the beginning line of parallel branches is active and the preceding transition
condition has the value TRUE, then in all parallel branches each the first step will get active. The branches now will be
processed parallel to one another. The step subsequent to the double-line at the end of the branching will become active
when all previous steps are active and the transition condition after the double-line has the value TRUE.

Processing order of elements in a sequence:

1. Reset of the IEC actions All action control flags of the IEC actions get reset (not
however the flags of IEC actions that are called within
actions!).

2. Step Exit Actions ("step deactivated") All steps are checked in the order which they assume in
the sequence chart (top to bottom and left to right) to
determine whether the requirement for execution of the
step exit action is provided, and - if that is the case - this
will be executed. An exit action will be executed, if the step
is going to get deactivated, that is if its entry and step
actions - if existing - have been executed during the last
cycle, and if the transition for the following step is TRUE.

3. Step Entry Actions Eingangsaktionen ("step activated ") All steps are tested in the order which they assume in the
sequence to determine whether the requirement for
execution of the step entry action is provided and - if that
is the case - this will be executed. An entry action will be
executed, if the step-preceding transition condition is TRUE
and thus the step has been activated.

4. Timeout check, Step Active Actions For all steps , the following is done in the order which they
assume in the sequence:- (not yet implemented) If
applicable, the elapsed time is copied into the
corresponding implicit step status variable <stepname>.t-
(not yet implemented) If applicable, any timeout is tested
and the SFC error flags are serviced as required.- For
non-IEC steps, the corresponding step active action is
now executed.

5. IECActions IEC actions that are used in the sequence are executed in
alphabetical order. This is done in two passes through the
list of actions. In the first pass, all the IEC actions that are
deactivated in the current cycle are executed. In the
second pass, all the IEC actions that are active in the
current cycle are executed.

6. Transition check, Activating next steps Transitions are evaluated: If the step in the current cycle
was active and the following transition returns TRUE (and if
applicable the minimum active time has already elapsed),
then the following step is activated.

1 of 2 13/09/2016 9:52
Sequence of processing in SFC http://infosys.beckhoff.com/content/1033/tc3_plc_intro/136056971.ht...

The following must be noticeed concerning implementation of actions:It can come about that an
action is carried out several times in one cycle because it is associated with multiple sequences.
(For example, an SFC could have two IEC actions A and B, which are both implemented in SFC,
and which both call IEC action C; then in IEC actions A and B can both be active in the same cycle
Note
and furthermore in both actions IEC action C can be active; then C would be called twice). If the
same IEC action is used simultaneously in different levels of an SFC, this could lead to undesired
effects due to the processing sequence described above. For this reason, an error message is
issued in this case. It can possibly arise during processing of projects created with older versions of
the programming system.

Notice the possibility of using implicit variables for controlling the status of steps and actions resp.
the execution of the chart.

Note

2 of 2 13/09/2016 9:52
SFC Editor in online mode http://infosys.beckhoff.com/content/1033/tc3_plc_intro/136058507.ht...

PLC

SFC Editor in online mode


In online mode the SFC-Editor provides views for monitoring and for writing and forcing the variables and expressions on the
controller. Debugging functionality (breakpoints, stepping etc.) is not yet available. See below.
▪ For information on how to open objects in online mode see “User Interface in online mode ” .

▪ Notice that the editor window of an SFC object also includes the Declaration Editor in the upper part. For general
information on the Declaration Editor in online mode see “Declaration Editor in Online Mode ”. In case of having declared
implicit variables ( SFC flags) via the SFC Settings dialog, those will be added here, but will not be viewed in the offline
mode of the declaration editor.

▪ Also please notice the sequence of processing of the elements of a sequential function chart.

▪ See the object properties resp. the SFC Editor options and SFC defaults for settings concerning compilation resp. online
display of the SFC elements and their attributes.

▪ Consider the possible use of flags for watching and controlling the processing of an SFC.

Monitoring
Active steps are displayed filled blue-colored. The display of step attributes depends on the currently set SFC Editor options.

Breakpoint positions in SFC Editor: (not yet implemented)


The possible breakpoint positions basically are those positions in a POU at which values of variables can change or at which the
program flow branches out resp. another POU is called. See possible positions in the following picture.

Notice for breakpoints in methods: A breakpoint will be set automatically in all methods which might
be called. So, if an interface-managed method is called, breakpoints will be set in all methods of
function blocks implementing that interface and also in all derivative function blocks subscribing the
method. If a method is called via a pointer on a function block, breakpoints will be set in the method
Note
of the function block and in all derivative function blocks which are subscribing the method.

1 of 1 13/09/2016 9:53

You might also like