Text Editors

The text editors (the instruction list editor and the editor for Strucured text) of TwinCAT PLC Control offer the usual capabilities of Windows text editors. The implementation in the text editors is supported by syntax coloring.

Text Editors 1:

Text Editors for the Instruction List and Structured Text

The most important commands are found in the context menu (right mouse button or <Ctrl>+<F10>). The text editors use the following menu commands in special ways:

'Insert' 'Operator'

With this command all of the operators available in the current language are displayed in a dialog box. If one of the operators is selected and the list is closed with OK, then the highlighted operator will be inserted at the present cursor position.

'Insert' 'Operand'

With this command all variables in a dialog box are displayed. You can select whether you would like to display a list of the global, the local, or the system variables. If one of the operands is chosen, and the dialog box is closed with OK, then the highlighted operand will be inserted at the present cursor position.

'Insert' 'Function'

With this command all functions will be displayed in a dialog box. You can choose whether to have a list displaying user-defined or standard functions. If one of the functions is selected and the dialog box is closed with OK, then the highlighted function will be inserted at the current cursor position. If the With arguments option was selected in the dialog box, then the necessary input and output variables will also be inserted.

'Insert' 'Functionblock'

With this command all function blocks are displayed in a dialog box. You can choose whether to have a list displaying user-defined or standard function blocks. If one of the function blocks is selected and the dialog box is closed with OK, then the highlighted function block will be inserted at the current cursor position. If the With arguments option was selected in the dialog box, then the necessary input and output variables of the function block will also be inserted.

Calling POUs with output parameters

The output parameters of a called POU can be directly assigned upon being called in the text languages IL and ST. Example: Output parameter out1 of afbinst is assigned variable a.

IL: CAL afbinst(in1:=1, out1=>a) 
ST: afbinst(in1:=1, out1=>a);

The text editors in Online mode

The online functions in the editors are set breakpoint and single step processing (steps). Together with the monitoring, the user thus has the debugging capability of a modern Windows standard language debugger.

In Online mode, the text editor window is vertically divided in halves. On the left side of the window you will then find the normal program text; on the right side you will see a display of the variables whose values were changed in the respective lines.
The display is the same as in the declaration part. That means that when the PLC is running, the present values of the respective variables will be displayed.

The following should be noted when monitoring expressions or Bit-addressed variables: in the case of expressions, the value of the entire expression is always displayed. Example: a AND b is displayed in blue or with „:=TRUE“ if both a and b are TRUE. For Bit-addressed variables, the bit value that is addressed is always monitored (e.g. a.3 is displayed in blue or with „:=TRUE, if a has the value 4).

If you place the mouse pointer briefly above a variable, then the type and the comment about the variable will be displayed in a Tooltip.

'Extras' 'Monitoring Options'

With this command you can configure your monitoring window. In the text editors, the window is divided into two halves during monitoring. The pro-gram is located in the left half. In the right half, all variables that are located in the corresponding program line are monitored. You can specify the Monitor Window Width and which Distance two variables should have in a line. An distance declaration of 1 corresponds, in this case, to a line height in the selected font.

Text Editors 2:

Monitoring Options Dialog Box

Breakpoint Positions

Breakpoint PositionsSince in TwinCAT PLC Control several IL lines are internally combined into a single C-code line, breakpoints can not be set in every line. Breakpoint positions include all positions in a program at which values of variables can change or where the program flow branches off. (Exception: function calls. If necessary, a breakpoint in the function must be set here.) At the positions lying inbetween, a breakpoint would not even make sense, since nothing has been able to change in the data since the preceding breakpoint position. This results in the following breakpoint positions in the IL:

Structured text accommodates the following breakpoint positions:·

Breakpoint positions are marked by the display of the line number field in a darker gray.

Text Editors 3:

IL Editor with Possible Breakpoint Positions (darker number fields)
How do you set a breakpoint?

In order to set a breakpoint, click the line number field of the line where you want to set a breakpoint. If the selected field is a breakpoint position, then the color of the line numbers field will change from dark gray to light blue, and the breakpoint will be activated in the PLC.

Deleting Breakpoints

Correspondingly, in order to delete a breakpoint, click on the line number field of the line with the breakpoint to be deleted. Setting and deleting of breakpoints can also be selected via the menu ("Online" "Toggle Breakpoint"), via the function key <F9>, or via the symbol in the tool bar.

What happens at a breakpoint?

If a breakpoint is reached in the PLC, then the screen will display the break with the corresponding line. The line number field of the line where the PLC is positioned will appear in red.
The user program is stopped in the PLC. If the program is at a breakpoint, then the processing can be resumed with "Online" "Run".
In addition, with "Online" "Step over" or "Step in" you can cause the program to run to the next breakpoint position. If the instruction where you are located is a CAL command, or, if there is a function call in the lines up to the next breakpoint position, then you can use "Step over" to bypass the function call. With "Step in", you will branch to the open POU.

Line Number of the Text Editor

The line numbers of the text editor give the number of each text line of an implementation of a POU. In Off-line mode, a simple click on a special line number will mark the entire text line. In Online mode, the background color of the line number indicates the breakpoint status of every line:

In Online mode, simply clicking the mouse will change the breakpoint status of this line.