To evaluate potential programming errors, you can use the debugging functionality.
For testing purposes, an application can also run in simulation without any required link to an actual target device. While simulation avoids the need to connect to physical hardware, there are limitations to which you may need to complete debugging online.
Breakpoints for Forcing Execution Stops
A breakpoint that is set in an application program stops program execution. The variable values can then be seen at the current execution point. The current position can be determined more precisely using the Call Stack.
Only the debug task that has just reached the breakpoint is stopped. The other tasks continue to execute. The possible breakpoint positions depend on the respective program editor. In each case, there is a breakpoint at the end of a POU.
NOTE: The inputs / outputs handled by the debug task are not updated when stopped at a breakpoint. This applies even if the option Update IO while in stop is enabled in the PLC settings tab of the device editor.
Refer to the chapter Breakpoints Commands for a description of the commands concerning breakpoints. The Breakpoints dialog box provides an overview on all breakpoints, allowing you to add, remove, and modify breakpoints.
The stop at the breakpoint can be dependent on the following conditions:
oAt the time, a specific boolean expression is TRUE.
oWhich cycle number is running.
oWhich task is executing.
oWhen the value of a variable is modified (data breakpoint).
Declaring a specific debug task can help to avoid that several tasks are affected by the error check (refer to the Breakpoints and Stepping in Applications with Multiple Tasks paragraph).
In online mode, the Breakpoints dialog box allows you to change a breakpoint and data breakpoint in such a way that it becomes an execution point. Then the program does not stop at the position, but the code processing is initiated.
Symbol |
Description |
---|---|
![]()
|
Breakpoint enabled. |
![]()
|
Breakpoint disabled. |
![]()
|
The breakpoint is set in another instance of the function block that is open in the editor. |
![]()
|
Stop at breakpoint. |
![]()
|
Conditional breakpoint enabled. |
![]()
|
Conditional breakpoint disabled. |
![]()
|
Execution point enabled. |
![]()
|
Execution point disabled. |
![]()
|
Conditional execution point enabled. |
![]()
|
Conditional execution point disabled. |
![]()
|
Current step position. Indicated by a yellow arrow before the respective line and a yellow shadow behind the concerned operation. |
![]()
|
Data breakpoint enabled. |
![]()
|
Data breakpoint disabled. |
![]()
|
Stop at data breakpoint. |
![]()
|
Data execution point enabled. |
![]()
|
Data execution point disabled. |
![]()
|
Stop at data execution point. |
![]()
|
Conditional data execution point enabled. |
![]()
|
Conditional data breakpoint enabled. |
Stepping allows a controlled execution of an application program in online mode, for debugging purposes. Before you can use stepping commands, the program must be stopped at a defined program step, for example by setting a breakpoint. Basically, you step from one instruction to the next by step into an instruction, step over the next instruction or step out of an instruction. Refer to the chapter Breakpoint-Related Commands for a description of the stepping commands.
EcoStruxure Machine Expert provides the following stepping functions:
oStep into command: Execution of a single step; this also applies to POUs called within a step.
oStep over command: Execution of a single step; POUs are executed completely within a step.
oStep out command: If the application program does not contain any calls, a jump back to the start of the application is executed.
oRun to Cursor command: Execution of the program up to a temporary definable position.
oSet next statement command: Definition of the next instruction (statement) to be executed.
oShow next statement command: Jump to the instruction (statement) to be executed in the next step.
oCall Stack view: This view indicates the currently reached step position with the complete call path.
The possible stop positions when stepping through an application program depend on the editor type. The current position is indicated by the yellow arrow.
The Call Tree view shows the location of the function block in the call structure of an application program even before compiling the application.
Example of a Step Into Operation
Starting from the breakpoint you can execute each single command line with the stepping command.
Step Into, example
Data breakpoints allow you to stop program execution when the value of a variable changes.
This function is not available for all supported controllers. Consult the Programming Guide specific to your controller.
The number of data breakpoints you can define depends on the number of registers that is available in the controller you are using. A message is displayed when you attempt to set a data breakpoint and the maximum number has been reached.
The following options exist for data breakpoints as for normal breakpoints:
oLinking the halt at the data breakpoint to an additional condition, refer to Conditional Breakpoints.
oRedefining a data breakpoint to a data execution point where the program does not halt, but processes specific code, refer to Execution Points.
Breakpoints and Stepping in Applications with Multiple Tasks
Debugging cannot be performed on multiple tasks at the same time. While you are working on a task with breakpoints or stepping, breakpoints are ignored in other tasks.
If a breakpoint can be hit by multiple tasks, because the POU is used by multiple tasks, only the task that executes first will be halted. Consider this in case of single stepping or if you continue debugging after a halt. If only one certain task should be concerned (debug task), you can specify it in the breakpoint condition properties (Breakpoints > New Breakpoint dialog box, tab Condition).
Flow Control for Displaying Exact Values When Processing
You can activate flow control to track parts of the application that have already run. As opposed to standard monitoring, which displays only the variable value between two cycles, the flow control yields the value for each processing step at the moment it is rendered. Also refer to the Flow Control description in the Menu Commands Online Help.
Variable Values at Execution Stop
At every execution stop, EcoStruxure Machine Expert displays the values of variables in the current cycle (monitoring). To determine the current position, you can display the call stack of a variable. Also refer to the Call Stack description in the Menu Commands Online Help.