Stepwise processing of the program (stepping)
You can execute a PLC project step by step, navigating through the code. This is useful for determining the status of your code at runtime. You can examine the call sequence, track variable values or determine errors. For this purpose, step commands are available in the menu Debug. The commands become available when the program is at a defined program step (debug mode). During debug mode, the current stop position is highlighted in yellow and marked in the text editors with the symbol .
Switch to debug mode
- The PLC project is in online mode.
- 1. Set breakpoints in the POUs at the locations in the code you want to examine.
- 2. Start the program.
- The program starts, the code is processed to the first breakpoint. The project is now in debug mode.
- The editor with the current stop position is opened. The line of code with an active breakpoint, where the program execution was stopped, is highlighted in yellow and marked with the symbol (stop at breakpoint). The instruction has not been executed yet.
- You can select the different step commands or display the call stack.
Behavior of the step commands
- Command Step over ("Step Over")
- The instruction at the stop position is executed. The program stops before the next instruction in the programming block.
- If there is a call in the statement (from a program, a function block instance, a function, a method or an action), the subordinate programming block is completely traversed in one step.
- Command Step into ("Step Into")
- The instruction at the stop position is executed. The program stops before the next instruction.
- If there is a call in the instruction (from a program, a function block instance, a function, a method or an action), the program jumps to this subordinate programming block. The first instruction there is executed and the program is stopped before the next instruction. The new current stop position is then in the called programming block.
- Command Step out ("Step Out")
- The command executes the programming block from the current stop position to the end of the block and then jumps back to the calling programming block. At the call position (in the line with the call) the program is stopped.
- If the current stop position is in the main program, the programming block is run through to the end. Then the program jumps back to the beginning (to the program start at the first code line in the programming block) and stops there.
- Command Run To Cursor ("Run to Cursor")
- First place the cursor at any line of code and then select the command. The program is executed from the current stop position and stops at the current cursor position without executing the code of this line.
- Command Set next statement ("Set Next Statement")
- First place the cursor at any line of code (even before the current stop position) and then select the command. The instruction marked with the cursor will be executed next. All instructions in between are ignored and skipped.
- Command Show Next Statement ("Show Next Statement")
- If you do not see the current stop position, select the command. Then the window with the current stop position becomes active and the stop position becomes visible.
Select the command PLC > Window > Call Stack to display the previous call tree completely for the stop position currently reached in the program execution.
The Call Tree view therefore shows where the function blocks are located in the call structure of the program at all times, even before compilation of the PLC project. |