-

Debugging SFC Code

PLCnext Engineer extends the IEC 61131-3 standard by implementing SFC operating modes used to control the execution of the SFC code. For that purpose, each SFC function block gets formal parameters by default when it is inserted into a code worksheet by drag and drop from the COMPONENTS area.

When debugging SFC code worksheets, the graphical editor provides additional debugging commands used to control the SFC step chain execution, to switch the SFC operating mode, reset the step chain, etc.

In online SFC worksheets, active steps and their actions are displayed green, inactive steps are shown brown.

Note
To debug inline transitions and actions, you have to activate the option 'Debug Functions' in the Cockpit. Click the following button before compiling and writing the project to the controller.


Activating the button opens the 'Debug Code Settings' dialog. In the dialog, select the SFC items you want to debug. (In order to keep processor load and memory consumption as low as possible, mark only those items (POUs) that are really required.)
If activated, additional code is generated and executed which then supports debug functions for the mentioned POU parts. Note that this option increases the execution time and memory consumption on the controller. Deactivate the option for normal operation, i.e., after debugging.

Debugging commands in SFC

Toolbar buttonKeyboard shortcutDescription
<Ctrl>+<ALT>+<E>The operating mode as preset at the SFC function block input PRESET_OPERATING_MODE is activated.
<Ctrl>+<ALT>+<R>Corresponds to setting the operating mode at the SFC function block input PRESET_OPERATING_MODE to SFC_AUTO.
<Ctrl>+<ALT>+<H>Corresponds to setting the operating mode at the SFC function block input PRESET_OPERATING_MODE to SFC_HALT.
<Ctrl>+<ALT>+<S>Corresponds to setting the operating mode at the SFC function block input PRESET_OPERATING_MODE to SFC_STEP.
<Ctrl>+<ALT>+<Shift>+<S>Corresponds to setting the operating mode at the SFC function block input PRESET_OPERATING_MODE to SFC_FORCED_STEP.
<Ctrl>+<ALT>+<N>Executes the succeeding step in the SFC program. Corresponds to applying a rising edge to the SFC function block input STEP. Only active in operating modes SFC_STEP or SFC_FORCED_STEP.
Resulting SFC behavior:

  • In SFC_STEP mode: a rising edge executes the succeeding step if the relevant transition condition is fulfilled.
  • In SFC_FORCED_STEP mode: a rising edge executes the succeeding step independent of the transition value.
<Ctrl>+<ALT>+<A>Activates the selected step. Only possible in SFC_HALT mode.
<Ctrl>+<ALT>+<D>Deactivates the selected step. Only possible in SFC_HALT mode.
-Acknowledges and thus resets an error that occurred while executing the SFC step chain (e.g., maximum step time exceeded or step time lower than minimum step time).

Only possible in SFC_HALT mode.

Clicking the icon exits the SFC_HALT mode and continues execution with the previously active operating mode.

Corresponds to setting the SFC function block input ACKNOWLEDGE_ERROR to TRUE.

In online worksheets and in the WATCHES window an enumeration data type SFC_OPERATION_MODE with the operating modes as members is available. This applies both to variables of the data type SFC_OPERATION _MODE and to the PRESET_OPERATING_MODE formal parameter of the SFC FB itself.
The following example shows the variable OpMode (connected to the PRESET_OPERATING_MODE input) in the WATCHES window where the possible values of the SFC_OPERATION_MODE can be selected from the drop-down list.