Skip to main content

Editor

The FBD/LD/IL editor is a combined editor for graphical programming of the function block diagram, ladder diagram, or instruction list.

Tip

IL can be enabled in the CODESYS options if required: In the FBD, LD and IL dialog, on the IL tab, select the Enable IL option.

There is a shared set of commands and elements and CODESYS automatically converts each of the three programming languages into the others internally.

The code in the implementation part is structured in all three languages by means of networks.

The FBD/LD/IL menu contains the commands for working in the editor.

In offline and online mode, you can use the command to toggle between the editor views at any time.

The behavior of the FBD/LD/IL editor is defined by the settings in Tools → Options, category FBD, LD and IL .

Important

There are some special elements which CODESYS cannot convert, and therefore it displays only in the applicable language. There are also constructs which are not clearly convertible between IL and FBD and are therefore "normalized" (nullified) when converted back to FBD. This concerns the negation of expressions and explicit/implicit assignment of function block inputs and outputs.

An error-free conversion between the languages requires syntactically correct code. Otherwise parts of the implementation can be lost.

FBD and LD editor

Inserting and arranging elements

You can drag elements from the ToolBox view into the implementation part of the editor. Alternatively, you could also use the commands of the context menu or the FBD/LD/IL menu.

Settings for the display and interface are defined in the  CODESYS-Options, Category FBD, LD and IL.

When you drag an element over a network in the editor, all possible insertion points are displayed with gray diamond-shaped, triangular, or arrow-shaped position marks. As soon as the mouse pointer is hovered over one of these marks, the mark turns green. Now when the mouse button is released, CODESYS inserts the element at this position.

Example 4. Example
_cds_img_ld_insert_positions.png


When you drag a function block or an operator from the ToolBox or a network at the left side of the network onto one of the two arrows, CODESYS automatically creates a new network and inserts the element there.

To replace an element, drag a suitable other element onto its position. Elements which you can replace by the new element are indicated by CODESYS in the editor with text fields (example: Replace, Attach input).

You can use the usual commands in the Edit menu to cut, copy, paste, and delete elements. Copying also works by dragging and dropping while holding down the Ctrl key.

Important

The operators with EN/ENO functionality can only be inserted in the FBD/IL editor.

Selecting elements

A box or a connecting line in the editor is selected by clicking it so that it is in focus. Multiselection is possible by holding down the Ctrl key. A selected element is shaded in red.

Tooltip

When the cursor points to specific elements (for example, to a variable or to an input), a tooltip displays information about this element.

In the case of elements underlined with a wavy red line, the tooltip shows the precompile error message of the error which occurs with this element.

Table 1. Navigating in the editor

Using the keys and commands described below, you can set the focus within the editor on a different cursor position. The switch between the positions also works across the entire network.

Switch to the adjacent cursor position, along the signal flow (from left to right, and right to left)

Switch to the next cursor position above or below the current position, if this adjacent position belongs to the same logical group

For example, all connections of a box form a logical group.

If such a logical group does not exist: change to the first cursor position in the next higher or lower adjacent element. In the case of parallel-connected elements, navigation is done along the first branch.

Ctrl+Home

Switch to the first network; this will be selected

Ctrl+End

Switch to the last network; this will be selected

Page Up ↑

Scroll up one page

The top network on this page is selected.

Page Down ↓

Scroll down one page

The bottom network on this page is selected.

Command: Go to

Switch to a specific network



Open function block

When a function block is inserted into the editor, you can double-click it or click the Browse → Go to Definition command in the context menu to open its implementation.

IL editor

For programming with the editor, see the following instructions: Programming in Instruction List (IL)

Inserting and arranging elements

You can insert elements with the help of the commands of the FBD/LD/IL menu of the context menu. You can also drag a new network from the ToolBox into the implementation part of the editor.

You can use the usual commands in the Edit menu to cut, copy, paste, and delete elements. Copying also works by dragging and dropping while holding down the Ctrl key.

Important

Note that operators with EN/ENO functionality can only be inserted in the FBD and IL editors.

Each program line is entered in a table row.

Table 2. Structure of networks in the IL editor

First line: Network title

Requirement: The option is enabled in the CODESYS options.

Second line: Network comment

Requirement: The option is enabled in the CODESYS options.

Third line and so on:

Column

Contents

Description

1

Operator

Contains the IL operator (LD, ST, CAL, AND, OR, etc.) or a function name

For more information, see: Modifiers and Operators in IL

When you call a function block, you also have to specify the corresponding parameters here, and in the preceding field you have to enter := or => in this case.

2

Operand

Contains exactly one operand or the name of a jump label

In the case of several operands, you have to enter them in multiple rows and when doing so insert a comma directly after the individual operands. (See example below)

3

Address

Contains the address of the operand as defined in its declaration

Not editable

You can use the Show symbol address option to enable or disable the display. To do this, click Tools → Options, the FBD, LD and IL editor category, and the General tab.

4

Symbol comment

Contains the comment which has been specified for the operand if necessary in the declaration

Not editable

You can enable or disable the display by means of the Show symbol comment option in Tools → Options, in the FBD, LD and IL editor category, on the General tab.

5

Operand comment

Comment for the current program line

You can enable or disable the display by means of the Show operand comment option in Tools → Options, in the FBD, LD and IL editor category, on the General tab.



Example 5. Example
_cds_img_il_example.png


Table 3. Navigating in the editor

Key(s)/command

Cursor movement

Jumps to the field located above or below

Tab

Jumps to the next field on the right within the row

Shift+Tab

Jumps to the previous field to the left within the row

Space

Opens the editing frame for the selected field. Alternatively, you could also click on the field. The button for the Input Assistant dialog may be available.

Ctrl+Enter

Inserts a new row below the current row

Del

Deletes the current row

Ctrl+Home

Sets the focus at the start of the document and marks the first network

Ctrl+End

Sets the focus at the end of the document and marks the last network

Page Down

Scrolls up one page and marks the top rectangle

Page Up

Scrolls down one page and marks the top rectangle