Use of breakpoints

Breakpoints are generally used for finding errors in the program. You can set breakpoints at certain positions in the program in order to force an execution stop there and observe the variable values. TwinCAT 3 PLC supports breakpoints in all IEC editors.

The stop at the breakpoint can be linked to additional conditions. You can also redefine breakpoints as execution points at which the program doesn't stop, but instead executes certain code.

Use of breakpoints 1:

The view Breakpoints (menu PLC > Windows) provides an overview of all defined breakpoints. Additional commands are available to you there for the simultaneous changing of several breakpoints.

The status of breakpoints and execution points is marked in the editor with the following symbols:

See also:

Breakpoints in PLC projects with several tasks

If a breakpoint is reached when executing a PLC project, no further code in this PLC project will be executed by any task. Code located outside of this PLC project will still be executed.

Use of breakpoints 12:

If the program on the PLC has stopped at a breakpoint, an online change or download stops all tasks. This means that the PLC stops. In this case TwinCAT displays a corresponding message and you can decide whether or not you wish to continue with the login.

Setting a single breakpoint (example: ST editor)

The project is in online mode.
1. Open a POU in ST language in the editor.
2. Place the cursor in the line in which a breakpoint is to be set.
3. Select the command Toggle Breakpoint in the menu Debug or in the context menu or press the [F9] key.
The line is colored red and marked with the icon Use of breakpoints 13: (breakpoint enabled). If the program has stopped at the breakpoint, the line is marked with the icon Use of breakpoints 14: (stop at breakpoint). The execution of the program stops.
4. Select the command Start in the menu PLC or in the toolbar TwinCAT PLC Toolbar Options or press the [F5] key.
The program continues to run.
5. Set further breakpoints and check the values of variables at the stopping positions.
6. Place the cursor in the line in which a breakpoint is to be deleted.
7. Select the command Toggle Breakpoint in the menu Debug or in the context menu or press the [F9] key.
The marking disappears. The breakpoint is deleted.

See also:

Defining a breakpoint condition (example: ST editor)

The project is in online mode.
1. Open a POU in ST language in the editor.
2. Select the command Breakpoints in the menu PLC > Windows.
The Breakpoints view opens.
3. Select the command New in the toolbar.
The dialog New Breakpoint opens. The tab Location is visible. Alternatively, you can open the dialog using the command New Breakpoint in the menu Debug.
4. Select the POU and the position of the new breakpoint.
5. Select the tab Condition.
6. In the section Hit Count, select the option Break when the hit count is a multiple of and enter the value 5 in the field to the right of it.
7. Also define a Boolean condition for when the breakpoint should be active. Activate the option Break if TRUE. Enter a Boolean variable in the field to the right of it.
8. Activate the option Enable breakpoint immediately.
9. Close the dialogue.
The line is colored red and marked with the icon Use of breakpoints 15:.

Now observe the running program. As long as the Boolean variable for the condition is FALSE, the condition for the breakpoint is not satisfied and the program runs. If you set the variable to TRUE, the condition is satisfied and the program stops at this breakpoint every 5th pass.

See also:

Defining an execution point (example: ST editor)

The project is in online mode.
1. Open a POU in ST language in the editor.
2. From the menu PLC > Window select the command Breakpoints.
The Breakpoints view opens.
3. Select the command New in the toolbar.
The dialog New Breakpoint opens. The Location tab is visible.
Alternatively, you can open the dialog using the New Breakpoint command in the Debug menu.
4. Select the POU and the position of the execution point.
5. Select the Execution point settings tab.
6. Activate the Execution point option.
In the field Execute the following code, enter the desired instructions that are to be executed on reaching the execution point. For example, nCounter := nCounter + 1;, if the variable nCounter is available.
7. Close the dialog.
The line is colored red and marked with the icon Use of breakpoints 16:

The program does not stop on reaching the execution point; instead, the defined code is executed.

See also: