CFC editor in online mode

In online mode, you can monitor controller variable values in the CFC Editor and modify them. You can also use the TwinCAT debugging functions, such as breakpoints and step-by-step execution.

Monitoring

You can observe values in the declaration part as well as in the implementation part (with inline monitoring) as usual.

Inline monitoring for a function block is only possible if an instance of the function block is open. No values are displayed in the basic implementation view.

Monitor boolean variables

The connections between boolean variables are displayed in color according to their actual value: TRUE in blue and FALSE in black. The element pins are decorated with the actual value.

Sample

An application contains a CFC programming block. There an internal boolean variable is toggled: the variable bToggle changes its state from TRUE to FALSE with each bus cycle.

CFC editor in online mode 1:
CFC editor in online mode 2:

Monitor scalar variables

For scalar variables, the element pins are decorated with the actual values.

Sample

CFC editor in online mode 3:

Forcing and Writing Variables Values

In online mode you can prepare a value for forcing or writing a mapped variable in the declaration editor.

If you have enabled the option Prepare values in implementation part in the TwinCAT options under category TwinCAT > PLC Environment > CFC editor, you can also prepare values in the implementation part. To do this, open the Prepare value dialog by double-clicking on the monitoring box next to each element or directly on the element. For boolean variables, no dialog appears, but each mouse click on the value displayed next to the variable toggles between TRUE and FALSE.

Prepared values are displayed in angle brackets. After the writing or forcing has been executed, a red "F" appears in the monitoring box.

Change constant input parameters of function block instances

Input parameters of function block instances of type VAR_CONSTANT can also be changed in online mode. The parameters are adjusted accordingly. After logging out, you can apply these parameters to your project with the command Accept prepared parameter values.

A CFC editor is active. A function block is instantiated, which has VAR_INPUT CONSTANT variables in its declaration.
1. Open the POU by calling the function block instance in the editor.
2. Log on to the controller.
3. Click in the Parameter field of one of the function block instances.
CFC editor in online mode 4:
The Edit Parameters dialog opens.
4. In the Value column, click in an inline monitoring field of a parameter.
The Prepare Value dialog opens.
5. Enter a new value in the field Prepare a new value for the next write or force operation.
6. Confirm the entry with OK.
The prepared value is displayed in angle brackets next to the current value (in the example <5>)
CFC editor in online mode 5:
7. Write the prepared value with the command Write values in the PLC menu or in the toolbar.
The prepared value is written. The parameter is changed and is shown in square brackets.
CFC editor in online mode 6:Next to the parameter field of the function block instance, the difference of the two values is represented by a red cross
CFC editor in online mode 7:
8. Close the Edit Parameters dialog.
9. Log out.
10. Click in the Parameter field of one of the function block instances or select the function block instance and use the command Edit Parameters in the CFC menu.
The Edit Parameters dialog opens again.
11. Select the command Save Prepared Parameters to Project.
The changed parameter value is transferred to the project. The asterisk next to the parameter field disappears.

See also:

Breakpoint positions

Possible positions of a breakpoint

Select the command Toggle Breakpoint from the Debug menu to set a breakpoint or delete an existing one. Red circles in the block diagram represent an activated breakpoint.

CFC editor in online mode 8:
CFC editor in online mode 9:

A breakpoint is automatically set in all methods that can be called.
Thus, if a method is called which is defined via an interface, breakpoints are set in all methods of function blocks that implement this interface. This also applies in all derived function blocks that define the method.

Execute programming block step by step

You can process a programming block step by step in debug mode. A programming block that is called is internally supplemented by a RETURN at the beginning before the element with the number 0 and at the end after the last element. During step-by-step processing, these are automatically jumped to.

See also: