Editing Specific Inline Code
Editing Specific Inline Code
Editing Specific Inline Code
i
General information about specific inline code
These topics contain only information relevant for editing specific inline code statements and for
online monitoring of textual and graphical worksheets containing these statements. All procedures,
which are generally applicable are described in detail in the preceding topics of this chapter.
Specific inline code statements can be used in the textual language IL and the graphical language
LD. Specific means, that the statements are provided by a distinct PLC manufacturer and that they
are only applicable in conjunction with this specific PLC. For compiling and linking these inline code
statements the appropriate DLLs, delivered with the programming system are required.
In IL the specific statements are embedded in a code block, which uses the keywords
BEGIN_SPECIFIC and END_SPECIFIC to switch between the IEC mode and the specific mode.
In LD the programming system provides a so called arithmetic box, in which the specific code
statements has to be entered. This arithmetic box can be inserted already connected to an existing
LD network or as a single object, which has to be connected to the LD network using the
connection mode.
1
Editing specific inline code in IL
In IL the keywords BEGIN_SPECIFIC and END_SPECIFIC are used to define the code blocks
containing the specific code statements. These keywords indicate the switch between IEC mode
and the specific mode. They can be inserted by just typing them or using the Edit Wizard.
Following the start keyword BEGIN_SPECIFIC, which introduces programming in the specific
mode, the code statements has to be entered in the usual way, i.e. the complete text editor
functionality can be used when entering the specific code. When editing specific code comments
can also be inserted using asterisks and parentheses according to editing in IEC IL. Having entered
the statements the keyword END_SPECIFIC is required to finish the specific code block and to
switch back to the IEC mode.
In order to execute the statements in the specific code block, a condition must be loaded into the
accumulator in the preceding IEC IL, which decides whether the following specific code is executed
or not. If the preceding IEC IL operator returns the boolean value TRUE, the specific statements
are executed otherwise the code block is ignored.
For an example of an instruction list with embedded code statements click here.
LD X2
AND( X0
OR R0
)
ANDN R1
ST R0
LD TRUE
BEGIN_SPECIFIC (* introducing specific code *)
R1 = WX10 == WX20
R2 = WX10 < WX20
R3 = WX20 < WX10
END_SPECIFIC (* finishing specific code *)
Before editing specific inline code in IL you have to call the text editor with the IL worksheet, using
the project tree. To perform this, double click on the POU name in the project tree to open the
corresponding subtree which contains the relevant IL worksheet. Having performed this, double
click on the icon 'Worksheet in IL' in the project tree to open the worksheet.
When inserting the code block, the specific statements are only executed, if the preceding IEC IL
2
Editing specific inline code in IL Editing specific inline code in IL
If the Edit Wizard is not visible on your screen, press <SHIFT> + <F2> or click on the icon 'Edit
Wizard' in the toolbar:
The Edit Wizard is activated by clicking in the Edit Wizard or pressing <ALT> + <3>.
How to proceed:
• Locate the code body position, where the new code block (including the keywords
BEGIN_SPECIFIC and END_SPECIFIC) is to be inserted. Click the left mouse button to
set a text cursor.
• Open the Edit Wizard list box 'Group' and select the group 'Operators'. The available
operators are displayed in the selection area of the Wizard.
• Double click on the operator. The keywords BEGIN_SPECIFIC and END_SPECIFIC are
inserted automatically at the text cursor position.
Now you have to enter the specific code statements following the keyword BEGIN_SPECIFIC.
• Position the text cursor behind the keyword BEGIN_SPECIFIC and press <↵> to insert a
new line.
• Enter the specific code statements in the usual way using the complete text editor
functionality. Note that new statements has to start always in a new line. The following
figure shows how the specific code block is embedded in the IEC instruction list.
3
Editing specific inline code in LD
Editing the specific inline code in LD is done using a specific input dialog box, the so called
arithmetic box. The statements according to the specific code will be entered directly in this
arithmetic box. It includes a text editor functionality, which provides all standard functions of a
conventional text editor, such as copying, cutting, pasting etc. IEC comments are also possible
using parenthesis and asterisks. While editing in the arithmetic box a maximum of 19 code and
comment lines are allowed. If this maximum number is exceeded the following code lines are cut.
An arithmetic box can only be inserted in an existing LD network next to the right power rail, i.e.
there are no following objects possible on the right side of the arithmetic box. If you try to insert an
arithmetic box for example between two LD objects (e.g. two contacts) a collision message is
displayed.
The specific code entered in the arithmetic box is only executed, if the object left to the arithmetic
box returns the boolean value TRUE otherwise the specific code is ignored.
When editing specific code statements in LD in the arithmetic box, the programming system
provides a helpful syntax check function, which allows to check the entered statements directly
within in the arithmetic box. If the programming system detects any errors in the syntax the
corresponding dialog box is extended automatically by a new field containing the error and warning
messages detected by the check routines. The error handling is then equal to the error handling in
the general programming system, i.e. by double clicking on a particular error message, the
corresponding error is marked in the arithmetic box.
An arithmetic box can only be inserted in an existing LD network next to the right power rail, i.e.
there are no following objects possible on the right side of the arithmetic box. If you try to insert an
arithmetic box for example between two LD objects (e.g. two contacts) a collision message is
displayed.
The specific code entered in the arithmetic box is only executed, if the object left to the arithmetic
box returns the boolean value TRUE otherwise the specific code is ignored.
How to proceed:
• Click with the right mouse button on the LD object next to the right power rail to open its
context menu.
This means for the following example that contact 'C001' must return the boolean value
TRUE in order to execute the statements in the arithmetic box.
4
Editing specific inline code in LD Inserting an arithmetic box as a single object...
Or
Select the context menu item 'Inline Box...'.
The empty dialog 'Inline Code' appears.
• In the input field of the dialog enter the statements according to the specific code. IEC
comments are also allowed using parenthesis and asterisks. Note that a maximum of 19
code and comment lines are possible in the this field. If this maximum number is
exceeded the following code lines are cut.
• When you have finished entering the specific code, press the button 'Check' in the dialog
'Inline Code' to check the syntax of the entered code. If there are no syntax errors a box
with the message 'Check successful!' appears, otherwise the dialog box is extended
automatically by a new field containing the error and warning messages detected by the
check routines. Double clicking on a particular message in this field marks the related line
automatically in the arithmetic box.
• After editing and checking the specific statements confirm the dialog. The arithmetic box is
now inserted behind the marked LD object in the LD network.
Example:
If you want to edit the contents in the dialog 'Inline Code' just double click on the arithmetic
box in the LD network. The dialog is opened and you can edit the statements in the usual
way.
The height of the arithmetic box is automatically extended in accordance with the amount of lines.
Following objects underneath the edited arithmetic box are moved automatically.
How to proceed:
5
Editing specific inline code in LD Connecting an arithmetic box to an LD network
• Locate the position where you want to place the arithmetic box. Click into the worksheet to
set an insertion mark.
Or
Press the right mouse button to open the context menu of the worksheet (editor) and
select the context menu item 'Inline Box...'.
• In the input field enter the statements according to the specific code. IEC comments are
also allowed using parenthesis and asterisks. Note that a maximum of 19 code and
comment lines are possible in the input field. If this maximum number is exceeded the
following code lines are cut.
• When you have finished entering the specific code, press the button 'Check' in the dialog
'Inline Code' to check the syntax of the entered code. If there are no syntax errors a box
with the message 'Check successful!' appears, otherwise the dialog box is extended
automatically by a new field containing the error and warning messages detected by the
check routines. Double clicking on a particular message in this field marks the related line
automatically in the arithmetic box.
• After editing and checking the specific statements confirm the dialog. The arithmetic box is
inserted at the desired position.
In the next step you have to connect the arithmetic box to an existing LD network in order to create
a legal network.
The height of the arithmetic box is automatically extended in accordance with the amount of lines.
Following objects underneath the edited arithmetic box are moved automatically.
When connecting an arithmetic box to an LD network using the connection mode, the left (green)
connection point of the box must be connected to the output of an LD object, which represents the
condition, whether the inline code is executed or not. This means the previous LD object must
return the boolean value TRUE in order to execute the specific code statements.
Using the connection mode, objects can be linked only using a horizontal line. So your line should
start at the connection point of the arithmetic box and move away from the box in a horizontal way.
How to proceed:
6
Editing specific inline code in LD Connecting an arithmetic box to an LD network
• Move the mouse to the output of the last object in the LD network.
As the right power rail is an optional object, the right connection point of the arithmetic box must not
be connected to the right power rail. Nevertheless you can perform this connection also using the
connection mode.
• Move the mouse to the right power rail and press the right mouse button when the mouse
pointer is positioned on the power rail. The connection is established and the power rail is
extended automatically.
7
Online monitoring of worksheets containing specific
inline code
Related topics:
If you are compiling a project or parts of it containing specific code statements for the first time, in
many cases the compiler detects programming errors. In those cases a message appears in the
sheet 'Build' of the message window, announcing the number of detected errors and warnings. This
is regardless of whether the worksheets contain specific inline code or not. The corresponding error
messages are then displayed in the sheet 'Errors' of the message window.
According to the general error handling, you can open directly the worksheet or the arithmetic box
where the programming error is occurred by double clicking on the error message in the sheet
'Errors'. The corresponding line is marked automatically in the worksheet.
If the specific code statements in an arithmetic box in LD worksheets contain an error, double
clicking on the error message in the message window opens directly the arithmetic box and the
corresponding line in the box where the error was detected is marked.
Having compiled your project using the menu items in the submenu 'Build' and the compiler detects
no errors you have to download it to the simulation or PLC.
For detailed information about downloading a project to the PLC refer to the specific PLC help.
8
Online monitoring of worksheets containing specific inline code Online values in IL worksheets...
For a detailed description of calling worksheets in online mode and the notes you have to take into
account refer to the general PLC help.
How to proceed:
• If the desired worksheet is not yet opened, open the corresponding subtree in the project
tree, containing the desired worksheet by double clicking on the POU name.
Example:
• Click on the icon 'Debug on/off' in the toolbar to switch all worksheets in online mode.
For specific code statements the online values on the left side are displayed in the order of the
code statement variables as shown in the following figure. This means the first online value on the
left corresponds to the first variable on the right. In the following example the value 'FALSE' relates
to the variable 'R1'.
In general up to 4 values can be displayed at once for a single code statement line.
9
Online monitoring of worksheets containing specific inline code Online values in LD worksheets...
In the following figure, the mouse has been placed on the second line of the arithmetic box. The
tooltip values correspond to the PLC values in the order of displayed data, i.e. the first value 'TRUE'
relates to the variable 'R2' in the second arithmetic box code line. The values in the tooltip are
continuously updated, if the mouse cursor is not moved.
In general up to 4 values can be displayed at once for a single code statement line.
10