Running and debugging IEC 61131-3 programs
Running programs in the IDE
It is possible to compile and run POUs directly in the IDE, before generating the C code and cross-compile the binary file.
To run a program (in general, a POU), you can either:
right-click over the program file, in the Project
Explorer, select Run as... - GEB IEC-61131
- select from the main menu,
with the pou selected,
(Run- Run as... - GEB IEC-61131) or directly via the first menu option (Run - Run)
- press the (customizable) key shortcut Ctrl-F11
Actually, the direct "Run" command, from the menu or the Ctrl-F11 shortcut invokes the last "Run configuration". This is a standard Eclipse concept, which allows to create-edit-save-invoke several customized "launch configurations", for running or debugging. See the Eclipse help if you need more info.
A "Run" command will typically execute the program body and show in the console the values of its variables.
Bear in mind that the emulator that runs the IEC-61131 code is decoupled from the device definition, and hence it cannot emulate device-specific features of the project, such as mapping of directly represented variables, schedulling of POUs execution, etc.
Before run a program in Debug mode, you probably want to set some breakpoints first. See below to do this.
To run a program in Debug mode:
In Debug mode the IDE will suggest the user to switch to the "Debug perspective", which is recommended.
- right-click over the program file,
in the Project Explorer, select Debug as... - GEB IEC-61131
- select from the main menu,
with the pou selected, (Debug- Debug as... - GEB IEC-61131)
via the first menu option (Debug - Debug)
- press the (customizable) key shortcut F11
The execution will stop at the user defined breakpoints. From there, you can resume the execution or step over each instruction (F6). The Variables view will show the current values of each variable.
Setting breakpoints for debugging
Breakpoints can be set on instructions (in textual languages) or in graphical elements (in graphical languages).
- Textual languages:
double click on the left margin, in the GEB Text Editor, over the line to place the breakpoint. A blue circle will appear.
- Graphical languages: in the GEB Ladder Editor,
right click over the graphical element, and select "Toggle breakpoint". The elements with breakpoints will display a blue background.
Debugging with device I/O variables
IEC 61131-3 support directly addressed variables (digital and analog I/O, specific for the
device) are supported via AT addressing: eg, a variable declared as
X8 AT %IX8.2 : BOOL; would represent a digital input at some (device specific)
"address" 8.2. The real mapping and reading of that address is implemented in
the device code (provided by the OEM manufacturer), and takes place actually
when the executable runs on the real device. During simulation in the IDE,
these I/O variables (digital and analog) are displayed in a special panel,
and the values of the inputs can be change manually by the user, during the simulation.
The videos include a demo.