SFC Parameters, Operating Modes and Data Types
This topic contains the following descriptions:
SFC parameters and operating modes as IEC 61131-3 extensions
PLCnext Engineer extends the IEC 61131-3 standard by implementing SFC operating modes used to control the execution of the SFC program. For that purpose, each SFC function block gets parameters by default when it is inserted into a code worksheet by drag and drop from the COMPONENTS area.
When creating an SFC block using the command 'Add SFC Function Block' (context menu on the 'Functions & Function Blocks' folder in the COMPONENTS area), the parameters are available as input and output formal parameters at the FB icon.
When creating a compact SFC block using the command 'Add Compact SFC Function Block', most of the parameters are combined in a STRUCT data type which is to be connected to an InOut formal parameter. Only the dynamically generated 'STEP_STATES' and 'STRUCTURE' are implemented as formal parameters.
The only difference between the normal and the compact SFC FB is the way it is connected in the calling POU. The contained SFC code and functional possibilities are identical.
When debugging SFC code worksheets in debug mode, the debugging commands provided on the editor's toolbar can be used to set the formal parameters of the SFC function block (e.g., to change the operating mode, to acknowledge an SFC error, etc.) independent of the value connected to the function block inputs. See the topic "Debugging SFC Code" for details.
SFC operating modes
The following operating modes are available. They are available as members in the SFC_OPERATING_MODE enumeration. Via this ENUM an operating mode can be set at the PRESET_OPERATING_MODE input and is indicated at the ACTIVE_OPERATING_MODE output.
Operating mode | Description |
---|---|
Automatic mode SFC_OPERATING_MODE_AUTO in Enum | The automatic mode is the initial mode after a cold/warm restart. In automatic mode, the SFC chart is evaluated normally, i.e., the steps become active/inactive and the actions are executed according to their qualifiers according to the evaluation of the transitions and depending on the states of Interlocks, if attached to the steps. |
Step mode SFC_OPERATING_MODE_STEP in Enum | In step mode, the succeeding step of the SFC program is only executed if the relevant transition condition is fulfilled and a rising edge is detected at the 'PROCEED' input of the function block instance. |
Forced (unconditional) mode SFC_OPERATING_MODE_STEP_FORCED in Enum | In forced mode, the succeeding step of the SFC program is executed if a rising edge is detected at the 'PROCEED' input of the function block instance. This happens independently of the transition value. |
Halt mode SFC_OPERATING_MODE_HALT in Enum | In halt mode the transitions do not change the state of the SFC chart. The currently active steps are not executed and the assigned actions are not triggered. The halt mode is activated in case of an SFC error.In halt mode, a step can be activated/deactivated via the STEP_ID input (see below). |
Input (formal) parameters
Note
For compact SFC function blocks, all inputs are combined in the same order in the SFC_PARAMETERS structure. Declare a variable of this data type and connect it to the PARAMETERS InOut formal parameter of the compact SFC function block or connect a suitable function block. |
Note
None of the formal parameters must necessarily be connected and used in the calling POU. Unconnected inputs are used with the default initial value noted in the table below. When the default values are used, SFC operates as defined by the IEC 61131-3 standard. |
Parameter | Data type | Meaning | |
---|---|---|---|
PRESET_OPERATING_MODE | SFC_OPERATING_MODE (ENUM) | Sets the operating mode.Initial value: SFC_OPERATING_MODE_AUTOThe available operating modes are described above. | |
FINAL_SCAN | BOOL | Enables/disables the final scan function.The final scan function executes all actions of the currently active step just one more time after the step becomes inactive before switching to the succeeding step in the program.Initial value: FALSEAccording the IEC 61131-3 standard, both settings (with or without final scan) are allowed.
|
|
EVALUATE_ALL_TRANSITIONS | BOOL | The value TRUE initiates that all transitions are evaluated during every scan of the chain (although only transitions at the current execution position are relevant). This way, it can be determined which transitions would become TRUE and would therefore activate its subsequent step(s) if its preceding step would be the active one. The lines connected to the appropriate transitions are highlighted in the code.Initial value: FALSE | |
PROCEED | BOOL | This input is only relevant if one of the operating modes SFC_OPERATING_MODE_STEP or SFC_OPERATING_MODE_STEP_FORCED is active.Initial value: FALSE Edge-triggered input to execute the succeeding step in the SFC program.
|
|
STEP_ID | DINT | While the SFC chart is in halt mode (SFC_OPERATING_MODE_HALT), this input can be used to activate or deactivate a particular step. To activate a particular step: apply the corresponding step ID to this input and then switch the ACTIVATE_STEP input to TRUE. To deactivate a particular step: apply the corresponding step ID to this input and then switch the DEACTIVATE_STEP input to TRUE.After a successful activation/deactivation, the STEP_ID input is automatically set to the value -1. Otherwise the step number is kept.
|
|
ACTIVATE_STEP | BOOL | While the SFC chart is in halt mode (SFC_OPERATING_MODE_HALT), the value TRUE at this input activates the step whose step ID is specified at the STEP_ID input (see table row above). After a successful activation, the input is automatically reset to FALSE. |
|
DEACTIVATE_STEP | BOOL | While the SFC chart is in halt mode (SFC_OPERATING_MODE_HALT), the value TRUE at this input deactivates the step whose step ID is specified at the STEP_ID input (see table row above). After a successful deactivation, the input is automatically reset to FALSE. |
|
ACKNOWLEDGE_ERROR | BOOL | Edge-triggered input for acknowledging and thus resetting an error that occurred while executing the SFC program (e.g., maximum step time exceeded or step time lower than minimum step time). In the case of an error, the SFC function block is switched to halt mode. The currently active steps are not executed and the assigned actions are not triggered.With a rising edge at the input, the function block exits the halt mode and continues execution with the previously active operating mode.Initial value: FALSE |
Output (formal) parameters
Note
For compact SFC function blocks, the outputs except STRUCTURE and STEP_STATES are combined in the same order in the SFC_PARAMETERS structure. Either declare a variable of this data type and connect it to the PARAMETERS InOut formal parameter of the compact SFC function block or connect a suitable function block. |
Note
None of the formal parameters must necessarily be connected and used in the calling POU. Unconnected inputs are used with the default initial value noted in the table below. When the default values are used, SFC operates as defined by the IEC 61131-3 standard. |
Parameter | Data type | Meaning |
---|---|---|
STRUCTURE | Data type depends on the set compiler options.SFC_GRAPH_STRUCTURE if static arrays are set in the compiler options. FBTypeName_SFC_GRAPH_STRUCTURE if dynamic arrays are used. (STRUCT) | Indicates the type info of the SFC function block as STRUCT data type. Refer to section "SFC Data Types" below for a detailed structure description.If the compiler option 'Use Dynamic Arrays for SFC Info' is activated ('Extras > Options | Compiler | IEC Compiler Settings)', the length of the ObjectTypeInfo array in this structure is dynamic (according to the number of contained SFC objects) and therefore type-specific. Refer to section "Dynamic Array Sizes" for details.Declare a variable of this data type and connect it to the STRUCTURE output of the SFC function block. |
STEP_STATES | Data type depends on the set compiler options.SFC_STEP_STATES if compiler option "static arrays" is set. FBTypeName_SFC_STEP_STATES if dynamic arrays are used. (STRUCT) | Indicates the state info of the SFC function block as STRUCT data type. Refer to section "SFC Data Types" below for a detailed structure description.If the compiler option 'Use Dynamic Arrays for SFC Info' is activated ('Extras > Options | Compiler | IEC Compiler Settings)', the length of the ObjectStateInfo array in this structure is dynamic according and therefore type-specific. Refer to section "Dynamic Array Sizes" for details.Declare a variable of this data type and connect it to the STEP_STATES output of the SFC function block. |
ACTIVE_OPERATING_MODE | SFC_OPERATING_MODE (ENUM) | Indicates the currently active operating mode of the function block instance. The possible operation modes (enumeration members) are described above. |
ERROR | BOOL |
|
ERROR_CODE | INT | Outputs the error number as INT value. |
INTERLOCK_FAULT | BOOL |
|
SFC data types
SFC_GRAPH_STRUCTURE with all included data types (STRUCTs and ENUMs), used at the STRUCTURE output
SFC_STEP_STATES structure, used at the STEP_STATES output
Dynamic Array Sizes in SFC info structures
The size of the arrays inside the STRUCTs at the outputs STRUCTURE and STEP_STATES can be static or dynamic, depending on your compiler settings. Select 'Extras > Options' and select the category 'Compiler | IEC Compiler Settings'. Here, the option 'Use dynamic arrays for SFC info' is available.