IEC 61131-3 Programming Environment

IEC 61131-3 Programming Environment

Previous chapter Next chapter Show all Show all Hide all Hide all

Warnning : Not all functions and not all features listed in this document are all supported by
ICP DAS Win-GRAF PACs. Some of them are not supported.
Please refer the PAC datasheet and Win-GRAF user manual for details.

In this section

The Workspace

The main window

Windows

Managing programs

Variable editor

Editing programs

Quick Search

Bookmarks

Project Settings

Build project

Configurations

On Line Change

Definitions

Running the application

Fieldbus configuration

Tools

Resources

Networked applications - Binding

Uploading projects source code

Libraries
Please contact us for any questions or comments: service@icpdas.com


The Workspace

IEC 61131-3 Programming Environment -> The Workspace

The Workbench enables you to edit several projects in the same workspace. Projects of the workspace are shown in the left-hand window of the Workbench, with their contents (programs, lists...). The set of projects edited in the Workbench is called "Project List" in menu commands.

Practically, each project is stored as a folder on the disk. Any relevant information about a project is stored with that folder. The list itself is stored in a file suffixed by ".W5L" that only stores the list of project folders and few configuration data. Thus projects can easily be moved / re-arranged in project lists. Project folders are commonly saved at the location as the .W5L file, but can also be located somewhere else on the disk or the network.

Working with project lists

Use the command of the "File" menu for managing project lists. You can add to project lists either new projects or projects already existing on the disk. When you remove a project from the list, the project folder is NOT deleted and remains on the disk.

The Startup project

One of the projects is marked as blod in the workspace window. This s the "Startup project". The Startup Project is the one used when entering On Line or Simulation modes. You can only test one project at a time. To change the Startup Project, select a project name in the Workspace window and use the command "Set As Startup Project" of the contextual right-click menu.

Recovering projects from older versions

To edit a project created with earlier versions of the Workbench, you must:

1- Create a new project list

2- Run the menu command "Add / Existing Project" and select the folder where the project is stored.

By creating a new project list, you will be prompted for specifying a .W5L filename for storing the list. It is recommended to store this file at the same location as the project folder.


The main window

IEC 61131-3 Programming Environment -> The main window

The toolbar of the main window is a control panel that groups main commands of the Workbench:

Icon | Description
 | Create a new document.
 | Open the selected document.
 | Save the active document.
 | Print the contents of the active window.
 | Cut the current selection.
 | Copy the current selection.
 | Paste the contents of the clipboard.
 | Delete the current selection.
 | Erase the contents of the active window.
 | Edit the list of I/O boards.
 | Run the fieldbus configurator.
 | Check the syntax of the active document.
 | Build projects (compile).
 | Batch download (download all edited projects)
 | Run the simulation.
 | Debug in connected On Line mode.

The window includes in its status bar a small box that enables searching for a text in the contents of the window.

Also displayed in the status bar are the communication parameters used for On Line test. Double click on this area of the status bar to change communication parameters.


Windows

IEC 61131-3 Programming Environment -> Windows

Here is the workspace of the Workbench and its main areas:

  1. Here you can open documents (programs, watch lists, graphics...)
  2. The workspace: documents are created and open from this list
  3. The output window reports messages and provide most of diagnostic tools
  4. The variable editor is used for declaring variables and instances
  5. The property grid and z-order panes are used for designing graphic documents
  6. The blocks pane lists all available functions and blocks you can use in programs
  7. The spy list enables quick dynamic watch of variables during debug
  8. The define pane shows various types of definitions
  9. The graphics pane lists all available kinds of graphic objects

Every fixed area (except area 1) can be hidden or shown using the commands of the View menu.

In the middle area are open documents of the workspace. In case several documents are open together, use the tab control at the bottom of the area to select the active document. Use the [image] button in the title bar to close the active document.

The variable editor and document windows in the middle area can be maximized at any moment by clicking the [image] button or double clicking in their title bar.

When several documents are open in the middle area, you can lock one of them at the top or on the left of the area. For that, right click on the corresponding tab and select Lock. The same menu enables you at any time to unlock the document or lock another one:

The active document is written bold in the tab list. The locked document is written in italic.


Managing programs

IEC 61131-3 Programming Environment -> Managing programs

Programs are managed from the Workspace area on the left of the Workbench main window. To work with programs, activate the workspace area and use the Increase/Decrease buttons when the Period or Phase column is select the Programs tab in it.

Here you can declare an manage the programs and User Defined Function Blocks (UDFBs) of your application. The workspace shows the list of all programs and UDFBs, initially sorted by alphabetic order.

Creating programs

Icon | Description
 | Press this button in the toolbar for creating a new program. You have to select its language at this time. The programming language of a program can be changed later by converting the program. You can also declare a child program for a selected SFC program.

When you create a program or UDFB, you have to enter its properties. A wizard guides you for defining:

  • the identification and main attributes of the program
  • its advanced parameters for its execution at runtime
  • its description

The same box can be used later to rename a program, change its properties and its description.

The box also includes a wizard for defining/arranging input and output parameters in case of a UDFB or sub-program

The program property box can also be used for protecting the program against editing.

Programs must have unique names. The name cannot be a reserved keyword of the programming languages and cannot have the same name as a standard or "C" function or function block. A variable should not have the same name as a declared variable The name of a program should begin by a letter or an underscore ("_") mark, followed by letters, digits or underscore marks. It is not allowed to put two consecutive underscores within a name. Naming is case insensitive. Two names with different cases are considered as the same.

Opening programs

Press Enter or double click on a program to open it with the appropriate editor. An open program cannot be renamed or deleted.

Copying programs

Use the File / Copy command for duplicating the selected program. Copy cannot be used for erasing an existing program. You must enter a new name for the destination of the copy.

Arranging programs in folder

Default workspace shows all programs in alphabetic order. You can freely arrange them in a tree by creating folders. Use the New folder command in the right-click popup menu to create a new folder. Simply click on its name to rename it. You can create several levels of folders.

Then, simply drag programs in folders to re-arrange the tree. Programs, sub-programs and UDFBs can be put together in the same folder. Within a folder, all items are sorted in alphabetic order.

Defining the execution sequence

Use the Cycle command in the context menu to define the execution order of various programs in a seperate box. The box shows the list of the main programs, as they will be executed in runtime cycles. You can:

  • use the Move buttons to change the order of the programs within the cycle.
  • use the Select buttons to specify if the program must be called in the cycle. Unselected programs are not kept at compiling time, and are shown with a red cross icon in the workspace.
  • use the Increase/Decrease buttons when the Period or Phase column is selected to change the scheduling of a program. This enables you to define "slow" programs that are not called on every cycle. See the Program advanced properties for further details.

In this section

Program properties

Program properties - input/output parameters

Program properties - advanced

Program properties - description

Protecting a program

Converting a program to another language


Program properties

IEC 61131-3 Programming Environment -> Managing programs -> Program properties

Previous chapter Next chapter Show all Show all Hide all Hide all

This box enables you to define the properties of a program or function block. Refer to the description of Program Organization Units (POU) for further description of different kings of POUs.

A program is identified by a unique name and a single line description text. The name of a program should begin by a letter or an underscore ("_") mark, followed by letters, digits or underscore marks. It is not allowed to put two consecutive underscores within a name. Naming is case insensitive. Two names with different cases are considered as the same.

When you create a new POU, you have to select its programming language. The programming language cannot be changed later.

Then you must choose a execution style for the POU:

  • Main program (called in the cycle)
  • Sub-program (explicitely called by other programs)
  • UDFB (User Defined Function Block)
  • Child SFC program (activated by its parent SFC program)

For a CHILD SFC program, you have to select its parent SFC program. This parent can be changed later.


Program properties - input/output parameters

IEC 61131-3 Programming Environment -> Managing programs -> Program properties - input/output parameters

Previous chapter Next chapter Show all Show all Hide all Hide all

From the Program Properties wizard, you can easily define and arrange input and output parameters of a UDFB or sub-program.

The wizard shows you 2 lists of parameters, for inputs and outputs. Each parameter has a name, a data type and a dimension, plus a text description. Use the following commands in the wizard:

Edit: Press this button for changing the definition of the selected parameter. Pressing this button when the last line (...) of the list is selected enables you to add a new parameter.

Delete: Press this button to remove the selected parameter.

Move Up / Down: Press these buttons to move the selected parameter in the list and thus arrange the order of parameters. The order has a strong importance as it defines the calling prototype of the UDFB or sub-program.

info Info

Input/output parameters can also be entered directly in the variable editor.


Program properties - advanced

IEC 61131-3 Programming Environment -> Managing programs -> Program properties - advanced

Previous chapter Next chapter Show all Show all Hide all Hide all

This box enables you to enter advanced properties for a main program.

For a main program, you can decide whether it is enabled or disabled. If disabled, the program is not included in the application code by the compiler.

Execution mode

You can define various sampling periods for programs of the application. Default period is "1": the program is executed on each cycle. Giving slower period to some programs is an easy way to give higher priority to some other programs. Here you can define:

  • A period (how many cycles between two executions of the program)
  • A phase (an offset that enables to dispatch slow programs among few cycles)

Advanced

These parameters are reserved for some specific runtimes and should never be changed when using a standard Win-GRAF PAC driver system.


Program properties - description

IEC 61131-3 Programming Environment -> Managing programs -> Program properties - description

Previous chapter Next chapter Show all Show all Hide all Hide all

In addition to the single line description entered in the main page, you can here enter a complete multiline description text where you can:

  • Describe the behaviour and programming.
  • Add some modification tracking notes.
  • Add some guidelines if the POU is aimed to be used in other applications.


Protecting a program

IEC 61131-3 Programming Environment -> Managing programs -> Protecting a program

Previous chapter Next chapter Show all Show all Hide all Hide all

The Security tab in the Program properties dialog box enables you to protect a program, sub-program or UDFBs against editing.

To protect the program, press the Set protection button and enter a password. The program is then encrypted. A protected program cannot be open anymore for editing. Its variables remain visible in the variable editor but cannot be modified.

To remove the protection, press the Remove protection button and enter the password specified when protection was set. The program is then decrypted and becomes available again for editing and modifications.

info Info

An encrypted program is not taken into account by the following tools:

  • Find / Replace in files.
  • Project comparison.
  • Building monitoring applications.
  • Generation of HTML documents.
  • Step by step debugging.


Converting a program to another language

IEC 61131-3 Programming Environment -> Managing programs -> Converting a program to another language

Previous chapter Next chapter Show all Show all Hide all Hide all

The Workbench includes a powerful feature that enables you to convert a program written in an IEC language to another language. When a program is selected in the Workspace or is open for editing, use the commands of the Tools / Convert program menu to convert it.

Any conversion in between ST, IL, LD and FBD are possible. Conversion of SFC programs is not allowed. Converted POUs can be main programs, UDFBs or sub-programs.

The program must be saved and the project built without errors before converting a program.

When a program is converted to another language, its former implementation in the original language is kept until you make a change in the converted program. Thus, if you re-convert it back to the original language, you get 100% of the original contents.

info Info

When a program is converted, some presentation items (such as blank lines in ST or specific alignment in FBD) are lost.

It is possible that converting a language requires some new intermediate variables to be declared. Such variables are declared locally to the program and are prefixed with "_T".


Variable editor

IEC 61131-3 Programming Environment -> Variable editor

Variables are declared in the top/right area of the Workbench main window.

The variable editor is a grid tool that enables you to declare all variables of the application. Variables in the editor are sorted by groups:

  • Global variables.
  • "Retain" non volatile global variables.
  • I/O variables (each I/O device is a group).
  • variables local to a program (including in and out parameters in case of a UDFB).

Please refer to the description of variables in the language reference for a more detailed overview.

Each group is marked with a gray header in the variable list. The "-" or "+" icon on the left of the group header can be used to expand or collapse the group:

Double clicking the header line enables you to sort, show or hide columns, and to apply a filter for each column. Filter is described as a text string that may contain '?' and '*' wildchars.

Using the grid:

Each variable is described with:

creating new variables
using the editing grid
sorting variables of a group

defining I/O devices
editing as text
bookmarks
  • a name
  • a data type and a dimension
  • an attribute
  • an initial value
  • a tag and a description text
  • OEM defined properties
  • a user group (*)

info Info

Use the Syb column to specify if the variable symbol must be embedded, such as defined in the variable properties.

(*) The user group enables logical sorting of variables in the grid.

In this section

Creating new variables

Variable list - active grid

Sorting variables

Naming a variable

Variable data type and dimension

Attributes of a variable

Initial value of a variable

Variable tag and description

I/O devices

Variable properties

Editing variables as text


Creating new variables

IEC 61131-3 Programming Environment -> Variable editor -> Creating new variables

Previous chapter Next chapter Show all Show all Hide all Hide all

Hit INSERT key in the variable editor to create a new variable in the selected group. The variable is added at the end of the group. Variables are created with a default name. You can rename a new variable or change its attribute using the variable editing grid.

You cannot insert a new variable in an I/O group.

In case of a group corresponding to local variables of a UDFB, pressing the INSERT key gives you the choice between:

  • adding an IN (input) parameter.
  • adding an OUT (output) parameter.
  • adding a private variable.

IN and OUT parameters always appear at the beginning of a UDFB group.


Variable list - active grid

IEC 61131-3 Programming Environment -> Variable editor -> Variable list - active grid

Previous chapter Next chapter Show all Show all Hide all Hide all
Icon | Description
 | Press this button or hit SPACE bar to enable or disable the active grid.

The variable editor enables you to enter directly each piece information in the cells of an active grid. The active grid can be activated or disabled at any moment.

When the active grid is disabled, modifying a variable is done through a dialog box. Press the ENTER key when the grid is inactive to open the variable setting box.

When the active grid is active, the name of the selected column is displayed in bold characters. The text of selected cell (or ". . ." if empty) is marked in bold yellow characters:

At any time you can drag with the mouse column separators in the main grid header for resizing columns.

Press the following keys for browsing groups of variables:

Shortcut | Description
Ctrl + Page Up | Move the selection to the head of the previous group.
Ctrl + Page Down | Move the selection to the head of the following group.


Sorting variables

IEC 61131-3 Programming Environment -> Variable editor -> Sorting variables

Previous chapter Next chapter Show all Show all Hide all Hide all

At any moment you can sort variables of a group according to their name, type or dimension. For that you simply need to:

  1. Move the cursor to the header of the group.
  2. Click on the name of the wished column.

The workbench always keeps the original order of declared variables, in order to allow safe On Line change. Each time you insert a new variable or expand/collapse a group, the original sorting is re-applied.


Naming a variable

IEC 61131-3 Programming Environment -> Variable editor -> Naming a variable

Previous chapter Next chapter Show all Show all Hide all Hide all

To change the name of the variable, enable the modification mode in the grid and move the cursor to the selected name cell. Then press ENTER or hit the first character of the new name. Name is entered in a small box. Hit ENTER to validate the name or ESCAPE to cancel the change.

A variable must be identified by a unique name within its parent group. The variable name cannot be a reserved keyword of the programming languages and cannot have the same name as a standard or "C" function or function block. A variable should not have the same name as a program or a user defined function block.

The name of a variable should begin by a letter or an underscore ("_") mark, followed by letters, digits or underscore marks. It is not allowed to put two consecutive underscores within a variable name. Naming is case insensitive. Two names with different cases are considered as the same.

Naming Physical I/Os

Each I/O channel as a predefined symbol that reflects its physical location. This symbol begins with "%I" for an input and "%Q" for an output, followed by a letter identifying the physical size of the data. Refer to the description of variables for more details.

You cannot change the "%..." name of an I/O variable. This name is directly allocated according to the I/O devices defined in the I/O device list. But you can give an alias (a readable name) to each I/O channel. In that case, either the "%" name or the alias can be used in programs with no difference. The alias must fit to the same rules as a variable name.

When an alias is defined for a variable, both "%..." name and alias are displayed in the name column of the grid.


Variable data type and dimension

IEC 61131-3 Programming Environment -> Variable editor -> Variable data type and dimension

Previous chapter Next chapter Show all Show all Hide all Hide all

To change the type and dimension of the variable, enable the modification mode in the grid and move the cursor to the appropriate cell and press ENTER.

Each variable must have a valid data type. It can be either a basic data type or a type of function block or UDFB. Changing the data type of an I/O variable is restricted by the physical implementation of the I/O device.

If the selected data type is STRING, you must specify a maximum length, that cannot exceed 255 characters.

Additionally, you can specify dimension(s) for an internal variable, in order to declare an array. Arrays have at most 3 dimensions. All indexes are 0 based. For instance, in case of single dimension array, the first element is always identified by ArrayName[0]. The total number of items in an array (merging all dimensions) cannot exceed 65535.

Using the variable editor, you must enter integer dimensions separated by comas. For instance: 3,10,5.


Attributes of a variable

IEC 61131-3 Programming Environment -> Variable editor -> Attributes of a variable

Previous chapter Next chapter Show all Show all Hide all Hide all

Each variable has an attribute displayed in the corresponding column of the grid. Physical I/Os are marked as either Input or Output. Inputs are read-only variables. For each internal variable, you can select the Read Only. Otherwise, the attribute column of an internal variable is empty. Parameters of User Defined Function Blocks are marked as either IN or OUT.

To change the attribute of an internal variable, enable the modification mode in the grid and move the cursor to the selected attribute cell. Then press ENTER to set or reset the Read Only attribute.


Initial value of a variable

IEC 61131-3 Programming Environment -> Variable editor -> Initial value of a variable

Previous chapter Next chapter Show all Show all Hide all Hide all

A variable may have an initial value. The value must be a valid constant expression that fits to the data type of the variable. The initial value is displayed in red if it is not a valid expression for the selected data type.

There is no initial value for arrays and instances of function blocks.

To change the initial value of a variable, enable the modification mode in the grid and move the cursor to the selected init value cell. Then press ENTER to enter the new value.


Variable tag and description

IEC 61131-3 Programming Environment -> Variable editor -> Variable tag and description

Previous chapter Next chapter Show all Show all Hide all Hide all

The workbench enables you to freely enter for each variable two strings that describe the variable:

  • The Tag is a short comment, that can be displayed together with the variable name in graphic languages.
  • The Description is a long comment text that describes the variable.

To change the tag or description the of a variable, enable the modification mode in the grid and move the cursor to the corresponding cell. Then press ENTER to enter the new text.


I/O devices

IEC 61131-3 Programming Environment -> Variable editor -> I/O devices

Previous chapter Next chapter Show all Show all Hide all Hide all
Icon | Description
 | Press this button in the main window to open the I/O device editor.

The I/O device editor is run is a separate box. It is used for declaring and setting up I/O devices, and establish the link between the application variables and physiqual equipment.

The list shows the possible slot numbers between 0 and 255. Select a slot and:

  • Hit ENTER for selecting or changing the type of I/O device to be put on this slot. In the selection box, I/O devices are sorted by categories. Select the All choice for displaying the full list of available devices. The description note of the selected device is displayed in the selection window. Double click on a device or hit ENTER to select it. Press ESCAPE to cancel the operation.
  • Run Edit / Rename menu command to change the name of the device. You can freely give any name to each I/O device.
  • Hit Alt+ENTER or run Edit / Properties menu command to setup the physical properties of the device. Refer to OEM instructions for detailed explanation about I/O device properties.
  • Hit SPACE bar to set the selected I/O device as Virtual or Real (normal). A virtual device is disconnected from physical operations and is managed as group of internal variables at run-time Using virtual devices enables you to test your application even if the actual hardware is not available. Virtual devices are marked in blue and between parenthesis in the device list:

There can be either simple or complex I/O devices. A simple I/O device is a group of I/O channel. All channels of the group have consistent data types, the same direction (input or output), and are numbered from 0. A complex I/O device is a list of simple devices, and generally represents a mixed type/direction equipment.


Variable properties

IEC 61131-3 Programming Environment -> Variable editor -> Variable properties

Previous chapter Next chapter Show all Show all Hide all Hide all

The workbench enables you to embed in the application code extra information for each variable. Run the Edit / Properties when a variable is selected in the grid to edit its properties in a separate box. You also can set the View / Properties menu option to display variable properties in one more column in the grid.

Publishing properties

Select the Publishing tab to enter the pieces of information you want to embed in the target application and publish for extra embedded software. For each variable, you can embed:

  • Its symbol.
  • A profile name.
  • A list of OEM defined properties.

The list of properties is entered in the grid at the bottom of the box, and corresponds to the selected profile. Refer to OEM instructions for further description of available profiles.

To change a value in the property list, double click on a line, or hit the first character of the value. Press ENTER to validate a value or ESCAPE to cancel the change.

seealso See also

Fieldbus configuration


Editing variables as text

IEC 61131-3 Programming Environment -> Variable editor -> Editing variables as text

Previous chapter Next chapter Show all Show all Hide all Hide all

As an alternative to the user friendly grid for editing variables, it is possible to declare variables as text. Text editing applies to all the variables of a group. It cannot be an I/O group. During text editing, the group and all its variables are locked in the grid so that no change can be entered from other windows.

To edit a group of variable as text, select the group in the grid and run the Tools / Edit variables as text menu command.

Sereval syntaxes are available for describing variables:

Syntax | Description
IEC61131-3 | The original IEC61131-3 syntax for declaring variables
XML tags | An easy XML structure using tags and attributes
CSV | CSV format (separator: semicolon)

In this section

Editing variables as text using IEC61131-3 syntax

Editing variables as XML tags

Editing variables as text in CSV format


Editing variables as text using IEC61131-3 syntax

IEC 61131-3 Programming Environment -> Variable editor -> Editing variables as text -> Editing variables as text using IEC61131-3 syntax

Previous chapter Next chapter Show all Show all Hide all Hide all

Using IEC61131-3 syntax, variables are declared within structured blocks. Each blocks begins with VAR, VAR_INPUT, VAR_OUTPUT or VAR_EXTERNAL keyword and ending with END_VAR keyword (with no semicolon after). Below is the meaning of each keyword:

Keyword | Description
VAR | Memory variables. Can be global, local or RETAIN depending on the edited group.
VAR_INPUT | Input parameters of a block. Available only when the edited group is a UDFB.
VAR_OUTPUT | Output parameters of a block. Available only when the edited group is a UDFB.
VAR_EXTERNAL | External variables. Can be global or local depending on the edited group.

Basic syntax for declaring a variable

To declare a variable, simply enter its symbol, followed by ":" and its data type. If the data type is STRING, it must be followed the maximum length between parenthesis.

Example Example

MyVar : BOOL;
MyString : STRING(255);

To indicate that a variable has the read only attribute, insert the CONSTANT keyword at the beginning of the variable declaration:

CONSTANT VarName : DataType;

To declare an array, the data type must be preceeded by ARRAY [ dimensions ] OF. There are at most 3 dimensions, separated by comas. Each dimension is specified as 0 .. MaxBound.

Example Example

Array1 : ARRAY [0 .. 99] OF DINT;
Matrix : ARRAY [0 .. 9, 0 .. 9, 0 .. 9] OF REAL;

Additionaly, you can specify an initial value for single variables. The initial value is entered after the data type, and is preceeded by ":=". The initial value must be a valid constant expression that fits the data type.

Example Example

MyBool : BOOL := TRUE;
MyString : STRING(80) := 'Hello';
MyLongReal : LREAL := lreal#1.0E300;

Additional information and description texts

As a variable may have additional properties and comment texts in the Workbench, we use special directives entered as IEC comments AFTER the declaration of the variable, to specify additional info. The following directives are available:

Directive | Description
(*$tag=Text*) | Variable tag (short comment).
(*$desc=Text*) | Variable description.
(*$profile=ProfileName*) | Variable embedded profile.
(*$embed=Text*) | Variable embedded properties (the syntax is the one shown in the variable grid, in the Property column).

You can also use "//" single line comments to enter the directives:

//$tag=Text
//$desc=Text
//$profile=ProfileName
//$embed=Text


Editing variables as XML tags

IEC 61131-3 Programming Environment -> Variable editor -> Editing variables as text -> Editing variables as XML tags

Previous chapter Next chapter Show all Show all Hide all Hide all

You can describe variable using a simple XML structure, where each variable is described as an XML tag. The file must fit the baisc XML syntax. Values of tag attributes mus be entered between double quotes. Characters < > " ' & are reserved to XML and cannot appear in values of tag attributes. Instead you should use the following sequences:

Character | Sequence
< | &lt;
> | &gt;
" | &quot;
' | &apos;
& | &amp;

Below is the tag structure for variable declaration:

<k5project>
|
+-<vargroup>
|
+-<var>*
|
+-<varinfo>*

(the "*" mark indicates that the tag can appear 0 or more times)

The rest of this page describes the format and meaning of each tag:

<k5project>

This tag must be entered at the top level and is unique. It is reserved for extensions (enhancement of the XML structure), and specifies the version of the syntax. Its attributes are:

Attribute | Description
version | Reserved for future extensions. This attribute is mandatory and must be "1.0".

The <K5Project> tag contains one <vargroup> tag.

<vargroup>

This tag must appear with the <K5Project>, and contains all <var> tags for variables of the group. In this version, the tag has no attribute (the name of the group is implicit).

<var>

This tag describes the basic definition of one variable. Its attributes are:

Attribute | Description
name | Symbol of the variable. This attribute is mandatory.
type | Name of the data type of the variable. This attribute is mandatory.
len | Maximum length if the data type is STRING. This attribute is mandatory for STRING variables, and should not appear for other data types.
dim | Dimension(s) if the variable is an array. There are at most 3 dimensions, seperated by comas. This attribute is optionnal.
attr | Attributes of the variable, separated by comas. Possible values are: IN: this is an INPUT parameter (for UDFBs only). OUT: this is an OUTPUT parameter (for UDFBs only). external: this is an external variable. constant: variable is read only. This attribute is optional.
init | Initial value of the variable. Must be a valid constant expression that fits the data type. This attribute is optionnal.

The <var> tag contains zero or more <varinfo> tags.

<varinfo>

This tag indicates an additional info for the variable it belongs to. Its attributes are:

Attribute | Description
type | Type of information contained in the data attribute. Possible values are: tag: variable tag (short comment). desc: description. profile: name of the embedded profile. embed: set of embedded properties. This attribute is mandatory.
data | Data specified y the type attribute, in text format. This attribute is mandatory.


Editing variables as text in CSV format

IEC 61131-3 Programming Environment -> Variable editor -> Editing variables as text -> Editing variables as text in CSV format

Previous chapter Next chapter Show all Show all Hide all Hide all

Using CSV format, each variable is defined on one line of text. Each component of the variable definition is entered as one CSV element. CSV elements are separated by semicolons. Each element is written between double quotes. A double quote within an element is represented by two double quotes. CSV format is an easy way to exchange variable declaration with Spreadsheet applications.

It is not mandatory that all elements (all columns) appear in the text. The first line must contain the list of columns used, using the following keywords:

Keyword | Description
name | Symbol of the variable. This item is mandatory.
type | Name of the data type. This item is mandatory, and must appear before len, dim and init columns.
len | String length if the data type is STRING. This item must be empty for other data types.
dim | Dimensions in case of an array. There are at most 3 dimensions, separated by comas.
attr | Attribute of the variable, can be: IN: input parameter of a UDFB. OUT: output parameter of a UDFB. external: extern variable.
RO | If YES indicates that the variable has the read-only attribute. (Note: you can also use TRUE or 1 value)
init | Initial value of the variable. Must be a valid constant expression that fits the data type.
tag | Short description text.
desc | Description text.
profile | Name of the embedded profile.
embed | Embedded properties (same syntax as displayed in the variable editor grid).

Below is an example of CSV text for the declaration of 3 variables, with some columns missing:

Example Example

"name","type","len","attr","RO"
"MyVar","BOOL","","","NO"
"ExtVar","DINT","","external","YES"
"MyStr","STRING","10","","NO"


Editing programs

IEC 61131-3 Programming Environment -> Editing programs

The Programming environment provide language dedicated editors for:

Sequential Function Chart (SFC)
Function Block Diagram (FBD)
Ladder Diagram (LD)
Structure Text (ST) and Instruction List (IL)

Please refer to the following topics for common features:

Selecting function blocks
Selecting variables and instances
Quick Search
Bookmarks

The editor provides you the ideal programming environment with drag and drop features:

  • Drag a variable from the list to the program to insert it.
  • Drag a definition to the program to insert its name.
  • Drag a block in the program to insert it.
  • Drag a function block to the variable list to declare an instance.
  • Drag a variable from the program or from the variable list to the spy list.
  • Double click on a line of the output window to highlight the corresponding code.

In this section

Sequential Function Chart (SFC) Editor

Function Block Diagram (FDB) Editor

Ladder Diagram (LD) Editor

Structured Text (ST) / Instruction List (IL) Editor

Selecting function blocks

Selecting variables and instances


Sequential Function Chart (SFC) Editor

IEC 61131-3 Programming Environment -> Editing programs -> Sequential Function Chart (SFC) Editor

Previous chapter Next chapter Show all Show all Hide all Hide all

The Workbench proposes two different editors for entering Sequential Function Chart (SFC) programs:

Grid Editor

The Grid editor supports advanced graphic features such as drag and drop, so that you can rapidly and freely arrange the elements of your diagram in a grid. It also supports easy keyboard shortcuts and automatic chart formatting when inserting or deleting items and thus enables quick input using the keyboard.

Free Form Editor

The Free form editor supports advanced graphic features such as drag and drop, and let you free to arrange steps and transitions within a graphic layout.

info Info
  • The editor is selected when creating the program.

In this section

SFC Grid Editor

SFC Free Form Editor

Using the SFC toolbar

Drawing SFC divergences

Viewing SFC charts

Moving and copying SFC charts

Renumbering steps and transitions

Entering actions of a step

Entering the condition of a transition

Entering notes for steps and transitions


SFC Grid Editor

IEC 61131-3 Programming Environment -> Editing programs -> Sequential Function Chart (SFC) Editor -> SFC Grid Editor

Previous chapter Next chapter Show all Show all Hide all Hide all

The SFC grid editor is a powerful graphical tool that enables you to enter and manages Sequential Function Chart according to the IEC 61131-3 standard. The editor supports advanced graphic features such as drag and drop, so that you can rapidly and freely arrange the elements of your diagram. It also supports automatic chart formatting when inserting or deleting items and thus enables quick input using the keyboard.

SFC diagram components | Related sections
Steps Transitions Divergences Parallel branches Jump to a step Actions Conditions Timeout check | Using the SFC toolbar Drawing divergences Viewing the chart Moving or copying parts of the chart Entering macro-steps Renumbering steps and transitions Entering actions of a step Entering condition of a transition Notes for steps and transitions Bookmarks

info Info
  • To change the number of a step, transition or jump, select it and hit Ctrl+ENTER keys.
  • Hit SPACE bar on the main corner (on the left) of a divergence or convergence to set double/single horizontal line style.


SFC Free Form Editor

IEC 61131-3 Programming Environment -> Editing programs -> Sequential Function Chart (SFC) Editor -> SFC Free Form Editor

Previous chapter Next chapter Show all Show all Hide all Hide all

The SFC Free Form editor is a full graphical mouse driven editor that enables you to enter and manages Sequential Function Chart according to the IEC 61131-3 standard. The editor supports advanced graphic features such as drag and drop, and let you free to arrange steps and transitions within a graphic layout.

SFC diagram components | Related sections
Steps Transitions Divergences Parallel branches Actions Conditions Timeout check | Using the SFC toolbar Viewing the chart Moving or copying parts of the chart Renumbering steps and transitions Entering actions of a step Entering condition of a transition Notes for steps and transitions Bookmarks

You can simply drag items (step, transition, jump) from the editor toolbar to the graphic layout to insert objects. Objects can then be freely moved by drag and drop.

You must draw links by dragging with the mouse from an item to another in the direction of the flow. When you put the mouse cursor over a step or transition, a green mark indicates you from where dragging a new link.

To draw a divergence or convergence, simply link items together (for instance from a step to several transitions). The editor will take care of drawing horizontal lines. When a link is selected you can move its segments using the mouse in order to change its routing.


Using the SFC toolbar

IEC 61131-3 Programming Environment -> Editing programs -> Sequential Function Chart (SFC) Editor -> Using the SFC toolbar

Previous chapter Next chapter Show all Show all Hide all Hide all

The vertical toolbar on the left side of the editor contains buttons for inserting items in the chart. Items are always inserted before the selected item. The chart is automatically rearranged when a new item is inserted.

Icon | Description
 | Insert an initial step.
 | Insert a Step.
 | Insert a transition.
 | Insert a jump to a step.
 | Insert the main (left side) corner of a divergence or convergence.
 | Insert a divergence corner.
 | Insert a convergence corner.

Use the following keyboard commands when an item is selected:

  • ENTER: edit the level 2 of a step or transition.
  • Ctrl+ENTER: change the number of a step, transition or jump.

The last button of the toolbar enables you to switch between possible displays:

Icon

Description

Swap between possible overviews of level 2 in the level 1 chart:

  • Display code of actions and conditions.
  • Display notes attached to steps and transitions.


Drawing SFC divergences

IEC 61131-3 Programming Environment -> Editing programs -> Sequential Function Chart (SFC) Editor -> Drawing SFC divergences

Previous chapter Next chapter Show all Show all Hide all Hide all

When using the SFC editor, you just need to place items in the grid. The editor calculates and draws lines automatically to link steps, transitions and jumps you place in the chart.

The same method is used for drawing divergences: you just need to place the corners that identifies divergences, convergences and branches. The editor takes care of drawing vertical and horizontal lines. Use the following buttons in the SFC toolbar:

Icon | Description
 | Insert the main (left side) corner of a divergence or convergence.
 | Insert a divergence corner.
 | Insert a convergence corner.

attention Attention

Divergences are always drawn from the left to the right. The first branch, on the left, contains the corners that identify the divergence. It must be aligned with the previous step or transition:

How to proceed

  1. Insert the main corner (on the left side branch) of the divergence and the convergence.
  2. Insert corners at the top of each branch (divergence).
  3. Insert corners at the bottom of the branches where a divergence is wished.

Simple or double divergence lines

You can change the drawing of a divergence or convergence horizontal line, for drawing simple or double lines according to SFC definition. To do that, move the selection on the main corner (on the left) and hit the SPACE bar.


Viewing SFC charts

IEC 61131-3 Programming Environment -> Editing programs -> Sequential Function Chart (SFC) Editor -> Viewing SFC charts

Previous chapter Next chapter Show all Show all Hide all Hide all

The chart is entered in a logical grid. All objects are snapped to the grid. You can use the commands of the View menu for displaying of hiding grid lines. The (x,y) coordinates of the mouse cursor are displayed in the status bar. This helps you locating errors detected by the compiler, or aligning objects in the chart.

At any moment you can use the commands of the View menu for zooming in or out the edited chart. You also can press the [+] and [-] keys of the numerical keypad for zooming the diagram in or out.

You also can drag the separation lines in vertical and horizontal rulers to freely resize the cells of the grid:

The SFC editor adjusts the size of the font according to the zoom ratio. When cells are wide enough, a text overview with the contents of the step or transition (level 2). The last button of the toolbar enables you to switch between possible displays:

Icon

Description

Swap between possible overviews of level 2 in the level 1 chart:

  • Display code of actions and conditions.
  • Display notes attached to steps and transitions.


Moving and copying SFC charts

IEC 61131-3 Programming Environment -> Editing programs -> Sequential Function Chart (SFC) Editor -> Moving and copying SFC charts

Previous chapter Next chapter Show all Show all Hide all Hide all

The SFC editor fully supports drag and drop for moving or copying items. To move items, select them and simply drag them to the wished position.

To copy items, you may do the same, and just press the CONTROL key while dragging. It is also possible to drag pieces of charts from a program to another if both are open and visible on the screen.

At any moment while dragging items you can press ESCAPE to cancel the operation.

Alternatively, you can use classical Copy / Cut / Paste commands from the Edit menu. Paste is performed at the current position.


Renumbering steps and transitions

IEC 61131-3 Programming Environment -> Editing programs -> Sequential Function Chart (SFC) Editor -> Renumbering steps and transitions

Previous chapter Next chapter Show all Show all Hide all Hide all

Each step or transition is identified by a number. A jump to a step is also identified by the number of the destination step. The SFC editor allocates a new number to each step or transition inserted in the chart.

To change the number of a step, transition or jump, select it and hit Ctrl+ENTER keys.

It is not possible to change the number of a step or a transition if its level 2 is currently open for editing. The number is used for identifying the step or transition in the level 2 editing window.

In compiler reports, a step is identified by its number prefixed by GS. A transition is identified by its number prefixed by GT.


Entering actions of a step

IEC 61131-3 Programming Environment -> Editing programs -> Sequential Function Chart (SFC) Editor -> Entering actions of a step

Previous chapter Next chapter Show all Show all Hide all Hide all

Actions and notes attached to a step (level 2) are entered in a separate window. To open the level 2 editing window of a step or transition, double click on its symbol in the chart, or select it and hit ENTER.

The level 2 editing window proposes 4 views for entering different types of level 2 information:

  • Simple actions entered as text.
  • P1 actions than can be programmed in ST/IL text, LD or FBD.
  • N actions than can be programmed in ST/IL text, LD or FBD.
  • P0 actions than can be programmed in ST/IL text, LD or FBD.
  • Text notes.

Use the tab buttons in the level 2 editing window for selecting a view:

When editing P1, N or P0 actions, use the Edit / Set Language menu command to select the programming language. This command is not available if the action block is not empty.

The first view ("Action") contains all simple actions to control a boolean variable or a child SFC chart. However, it is possible to directly enter action blocks programmed in ST together with other actions in this view. Use the following syntax for entering ST action blocks in the first pane:

ACTION ( qualifier ) :
statements...
END_ACTION;

Where qualifier is "P1", "N" or "P0".


Entering the condition of a transition

IEC 61131-3 Programming Environment -> Editing programs -> Sequential Function Chart (SFC) Editor -> Entering the condition of a transition

Previous chapter Next chapter Show all Show all Hide all Hide all

The condition and notes attached to a transition (level 2) are entered in a separate window. To open the level 2 editing window of a step or transition, double click on its symbol in the chart, or select it and hit ENTER.

The level 2 editing window proposes 2 views for entering different types of level 2 information:

  • Condition programmed in ST/IL text or LD.
  • Text notes.

Use the tab buttons in the level 2 editing window for selecting a view:

When editing the condition, use the Edit / Set Language menu command to select the programming language. This command is not available if the condition is not empty. FBD cannot be used to program a condition.


Entering notes for steps and transitions

IEC 61131-3 Programming Environment -> Editing programs -> Sequential Function Chart (SFC) Editor -> Entering notes for steps and transitions

Previous chapter Next chapter Show all Show all Hide all Hide all

The SFC editor supports the definition of text notes for each step and transition. The notes are entered in the level 2 editing window of steps and transitions. Refer to the following topics for further information about the level 2 editing window:

  • entering Level 2 for steps
  • entering Level 2 for transitions

Notes can be displayed in the chart. The last button of the toolbar enables you to switch between possible displays:

Icon

Description

Swap between possible overviews of level 2 in the level 1 chart:

  • Display code of actions and conditions.
  • Display notes attached to steps and transitions.

Notes have no meaning for the execution of the chart. Entering notes for steps and transitions enables you to enhance the auto-documentation of your programs. It also provides an easy way to write and exchange specifications of an SFC program before actions and conditions are programmed.


Function Block Diagram (FDB) Editor

IEC 61131-3 Programming Environment -> Editing programs -> Function Block Diagram (FDB) Editor

Previous chapter Next chapter Show all Show all Hide all Hide all

The FBD editor is a powerful graphical tool that enables you to enter and manages Function Block Diagrams according to the IEC 61131-3 standard. The editor supports advanced graphic features such as drag and drop, object resizing and connection lines routing features, so that you can rapidly and freely arrange the elements of your diagram. It also enables you to insert in a FBD diagram graphic elements of the LD (Ladder Diagram) language such as contacts and coils.

FBD diagram components | Related sections
Function blocks Variable tags Comment texts Corners Network breaks Labels Jumps Use of ST instructions | Using the FBD toolbar Selecting function blocks Drawing connection lines Selecting and entering variables and FB instances Viewing the diagram Moving or copying parts of the diagram Inserting an object on a line Resizing objects Bookmarks
LD components |
Contacts Coils "OR" vertical rail Power rails |

info Info

When a contact or a coil is selected, You can press the SPACE bar to change its type (normal, negated, pulse...).

In this section

Using the FBD toolbar

Drawing FBD connection lines

Selecting FBD variables and instances

Viewing FBD diagrams

Moving or copying FBD objects

Inserting FBD objects on a line

Resizing FBD objects


Using the FBD toolbar

IEC 61131-3 Programming Environment -> Editing programs -> Function Block Diagram (FDB) Editor -> Using the FBD toolbar

Previous chapter Next chapter Show all Show all Hide all Hide all

The vertical toolbar on the left side of the editor contains buttons for all available editing features. Push the wished button before using the mouse in the graphic area.

Icon

Description

Selection: In this mode, you cannot insert any element in the diagram. The mouse is used for selecting object and lines, select tag name areas, move or copy objects in the diagram. At any moment you can press the ESCAPE key to go back to the Selection mode.

Insert Block: In this mode, the mouse is used for inserting blocks in the diagram. Click in the diagram and drag the new block to the wished position. The type of block that is inserted is the one currently selected in the list of the main toolbar.

Insert variable: In this mode, the mouse is used for inserting variable tags. Variable tags can then be wired to the input and output pins of the blocks. Click in the diagram and drag the new variable to the wished position.

Insert comment text: In this mode, the mouse is used for inserting comment text areas in the diagram. Comment texts can be entered anywhere. Click in the diagram and drag the text block to the wished position. The text area can then be selected and resized.

Insert connection line: In this mode, the mouse is used to wire input and output pins of the diagram objects. The line must always be drawn in the direction of the data flow: from an output pin to an input pin. The FBD editor automatically selects the best routing for the new line. You can change the default routing by inserting corners on lines. (see below)

You also can drag a line from an output pin to an empty space. In that case the editor automatically finished the line with a user defined corner so that you can continue drawing the connection to the wished pin and force the routing while you are drawing the line.

Insert corner: In this mode, the mouse is used for inserting a user defined corner on a line. Corners are used to force the routing of connection lines, as the FBD editor imposes a default routing only between two pins or user defined corners. Corners can then be selected and moved to change the routing of existing lines.

Insert network break: In this mode, the mouse is used for inserting a horizontal line that acts as a break in the diagram. Breaks have no meaning for the execution of the program. They just help the understanding of big diagrams, by splitting them in a list of networks.

Insert label: In this mode, the mouse is used for inserting a label in the diagram. A label is used as a destination for jump symbols (see below).

Insert jump: In this mode, the mouse is used for inserting jump symbols in the diagram. A jump indicates that the execution must be directed to the corresponding label (having the same name as the jump symbol). Jumps are conditional instructions. They must be linked on their left side to a Boolean data flow.

Insert left power rail: In this mode, the mouse is used for inserting a left power rail in the diagram. A left power rail is an element of the LD language, and represents a TRUE state that can be used to initiate a data flow. Power rails can then be selected and resized vertically according to the wished network height.

Insert contact: In this mode, the mouse is used for inserting in the diagram a contact as in Ladder Diagrams.

Insert “OR” rail: In this mode, the mouse is used for inserting a rail that collects several Boolean data flows for an “OR” operation, in order to insert parallel contacts such as done in Ladder Diagrams.

Insert coil: In this mode, the mouse is used for inserting in the diagram a coil as in Ladder Diagrams. It is not mandatory that a coil be connected on its right side.

Insert right power rail: In this mode, the mouse is used for inserting a right power rail in the diagram. A right power rail is an element of the LD language, and is commonly used for terminating Boolean data flows. However it is not mandatory to connect coils to power rails. Right power rails have no meaning for the execution of the diagram.

In this section

FBD variables

FBD comments

FBD corners

FBD network breaks

FBD "OR" vertical rail


FBD variables

IEC 61131-3 Programming Environment -> Editing programs -> Function Block Diagram (FDB) Editor -> Using the FBD toolbar -> FBD variables

Previous chapter Next chapter Show all Show all Hide all Hide all

All variable symbols and constant expressions are entered in FBD diagrams using small boxes. Press the following button in the FBD toolbar for inserting a variable tag:

Icon | Description
 | Insert variable: In this mode, the mouse is used for inserting variable tags. Click in the diagram and drag the new variable to the wished position.

Double click on a variable tag to open the variable selection box and either select the symbol of the wished variable or enter a constant expression.

Variables tags must then be linked to other objects such as block inputs and outputs using connection lines.

You can resize a variable box vertically in order to display together with the variable name its tag (short comment text), its description text, plus its I/O location if the variable is mapped to an I/O channel. The variable name is always displayed at the bottom of the rectangle:

tag

description

% location

name


FBD comments

IEC 61131-3 Programming Environment -> Editing programs -> Function Block Diagram (FDB) Editor -> Using the FBD toolbar -> FBD comments

Previous chapter Next chapter Show all Show all Hide all Hide all

Comment text areas can be entered anywhere in a FDB diagram. Press the following button in the FBD toolbar for inserting a new comment area:

Icon | Description
 | Insert comment text: In this mode, the mouse is used for inserting comment text areas in the diagram. Comment texts can be entered anywhere. Click in the diagram and drag the text block to the wished position.

Double click on the comment area for entering or changing the attached text. When selected, comment texts can be resized.


FBD corners

IEC 61131-3 Programming Environment -> Editing programs -> Function Block Diagram (FDB) Editor -> Using the FBD toolbar -> FBD corners

Previous chapter Next chapter Show all Show all Hide all Hide all

Corners are used to force the routing of connection lines, as the FBD editor imposes a default routing only between two pins or user defined corners. All variable symbols and constant expressions are entered in FBD diagrams using small boxes. Press the following button in the FBD toolbar for inserting a corner on a line:

Icon | Description
 | Insert corner: In this mode, the mouse is used for inserting a user defined corner on a line.

You can drag a new line from an output pin to an empty space. In that case the editor automatically finished the line with a user defined corner so that you can continue drawing the connection to the wished pin and force the routing while you are drawing the line.

Corners can then be selected and moved to change the routing of existing lines.


FBD network breaks

IEC 61131-3 Programming Environment -> Editing programs -> Function Block Diagram (FDB) Editor -> Using the FBD toolbar -> FBD network breaks

Previous chapter Next chapter Show all Show all Hide all Hide all

Network breaks can be entered anywhere in a FBD diagram. Breaks have no meaning for the execution of the program. They just help the understanding of big diagrams, by splitting them in a list of networks. Press the following button in the FBD toolbar for inserting a new break:

Icon | Description
 | Insert network break: In this mode, the mouse is used for inserting a horizontal line that acts as a break in the diagram.

The break line is drawn on the whole diagram width. No other object can overlap a network break. Break lines can then be selected and moved vertically to another location.

Network breaks can also be used for browsing the diagram. Press Ctrl+Page Up or Ctrl+Page Down keys to move the selection to the next or previous network break.


FBD "OR" vertical rail

IEC 61131-3 Programming Environment -> Editing programs -> Function Block Diagram (FDB) Editor -> Using the FBD toolbar -> FBD "OR" vertical rail

Previous chapter Next chapter Show all Show all Hide all Hide all

The FBD editor enables the drawing of LD rungs. A particular object, the "OR" rail can be inserted on a rung in order to connect parallel contacts together. Press the following button in the FBD toolbar for inserting a new "OR" rail:

Icon | Description
 | Insert OR rail: In this mode, the mouse is used for inserting a rail that collects several Boolean data flows for an OR operation, in order to insert parallel contacts such as done in Ladder Diagrams.

The OR rail has exactly the same meaning as an OR block regarding the execution of the diagram.


Drawing FBD connection lines

IEC 61131-3 Programming Environment -> Editing programs -> Function Block Diagram (FDB) Editor -> Drawing FBD connection lines

Previous chapter Next chapter Show all Show all Hide all Hide all
Icon | Description
 | Press this button before inserting a new line.

The editor enables you to terminate a connection line with a boolean negation represented by a small circle. To set or remove the boolean negation, select the line and press the SPACE bar.

Connection lines must always be drawn in the direction of the data flow: from an output pin to an input pin. The FBD editor automatically selects the best routing for the new line. Connection lines indicate a data flow between the following possible objects:

Icon | Description
 | Block: Refer to the help on the block for the description of its input and output pins, and the expected data types for the coherency of the diagram.
 | Variable: Variable can be connected on their right side (to initiate a flow) or on their left side for forcing the variable, if it is not “read only”. The flow must fit the data type of the variable.
 | Jump: A jump must be connected on its left side to a Boolean data flow.
 | Left power rail: Left power rails represent a TRUE state and can be connected to a non limited number of objects on their right side.
 | Contact: A contact must be connected on its left side and on its right side to Boolean data flows.
 | “OR” rail: Such rail that collects several Boolean data flows for an “OR” operation, in order to insert parallel contacts such as done in Ladder Diagrams. It may have several connections on its left side and on its right side. All connected data flows must be Boolean.
 | Coil: A coil must be connected on its left side to a Boolean data flow. It is not mandatory that a coil be connected on its right side.
 | Right power rail: A right power rail is an element of the LD language, and is commonly used for terminating Boolean data flows. It has a non limited number of connections on its left side. It is not mandatory to connect coils to power rails.


Selecting FBD variables and instances

IEC 61131-3 Programming Environment -> Editing programs -> Function Block Diagram (FDB) Editor -> Selecting FBD variables and instances

Previous chapter Next chapter Show all Show all Hide all Hide all
Icon | Description
 | Press this button or press ESCAPE before any selection.

To select the name of the declared variable to be attached to a graphic symbol, you must be in Selection mode. Simply double click on the tag name gray area. The following types of object must be linked to valid symbols:

Icon | Description
 | Block: If it is a function block, you must specify the name of a valid declared instance of the corresponding type.
 | Variable: Must be attached to a declared variable. Alternatively, a variable box may contain the text of a valid constant expression.
 | Label: Must have a name. The name must be unique within the diagram.
 | Jump: must have the same name as its destination label.
 | Contact: Must be attached to a declared Boolean variable.
 | Coil: Must be attached to a declared Boolean variable.

Symbols of variables and instances are selected using the variable list, that can be used as the variable editor. You can simply enter a symbol or constant expression in the edit box and press OK. You also can select a name in the list of declared object, or declare a new variable by pressing the Create button.

more details...


Viewing FBD diagrams

IEC 61131-3 Programming Environment -> Editing programs -> Function Block Diagram (FDB) Editor -> Viewing FBD diagrams

Previous chapter Next chapter Show all Show all Hide all Hide all

The diagram is entered in a logical grid. All objects are snapped to the grid. You can use the commands of the View menu for displaying of hiding the points of the grid. The (x,y) coordinates of the mouse cursor are displayed in the status bar. This helps you locating errors detected by the compiler, or aligning objects in the diagram.

At any moment you can use the commands of the View menu for zooming in or out the edited diagram. You also can press the [+] and [-] keys of the numerical keypad for zooming the diagram in or out.


Moving or copying FBD objects

IEC 61131-3 Programming Environment -> Editing programs -> Function Block Diagram (FDB) Editor -> Moving or copying FBD objects

Previous chapter Next chapter Show all Show all Hide all Hide all
Icon | Description
 | Press this button or press ESCAPE before selecting objects.

The FBD editor fully supports drag and drop for moving or copying objects. To move objects, select them and simply drag them to the wished position.

To copy objects, you may do the same, and just press the CONTROL key while dragging. It is also possible to drag pieces of diagrams from a program to another if both are open and visible on the screen.

At any moment while dragging objects you can press ESCAPE to cancel the operation.

Alternatively, you can use classical Copy / Cut / Paste commands from the Edit menu. When you run the Paste command, the editors turns in Paste mode, with a special mouse cursor. Click in the diagram and move the mouse cursor to the wished position for inserting pasted objects.

Using the keyboard

When graphic objects are selected, you can move them in the diagram by hitting the following keys:

Shortcut | Description
Shift + Up | Move to the top.
Shift + Down | Move to the bottom.
Shift + Left | Move to left.
Shift + Right | Move to right.

When an object is selected, you can extend the selection by hitting the following keys:

Shortcut | Description
Shift + Control + Home | Extend to the top: select all objects before the selected one.
Shift + Control + End | Extend to the bottom: select all objects after the selected one.

To insert or delete space in the diagram, you can simply select an object, press Shift+Control+End to extend the selection and then move selected objects up or down.

Auto alignment

When objects are selected, the following keystrokes automatically align them:

Shortcut | Description
Control + Up | To the top.
Control + Down | To the bottom.
Control + Left | To left.
Control + Right | To right.


Inserting FBD objects on a line

IEC 61131-3 Programming Environment -> Editing programs -> Function Block Diagram (FDB) Editor -> Inserting FBD objects on a line

Previous chapter Next chapter Show all Show all Hide all Hide all

The FBD editor enables you to insert an object on an existing line and automatically connect it to the line. This feature is available for all objects having one input pin and one output pin, such as variable boxes, contacts and coils. This feature is mainly useful when entering pieces of Ladder Diagrams. Just draw a horizontal line between left and right power rails: this is the rung. Then you can simply insert contacts and coils on the line to build the LD rung.


Resizing FBD objects

IEC 61131-3 Programming Environment -> Editing programs -> Function Block Diagram (FDB) Editor -> Resizing FBD objects

Previous chapter Next chapter Show all Show all Hide all Hide all
Icon | Description
 | Press this button or press ESCAPE before selecting objects.

When an object is selected, small square boxes indicates you how to resize it with the mouse. Click on the small square boxes for resizing the object in the wished direction.

Not all objects can be resized. The following table indicates possible operations:

Item | Possible operations
Variable | Horizontally and vertically (*)
Block | Horizontally
Labels and jumps | Horizontally
Power rails | Vertically
OR rail | Vertically
Comment area | In all directions.

(*) Resizing a variable box vertically enables you to display together with the variable name its tag (short comment text), its description text, plus its I/O location it the variable is mapped to an I/O channel. The variable name is always displayed at the bottom of the rectangle:

% location

description

tag

name


Ladder Diagram (LD) Editor

IEC 61131-3 Programming Environment -> Editing programs -> Ladder Diagram (LD) Editor

Previous chapter Next chapter Show all Show all Hide all Hide all

The LD editor is a powerful graphical tool that enables you to enter and manages Ladder Diagrams according to the IEC 61131-3 standard. The editor enables quick input using the keyboards, and supports advanced graphic features such as drag and drop.

LD diagram components: | Related sections:
Rungs Contacts Coils Power rails Function blocks Labels Jumps Comments Use of ST instructions | Using the LD toolbar Selecting function blocks Selecting and entering variables and FB instances Viewing the diagram Moving or copying parts of the diagram Bookmarks

info Info

When a contact or a coil is selected, You can press the SPACE bar to change its type (normal, negated, pulse...).

In this section

Using the LD toolbar

Managing Rungs

Comments in LD diagrams

Viewing LD diagrams

Moving and copying LD items


Using the LD toolbar

IEC 61131-3 Programming Environment -> Editing programs -> Ladder Diagram (LD) Editor -> Using the LD toolbar

Previous chapter Next chapter Show all Show all Hide all Hide all

The vertical toolbar on the left side of the editor contains buttons for inserting items in the diagrams. Items are inserted at the current position in the diagram.

Icon, Shortcut | Description
Shift+F4 | Insert a contact before the selected item.
F4 | Insert a contact after the selected item.
Ctrl+F4 | Insert a contact in parallel with the selected items
Ctrl+Space | Insert a horizontal line before the selected item so that it is pushed to the right.
Shift+F8 | Insert a block before the selected item.
F8 | Insert a block after the selected item.
Ctrl+F8 | Insert a block in parallel with the selected items.
Shift+F9 | Add a jump in parallel with the selected coil.
F9 | Add a coil in parallel with the selected coil.
Ctrl+R | Insert a new rung in the diagram.
Ctrl+D | Insert a comment between rungs.


Managing Rungs

IEC 61131-3 Programming Environment -> Editing programs -> Ladder Diagram (LD) Editor -> Managing Rungs

Previous chapter Next chapter Show all Show all Hide all Hide all
Icon | Description
 | Press this button in the LD toolbar to insert a new rung.

A LD diagram is a sequential list of rungs. Each rung represents left to right boolean power flow, that begins with a power rail, always drawn in the first column of the diagram, and finishes with a coil or a jump symbol.

Each Rung is identified by a default numbered identifier (Rnnn) displayed on the left of the power rail. The rung identifier can be used as a target for jump instructions. Alternatively you can enter a specific rung label by double clicking in the rung head on the left margin.

The LD editor enables you to manipulate whole rungs by selecting only their head in the left margin. The following example shows a selected rung:

Example Example

When a rung is selected, use the commands of the Edit menu to delete, copy or cut it.


Comments in LD diagrams

IEC 61131-3 Programming Environment -> Editing programs -> Ladder Diagram (LD) Editor -> Comments in LD diagrams

Previous chapter Next chapter Show all Show all Hide all Hide all
Icon | Description
 | Press this button in the LD toolbar to insert a new comment line.

The LD editor enables you to insert comment texts in the diagram. A comments is a single line of text inserted between two rungs. The comment text is displayed on a double line in the diagram:

Comment texts have no meaning for the execution of the diagram. They are used to enhance the readability of the program, enabling the description of each rung.

The comment text remains visible when the diagram is scrolled horizontally. To change the text of the comment, place the selection anywhere on the comment line and hit ENTER key, or simply double click on the comment line.


Viewing LD diagrams

IEC 61131-3 Programming Environment -> Editing programs -> Ladder Diagram (LD) Editor -> Viewing LD diagrams

Previous chapter Next chapter Show all Show all Hide all Hide all

The diagram is entered in a logical grid. All objects are snapped to the grid. You can use the commands of the View menu for displaying of hiding grid lines. The (x,y) coordinates of the mouse cursor are displayed in the status bar. This helps you locating errors detected by the compiler, or aligning objects in the diagram.

At any moment you can use the commands of the View menu for zooming in or out the edited diagram. You also can press the [+] and [-] keys of the numerical keypad for zooming the diagram in or out.

You also can drag the separation lines in vertical and horizontal rulers to freely resize the cells of the grid:

The LD editor adjust the size of the font according to the zoom ratio so that the name of variables associated with contacts and coils are always visible. If cells have sufficient height, variable names are completed with other pieces of information about the variable:

  • Its tag (short description).
  • Its description text.
  • Its I/O name (%...) if the variable has a user defined name.


Moving and copying LD items

IEC 61131-3 Programming Environment -> Editing programs -> Ladder Diagram (LD) Editor -> Moving and copying LD items

Previous chapter Next chapter Show all Show all Hide all Hide all

The LD editor fully supports drag and drop for moving or copying objects. To move objects, select them and simply drag them to the wished position, in the same rung or in another rung.

To copy objects, you may do the same, and just press the CONTROL key while dragging. It is also possible to drag pieces of diagrams from a program to another if both are open and visible on the screen.

At any moment while dragging objects you can press ESCAPE to cancel the operation.

Alternatively, you can use classical Copy / Cut / Paste commands from the Edit menu. Paste is performed at the current position.

You can manipulate whole rungs by selecting only their head in the left margin (select only the cell where the rung number is displayed).


Structured Text (ST) / Instruction List (IL) Editor

IEC 61131-3 Programming Environment -> Editing programs -> Structured Text (ST) / Instruction List (IL) Editor

Previous chapter Next chapter Show all Show all Hide all Hide all

The ST / IL editor is a powerful language sensitive text editor dedicated to IEC 61131-3 languages. The editor supports advanced graphic features such as drag and drop, syntax coloring and active tooltips for efficient input and test of programs in ST and IL.

The ST / IL editor also supports context sensitive help. Place the caret on a keyword or on the name of function or function block and hit F1 key to get help about the text.

In this section

ST / IL Language selection

ST / IL Syntax editing

Auto completion of words

ST / IL Drag and drop features

Tooltips in the ST / IL Editor


ST / IL Language selection

IEC 61131-3 Programming Environment -> Editing programs -> Structured Text (ST) / Instruction List (IL) Editor -> ST / IL Language selection

Previous chapter Next chapter Show all Show all Hide all Hide all

The Workbench allows you to mix ST and IL languages in textual program. ST is the default language. When you enter IL instructions, the program must be entered between "BEGIN_IL" and "END_IL" keywords, such as in the following example:

Example Example

BEGIN_IL
LD var1
ST var2
END_IL


ST / IL Syntax editing

IEC 61131-3 Programming Environment -> Editing programs -> Structured Text (ST) / Instruction List (IL) Editor -> ST / IL Syntax editing

Previous chapter Next chapter Show all Show all Hide all Hide all

The ST / IL editor supports syntax coloring according to the selected programming language (ST or IL). The editor uses different colors for the following kind of words:

  1. Default (identifiers, separators...)
  2. Reserved keywords of the language
  3. Constant expressions
  4. Comments

The set of colors used can be changed from the Tools/Options menu command.

Some more features are available for smart editing and are referred to as "Intellisense". Intellisense can be memory consuming and can be activated or deactivated from the Tools/Options menu command. After activating or de-activating the Intellisense, you must close and reopen your project list. The following features are available when Intellisense is activated:

Conditional compiling coloring

Parts of code conditionned by #ifdef pragmas and that are not validated are grayed.

Auto-indentation

Lines are automatically formatted (indented) on the left as you enter structured ST statements.

Auto-completion of ST statements

On an empty line, just enter the main keyword of a ST statement such as "for", "if"... and imediately press the ENTER key. The whole statement will be completed including comments that will guide you through the syntax. The caret is automatically placed where you must enter the first required term or condition.

Auto-completion of function calls

Enter the name of a function simply followed by an opening parenthesis and immediately press the ENTER key. The call will be completed with the appropriate argument list including comments and possibly default values so that you are guided through the list of values to be passed to the called function.

Auto-declaration of missing symbols

When you press ENTER at the end of a line containing an unknown variable symbol, you will be prompted for declaring it immediately.


Auto completion of words

IEC 61131-3 Programming Environment -> Editing programs -> Structured Text (ST) / Instruction List (IL) Editor -> Auto completion of words

Previous chapter Next chapter Show all Show all Hide all Hide all

The ST / IL editor includes powerful commands for automatic completion of typed words, according to declared variables and data types. The following features are available:

Auto completion of a variable name

If you enter the first letters of a variable name, you can hit the CTRL+SPACE key for automatically completing the name. A popup list is displayed with possible choices if several declared variable names match the type characters.

Selection of FB member

When you type the name of a function block instance (use either as an instance or a data structure), pressing the point "." after the name of the instance opens a popup list with the names of possible members.

Other syntax related commands

When lines are selected, you can automatically indent them. Press TAB or Shift+TAB keys to shift the lines to the left or to the right, by adding or removing blank characters on the left.


ST / IL Drag and drop features

IEC 61131-3 Programming Environment -> Editing programs -> Structured Text (ST) / Instruction List (IL) Editor -> ST / IL Drag and drop features

Previous chapter Next chapter Show all Show all Hide all Hide all

The ST / IL editor supports powerful drag and drop features that help you developing and testing your programs. You can:

  • Drag text (words or lines) from the ST / IL editor to another application (such as a text editor).
  • Do the opposite.
  • Drag a variable symbol from the variable editor to the ST / IL editor.
  • Drag a variable symbol from the ST / IL editor to the watch list (*).

(*) When dragging the symbol of an array to the watch list, all items of the array are added to the watch list.


Tooltips in the ST / IL Editor

IEC 61131-3 Programming Environment -> Editing programs -> Structured Text (ST) / Instruction List (IL) Editor -> Tooltips in the ST / IL Editor

Previous chapter Next chapter Show all Show all Hide all Hide all

During test (connected mode or simulation) of the program the ST / IL editor shows in a tooltip the current value of the variable pointed to by the mouse cursor. You do not need to run any specific command to open the tooltip. Just put the mouse on the variable symbol and wait for one second.

The value shown in the tooltip is automatically refreshed while the tooltip is open.


Selecting function blocks

IEC 61131-3 Programming Environment -> Editing programs -> Selecting function blocks

Previous chapter Next chapter Show all Show all Hide all Hide all

All available operators, functions and function blocks are listed in the bottom/right area of the editor. The list of available blocks is sorted into categories.

The All category enables you to see the complete list of available blocks. The Recent category contains the last used blocks. The Project category lists all UDFBs and sub-programs declared in the project.

To insert a block in a program, simply select it in the list and drag it with the mouse to the wished position in the edited text or diagram.

Press the F1 key when a block is selected to have help about its function, input and output pins. In selection mode, you also can double click the mouse on a block of the diagram to change its type, and set the number of input pins if the block can be extended.


Selecting variables and instances

IEC 61131-3 Programming Environment -> Editing programs -> Selecting variables and instances

Previous chapter Next chapter Show all Show all Hide all Hide all

Symbols of variables and instances are selected using the variable list, that can be used as the variable editor. Selecting variables is available from all editors:

  • In FBD diagrams, double click on a variable box, a FB instance name, a contact or a coil to select the associated variable.
  • In LD diagrams, double click on a contact, a coil or a block input or output to select the variable. Double click on the top of a FB rectangle to select an instance.
  • In ST/IL texts, run the Insert / Set Variable in the Edit menu to select a variable and insert its name in the text.

When the variable editor is visible in the editor window, you can simply drag a variable from the list to the program to insert it.

When inserting a variable name manually, the Workbench automatically checks if it exists and if not, proposes you to declare it right now.


Quick Search

IEC 61131-3 Programming Environment -> Quick Search

You can use commands of the Edit menu to find and replace texts in the diagram. Alternatively, you can use the Quick Search box in the status bar:

This feature can be used in any window.

Simply click on the edit box, enter the text you want to search and press ENTER key. You also can press the small icon for searching the next occurrence of the searched text.


Bookmarks

IEC 61131-3 Programming Environment -> Bookmarks

Bookmarks are used for navigating in a document. You can freely insert bookmarks everywhere in a document. Then you can jump from a bookmark to another with a single command for browsing the document. Bookmarks are supported in all program editors plus the variable editor.

Below are the available commands for using bookmarks:

Shortcut | Description
Ctrl + F2 | Toggle the bookmark at the current position.
Shift + F2 | Go to the next bookmark.

According to the type of document, the possible locations for a bookmark are:

  • In the text editor, a bookmark is placed on a line of text.
  • In the SFC editor, a bookmark is placed on a SFC symbol (step, transition, jump...).
  • In the FBD editor, a bookmark is placed on any FBD object (not on a line).
  • In the LD editor, a bookmark is placed on a rung header.
  • In the variable editor, a bookmark is placed on any line of the grid (variable or group).

info Info

Bookmarks are valid only while the editing window is open, and are not stored in the document when the window is closed.


Project Settings

IEC 61131-3 Programming Environment -> Project Settings

Run the Project / Settings menu command to enter the settings of the project:

  • Main parameters
  • Target identification
  • Runtime settings
  • Compiling options
  • Debug options
  • On Line Change
  • Using a "C" compiler

In this section

Project Settings

Project Settings - Target

Project Settings - Runtime

Project Settings - Compiler

Project Settings - Debug

Project Settings - On Line Change

Project Settings - "C" compiling


Project Settings

IEC 61131-3 Programming Environment -> Project Settings -> Project Settings

Previous chapter Next chapter Show all Show all Hide all Hide all

This box enables you to define main parameters for building and running the runtime application.

Target

You must specify the kind of Win-GRAF PAC driver installed in your target system. It can be:

  • T5RTI: standard Win-GRAF PAC driver for little endian processors (Intel like byte ordering)
  • T5RTM: standard Win-GRAF PAC driver for big endian processors (Motorola like byte ordering)
  • Custom

To define the settings of a custom runtime, press the Advanced button.

Code generation

If you want step by step debugging to be available during simulation or On Line test, you need to select the DEBUG compiling mode. If step by step debugging is no more required, you should select the RELEASE compiling mode in order to give highest performance to the runtime application.

Execution mode

You must specify in this box how the cycles must be triggered at run-time:

  • as fast as possible: the target does not wait between two cycles. The target simply runs as fast as possible
  • triggered: you must specify the duration of a cycle, expressed as a number of micro-seconds. Refer to OEM instructions for explanations of the supported accuracy for the cycle timing of your target system.

External objects

The workbench enables you to use in a projects some objects defined in other projects, such as UDFBs. This provides an easy way to manage libraries of IEC written function blocks that can be re-used in various projects. In addition to this feature, the workbench provides an easy way to safely handle externally defined objects in the local project.

Press the Edit button to manage external objects used in your project.

Other options

Press the Advanced button to view more parameters and options for advanced settings.


Project Settings - Target

IEC 61131-3 Programming Environment -> Project Settings -> Project Settings - Target

Previous chapter Next chapter Show all Show all Hide all Hide all

This box enables you to select the kind of Win-GRAF PAC driver installed in your target system.

Target

You must specify the kind of Win-GRAF PAC driver installed in your system. It can be:

  • T5RTI: standard Win-GRAF PAC driver for little endian processors (Intel like byte ordering).
  • T5RTM: standard Win-GRAF PAC driver for big endian processors (Motorola like byte ordering).
  • Custom.

If you select a standard T5RTI or T5RTM runtime, all other settings available in this box are imposed. If you are using a Custom runtime, please refer to your OEM instructions for filling other parameters.

Identification

A target is identified by a name. This name will be included in the built code and checked at runtime. In addition, you must specify the suffix of the file generated at build time that contains the downloaded code. Download is not possible if the suffix entered here does not match the one expected by the runtime.

Processor

You must specify in this box the byte ordering convention of the runtime processor:

  • Little endian (Intel-like byte ordering).
  • Big endian (Motorola-like byte ordering).

P-Code

Select the Custom choice if your runtime system works with a specific p-code instruction set.


Project Settings - Runtime

IEC 61131-3 Programming Environment -> Project Settings -> Project Settings - Runtime

Previous chapter Next chapter Show all Show all Hide all Hide all

This box enables you to select the main build and execution options for the runtime application.

Code generation

If you want step by step debugging to be available during simulation or On Line test, you need to select the DEBUG compiling mode. If step by step debugging is no more required, you should select the RELEASE compiling mode in order to give highest performance to the runtime application.

Execution mode

You must specify in this box how the cycles must be triggered at run-time:

  • As fast as possible: the target does not wait between two cycles. The target simply runs as fast as possible.
  • Triggered: you must specify the duration of a cycle, expressed as a number of micro-seconds. Refer to OEM instructions for explanations of the supported accuracy for the cycle timing of your target system.

Variable locking

Depending on the value of the Lock entry, more or less locking features will be supported at run time. Below are possible values:

  • I/Os I/O variables can be locked and forced at run time.
  • All All variables can be locked and forced at run time.
  • None Variable forcing is fully disabled.

The "I/Os" choice applies to I/O boards only.

Arrays, structures and instances

Validate the Store complex variables in a separate segment option for indicating that complex variables (arrays, structures and FB instances must be managed separately from single variables. Setting this options enables you to manage more complex data types in your applications. See details


Project Settings - Compiler

IEC 61131-3 Programming Environment -> Project Settings -> Project Settings - Compiler

Previous chapter Next chapter Show all Show all Hide all Hide all

This box enables you to select the advanced compiling options for building the runtime application.

Options

The following options are available

  • Enable FBD line coloring during debug.
  • Display warning messages (uncheck this option to remove all warning reports during build).
  • Enable large jump instructions (*).
  • Embed all symbols with the downloaded application code.
  • Keep the case of embedded symbols (if not checked, all embedded symbols are turned uppercase).
  • Check SFC chart safety.
  • Check array bounds at runtime.
  • Remove the code of unreferenced sub-programs and UDFBs (**).
  • Check IEC conformity (***).
  • Allocate status bits for variables with embedded properties.

(*) For very large programs, jump instructions (e.g. for IF and loops ST instructions) may lead to compiling errors because the target of the jump is too far. In that case you need to check this option. Warning: this options is not supported by runtime systems older than version V2.20.

(**) If you check this option, the code of unused sub-programs and UDFBs is not included in the compiled code. This enables you to reduce the size of the downloaded code. Note that such sub-programs and UDFBs still exist in the code and their variables are defined, so that possible later On Line Change remains possible.

(***) If you check this option, some warning messages will be output each time you use in your programs some specific functions or function blocks that are not defined in the IEC standard. This only appy to embedded blocks and not to UDFBs written in IEC language.

Runtime password

Optionally you can define a password for the target application. If the password is defined in the compiling option, the user will be prompt for entering the password each time a remote connection is established to the target. The password is a number. If the password is "0", it means that no password is defined.

Other options

Other non documented options may be entered in this box. You normally don't have to change these options unless you're asked by your technical support.

In this section

Coloring FBD Flow lines

Safety build options

Management of complex variables at runtime


Coloring FBD Flow lines

IEC 61131-3 Programming Environment -> Project Settings -> Project Settings - Compiler -> Coloring FBD Flow lines

Previous chapter Next chapter Show all Show all Hide all Hide all

As an option, the debugger may display real time status of FBD flow lines during debug of simulation.

This option must be selected before compiling the project. It is selected from the Enhanced tab of the Compiling Options dialog box.

When this option is selected, the compiler automatically add variables and instructions to the generated application code so that status of all FBD flow lines can be spied during debug of simulation.

Selecting this option increase the size of the downloaded code and may lead to less runtime performance. It is recommended to uncheck this option when the application is fully tested and compiled in RELEASE mode for its final implementation.


Safety build options

IEC 61131-3 Programming Environment -> Project Settings -> Project Settings - Compiler -> Safety build options

Previous chapter Next chapter Show all Show all Hide all Hide all

The compiler and debugger includes several options that enable you to increase the safety of your runtime applications. Such options are selected from the Enhanced tab of the Compiling Options dialog box:

Check array bounds at runtime

When this option, is checked, the compiler automatically include extra instructions in the application code so that bounds are checked before reading or writing any array item. It is highly recommended to check this option during the development and validation of your applications.

Unchecking this option allows to decrease the application code size and leads to higher runtime performance.

Check safety of SFC charts

As an option, the compiler may check the safety of all SFC charts at compiling time. This enables the detection of posssible unsafe or blosking situations due to the form of the SFC chart. Below are some examples of such situations.

Example Example
Possible unsafe situation: As there is no "AND" convergence, several steps (such as 1 and 2) may be active at the same time. | Possible blocking situation: As either transition 1 or 101 is crossed, the transition 2 can never be crossed.

info Info

The compiler just provides warning messages when checking SFC charts. You always keep the possibility to run your application even if unsafe situations are reported.


Management of complex variables at runtime

IEC 61131-3 Programming Environment -> Project Settings -> Project Settings - Compiler -> Management of complex variables at runtime

Previous chapter Next chapter Show all Show all Hide all Hide all

The following option in the Enhanced tab of the compiling options dialog box defines how complex variables are managed at runtime:

Check | Description
 | Store complex variables in a separate segment.

If this options is set, then all complex variables are stored separately from other variables in the memory of the Win-GRAF PAC driver. If not, complex variables are stored together with single variables.

attention Attention

This option is not supported by Win-GRAF PAC drivers version 2.20 or earlier.

This option must be used carefully. Setting upt this option enables more programming possibility regarding complex variables and extends the capacity of the runtime memory. On another hand, the runtime application may have lower performance when this option is set. It is recommended to keep this option off as far as you do not need extra features related to it. This ensures that your application has highest runtiume performances.

Complex variables are arrays, structures, and instances of function blocks. When this option is set, the following features are allowed for programming:

  • You can use arrays of structures.
  • You can use arrays of FB instances.
  • You can pass any complex data (array, structure, instance) to a UDFB or sub-program.
  • There is nearly no limitation in the amount of complex data declared.
    (theorically up to 4GB - but practically limited by the memory available in the runtime)


Project Settings - Debug

IEC 61131-3 Programming Environment -> Project Settings -> Project Settings - Debug

Previous chapter Next chapter Show all Show all Hide all Hide all

This box enables you to select the main options applied when simulating or debugging the runtime application.

Simulation

If you select the Always start simlator in Cold Start mode, then the box normally opened when running the simulator for starting mode selection is not displayed.

This option applies to any project.

Connected to the runtime

These options enables you to impose some prompt messages for a user confirmation in most sensitive debug commands:

  • Stop the runtime application.
  • Download application code.
  • On Line change.

These options apply to any project.

When starting the runtime

These options allow you to select which kind of starting mode should be proposed to the user per default when starting the runtime application. Note that the user will still be allowed to change the starting mode in the box.

Communication parameters

Here you can select the way communication parameters are set:

  • Use current settings: check this option for always starting communication with the latest selected parameters.
  • Always use: alternatively, you can enter here the communication parameters that should be used for this project.


Project Settings - On Line Change

IEC 61131-3 Programming Environment -> Project Settings -> Project Settings - On Line Change

Previous chapter Next chapter Show all Show all Hide all Hide all

This box enables you to select the main options for the management of On Line change. Please refer to the description of On Line change capabilities for further details about this feature.

This box allows you to enable or disable the On Line change feature. When On Line Change is enabled, in order to allow the declaration of new variables and blocks, you have to define the amount of memory to be allocated in the target for each type of data. This includes:

  • The number of variable for each type (8, 16, 32 or 64 bits, character strings).
  • The number of function block instances.
  • The amount of memory for storing character strings.
  • The amount of memory for private data of function block instances.
  • The amount of variables published (with embedded symbol or profile).
  • The sizing of extra segment for storing complex variables.

To setup a value, select the corresponding item in the list, select the Value option, enter a new number in the Value box and press the Set button. You can select several items in the list for assigning the value to any selected items.

If your project has been built, the box shows you in the list the size actually used by the application according to the last build. A progress bar shows you the percentage of used space for each item. In addition, instead of entering an absolute value, you may select to enter a "free margin" to add the used space.

attention Attention
  • The "Used" numbers displayed in the box may be obsolete if you entered changes in your project since the last build.
  • The used space indicated for FB instance data is an approximative value based on an evaluation performed by the simulator. This may omit some runtime specific function blocks. So the size actually used on your runtime system may be greater.


Project Settings - "C" compiling

IEC 61131-3 Programming Environment -> Project Settings -> Project Settings - "C" compiling

Previous chapter Next chapter Show all Show all Hide all Hide all

For ultimate performances, the compiler can produce machine code by using a "C" compiler. In that case the p-code is post-compiled to "C" and then compiled using a 3rd party "C" compiler. This box enables you to select the required "C" compiler and setup relevant options.

attention Attention

The possibility to use a "C" compiler depends on the Win-GRAF PAC driver implementation. Refer to your OEM instructions for knowing if this feature is enabled and which "C" compiler can be used.

Selecting the "C" compiler

The main list propose possible "C" compilers and indicates for which runtime system. Select the None choice if you do not want to enable "C" compiling.

Options

You can ask the workbench to generate both machine code and classical p-code. If this option is selected, then the application will require more space in the runtime system. Some debugging features such as step by step debugging and variable locking are not available when the runtime runs machine code. If this option is set, you will be available during debug to change "on the fly" from machine code execution to p-code interpretation. Turning the runtime to p-code execution will then enable advanced debugging features.

If can select the Load compiled code option, then the code file (typically a DLL) will be automatically downloaded together with the application code.

The "C" compiler is run in a DOS-like prompt window. You can check the Show compiler window option if you want this window to be visible when post-compiling.

3rd party tool folder

You must specify where the 3rd party "C" compiler is installed on your computer. You can press the Check button to verify that the workbench actually recognizes the compiler in this folder.

Target code file name

Here you can enter the name of the code file to be produced by the "C" compiler. Refer to your OEM instructions if your runtime system does not use the default name.


Build project

IEC 61131-3 Programming Environment -> Build project

Icon | Description
 | Press this button in the main window or press F7 key to build the project. When managing or editing programs, F7 key is also available.

The project must be built (compiled) before it is simulated or downloaded to the target.

The compiler reports messages in the output window. If compiling errors occur, just double click on an error message for opening the corresponding program at the appropriate location. Other commands are available in the Project menu to:

  • "Clean" the project: This command deletes all files created during the last compiling.
  • Set the compiling options


Configurations

IEC 61131-3 Programming Environment -> Configurations

The Workbench includes in standard many features and a rich collection of functions and function blocks. Depending on the runtime configuration, some features or blocks may not be available. You can select a configuration in order to highlight in the Workbench the features not supported by the runtime.

Icon | Description
 | Run the Project / Configuration menu command to select a configuration

The list of possible configurations is displayed. The <Default> choice indicates that no special constraint must be hilighted

Press OK to select a configuration. If your OEM provides you with a configuration file (.CFG) that describes its runtime system, you can add it to the list by pression the Import button.

If your runtime system is connected, you can directly load its configuration by pressing the Upload button.

When a configuration is selected in the list, other tabs of the configuration selection box show:

  • The identification of the runtime system.
  • Supported data types.
  • Supported functions and FBs of the standard libraries.
  • Additional OEM specific functions and FBs.

When you have selected a configuration, the Workbench:

  • Hilights in red any calls to unsupported blocks.
  • Hilights in red unsupported items in the list of blocks.
  • Reports some warning messages at compiling when unsupported blocks are called.


On Line Change

IEC 61131-3 Programming Environment -> On Line Change

The workbench enables you to change your application "on the fly" while it is running in the target system. In order to enable most kinds of changes, you need to configure the programming environment and enable the On Line changes.

Run the Build / Compiling Options menu command and select the On Line Change page to setup the application for accepting changes.

When the On Line Change is disabled, no On Line Change at all is possible. There is no limitation in editing and programming features when On Line Change is disabled.

When On Line change is enabled, you can perfrom on the fly the following kinds of changes:

  • Change the code of a program.
  • Change the condition of a SFC transition or the actions of a SFC step.
  • Create, rename or delete global and local variables.
  • Create, rename or delete global and local function block instances.

The following kinds of changes are not allowed:

  • Create, delete or rename a program.
  • Change SFC charts.
  • Change the local parameters and variables of a UDFB.
  • Change the type or dimension (or string length) of a variable or function block instance.
  • Change the set of I/O boards.
  • Change the definition of RETAIN variables.

In addition, the following programming features that are not safe during a change should not be used:

  • Pulse (P or N) contacts and coils (edge detection).
    Instead, you must use declared instances of R_TRIG and F_TRIG function blocks.
  • Loops in FBD with no declared variable linked.
    You need to explicitely insert a variable in the loop.

On Line Change will be denied by the runtime if some system resources are currently open when the change is performed. A system resource can be either a file open by file management functions, or a socket open by TCP/UDP functions, or an dynamic array created by ARCREATE functions.

The Embedded HMI data (screens, bitmaps, fonts, strings) are not updated during an On Line Change.

In order to allow the declaration of new variables and blocks, you have to define the amount of memory to be allocated in the target for each type of data. This includes:

  • The number of variable for each type (8, 16, 32 or 64 variables, character strings).
  • The number of function block instances.
  • The amount of memory for storing character strings.
  • The amount of memory for private data of function block instances.

The number of variables of each type actually used in the application is given as a report at the end of each build. Changes are allowed until you exceed the sizing for at least one type of data. At this time, if you need to declare new variables, you have to change the configuration of memory sizing, rebuild the application and perform a full download stopping the target application.

When On Line Change is enabled, all new created variables are marked in blue in the variable editor. Deleted variables are kept as ghosts, marked in gray and renamed with a "_del_" prefix. You are allowed to manually rename a ghost variable if you want to make it alive again.

info Info

The On Line Change feature can be experimented with the Simulator started in Hot Retart mode. A hot restart is possible when On Line Change is enabled and when the application includes valid changes.


Definitions

IEC 61131-3 Programming Environment -> Definitions

The compiler supports the definition of aliases. An alias is a unique identifier that can be used in programs to replace another text. Definitions are typically used for replacing a constant expression and ease the maintenance of programs.

There are three levels of definitions:

  • Common to all the projects installed on your machine.
  • Global to all programs of a project.
  • Local to one program.

Common and global definitions can edited from the File / Open menu of the main window. Local definitions are edited together with the corresponding program. Use the View / Local Defines menu command when editing a program to open its local definitions.

Definitions are entered in a text editor. Each definition must be entered on one line of text according to the following syntax:

#define Identifier Equivalence (* comments *)

Example Example

#define OFF FALSE (* redefinition of FALSE constant *)
#define PI 3.14 (* numerical constant *)
#define ALARM (bLevel > 100) (* complex expression *)

You can use a definition within the contents of another definition. The definition used in the other one must be declared first.

Example Example

#define PI 3.14
#define TWOPI (PI * 2.0)

info Info

A definition may be empty, for example:

#define CONDITION

Defined word can be used for directing the conditional compiling directives.

You can enter #define lines directly in the source code of programs in IL or ST languages.

The use of definitions may disturb the program monitoring and make error reports more complex. It is recommended to restrict the use of definitions to simple expressions that have no risk to lead to a misunderstanding when reading or debugging a program.

System definitions

The following words are predefined by the compiler and can be used in the programs:

Word | Description
__DATE__ | Date stamp of compiling expressed as a string constant expression Format is: Year/Month/Day-Hours-Minutes.
__MACHINE__ | Name of the machine where compiling is run, expressed as a string constant expression.
__USER__ | Name of the user where compiling is run, expressed as a string constant expression.

Example Example

The following ST program sets variables declared as STRING(255):

strDate := __DATE__;
strMachine := __MACHINE__;
strUser := __USER__;

Result:

strDate is '2007/11/25-10:45'
strMachine is 'LaptopJX'
strUser is 'John'


Running the application

IEC 61131-3 Programming Environment -> Running the application

Previous chapter Next chapter Show all Show all Hide all Hide all

Use the following commands in the main window to test or monitor your application:

Icon | Description
 | Press this button press Ctrl+F5 key to go On Line and establish the connection with the remote target. Project monitoring and downloading will be available when the connection is established.
 | Press this button press F5 key to start the simulation.

These commands apply to the Startup Project. You can only test one project at a time. To change the Startup Project, select a project name in the Workspace window and use the command "Set As Startup Project" of the contextual right-click menu.

Related topics:

  • Communication parameters
  • The control panel
  • The Log window

How to monitor the application:

  • Using editors in test mode
  • Using the Watch Window
  • Graphic monitoring
  • Command line debugging
  • Using the Digital Sampling Trace
  • Step by step debugging, breakpoints and call stack
  • Soft oscilloscope

From the program list, it is possible to control the execution of each program at run time. Use the command of the "Project" menu to:

  • Stop or start the selected program.
  • Pause (suspend) or resume (restart) the selected program.

Stopped programs are displayed in red in the list of programs. Suspended programs are displayed in blue.

In this section

Communication parameters

The control panel

Using the editors in test mode

The Watch window

Command line debugging

Using the watch window for graphic monitoring

Digital sampling trace

Step by step debugging

The Output window

Soft oscilloscope

Test Sequences


Communication parameters

IEC 61131-3 Programming Environment -> Running the application -> Communication parameters

Previous chapter Next chapter Show all Show all Hide all Hide all

Before turning the Workbench in On Line mode, you need to setup correct communication parameters.

In offline mode, the communication parameters are displayed in the status bar. To change them, use the Tools / Communication Parameters menu command or double click on the parameters in the status bar.

The workbench support several possible protocols for communicating with the runtime system:

  • Standard "T5" protocol - supported by most of runtimes.
  • Multiple runtime protocol - for runtime systems running several VM tasks
  • Remote access protocol - for remote serial communication through modems and radio.

Select the protocol in the drop list and and enter the settings in the box below. The "..." button opens a wizard box for helping you entering the communication parameters according to the selected protocol.

In this section

Settings of the "T5" protocol

Settings of the multiple runtime protocol

Settings of the Remote access protocol


Settings of the "T5" protocol

IEC 61131-3 Programming Environment -> Running the application -> Communication parameters -> Settings of the "T5" protocol

Previous chapter Next chapter Show all Show all Hide all Hide all

The "T5" protocol is supported by most of runtimes and can be used either over ETHERNET or with a peer to peer serial link.

For an ETHERNET communication, you need to enter the IP address of the target system. The workbench uses default port 1100. If your target uses another port number, enter it after the IP address, separated by a semicolon. For instance:

Ethernet communication

For an ETHERNET communication, you need to enter the IP address of the target system. The workbench uses default port 1100. If your target uses another port number, enter it after the IP address, separated by a semicolon. For instance:

127.0.0.1:1102

Serial Link

In case of a serial link, you must specify the communication port used on the PC, floowed by the communication parameters according to the following syntax:

COM<np>:<baudrate>,<parity>,<data>,<stops>

Parameter | Description
<np> | number of the serial port used on the PC
<baudrate> | baudrate
<parity> | parity: N (none) or E (even) or O (odd)
<data> | number of data bits (7 or 8)
<stops> | number of stop bits (1 or 2)

The following example shows setting for communicating on COM1 port, at 19200 bauds, with Even parity, 8 data bits and 1 stop bit:

Example Example

COM1:19200,E,8,1


Settings of the multiple runtime protocol

IEC 61131-3 Programming Environment -> Running the application -> Communication parameters -> Settings of the multiple runtime protocol

Previous chapter Next chapter Show all Show all Hide all Hide all

This protocol is to be used with runtime systems running several PLC tasks (VMs) and can be used either over ETHERNET or with a peer to peer serial link.

In addition to the ETHERNET or serial parameters, you must specify the task number between brackets at the beginning of the setting string. The first task number is 1. For instance:

[1]127.0.0.1:1102

For an ETHERNET communication, you need to enter the IP address of the target system. The workbench uses default port 1100. If your target uses another port number, enter it after the IP address, separated by a semicolon. For instance:

Ethernet communication

For an ETHERNET communication, you need to enter the IP address of the target system. The workbench uses default port 1100. If your target uses another port number, enter it after the IP address, separated by a semicolon. For instance:

[1]127.0.0.1:1102

Serial Link

In case of a serial link, you must specify the communication port used on the PC, floowed by the communication parameters according to the following syntax:

[task]COM<np>:<baudrate>,<parity>,<data>,<stops>

Parameter | Description
<np> | number of the serial port used on the PC
<baudrate> | baudrate
<parity> | parity: N (none) or E (even) or O (odd)
<data> | number of data bits (7 or 8)
<stops> | number of stop bits (1 or 2)

The following example shows setting for communicating on COM1 port, at 19200 bauds, with Even parity, 8 data bits and 1 stop bit:

Example Example

[1]COM1:19200,E,8,1


Settings of the Remote access protocol

IEC 61131-3 Programming Environment -> Running the application -> Communication parameters -> Settings of the Remote access protocol

Previous chapter Next chapter Show all Show all Hide all Hide all

This protocol is to be used for remote serial communication and is particularly well adapted to communication systems with severe constraints such as radios and modems. Optionally, the communication driver on the Workbench may take care of dialup if connected to a modem. Press the "..." button for entering parameters in a wizard box. The following parameters are required:

Parameter | Description
PC port | Identifier of the COM port on the PC. If you want to use an internal modem, you need to map it it to a virtual COM port.
Baudrate | Baudrate
Parity | Parity: N (none) or E (even) or O (odd)
Stop bits | Number of stop bits (1 or 2)
Unit number | This number identifies the remote unit in case of a multidrop network. The default number for a unit on a peer to peer network is 1. The unit number must be a value from 1 to 32767
Timeout | Communication timeout in seconds (time for a single "question+answer" exchange)
Trials | Number of consecutive trials in case of error
Packet size | The messages transported on the protocol may be up to 1024 bytes. If you select the "small" packet size, then the driver splits messages in frames that do not exceed 255 characters.

Additionally, you can specify some dialup options:

Option | Description
Dialup | If this option is checked, the driver dialups the specified number when going On Line.
Number | Number to dial.
Timeout | Dialup timeout in seconds.
Init. | Initialization string for setting up the modem.

info Info

The dial number specified here can be changed when the Workbench establishes the communication.


The control panel

IEC 61131-3 Programming Environment -> Running the application -> The control panel

Previous chapter Next chapter Show all Show all Hide all Hide all

When the workbench is used for test (On Line or Simulation), the toolbar provides information about run-time target and provides all commands for controlling the target:

  1. Status of the target application.
  2. Control commands.
  3. Change the cycle triggering.

The application status

The status box provides global information about the target, the running application and the communication links. Possible states are:

State | Description
No connection | Connection is not established
Connecting | The workbench is establishing the communication
Disconnecting | The workbench is closing the connection
No application | Target is stopped
Other application | Another application runs on the target
Communication error | Communication error occurred
Bad version | The target runs a different version of the application
RUN | The application is running
STOP | The application is in cycle stepping mode
SFC break | The application is stopped on a SFC breakpoint
Error | The application is stopped on error

When an application is active in the target, you can mode the mouse cursor on the state box to display the detailed versioning information in a tooltip.

Controlling the application - Available commands

Icon | Description
 | Starts the application.
 | Stops the application.
 | Pause the application in Cycle to Cycle mode.
 | Restart the application in normal mode.
 | Execute a single step.
 | Download: Loads the application if the target is stopped (no application). Loads new code for On Line change if the application is running.
 | On Line change.
 | Step in (available during step by step debugging).
 | Step over (available during step by step debugging).
 | Step out (available during step by step debugging).

Cycle timing:

The cycle timing is displayed in a tooltip when you place the cursor upon the application status box. It includes:

  • The last measured cycle time.
  • The programmed cycle triggering period.
  • The maximum (longest) detected cycle time.
  • The number of timing overflow detected.


Using the editors in test mode

IEC 61131-3 Programming Environment -> Running the application -> Using the editors in test mode

Previous chapter Next chapter Show all Show all Hide all Hide all

In Test (On Line or Simulation) mode, all editors are animated with real time values of the edited objects:

  • Program states are displayed in the program list. Stopped programs are marked in red. Suspended programs are marked in blue.
  • Values of variables are visible in the variable editor. Double click on a variable name to force or lock the variable.
  • Values of variables, contacts and coils are displayed in FBD diagrams. Double click on a variable name to force or lock the variable.
  • Values of variables, contacts and coils are displayed in LD diagrams. Double click on a variable name to force or lock the variable.
  • Step activities (tokens) are displayed in the SFC editor.
  • In the text (ST or IL) editor, place the mouse cursor on a variable name to display its real time value in a tooltip. Double click on the variable name with the SHIFT key pressed to force or lock the variable.

Locking variables

When you double click on a variable symbol during debug, a dialog box is open and enables you to change the value of the variable. It also enables you to Lock or Unlocked variable. When a variable is locked, its value is no more changed by the runtime. You can then force its value from the debugger independently from the runtime operations. Note that the set of variables that accept to be locked depends on the build options.

Use the Project / Locked variables menu command to display the list of variables currently locked. This box also enables to unlock all currently locked variables.


The Watch window

IEC 61131-3 Programming Environment -> Running the application -> The Watch window

Previous chapter Next chapter Show all Show all Hide all Hide all

In addition to programs, the Workbench enables you to create monitoring files for testing your applications. There are three styles of documents:

  • Watch list: a list of variables.
  • Recipe: a recipe is a list of variables completed with one or more predefined sets of values.
  • Graphic layouts with animated objects.

Lists, recipes and graphics are managed and open from the workspace area on the left of the Workbench window. Use the Insert commands of the right click popup menu to create a document. Then double click on it in the workspace to open it.

Managing lists

To insert a variable, use the Insert Variable popup menu command. Alternatively, you can drag variables from program editors or from the variable editor to the Watch window to insert them in the list.

Commands of the local toolbar allows you to modify or arrange the contents of the list. Use the Move commands to change the order of variables in the list. Lists can be created and edited in both off line and on line modes.

Forcing a variable

At run time, double click on the value of the variable in the list or press ENTER key when it is selected. A small box appears and allows you to force / control the selected variable.

Dumping values

At run time, the value of a variable is displayed in text format in the Value column. You can place the mouse cursor on the value to display it in hexadecimal format. This feature is very useful when you spy strings with a large length or including non printable characters.

Recipes

Use the File / New / Recipe menu command to create a recipe. In addition to the list of variables and their values, extra columns can be added in the list for defining sets of values. To enter a value in a set, you just need to select the corresponding cell and enter the value. Some values may be missing in a set. Commands of the local toolbar enable you to create, rename or delete columns. The Send Recipe button is used for applying all the values of the selected set to the variables of the list.

attention Attention
  • Use of recipes from the Workbench ensures that all variables are written together at the same moment in the runtime, i.e. in between two cycles. This leads to a limit of around 50 variables (or less if strings) sent together. This limit does not occur when the recipe is handled directly by the program with the ApplyRecipeColumn function.
  • Sending a recipe to the target requires special protocol. If the target is Win-GRAF PAC driver 1.21 or older, the request will be denied by the target system.


Command line debugging

IEC 61131-3 Programming Environment -> Running the application -> Command line debugging

Previous chapter Next chapter Show all Show all Hide all Hide all

The workbench includes a powerful tool that enables you to run debug and monitoring commands during simulation or connected mode tests. Commands are entered as in a console in prompt mode. Commands are avaibale for reading and writing any complex variable or expression.

Debugging in prompt mode is available from the Prompt tab of the output window.

Reading expressions

To read a variable or a complex ST expression, just enter it at the prompt and hit ENTER. The expression may contain any ST operator, and can be used with variable indexes in case of an array.

Example Example

>MyVar
= 100
>iLevel > 123.4
= FALSE
>MyArray[i+1]
= 123
>

The following ST operators can be used in expressions:

Operator | Description
& AND OR XOR | boolean operators
+ - / * | arithmetics
= <> < > <= >= | comparisons
[ , ] | array index specification
. | structure member specification

The ST expression can also include constant values.

Forcing variables

To force a variable, enter its name followed by the ":=" sign and any ST expression. The specification of the forced variable may include variable indexes in case of an array.

Example Example

>MyVar := 200
OK
>MyArray[i+1] := iValue + 2
OK
>

Specifying a parent program

In order to get access to local variables, you need to specify the name of the default parent program. For that, enter "!local=" followed by the name of the program. When a parent program is specified, all variables used in commands can be either global or local to this program.

Example Example

>!local=PROG1
>LocalVar
=123
>


Using the watch window for graphic monitoring

IEC 61131-3 Programming Environment -> Running the application -> Using the watch window for graphic monitoring

Previous chapter Next chapter Show all Show all Hide all Hide all

The Watch window enables you to create graphic pictures animated during simulation or On Line test with real time values of the project variables. To create a new graphic document, Use the Insert New Graphic popup menu command in the workspace.

See the list of available objects and their properties for more details on possible drawings.

  1. Graphic area.
  2. Properties of the selected object / arrangement of the Z-order.
  3. Available types of animated objects.

Graphics can also be exported as HTML pages to be displayed in a browser.

To insert a new object, simply drag it from the list of available objects (3) to the graphic area (4). You can then select it to move/resize it, or to enter its properties in the correponding grid (2). Graphic documents are suffixed with ".gra" and can be stored anywhere on the disk.

Below are the commands available from the graphic editor toolbar:

Icon | Description
 | Set Operate or Edit mode (see note below).
 | Select the previous item in the graphic area.
 | Select the next item in the graphic area.
 | Align selected items on the left.
 | Align selected items on the top.
 | Align selected items on the right.
 | Align selected items on the bottom.
 | Makes all selected items the same width (*).
 | Makes all selected items the same height (*).
 | Makes all selected items the same width and height (*).
 | Send to front: move the selected item to the top in Z order.
 | Send to back: move the selected item to the bottom in Z order.
 | Define the background color for the graphic area.

(*) In those commands, the item used as a reference for sizing is the one selected with grey sizing marks on its border. Click the wished item with CTRL key pressed to select the reference item.

The Operate button is used to enable/disable changes in the graphic when used On Line. When the operate mode is selected, no change can be made. In that mode, the mouse can be used for driving active objects such as buttons.

The Z-order tab in the property area shows the list of the graphic items sorted according to their Z order. You can simply move objects in that list to change the Z-order and thus arrange overlapping items.

In this section

Graphic objects

Graphic objects properties

Export graphics as HTML pages


Graphic objects

IEC 61131-3 Programming Environment -> Running the application -> Using the watch window for graphic monitoring -> Graphic objects

Previous chapter Next chapter Show all Show all Hide all Hide all

Below are available basic objects you can insert in your graphics:

Basic shapes

A collection of basic drawings is available. Each object may be either static, or linked to a variable used to enable its visibility (show/hide).

Properties

  • Identifier
  • Aspect
  • Variable symbol
  • Spying delay
  • Border size
  • Border color
  • Data format
  • Color when not connected
  • Background color
  • Background mode
  • Text
  • Text color
  • Text mode
  • Font name
  • Font size
  • TRUE color
  • FALSE color
  • Direction

see description...

Bitmaps

Bitmap file (BMP, GIF, JPG) can be inserted in the graphic area.

Properties

  • Identifier
  • Border size
  • Border color
  • Border style
  • Background color
  • Background mode
  • Text
  • Text color
  • Text mode
  • Font name
  • Font size
  • Pathname
  • Bitmap display mode

attention Attention

Large bitmaps are time consuming during animation and can lead to poor performances, mainly if they have the STRETCH display mode or the TRANS (transparent) background mode.

see description...

Scales

Scales are static drawings representing a X or Y axis, generally used to document other objects such as trend charts or bargraphs.

Properties

  • Identifier
  • Border size
  • Border color
  • Border style
  • Background color
  • Background mode
  • Text
  • Text color
  • Text mode
  • Font name
  • Font size
  • Minimum value
  • Maximum value
  • Direction
  • Placement
  • Nb divisions (main)
  • Nb divisions (small)
  • Scale color

see description...

Text boxes

Static, animated or edit text boxes are available for displaying / forcing variables. For edit boxes at runtime, double click on the object to enter the value and then hit ENTER to validate the input.

Properties

  • Identifier
  • Variable symbol
  • Spying delay
  • Border size
  • Border color
  • Border style
  • Data format
  • Background color
  • Background mode
  • Text
  • Text color
  • Text mode
  • Font name
  • Font size
  • Action

see description...

Switches and 2-state displays

Buttons, switches and 2-state displays are used for control or display of a boolean variable.

Properties

  • Identifier
  • Aspect
  • Variable symbol
  • Spying delay
  • Border size
  • Border color
  • Data format
  • Data color
  • Background color
  • Background mode
  • Text
  • Text color
  • Text mode
  • Font name
  • Font size
  • Action
  • Pathname for TRUE state
  • Pathname for FALSE state
  • Bitmap display mode

see description...

Analog buttons

Analog buttons are used for setting the value of an integer or real variable. Mouse is used for setting the value.

Properties

  • Identifier
  • Variable symbol
  • Spying delay
  • Border size
  • Border color
  • Border style
  • Data format
  • Data color
  • Background color
  • Background mode
  • Text
  • Text color
  • Text mode
  • Font name
  • Font size
  • Minimum value
  • Maximum value
  • Scale color

see description...

Bargraphs

Bargraphs are rectangles filled according to the value of an analog variable. Bargraphs can be horizontal or vertical.

Properties

  • Identifier
  • Variable symbol
  • Spying delay
  • Border size
  • Border color
  • Border style
  • Data format
  • Data color
  • Background color
  • Background mode
  • Text
  • Text color
  • Text mode
  • Font name
  • Font size
  • Minimum value
  • Maximum value
  • Direction

see description...

Trend charts

Trend charts enable the tracing of a variable as with an oscilloscope.

Properties

  • Identifier
  • Aspect
  • Variable symbol
  • Spying delay
  • Border size
  • Border color
  • Border style
  • Data format
  • Data color
  • Background color
  • Background mode
  • Text
  • Text color
  • Text mode
  • Font name
  • Font size
  • Minimum value
  • Maximum value
  • Nb of points

see description...

Analog meters

Analog meters provide a graphical display of an analog value.

Properties

  • Identifier
  • Variable symbol
  • Spying delay
  • Border size
  • Border color
  • Border style
  • Data format
  • Data color
  • Background color
  • Background mode
  • Text
  • Text color
  • Text mode
  • Font name
  • Font size
  • Minimum value
  • Maximum value
  • Scale color
  • Nb divisions (main)
  • Nb divisions (small)

see description...

Sliders

Sliders are used for entering an analog value with a horirontal or vertical mouse driven cursor.

Properties

  • Identifier
  • Variable symbol
  • Spying delay
  • Border size
  • Border color
  • Border style
  • Data format
  • Data color
  • Background color
  • Background mode
  • Text
  • Text color
  • Text mode
  • Font name
  • Font size
  • Minimum value
  • Maximum value
  • Scale color
  • Direction

see description...

Digital meters

Digital meters (digits) display the value of a variable with the same aspect as a digital clock.

Properties

  • Identifier
  • Aspect
  • Variable symbol
  • Spying delay
  • Border size
  • Border color
  • Border style
  • Data format
  • Data color
  • Background color
  • Background mode
  • Text
  • Text color
  • Text mode
  • Font name
  • Font size
  • Minimum value
  • Maximum value

see description...

Links

Links are mouse driven hyperlinks that are used as shortcuts for opening another graphic document. Using links enable the design of multi page animated applications.

Properties

  • Identifier
  • Border size
  • Border color
  • Background color
  • Background mode
  • Text
  • Text color
  • Text mode
  • Font name
  • Font size
  • Link

see description...

Connection status

Connection status is a box actuated with the current status of the connection and the connected runtime application. It is aimed for diagnostic.

Properties

  • Identifier
  • Spying delay
  • Border size
  • Border color
  • Border style
  • Data format
  • Data color
  • Background color
  • Background mode
  • Text
  • Text color
  • Text mode
  • Font name
  • Font size

see description...


Graphic objects properties

IEC 61131-3 Programming Environment -> Running the application -> Using the watch window for graphic monitoring -> Graphic objects properties

Previous chapter Next chapter Show all Show all Hide all Hide all

This page details all possible properties for graphic objects. Refer to the list of available objects for further information about which property is used for which object.

Identifier

You can freely attach a text identifier to each graphic object inserted in a document. Identifiers are useful for arranging overlapped objects as they appear in the Z-order list.

Variable symbol

This is the full name of the application variable connected to the graphic object. In case of a local variable, its symbol must be prefixed with the parent program name, separated with "/". Example: "MyProg/MyVar".

Spying delay

This is the minimum period for actuating the value of the connected variable, expressed as a number of milliseconds. If the delay is not specified or equal to 0, refresh is done as fast as possible.

Border size

This property indicates the width of the border drawn around the object, as a number of pixels. If this property is 0, then no border is drawn.

Border color

This property indicates the color of the border drawn around the object.

Border style

This property indicates the possible 3D effect used for drawing the border around the object. Possible values are:

FLAT = no 3D effect
3DUP = depressed 3D effect
3DDOWN = pressed 3D effect
3D = default 3D effect

Text color

This property indicates the color used for drawing texts in the graphic object.

Text mode

This property indicates the font effect used for drawing texts in the graphic object. Possible values are:

HIDE = text is not displayed
NORMAL = normal font
BOLD = bold text
ITALIC = italic text
UNDERLINE = underlined text

Font name

This property indicates the name of the character font used for drawing texts in the graphic object.

Font size

This property indicates the size of the character font used for drawing texts in the graphic object. The size is expressed as a percentage of the actual height of the object. Maximum possible value is 100. This ensures that the ratio is kept when the object is resized.

Background color

This property indicates the color used for filling the background of the object. In case of a bitmap, it specifies the color that should not be drawn if the TRANS (trasparent) background mode is specified.

Background mode

This property indicates whether the background of the object must be filled or not. If this property is OPAQUE, then the background is filled with teh specified background color. If this property is TRANS (trasparent) then background is not filled. Transparent drawing mode may be useful in case of overlapping objects.

attention Attention

Specifying the TRANS (transparent) mode for large bitmaps is time consuming and will affect the real time performances of graphic updates.

Data format

If defined, this property indicates that the value of the connected variable must be displayed on the graphic object. You must specify for this property a format string that indicates how the data must be formatted.

attention Attention

The text property is ignored when a data format is specified.

Format string has the same format as the famous "printf" function of "C" language. It may include static characters together with one of the following possible pragmas that specify the value:

%s = default formatting according to IEC syntax
%d = integer (decimal)
%X = hexadecimal
%g = floating point
%.nf = decimal real (n is the number of displayed decimal digits)

Example Example
Format | Value | Displayed String
&d | 12.3 | 12
Var = %g meters | 1.2 | Var = 1.2 meters
%.2f | 1.12345 | 1.12

info Info

Only one % pragma can be used in a string.

Text

If defined, this property indicates the text to be displayed on the graphic object.

attention Attention

This property is ignored when a data format is specified.

Bitmap display mode

For bitmap based objects, this property indicates whether the attached bitmap must keep its original aspect or be stretched to the actual size of the object. Possible values are:

ORIGINAL = Keep the original aspect of the bitmap (cut if too large).
STRETCH = Stretch or shrink the bitmap for fitting the actual size of the graphic object.

attention Attention

Large bitmaps with STRETCH display mode are time consuming during animation and can lead to poor performances.

Minimum value

For analog animated objects (meters, bargraphs, trends...) this property indicates the minimum possible value that can be displayed. For static scales, it indicates the value of the lowest mark.

Maximum value

For analog animated objects (meters, bargraphs, trends...) this property indicates the maximum possible value that can be displayed. For static scales, it indicates the value of the highest mark.

Data color

This property indicates the color used to represent the value of connected variable within the object (for example the filled part of a bargraph).

Nb divisions (main)

For objects including a graphic scale, this property indicates the number of main division marks to be drawn in the scale.

Nb divisions (small)

For objects including a graphic scale, this property indicates the number of small division marks to be drawn in the scale, between each main division mark.

Scale color

For objects including a graphic scale, this property indicates the color used for drawing the axis, the division marks and corresponding values of the scale.

Bitmap pathname

For bitmaps, this property specifies the pathname of the bitmap to be displayed. BMP, GIF and JPG formats are supported. If no directory is specified, the specified file name is searched:

  • In the project folder.
  • In the "\BITMAP" folder of the workbench.

Bitmap for "TRUE" state

For 2-state objects having the CUSTOM aspect, this property specifies the pathname of the bitmap to be displayed when the value of the attached variable is TRUE (or not zero for analogs). BMP, GIF and JPG formats are supported. If no directory is specified, the specified file name is searched:

  • In the project folder.
  • In the "\BITMAP" folder of the workbench.

Bitmap for "FALSE" state

For 2-state objects having the CUSTOM aspect, this property specifies the pathname of the bitmap to be displayed when the value of the attached variable is FALSE (or zero for analogs). BMP, GIF and JPG formats are supported. If no directory is specified, the specified file name is searched:

  • In the project folder.
  • In the "\BITMAP" folder of the workbench.

Color when not connected

For shapes, this property indicates the color used for filling shapes when no variable is attached to the graphic object.

TRUE color

For shapes, this property indicates the color used for filling shapes when the attached variable has the TRUE state, or non zero for analogs.

FALSE color

For shapes, this property indicates the color used for filling shapes when the attached variable has the FALSE state, or zero for analogs.

Direction (basic shapes)

For oriented shapes such as triangles, half ellipses or cylender, this property indicates the direction of the drawing; to the left, to the right, to the top or to the bottom.

Direction (scale)

For scales, this property indicates the direction of the axis. If LEFT, the minimum value is on the left side. If RIGHT, the minimum value is on the right side.

Placement (scale)

For scales, this property indicates the location of the scale within the object rectangle: on the left, on the right, on the top or at the bottom.

Action (text)

Indicates the possible mouse action for text boxes. Following values are possible:

STATIC = No mouse action.
EDIT = Double click opens an edit box for entering the variable value.

Action (switch)

Indicates the possible mouse action for switches. Following values are possible:

STATIC = No mouse action.
PUSHBUTTON = The variable is forced to TRUE when pressed and to FALSE when depressed.
SWITCH = The status os the variable is inverted when the button is pressed.
ONESHOTBUTTON = Same as switch, but the display remains depressed when the mouse is released.

Direction (bargraph)

For bargraphs, this property indicates the growing direction: to the left, to the right, to the top or to the bottom.

Nb of points (trends)

For trend charts, this property indicates the maximum number of stored points. If the width of the object (in pixels) is less than this number, then oldest points are not visible.

Direction (slider)

For slider, this property indicates whether the slider is horizontal (RIGHT) or vertical (TOP).

Link

This property indicates the name of the target .GRA animated document for shortcuts. If no directory is specified in the link, then the file is searched in the project folder.

Aspect (shapes)

This property indicates the type of basic shape to be drawn. Possible aspects are:

CYLINDER = A 3D like cylinder.
ELLIPSE = An ellipse.
HALFELLPISE = One half of an ellipse.
GATE = A simple vector drawing for a valve.
RECTANGLE = A rectangle.
ROUNDRECT = A rectangle with rounded corners.
TRIANGLE = A triangle.

Aspect (switches)

This property indicates the type of switch to be drawn. Possible aspects are:

DEFAULT = A standard Windows-like push button.
CUSTOM = A button with TRUE and FALSE drawings defined with bitmaps.

Aspect (trend charts)

This property indicates the type of drawing for a trend chart. Possible aspects are:

POINT = Only relevant dots are drawn.
LINE = Lines are drawn from point to point.
HISTO = Histogram style.

Aspect (digits)

This property indicates the type of drawing for a digital meter. Possible aspects are:

DEFAULT = Plain drawing.
BEZEL = All segments have a 3D effect.


Export graphics as HTML pages

IEC 61131-3 Programming Environment -> Running the application -> Using the watch window for graphic monitoring -> Export graphics as HTML pages

Previous chapter Next chapter Show all Show all Hide all Hide all

When an animated graphic picture is designed in the workbench, you can export it as a HTML page to be displayed in a browser. Displaying the graphics will require ActiveX Components to be installed on the PC. Note that these components are automatically installed together with the Workbench.

To export a graphic as HTML:

  1. Turn the Workbench Off Line.
  2. Open the graphic document.
  3. Run the menu command: Tools / Generalte HTML Graphic.

A wizard guides you through the steps for the creation of the HTML page. Press the Next button in the welcome page. The following page is displayed:

In this page you must select or create the destination folder where the HTML page and related files will be stored. It is strongly recommended to store the page in an empty folder. Select the target directory and press Next. The following page is displayed:

You must fill the following options with relevant values:

Option | Description
HTML file name | Name of the generated HTML file.
Target name | Driver used for communication with the runtime. Specify K5NET5.DLL for a standard Win-GRAF PAC driver.
Connection settings | Communication parameters for connecting to the runtime. In case of an IP address, must be followed by ":" and the IP port number. If not specified, the default port number used is 1100.
Width / Height | Size in pixel of the graphic area in the HTML page.
ZIP file name | Embedded document file name (see notes) This field must be empty if you do not want to download the page to the runtime system .
Include symbol table | If this option is checked, the symbol table used for communication is saved together with the HTML page. If not, symbols are uploaded when the HTML page is opened.
Scroll bar | Indicates whether you want the graphic area to include a scroll bar.

If you specify a "ZIP" file name, then all files used by the page are zipped and sent together with the HTML page to the runtime system. This assumes that the runtime system is connected and includes a WEB server. Refer to the instructions of your OEM to know if any path or file name is imposed for the ZIP file. Note that this ZIP file may be big as it may include bitmap pictures.

After you press the Next button, the page is built and the following page is displayed:

Check the Display HTML graphic option if you want to test right now your page in a browser.

If you have selected a "ZIP" file name for embedding the page to the runtime system, press Finish to download the page and attached documents to the runtime. When download is complete, Press Cancel to close the box.


Digital sampling trace

IEC 61131-3 Programming Environment -> Running the application -> Digital sampling trace

Previous chapter Next chapter Show all Show all Hide all Hide all

The runtime system as the simulator include a digital sampling trace recorder. The recorder is used to register periodically the state of up to 8 boolean variables. Samples can be registered either on each cycle or according to a configurable period. The digital sampling trace is a useful tool for tracking aleas and events in the runtime application.

The sampling trace can be configured and watched from the Output window. The sampling trace is available only during simulation or on line debugging.

attention Attention
  • The digital sampling trace is a unique resource of the runtime system. The settings of the recorder are the same for all recorded variables.
  • The recording is limited to 900 samples of up to 8 BOOL variables.
  • Sampling trace recorder may be not available on some targets. Please refer to OEM instructions for further details about available features.
  • The recording of the sampling trace is time consuming and may slow down performances of the runtime system.

Operations

Use the following commands in the Log window when the Digital Sampling Trace tab is focused:

Icon / Shortcut | Description
 | Define the variables and the settings of the sampling trace.
 | Start recording.
 | Stops recording.
 | Set or reset the auto-scroll mode.
+ / - | Zoom in or out (num pad).

Settings

Before starting a recording, you need to setup the parameters for the recorder. This includes the list of spied variables, a period (either a time or on each cycle), plus start and stop conditions. All variables must have the BOOL data type.

Note that, if you program a period for the recorder, it means "wait at least this time between two samples", and does not correspond to an accurate time synchronization.

Press the Set button to validate the settings. Press the Reset button to clear the current settings in the runtime system.

Start condition

The Start Condition tab of the settings box enables you to define which condition will start the recording. The following choices are available:

  • Immediately.
  • Later: you will have to manually start the recorder using the Start command.
  • On the rising or falling edge of a BOOL variable, possibly with a delay.

The delay is expressed as a number of samples omitted after the start condition occured, before the recording actually starts.

Stop condition

The Stop Condition tab of the settings box enables you to define which condition will stop the recording. The following choices are available:

  • Never: you will have to manually stop the recorder using the Stop command.
  • When the buffer is full.
  • On the rising or falling edge of a BOOL variable, possibly with a delay.

The delay is expressed as a number of samples passed after the stop condition, before the recording actually stops.

Remarks

The recorder cannot be restarted after points have been registered, even if stopped. To restart the recording, you first have to re-validate the settings.

The sampling trace must be configured or started when the Workbench is used either for simulation or on line debugging.

Use the File / Save As and Edit / Copy commands for exchanging recorded data with other applications such as spreadsheets.


Step by step debugging

IEC 61131-3 Programming Environment -> Running the application -> Step by step debugging

Previous chapter Next chapter Show all Show all Hide all Hide all

In addition to the cycle by cycle execution mode, the debugger has a rich collection of powerful features for making step by step debugging in the source code of your application. The step by step feature is completed by the possibility to place breakpoints in the source code of the application. The debugger also shows you the call stack of called UDFBs and sub-programs when stepping. Step by step debugging is available:

  • In ST and IL text programs (a step is a statement).
  • In LD program (a step is a rung).
  • In FBD (a step is a graphic symbol corresponding to an action).

attention Attention
  • Step by step debugging is available only if the project has been compiled with the DEBUG option. This option can be selected from the project compiling options dialog box.
  • An application compiled in DEBUG mode includes additional information for stepping. This leads to bigger code size and less performances. It is recommended to compile your application in RELEASE mode when the debugging is finished.
  • Step by step debugging may be not supported on some target systems. Please refer to OEM instructions for further details about available features.

There are two possibilities for entering the step by step debugging mode:

  • Place a breakpoint in a program (using the Build / Set-Remove Breakpoint command). When the breakpoint is reached, the execution stops at the specified location and you can step further in the program.
  • When the target is in cycle stepping mode (STOP), you can step at the beginning of the first program.

The following commands are available for stepping, either from the main control panel, or from the Build menu of editors:

Command Icon | Description
 | Step over: If the next instruction is a call of a function block or a sub-program, the execution continues up to the end of the called block.
 | Step in: If the next instruction is a call of a function block or a sub-program, the next step will be at the beginning of the called block.
 | Step out: If the current stepping position is in a called function block or a sub-program, the execution continues up to the end of the block.

In addition to these commands, you can at any time:

  • Execute the cycle (from the current position up to the end of the last program).
  • Restart the target in normal execution mode (RUN).

Breakpoints

To put or remove a breakpoint in a program, use the Build / Set-Remove Breakpoint menu command. If the current position is not on a valid line for stepping, the breakpoint is automatically moved to the nearest valid position.

Breakpoints can be placed in programs, sub-programs or UDFBs. They are not available in SFC programs.

You can see the list of active breakpoints in the Log Window or in the output window of an editor. From here you have the possibility to remove all breakpoints in a single command. At any moment you can double click on a breakpoint in the Log window to open the corresponding program at the breakpoint location.

The call stack

When stepping, the Call Stack is available in the Log Window or in the output window of editors. It shows the stack of called function blocks and/or sub-programs, from the top level calling program up to the current stepping position. For a UDFB, the Call Stack also indicates which instance of the UDFB is executed.

At any moment you can double click on a line of the Call Stack to open the corresponding program.


The Output window

IEC 61131-3 Programming Environment -> Running the application -> The Output window

Previous chapter Next chapter Show all Show all Hide all Hide all

Use the commands of the View menu to show or hide the Output Window.

Runtime messages

The Log window displays all run time messages emitted by the target or by the simulator when testing the application. Messages are stored even if the Log window is not open, so it is not useful to keep it always open.

During step by step debugging, the Log Window also shows the current call stack and the list of installed breakpoints.

Project history

Select the History tab to display a listing where are logged all modifications and operations performed in the project. You must check the Edit / Activate History menu option for enabling the logging of modifications. Use the Edit / Settings menu command to setup the maximum number of logged events, and select the kinds of events you want to log.

Digital Sampling Trace

The runtime system as the simulator include a digital sampling trace recorder. Refer to the description of the sampling trace for further details.

Prompt

This tab enables you to debug in prompt console-like mode.


Soft oscilloscope

IEC 61131-3 Programming Environment -> Running the application -> Soft oscilloscope

Previous chapter Next chapter Show all Show all Hide all Hide all

The soft oscilloscope enables you to track the value of boolean or numerical variables and display it in a curve. Spied variables are tracked by the runtime, which detects changes and assign time stamps so that the trend displayed is very accurate.

The soft oscilloscope is available during On Line debugging. It uses the Win-GRAF PAC spontaneous protocol (used for binding) over ETHERNET. Thus the soft oscilloscope cannot be used with runtime systems having no ETHERNET connection.

The soft oscilloscope is run from the Workspace window. Use commands of the contextual popup menu to create new soft scope configurations. Below is the soft oscilloscope screen:

  1. List of variables to be displayed.
  2. Diagram area (oscilloscope display).

In the diagram area, the user can zoom, explore a particular time range and automatically scroll the diagrams.

The scroll bar behind, represents the current watching time range. The complete width represents the full time since target has started to the current target time.

To add new symbols to be displayed in diagrams, drag and drop them from the variable editor, or double click in an empty line in the list area. These new symbols can be added in both On Line or Off Line modes.

The following pieces of information are configured in the list:

Parameter | Description
Symbol | Name of the spied variable.
Color | Color used to draw the curve.
#Diagram | Index of the diagram pane - default is 1. You can define up to 30 panes.
Hysteresis | Hysteresis to apply for change detection of analog values. The hysteresis is entered as an absolute value.
Value | The current value of the variable is refreshed in this column.
Minimum/Maximum | Range of the Y axis.
Time | Time and date of the last change.
Description | Free description text.

The following commands are available from the soft oscilloscope toolbar:

Icon | Description
 | Move the selected variable up or down in the list.
 | Sort variables of the list.
 | Setup time ranges.
 | Start the oscilloscope.
 | Stop the oscilloscope.
 | Start recording.
 | Save record to the file.
 | Reload record from file.
 | Auto-scroll mode (toggle).

When sampling is active, you can start recording all events from now by clicking on corresponding (red) button. You must specify a csv file where samples will be recorded. All events on all symbols will be recorded in this file until you uncheck recording by clicking the button again.

When sampling is inactive, you can save particular parts of the diagrams to the disk. For this, will select the symbol(s) in the list and then zoom the time area to fit the range you want to save. Selected events will be saved in a .rec file. Later, you can restore a .rec file to the diagram. When user restore his diagrams, only symbols existing in the list will be updated.

The Setup button opens the following box for configuring the X-axis of the display:

Two modes are available:

  • Zoom mode
  • Autoscroll mode

You can choose a specific time area to be displayed with from and to lines. Buttons near are used to zoom from the first start time and to the current time.

In autoscroll mode, diagrams are scrolled automatically at the refresh rate to display the specified time range. The refresh rate can be increased for better refresh in autoscroll mode (for instance if the time range is long and if there lots of events occur during this period).


Test Sequences

IEC 61131-3 Programming Environment -> Running the application -> Test Sequences

Previous chapter Next chapter Show all Show all Hide all Hide all

The Workbench includes an integrated tool for designing and running automated test scenarios. Test scenarios are so called "Test Sequences" and are documents of the workspace. To include a new test sequence in your workspace, right click on a folder an run the command "Insert New Item". Then, in category "Watch" select "Test Sequence" and enter a name for the sequence.

Syntax

The following syntaxes are allowed in a text sequence:

Comments

Empty and comment lines are allowed. Comments may have the following syntaxes:

// comment up to the end of line

(* delimited comment *)

Evaluation of an expression

You can evaluate a complex expression using ST operators. Function calls are not allowed within an expression. Examples:

Var1

Bool1 & (Var2 > 1000)

If an expression is entered alone on a line of a sequence, its value is simply displayed in the report when run.

Forcing a variable

A line may contain a statement to force a variable, using the syntax:

variable_name := expression ;

Examples:

Var1 := 1000;

Var1 := Var1 + 1;

Waiting for an expression to be TRUE

Use the following syntax to wait for an expression to be TRUE:

wait expression ;

A timeout may be specified in between brackets after the "wait" keyword:

wait [timeout] expression ;

Examples:

wait Bool1;

wait [t#5] Bool1 OR Bool2;

If not specified, the default timeout is 10 seconds.

Waiting for a delay

A line may contain a delay statement, using the syntax:

wait_time time_value;

Examples:

wait_time t#2s;

Use

Use the editor toolbar to check and run your sequence:

Commands:

1 | Use this button to activate or deactivate the sequence. The sequence must be deactivated for editing. When activated, the sequence can be run and tested.
2 | Check the syntax of the sequence.
3 | Abort the sequence when running.
4 | Pause the sequence when running.
5 | Start the execution of the sequence.
6 | Single step: execute the selected line
7 | Set/remove a breakpoint on the current line.
8 | Remove all breakpoints.

Use the commands of the popup menu to save the sequence and its report to a CSV file.

© ICP DAS. Please contact us for any questions or comments: service@icpdas.com


Fieldbus configuration

IEC 61131-3 Programming Environment -> Fieldbus configuration

Previous chapter Next chapter Show all Show all Hide all Hide all

The workbench includes an integrated fieldbus configuration tool for various kinds of networked I/Os and protocols. The configuration tool enables you to describe networks as configuration trees and to wire variables to the I/O channels of devices.

Icon | Description
 | Use the command File / Open / Fieldbus configuration.

The fieldbus configuration proposes the following workspace:

  1. Configuration tree.
  2. Items within the node currently selected in the tree.
  3. Variables of the project.

Each kind of fieldbus is shown as a top-level node in the configuration tree. Run the Edit / Insert Configuration menu command to select a configuration to be added to the tree. Each configuration is displayed as a 4 level tree having the following form:

- Configuration (kind of fieldbus)

- Communication port or master device

- Slave device or data block

- Connected variable

Use the following buttons in the toolbar for building the configuration tree:

Icon | Description
 | Insert a new fieldbus (top level) in the configuration.
 | Insert a new master/port node in the selected fieldbus.
 | Insert a new slave/data block node under the selected master.
 | Insert a new variable node under the selected slave.

When an item is selected in the tree, all its children can be edited in the grid below. Alternatively you can double click on an item in the tree to enter its properties in a dialog box. Use the View / Grid menu command to show or hide the grid area.

You can also drag a variable from the list of declared variables (on the right) directly to a slave item in the tree.

In this section

MODBUS networking


MODBUS networking

IEC 61131-3 Programming Environment -> Fieldbus configuration -> MODBUS networking

Previous chapter Next chapter Show all Show all Hide all Hide all

The Win-GRAF PAC driver includes fully integrated MODBUS master and slave functions for enabling MODBUS communication on serial link or ETHERNET.

Protocol specification

The following protocols are supported:

  • MODBUS-RTU on a serial link.
  • Open MODBUS on ETHERNET.

The following MODBUS function codes are supported:

1 read coils
2 read bit inputs
3 read holding registers
4 read input registers
5 write 1 coil
6 write 1 register
15 write N coils
16 write N registers

As a default, the first valid address for each kind of data is 1. If you use MODBUS devices with other addressing conventions, you can change the base offset for each kind of data using the Tools / Addresses menu command.

Architecture

The Win-GRAF PAC driver can be used either as a server (MODBUS slave) or as a client (MODBUS master). Both server and client may be active at the same time. This allows multiple applications such as:

  • Slave connection to a MODBUS master such as a SCADA system.
  • Master connection to pilot MODBUS I/Os.
  • Win-GRAF PAC to Win-GRAF PAC communication for real time exchange of variables (binding).

The configuration of slave and master functions is done in the Workbench. Any data used by MODBUS is fully integrated in the application code and the VM database.

Communication ports

The client side opens a new port (RS or ETHERNET) for each configured MODBUS port. The number of client ports is not limited.

On the server side, the management of low level communication (sending and receiving frames) is fully included in the Win-GRAF PAC communication server, sharing the same ports for MODBUS requests and native requests. Thus the number of possible connected MODBUS maters fits the limitation of the communication server:

  • One serial port.
  • Several ports on ETHERNET (platform dependent - generally 7 ports max).

Other slave ports can be open by calling MBSlaveRTU or MBSlaveUDP function blocks.

Note that the same port can be freely used either for communication with a MODBUS master or for dialog with the workbench. Both workbench and MODBUS frames are recognized by the communication server.

The MODBUS-TCP Server always used the configuration of the first port.

Data exchange - configuration

The Win-GRAF PAC driver manages a intermediate variable map representing MODBUS data, for both master and slave connections. A dedicated configuration tool is integrated in the Workbench. Run it using the File / Open / Fieldbus Configuration menu command from the main window.

The MODBUS configuration is represented as a tree:

- MODBUS Configuration
- Slave (variables that can be accessed from external MODBUS masters)
- Input bits data block (read by masters)
- Variable (*)
- Input words data block (read by masters)
- Variable (*)
- Coil bits data block (forced by masters)
- Variable (*)
- Holding bits data block (forced by masters)
- Variable (*)
- Master communication port (connected to external MODBUS slaves) (*)
- Data block (read or write / bits or words) (*)
- exchanged Variable (*)
- Command variable (*)
- Status variable (*)

(*) The items with this mark can appear several times in the configuration.

MODBUS Slave configuration

You need to configurate the MODBUS slave in order to make variables visible from external MODBUS masters such as SCADA systems. Below is a simple example of slave configuration:

Example Example

Double click on the Local Server item to setup the MODBUS slave number that will identify the runtime application. When the local server is selected, use the Edit / New data block menu command to insert MODBUS data blocks. The following kinds of block are available:

  • input bits: bits read by external masters (function 2).
  • coil bits: bits forced by by external masters (function 5 or 15).
  • input registers: words read by external masters (function 4).
  • holding registers: words forced by external masters (function 6 or 16).

Each data block is identified by a MODBUS base address and a number of items (bits or words).

attention Attention
  • Read and write requests sent by MODBUS masters will be denied if the range specified in the request does not fit within a data block defined in the configuration. Requests overlapping two data blocks will be denied.
    For example, if you configure a block of 16 words starting at address 1 and another block of 16 words starting at address 17, a request for read or write of 32 words starting at address 1 will be denied and an "address error" exception will be reported.

When a server data block is selected, use the Edit / New variable command to map a variable to an item of the data block. Each variable is identified by a valid symbol of a variable in the open project and an offset in the data block according to MODBUS addressing.For exchanging boolean variables through MODBUS words, a hexadecimal mask is available in order to define to which bit of a word a variable is attached. For example, enter the mask "0001" to map a boolean variable to the less significant bit of a word. For exchanging 32 bit variables (DINT, REAL...), you can select to map the variable on two consecutive words.

At any time you can sort the variables of each data block according to their offset using the Edit / Sort symbols menu command.

MODBUS Master configuration

You need to configurate MODBUS master ports in order to drive external MODBUS I/Os with variables. Below is a simple example of master configuration with just one port defined:

Example Example

Run the Edit / New port to create a MODBUS port. Each port corresponds to one logical or physical MODBUS network. A port is based on either serial link or ETHERNET network. For ETHERNET ports, you must enter the IP address of the slave and its ETHERNET port number (usually 502). For serial ports, you must enter the settings of the port, according to your target platform conventions (e.g. "COM1:9600,N,8,1" on a PC based platform). As an option, you can select that the master retrys to open the port each time the communication fails.

attention Attention
  • Refer to OEM instructions for further information about MODBUS port configuration. Some runtimes may use other port than 502. It may also happen that changing the port settings for communication with the Workbench affects the MODBUS port configuration.

Another option at the "port" level enables the management by the MODBUS stack of diagnostic counters for each slave. See below the list of possible status information you can map to variables.

When a port is selected, you can add new MODBUS data blocks by running the Edit / New data block menu command. The following types of blocks are available:

  • Read input bits (function 2).
  • Read coil bits (function 1).
  • Write coil bits (function 5 or 15).
  • Read input registers (function 4).
  • Read holding registers (function 3).
  • Write holding registers (function 6 or 16).

Each data block is identified by a MODBUS slave number, a base address and a number of items (bits or words). The number of items is limited by MODBUS (2000 bits read, 1968 bits forced, 125 words read or 120 words forced).

For each request, you must define a timeout value in milliseconds, and an activation mode. Possible activation mode are:

  • Periodic: you must then enter the minimum period.
  • On change: in case of a write request, means that the request is changed each time a variable changes.
  • On call: the request is activated using a variable.

For periodic requests, you must specify an alternate period to be used if the last exchange of the request has failed. This is typically used to slow down exchanges with faulty slaves.

When a server data block is selected, use the Edit / New variable command to map a variable to an item of the data block. Each variable is identified by a valid symbol of a variable in the open project and an offset in the data block according to MODBUS addressing.

For exchanging boolean variables through MODBUS words, a hexadecimal mask is available in order to define to which bit of a word a variable is attached. For example, enter the mask "0001" to map a boolean variable to the less significant bit of a word. For exchanging 32 bit variables (DINT, REAL...), you can select to map the variable on two consecutive words.

At any time you can sort the variables of each data block according to their offset using the Edit / Sort symbols menu command.

Status and command variables

When you map a variable to a data block in a master configuration, you can select it to be:

  • An exchange of data (exchange between the MODBUS map and the Win-GRAF PAC variables).
  • A status (diagnostic information provided to the application).
  • A command (using a variable for driving the stack).

Below are possible diagnostic and status information available:

Information | Meaning
Error report | The variable is set to an error value when the last unsuccessful exchange is performed on the request. It is reset to 0 on the next successful exchange.
Error report (set only) | Same as upper, but the variable is not reset by the MODBUS stack. The application is in charge of resetting the variable.
On-going request | The variable is set to 1 when the request is sent to the slave and reset to 0 after either an answer from the slave or a timeout.
Success counter | The variable is increased each time the request is exchanged successfully.
Fail counter | The variable is increased each time the exchange of the request leads to an error.
Retry counter | The variable is set to 0 on the first trial and increased each time the request is retried.
Slave: last error | The variable contains the error code of the last error detected on this slave.
Slave: last error date stamp | The variable contains the date stamp of the last error detected on this slave.
Slave: last error time stamp | The variable contains the time stamp of the last error detected on this slave.
Slave: last reset date stamp | The variable contains the date stamp of the last "reset" action performed on slave counters.
Slave: last reset time stamp | The variable contains the time stamp of the last "reset" action performed on slave counters.
Slave: transaction counter | The variable is increased on any new exchange performed with this slave, whatever the exchange is successful or faulty.
Slave: failed transaction counter | This variable is increased on any new faulty exchange with this slave.

Below are the possible commands you can map:

Command | Description
Command (enable) | The request is sent continuously as long as the mapped command variable is TRUE (or not zero).
Command (one shot) | The request is sent only once when the mapped command variable becomes TRUE (or not zero). The variable is reset to 0 after the exchange.
Reset counters | The request counters are reset to 0 when the variable becomes TRUE (or not zero), and the command variable is then reset to 0.
Slave: reset counters | The slave counters are reset to 0 when the variable becomes TRUE (or not zero), and the command variable is then reset to 0.

Below are possible error codes for "status" variables:

Error code | Meaning
0 | OK
1 | MODBUS function not supported.
2 | Invalid MODBUS address.
3 | Invalid MODBUS value.
4 | MODBUS server failure.
6 | Server is busy.
8 | Data parity error.
10 | Invalid gateway path.
11 | Gateway target failed.
128 | Communication timeout.
129 | Bad CRC16.
130 | RS232 communication error.

When you map a variable to a data block in a master configuration, you can select it to be a command. In that case, the data block is exchanged only when the variable is TRUE (or non zero for numerical data types).

Data types

You can freely map a variable of any data type to a MODBUS item. The runtime automatically converts the value to the type of the variable.

For exchanging boolean variables through MODBUS words, a hexadecimal mask is available in order to define to which bit of a word a variable is attached. For example, enter the mask "0001" to map a boolean variable to the less significant bit of a word. For exchanging 32 bit variables (DINT, REAL...), you can select to map the variable on two consecutive words.

STRING variables are not supported and cannot be exchanged with MODBUS. 64 bit variable (LINT and LREAL) cannot be extracted directly without lost of accuracy or data.


Tools

IEC 61131-3 Programming Environment -> Tools

In addition to programming and test features, the workbench offers a rich collection of tools for managing and maintaining projects:

  • Cross references
  • Import / export projects
  • Comparing projects
  • Building HTML documents
  • Monitoring applications
  • The Console

In this section

Cross references

Import / Export projects

Comparing projects

Building HTML documents

Monitoring applications

The console

Code Checker


Cross references

IEC 61131-3 Programming Environment -> Tools -> Cross references

Previous chapter Next chapter Show all Show all Hide all Hide all

The Cross Reference tools enable you searching for declared variables in the whole application. It can also be used as a powerful navigation tool for editing changes in the application programs.

The results of the search are displayed in the Cross References tab of the output window.

Search in all programs

Use the Edit / Find / Find in Files menu command to search for a text in all programs. The text is searched in all the programs of the project. Occurences are listed in the output window. You can double click on an occurrence to open the program at the appropriate location.

List unused variables

Use the Edit / Find / Unused variables command to display the list of declared variables that are not used in the programs of the application. This command is particularly useful when cleaning a project.

List OEM library elements

Use the Edit / Find / OEM Library elements command to list the I/O devices, functions and function blocks written in "C" that are used in your application.

Find / replace in all programs

The Edit / Replace in files command enables you to replace a text in all the programs of the application. When running this tool, it makes a first scan and displays all the programs where the specified variables is used. Check the programs where you want to replace. Locations of each replaced text are listed in the output window.


Import / Export projects

IEC 61131-3 Programming Environment -> Tools -> Import / Export projects

Previous chapter Next chapter Show all Show all Hide all Hide all

The Workbench enbales you to archive projects for exchanging them. An archive is a unique compressed ZIP file that contains all the files of a project.

Use the commands of the File menu in the main window to save the project to a ZIP file or open a project from a ZIP file.

When you export a project, you can select to embed in the archive the definition of the OEM library elements (I/O devices, "C" functions and function blocks) referenced in the project. It is recommended to check this option if you are using custom functions, blocks or I/O devices that may not be installed on other machines.

When you import a ZIP archive, the workbench builds a new project where the archive is decompressed. You can select the name of the created project and its location on the disk. If you decide to import to your local library the OEM library items embedded in the archive, you will have to confirm the copy in case of an overwrite. You can select in which OEM library you want to put imported library elements.

Note that it is not possible to overwrite in the import library an item currently defined in another library.


Comparing projects

IEC 61131-3 Programming Environment -> Tools -> Comparing projects

Previous chapter Next chapter Show all Show all Hide all Hide all

The workbench includes a powerful tool that graphically displays all the differences between two projects. This tools is highly useful when managing various versions of a project and quickly highlights changes for better diagnostic and maintenance.

The project comparison tool is launched from the Windows Start menu, in the Workbench group, by the Compare projects command. You must specify the full qualified pathname of each project, and optionnally select the following options:

  • Ignore case: When this option is checked, the comparison ignores differences due to the case of texts.
  • Ignore comments: When this option is checked, all comment texts are removed before comparison.
  • Ignore white spaces: When this option is checked, the comparison ignores all additional white spaces and end of line characters in text files.
  • Ignore diagram presentation: When this option is checked, the tool compare only the logic of charts and diagrams. Presentation changes (such as moving a part of a diagram) are ignored.
  • Sort variables: When this option is checked, the comparison does not take care of the order used for variable declaration.

In addition to those options, you can select the format you wish for viewing declaration of variables:

  • IEC syntax
  • XML text
  • CSV text

Press the OK button to start the comparison. When processing is complete, a special viewer enables you two explore the projects and highlights difference. The following items are compared:

  • programs
  • variable declarations
  • definitions (#define statements)
  • project options

Texts written in blak means that items are identical. Differences are written in red on grey background.

A line written in red on white background means that this item contains differences. Double click on the item to show details. Then you can click on the << button to go back to the upper level.

At any moment you can see in the title bar of the window the pathnames of left and right projects. The identification of the item currently displayed is written close to the << button.


Building HTML documents

IEC 61131-3 Programming Environment -> Tools -> Building HTML documents

Previous chapter Next chapter Show all Show all Hide all Hide all

The Workbench includes a powerful wizard for building the whole documentation of the project in HTML format. This feature provides an easy way to print or communicate the description of your project. During visualization of the HTML pages, many cross-reference shortcuts simplify the navigation in the document.

To build the document, run the Tools / Generate Html Document menu command from the main window. A wizard then guides you through the steps of generating the pages. You must select a folder where all HTML pages and attached pictures will be stored. It is recommended that you create a new empty folder the first time you generate the document of a project.

When generation is complete, the wizard proposes you to immediately take a look at the generated pages if a HTML browser is available on your machine.


Monitoring applications

IEC 61131-3 Programming Environment -> Tools -> Monitoring applications

Previous chapter Next chapter Show all Show all Hide all Hide all

The workbench includes a wizard that build a monitoring application for the open project. The monitoring application is operated by the Monitoring Tool for spying and controlling the project without need of a full Workbench. Run the Tools / Build monitoring application from the menu of the main window to start the wizard.

info Info

Depending on your license, the wizard may not be available.

Main principle

The Workbench (1) is used for building the monitoring application in a unique file (2). The standalone Monitoring Tool (3) operates the monitoring application: it animates documents according to real time values from the connected target runtime (4). A monitoring application groups programs, lists of variables, plus the trace of runtime messages. The tool displays the value of the variables and can be used for forcing a variable. The set of items available in the monitoring application is selected in the wizard when building the application. Below is the description of the following operations you must perform when using the wizard:

Identification of the monitoring application

The first step is to give a name to your application. This name will be displayed in the main title bar of the viewer. The configuration of a monitoring application can be saved on the Workbench project. You can select to reopen an existing configuration in this page.

Type of projects tree and main options

The following step consists in setting main options for the application. The list of visible items will be shown as a tree in the viewer. You can choose among various presentations for the tree.

If you check the Include symbol table option, the monitoring application willl work on the full symbol table generatedby the compiler. You must take care that the same version of the application is running on the target. If you don't select this option, then the monitoring tool will automatically upload symbols from the target at connection time. In that case, you must ensure that all used symbols are embedded in the runtime application.

Selecting items

The next step is to select all the items of the project that you want to include in the monitoring application.

Passwords for items

For each item included in the application you can define a password so that the corresponding document will be protected in the monitoring application.

Passwords for variables

You can define passwords for the Monitoring Tool to make write access (forcing) to runtime variables. For each variable you can select one of the following access protection:

  • Free : the variable can be freely forced.
  • Protected : forcing the variable is possible with a password.
  • No : the variable can never be forced.

Simply drag variables from the list at the bottom to the upper list to set its protection mode. The Default choice indicates the protection mode that should be applied to all variables not explicitely expressed in the upper list.

Destination file

Everything is now ready for generating the monitoring application. The next step prompts you for selecting the pathname of the file that will contain the monitoring application. The application is stored as a unique compressed file.

The end

Now the application is generated. You can run it in simulation mode in the last page of the wizard. This page also proposes you to save the current configuration of the application so that you can use it later for update purpose.

Security issues

All programs stored in the monitoring application are encrypted. The user of the viewer cannot explore, copy or drag the contents of a watched program.


The console

IEC 61131-3 Programming Environment -> Tools -> The console

The Workbench includes a powerfule console where you can, during the development of a project, run some operations in command line text mode instead of using menus. This may be very useful to automate some repetitive tasks or quickly manipulate objects of huge projects.

While editing, go in the Prompt tab of the output window:

Enter the command "?" to get the list of availablae commands and their syntax. Below are available commands, sorted by categories.

Special commands

Command | Description
? | Display help.
HELP | Display help (same as "?").
FOR | Iterate a command.

Managing programs

Command | Description
CreateProgram | Create a main program.
CreateSP | Create a sub-program.
CreateUDFB | Create a User Defined Function Block.
CreateSfcChild | Create a child SFC program.
CopyProgram | Duplicate a program.
DeleteProgram | Delete a program.
EnumProgram | Enumerate programs.
GetProgram | Get information about a program.

Managing variables

Command | Description
CreateVar | Create a variable.
CreateInParam | Create an input variable.
CreateOutParam | Create an output variable.
DimVar | Set variable dimensions.
DeleteVar | Delete a variable.
InitVar | Set variable initial value.
SybVar | Specifies whether the symbol of a variable must be embedded.
ProfileVar | Set variable profile an embedded properties.
EnumVar | Enumerate variables.
GetVar | Get information about a variable.
GetVarProp | Get variable embedded properties.

Managing data types (structures)

Command | Description
CreateStruct | Create a structure.
DeleteStruct | Delete a structure.
EnumStruct | Enumerate structures.

Managing I/O boards

Command | Description
CreateIO | Create an instance of an IO device.
IOParam | Set a parameter of an IO board.
IOAlias | Give an alias to an IO channel.
DeleteIO | Delete an instance of an IO device.
EnumIO | Enumerate IO boards.
GetIO | Get information about an IO board.

Managing comment texts

Command | Description
Comm | Set comment text.
Tag | Set short comment text (tag) - variables only.
GetComm | Display a comment text.
GetTag | Display a short comment text (tag) - variables only.

In this section

Special commands

Managing programs

Managing variables

Managing data types (structures)

Managing I/O boards

Managing comment texts


Special commands

IEC 61131-3 Programming Environment -> Tools -> The console -> Special commands

Previous chapter Next chapter Show all Show all Hide all Hide all

seealso See also

Managing programs

Managing program folders

Managing variables

Managing data types (structures)

Managing I/O boards

Managing comment texts

The console

In this section

? / HELP - Display help

FOR - iterate a command


? / HELP - Display help

IEC 61131-3 Programming Environment -> Tools -> The console -> Special commands -> ? / HELP - Display help

Previous chapter Next chapter Show all Show all Hide all Hide all

? / HELP - Display help

Syntax:

HELP [ command ]
? [ command ]

Arguments:

command : name of the command you want help about

info Info

If no "command" argument is specified, then HELP lists all possible commands.

seealso See also

FOR - iterate a command

Managing programs

Managing program folders

Managing variables

Managing data types (structures)

Managing I/O boards

Managing comment texts

The console


FOR - iterate a command

IEC 61131-3 Programming Environment -> Tools -> The console -> Special commands -> FOR - iterate a command

Previous chapter Next chapter Show all Show all Hide all Hide all

FOR - Iterate a command

Syntax:

FOR <min> TO <max> <command> [ args ]

Arguments:

min : first enumeration integer value (see notes)

max : last enumeration integer value (see notes)

command : command to execute

args : arguments of the command

info Info

In command arguments, you can use the special '%' characters, to be replaced with the iteration number. If you specify consecutive '%' characters, this represents the iteration index formatted on several characters, completed on the left by '0' digits'. For example, the command:

FOR 1 TO 3 CreateProgram LD Prog%%

creates 3 LD programs called Prog01, Prog02 and Prog03

Note that not all commands support FOR iterations. See details about specific commands for further information.

seealso See also

? / HELP - Display help

Managing programs

Managing program folders

Managing variables

Managing data types (structures)

Managing I/O boards

Managing comment texts

The console


Managing programs

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing programs

Previous chapter Next chapter Show all Show all Hide all Hide all

seealso See also

Special commands

Managing program folders

Managing variables

Managing data types (structures)

Managing I/O boards

Managing comment texts

The console

In this section

CreateProgram

CreateSP

CreateUDFB

CreateSfcChild

CopyProgram

DeleteProgram

EnumProgram

GetProgram


CreateProgram

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing programs -> CreateProgram

Previous chapter Next chapter Show all Show all Hide all Hide all

CreateProgram - Create a main program

Syntax:

CreateProgram <language> <name>

Arguments:

language : SFC or FBD or LD or ST or IL

name : program name

info Info

The program is created at the end (after the last existing program) of the cycle.

This command can be used in a "FOR" loop.

seealso See also

CreateSP - Create a sub-program

CreateUDFB - Create a User Defined Function Block

CreateSfcChild - Create a child SFC program

CopyProgram - Duplicate a program

DeleteProgram - Delete a program

EnumProgram - Enumerate programs

GetProgram - Get information about a program

Special commands

Managing program folders

Managing variables

Managing data types (structures)

Managing I/O boards

Managing comment texts

The console


CreateSP

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing programs -> CreateSP

Previous chapter Next chapter Show all Show all Hide all Hide all

CreateSP - Create a sub-program

Syntax:

CreateSP <language> <name>

Arguments:

language : FBD or LD or ST or IL

name : sub-program name

info Info

This command can be used in a "FOR" loop.

seealso See also

CreateProgram - Create a main program

CreateUDFB - Create a User Defined Function Block

CreateSfcChild - Create a child SFC program

CopyProgram - Duplicate a program

DeleteProgram - Delete a program

EnumProgram - Enumerate programs

GetProgram - Get information about a program

Special commands

Managing program folders

Managing variables

Managing data types (structures)

Managing I/O boards

Managing comment texts

The console


CreateUDFB

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing programs -> CreateUDFB

Previous chapter Next chapter Show all Show all Hide all Hide all

CreateUDFB - Create a User Defined Function Block

Syntax:

CreateUDFB <language> <name>

Arguments:

language : FBD or LD or ST or IL

name : function block name

info Info

This command can be used in a "FOR" loop.

seealso See also

CreateProgram - Create a main program

CreateSP - Create a sub-program

CreateSfcChild - Create a child SFC program

CopyProgram - Duplicate a program

DeleteProgram - Delete a program

EnumProgram - Enumerate programs

GetProgram - Get information about a program

Special commands

Managing program folders

Managing variables

Managing data types (structures)

Managing I/O boards

Managing comment texts

The console


CreateSfcChild

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing programs -> CreateSfcChild

Previous chapter Next chapter Show all Show all Hide all Hide all

CreateSfcChild - Create a child SFC program

Syntax:

CreateSfcChild <parent> <name>

Arguments:

parent : name of the parent SFC program

name : sub-program name

info Info

This command can be used in a "FOR" loop.

seealso See also

CreateProgram - Create a main program

CreateSP - Create a sub-program

CreateUDFB - Create a User Defined Function Block

CopyProgram - Duplicate a program

DeleteProgram - Delete a program

EnumProgram - Enumerate programs

GetProgram - Get information about a program

Special commands

Managing program folders

Managing variables

Managing data types (structures)

Managing I/O boards

Managing comment texts

The console


CopyProgram

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing programs -> CopyProgram

Previous chapter Next chapter Show all Show all Hide all Hide all

CopyProgram - Duplicate a program

Syntax:

CopyProgram <program> <newprogram>

Arguments:

program : name of the source program

newprogram : name of the destination program to be created

info Info

This command is used for creating copies of a program. It should not be used for overwriting an existing program.

This command can be used in a "FOR" loop.

seealso See also

CreateProgram - Create a main program

CreateSP - Create a sub-program

CreateUDFB - Create a User Defined Function Block

CreateSfcChild - Create a child SFC program

DeleteProgram - Delete a program

EnumProgram - Enumerate programs

GetProgram - Get information about a program

Special commands

Managing program folders

Managing variables

Managing data types (structures)

Managing I/O boards

Managing comment texts

The console


DeleteProgram

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing programs -> DeleteProgram

Previous chapter Next chapter Show all Show all Hide all Hide all

DeleteProgram - Delete a program

Syntax:

DeleteProgram <program>

Arguments:

program : program to delete - may contains '?' wildchars

info Info

This command can be used in a "FOR" loop.

seealso See also

CreateProgram - Create a main program

CreateSP - Create a sub-program

CreateUDFB - Create a User Defined Function Block

CreateSfcChild - Create a child SFC program

CopyProgram - Duplicate a program

EnumProgram - Enumerate programs

GetProgram - Get information about a program

Special commands

Managing program folders

Managing variables

Managing data types (structures)

Managing I/O boards

Managing comment texts

The console


EnumProgram

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing programs -> EnumProgram

Previous chapter Next chapter Show all Show all Hide all Hide all

EnumProgram - Enumerate programs

Syntax:

EnumProgram [ filter ]

Arguments:

filter : filtering strings - may contain '*' and '?' wildchars

info Info

This command cannot be used in a "FOR" loop.

seealso See also

CreateProgram - Create a main program

CreateSP - Create a sub-program

CreateUDFB - Create a User Defined Function Block

CreateSfcChild - Create a child SFC program

CopyProgram - Duplicate a program

DeleteProgram - Delete a program

GetProgram - Get information about a program

Special commands

Managing program folders

Managing variables

Managing data types (structures)

Managing I/O boards

Managing comment texts

The console


GetProgram

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing programs -> GetProgram

Previous chapter Next chapter Show all Show all Hide all Hide all

GetProgram - Get information about a program

Syntax:

GetProgram <program>

Arguments:

program : program name

info Info

This command cannot be used in a FOR loop.

seealso See also

CreateProgram - Create a main program

CreateSP - Create a sub-program

CreateUDFB - Create a User Defined Function Block

CreateSfcChild - Create a child SFC program

CopyProgram - Duplicate a program

DeleteProgram - Delete a program

EnumProgram - Enumerate programs

Special commands

Managing program folders

Managing variables

Managing data types (structures)

Managing I/O boards

Managing comment texts

The console


Managing variables

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing variables

Previous chapter Next chapter Show all Show all Hide all Hide all

seealso See also

Special commands

Managing programs

Managing program folders

Managing data types (structures)

Managing I/O boards

Managing comment texts

The console

In this section

CreateVar

CreateInParam

CreateOutParam

DimVar

DeleteVar

InitVar

SybVar

ProfileVar

EnumVar

GetVar

GetVarProp


CreateVar

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing variables -> CreateVar

Previous chapter Next chapter Show all Show all Hide all Hide all

CreateVar - Create a variable

Syntax:

CreateVar <name> <type>

Arguments:

name : name of the variable - see notes

type : data type (can be a function block to create an instance)

info Info

This function is used for declaring a variable, or for adding an item to a data structure. The name of the variable must be prefixed with its group name and the '.' separator. The variable is considered as GLOBAL if no prefix is specified. Below are some examples:

Argument | Description
VarName | A global variable.
RETAIN.VarName | A RETAIN variable.
ProgName.LocVarName | A variable local to a program.
UDFBName.ParamName | A parameter of a UDFB.
StructName.Item | An item of a data structure.

This command can be used in a FOR loop.

seealso See also

CreateInParam - Create an input parameter

CreateOutParam - Create an output parameter

DimVar - Set variables dimensions

DeleteVar - Delete a variable

InitVar - Set variable initial value

SybVar - Specifies whether the symbol of a variable must be embedded

ProfileVar - Set variable profile and embedded properties

EnumVar - Enumerate variables

GetVar - Get information about a variable

GetVarProp - Get variable embedded properties

Special commands

Managing programs

Managing program folders

Managing data types (structures)

Managing I/O boards

Managing comment texts

The console


CreateInParam

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing variables -> CreateInParam

Previous chapter Next chapter Show all Show all Hide all Hide all

CreateInParam - Create an input parameter

Syntax:

CreateInParam <POU>.<name> <type>

Arguments:

POU : name of the sub-program or UDFB

name : name of the parameter

type : data type (can be a function block to create an instance)

info Info

This command can be used in a FOR loop.

seealso See also

CreateVar - Create a variable

CreateOutParam - Create an output parameter

DimVar - Set variables dimensions

DeleteVar - Delete a variable

InitVar - Set variable initial value

SybVar - Specifies whether the symbol of a variable must be embedded

ProfileVar - Set variable profile and embedded properties

EnumVar - Enumerate variables

GetVar - Get information about a variable

GetVarProp - Get variable embedded properties

Special commands

Managing programs

Managing program folders

Managing data types (structures)

Managing I/O boards

Managing comment texts

The console


CreateOutParam

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing variables -> CreateOutParam

Previous chapter Next chapter Show all Show all Hide all Hide all

CreateOutParam - Create an output parameter

Syntax:

CreateOutParam <POU>.<name> <type>

Arguments:

POU : name of the sub-program or UDFB

name : name of the parameter

type : data type (can be a function block to create an instance)

info Info

This command can be used in a FOR loop.

seealso See also

CreateVar - Create a variable

CreateInParam - Create an input parameter

DimVar - Set variables dimensions

DeleteVar - Delete a variable

InitVar - Set variable initial value

SybVar - Specifies whether the symbol of a variable must be embedded

ProfileVar - Set variable profile and embedded properties

EnumVar - Enumerate variables

GetVar - Get information about a variable

GetVarProp - Get variable embedded properties

Special commands

Managing programs

Managing program folders

Managing data types (structures)

Managing I/O boards

Managing comment texts

The console


DimVar

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing variables -> DimVar

Previous chapter Next chapter Show all Show all Hide all Hide all

DimVar - Set variable dimensions.

Syntax:

DimVar <var> <Dim1> [ Dim2 [ Dim3 ] ]

Arguments:

var : name of the variable - see notes

dim1, dim2, dim3 : dimensions (from highest to lowest)

info Info

This function is used for variables, parameters of sub-programs and UDFBs or for items of data structures. The name of the variable must be prefixed with its group name and the '.' separator. The variable is considered as GLOBAL if no prefix is specified. Below are some examples:

Argument | Description
VarName | A global variable.
RETAIN.VarName | A RETAIN variable.
ProgName.LocVarName | A variable local to a program.
UDFBName.ParamName | A parameter of a UDFB.
StructName.Item | An item of a data structure.

This command can be used in a FOR loop.

seealso See also

CreateVar - Create a variable

CreateInParam - Create an input parameter

CreateOutParam - Create an output parameter

DeleteVar - Delete a variable

InitVar - Set variable initial value

SybVar - Specifies whether the symbol of a variable must be embedded

ProfileVar - Set variable profile and embedded properties

EnumVar - Enumerate variables

GetVar - Get information about a variable

GetVarProp - Get variable embedded properties

Special commands

Managing programs

Managing program folders

Managing data types (structures)

Managing I/O boards

Managing comment texts

The console


DeleteVar

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing variables -> DeleteVar

Previous chapter Next chapter Show all Show all Hide all Hide all

DeleteVar - Delete a variable

Syntax:

DeleteVar <var>

Arguments:

var : name of the variable - see notes

info Info

This function is used for variables, parameters of sub-programs and UDFBs or for items of data structures. The name of the variable must be prefixed with its group name and the '.' separator. The variable is considered as GLOBAL if no prefix is specified. Below are some examples:

Argument | Description
VarName | A global variable.
RETAIN.VarName | A RETAIN variable.
ProgName.LocVarName | A variable local to a program.
UDFBName.ParamName | A parameter of a UDFB.
StructName.Item | An item of a data structure.

This command can be used in a FOR loop.

seealso See also

CreateVar - Create a variable

CreateInParam - Create an input parameter

CreateOutParam - Create an output parameter

DimVar - Set variables dimensions

InitVar - Set variable initial value

SybVar - Specifies whether the symbol of a variable must be embedded

ProfileVar - Set variable profile and embedded properties

EnumVar - Enumerate variables

GetVar - Get information about a variable

GetVarProp - Get variable embedded properties

Special commands

Managing programs

Managing program folders

Managing data types (structures)

Managing I/O boards

Managing comment texts

The console


InitVar

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing variables -> InitVar

Previous chapter Next chapter Show all Show all Hide all Hide all

InitVar - Set variable initial value

Syntax:

InitVar <var> [ value ]

Arguments:

var : name of the variable - see notes

value : initial value (initial value is removed if this argument is omitted)

info Info

This function is used for variables, parameters of sub-programs and UDFBs or for items of data structures. The name of the variable must be prefixed with its group name and the '.' separator. The variable is considered as GLOBAL if no prefix is specified. Below are some examples:

Argument | Description
VarName | A global variable.
RETAIN.VarName | A RETAIN variable.
ProgName.LocVarName | A variable local to a program.
UDFBName.ParamName | A parameter of a UDFB.
StructName.Item | An item of a data structure.

This command can be used in a FOR loop.

seealso See also

CreateVar - Create a variable

CreateInParam - Create an input parameter

CreateOutParam - Create an output parameter

DimVar - Set variables dimensions

DeleteVar - Delete a variable

SybVar - Specifies whether the symbol of a variable must be embedded

ProfileVar - Set variable profile and embedded properties

EnumVar - Enumerate variables

GetVar - Get information about a variable

GetVarProp - Get variable embedded properties

Special commands

Managing programs

Managing program folders

Managing data types (structures)

Managing I/O boards

Managing comment texts

The console


SybVar

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing variables -> SybVar

Previous chapter Next chapter Show all Show all Hide all Hide all

SybVar - Specifies whether the symbol of a variable must be embedded

Syntax:

SybVar <var> < ON | OFF >

var : name of the variable - may contain '*' and '?' wildchars - see notes

info Info

This function is used for variables, parameters of sub-programs and UDFBs or for items of data structures. The name of the variable must be prefixed with its group name and the '.' separator. The variable is considered as GLOBAL if no prefix is specified. Below are some examples:

Argument | Description
VarName | A global variable.
RETAIN.VarName | A RETAIN variable.
ProgName.LocVarName | A variable local to a program.
UDFBName.ParamName | A parameter of a UDFB.
StructName.Item | An item of a data structure.

This command can be used in a FOR loop.

seealso See also

CreateVar - Create a variable

CreateInParam - Create an input parameter

CreateOutParam - Create an output parameter

DimVar - Set variables dimensions

DeleteVar - Delete a variable

InitVar - Set variable initial value

ProfileVar - Set variable profile and embedded properties

EnumVar - Enumerate variables

GetVar - Get information about a variable

GetVarProp - Get variable embedded properties

Special commands

Managing programs

Managing program folders

Managing data types (structures)

Managing I/O boards

Managing comment texts

The console


ProfileVar

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing variables -> ProfileVar

Previous chapter Next chapter Show all Show all Hide all Hide all

ProfileVar - Set variable profile and embedded properties

Syntax:

ProfileVar <var> [ profile [ props ] ]

Arguments:

var : name of the variable - may contain '*' and '?' wildchars - see notes

profile : profile name - the profile is removed if not specified

pros : embedded properties - properties are removed if not specified

info Info

Properties are written as 'name=value,name=value...' such as shown in the variable editor.

This function is used for variables, parameters of sub-programs and UDFBs or for items of data structures. The name of the variable must be prefixed with its group name and the '.' separator. The variable is considered as GLOBAL if no prefix is specified. Below are some examples:

Argument | Description
VarName | A global variable.
RETAIN.VarName | A RETAIN variable.
ProgName.LocVarName | A variable local to a program.
UDFBName.ParamName | A parameter of a UDFB.
StructName.Item | An item of a data structure.

This command can be used in a FOR loop.

seealso See also

CreateVar - Create a variable

CreateInParam - Create an input parameter

CreateOutParam - Create an output parameter

DimVar - Set variables dimensions

DeleteVar - Delete a variable

InitVar - Set variable initial value

SybVar - Specifies whether the symbol of a variable must be embedded

EnumVar - Enumerate variables

GetVar - Get information about a variable

GetVarProp - Get variable embedded properties

Special commands

Managing programs

Managing program folders

Managing data types (structures)

Managing I/O boards

Managing comment texts

The console


EnumVar

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing variables -> EnumVar

Previous chapter Next chapter Show all Show all Hide all Hide all

EnumVar - Enumerate variables

Syntax:

EnumVar [ filter ]

Arguments:

filter : filtering strings - may contain '*' and '?' wildchars

info Info

This function is used for variables, parameters of sub-programs and UDFBs or for items of data structures. The filtering string must be prefixed with its group name and the '.' separator. Variables are considered as GLOBAL if no prefix is specified. Below are some examples:

Argument | Description
* | A global variable.
RETAIN.* | A RETAIN variable.
ProgName.* | A variable local to a program.
UDFBName.* | A parameter of a UDFB.
StructName.* | An item of a data structure.

This command cannot be used in a FOR loop.

seealso See also

CreateVar - Create a variable

CreateInParam - Create an input parameter

CreateOutParam - Create an output parameter

DimVar - Set variables dimensions

DeleteVar - Delete a variable

InitVar - Set variable initial value

SybVar - Specifies whether the symbol of a variable must be embedded

ProfileVar - Set variable profile and embedded properties

GetVar - Get information about a variable

GetVarProp - Get variable embedded properties

Special commands

Managing programs

Managing program folders

Managing data types (structures)

Managing I/O boards

Managing comment texts

The console


GetVar

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing variables -> GetVar

Previous chapter Next chapter Show all Show all Hide all Hide all

GetVar - Get information about a variable

Syntax:

GetVar <var>

Arguments:

var : name of the variable - see notes

info Info

This function is used for variables, parameters of sub-programs and UDFBs or for items of data structures. The name of the variable must be prefixed with its group name and the '.' separator. The variable is considered as GLOBAL if no prefix is specified. Below are some examples:

Argument | Description
VarName | A global variable.
RETAIN.VarName | A RETAIN variable.
ProgName.LocVarName | A variable local to a program.
UDFBName.ParamName | A parameter of a UDFB.
StructName.Item | An item of a data structure.

This command cannot be used in a FOR loop.

seealso See also

CreateVar - Create a variable

CreateInParam - Create an input parameter

CreateOutParam - Create an output parameter

DimVar - Set variables dimensions

DeleteVar - Delete a variable

InitVar - Set variable initial value

SybVar - Specifies whether the symbol of a variable must be embedded

ProfileVar - Set variable profile and embedded properties

EnumVar - Enumerate variables

GetVarProp - Get variable embedded properties

Special commands

Managing programs

Managing program folders

Managing data types (structures)

Managing I/O boards

Managing comment texts

The console


GetVarProp

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing variables -> GetVarProp

Previous chapter Next chapter Show all Show all Hide all Hide all

GetVarProp - Get variable embedded properties

Syntax:

GetVarProp <var>

Arguments:

var : name of the variable - see notes

info Info

This function is used for variables, parameters of sub-programs and UDFBs or for items of data structures. The name of the variable must be prefixed with its group name and the '.' separator. The variable is considered as GLOBAL if no prefix is specified. Below are some examples:

Argument | Description
VarName | A global variable.
RETAIN.VarName | A RETAIN variable.
ProgName.LocVarName | A variable local to a program.
UDFBName.ParamName | A parameter of a UDFB.
StructName.Item | An item of a data structure.

This command cannot be used in a FOR loop.

seealso See also

CreateVar - Create a variable

CreateInParam - Create an input parameter

CreateOutParam - Create an output parameter

DimVar - Set variables dimensions

DeleteVar - Delete a variable

InitVar - Set variable initial value

SybVar - Specifies whether the symbol of a variable must be embedded

ProfileVar - Set variable profile and embedded properties

EnumVar - Enumerate variables

GetVar - Get information about a variable

Special commands

Managing programs

Managing program folders

Managing data types (structures)

Managing I/O boards

Managing comment texts

The console


Managing data types (structures)

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing data types (structures)

Previous chapter Next chapter Show all Show all Hide all Hide all

seealso See also

Special commands

Managing programs

Managing program folders

Managing variables

Managing I/O boards

Managing comment texts

The console

In this section

CreateStruct

DeleteStruct

EnumStruct


CreateStruct

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing data types (structures) -> CreateStruct

Previous chapter Next chapter Show all Show all Hide all Hide all

CreateStruct - Create a structure

Syntax:

CreateStruct <name>

Arguments:

name : structure name

info Info

This command can be used in a FOR loop.

seealso See also

DeleteStruct - Delete a structure

EnumStruct - Enumerate structures

Special commands

Managing programs

Managing program folders

Managing variables

Managing I/O boards

Managing comment texts

The console


DeleteStruct

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing data types (structures) -> DeleteStruct

Previous chapter Next chapter Show all Show all Hide all Hide all

DeleteStruct - Delete a structure

Syntax:

DeleteStruct <struct>

Arguments:

struct : structure name

info Info

This command can be used in a FOR loop.

seealso See also

CreateStruct - create a structure

EnumStruct - Enumerate structures

Special commands

Managing programs

Managing program folders

Managing variables

Managing I/O boards

Managing comment texts

The console


EnumStruct

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing data types (structures) -> EnumStruct

Previous chapter Next chapter Show all Show all Hide all Hide all

EnumStruct - Enumerate structures

Syntax:

EnumStruct [ filter ]

Arguments:

filter : filtering strings - may contain '*' and '?' wildchars

info Info

This command cannot be used in a FOR loop.

seealso See also

CreateStruct - create a structure

DeleteStruct - Delete a structure

Special commands

Managing programs

Managing program folders

Managing variables

Managing I/O boards

Managing comment texts

The console


Managing I/O boards

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing I/O boards

Previous chapter Next chapter Show all Show all Hide all Hide all

seealso See also

Special commands

Managing programs

Managing program folders

Managing variables

Managing data types

Managing comment texts

The console

In this section

CreateIO

IOParam

IOAlias

DeleteIO

EnumIO

GetIO


CreateIO

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing I/O boards -> CreateIO

Previous chapter Next chapter Show all Show all Hide all Hide all

CreateIO - Create an instance of an IO device

Syntax:

CreateIO <slot> <IOtype>

Arguments:

slot : slot number (0 .. 255)

IOtype : type of IO device

info Info

This command cannot be used in a FOR loop.

seealso See also

IOParam - Set a parameter of an IO board

IOAlias - Give an alias to an IO channel

DeleteIO - Delete an instance of an IO device

EnumIO - Enumerate IO boards

GetIO - Get information about an IO board

Special commands

Managing programs

Managing program folders

Managing variables

Managing data types

Managing comment texts

The console


IOParam

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing I/O boards -> IOParam

Previous chapter Next chapter Show all Show all Hide all Hide all

IOParam - Set a parameter of an IO board

Syntax:

IOParam <%board> <name> <value>

Arguments:

%board : address of the IO board (e.g. %QX0)

name : name of the parameter

value : value for the parameter

info Info

This command cannot be used in a FOR loop.

seealso See also

CreateIO - Create an instance of an IO device

IOAlias - Give an alias to an IO channel

DeleteIO - Delete an instance of an IO device

EnumIO - Enumerate IO boards

GetIO - Get information about an IO board

Special commands

Managing programs

Managing program folders

Managing variables

Managing data types

Managing comment texts

The console


IOAlias

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing I/O boards -> IOAlias

Previous chapter Next chapter Show all Show all Hide all Hide all

IOAlias - Give an alias to an IO channel

Syntax:

IOAlias <%channel> <alias>

Arguments:

%channel : address of the IO channel (e.g. %QX0.1)

alias : readable name to be used as an alias

info Info

This command cannot be used in a FOR loop.

seealso See also

CreateIO - Create an instance of an IO device

IOParam - Set a parameter of an IO board

DeleteIO - Delete an instance of an IO device

EnumIO - Enumerate IO boards

GetIO - Get information about an IO board

Special commands

Managing programs

Managing program folders

Managing variables

Managing data types

Managing comment texts

The console


DeleteIO

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing I/O boards -> DeleteIO

Previous chapter Next chapter Show all Show all Hide all Hide all

DeleteIO - Delete an instance of an IO device

Syntax:

DeleteIO <slot>

Arguments:

slot : slot number (0 .. 255)

info Info

This command cannot be used in a FOR loop.

seealso See also

CreateIO - Create an instance of an IO device

IOParam - Set a parameter of an IO board

IOAlias - Give an alias to an IO channel

EnumIO - Enumerate IO boards

GetIO - Get information about an IO board

Special commands

Managing programs

Managing program folders

Managing variables

Managing data types

Managing comment texts

The console


EnumIO

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing I/O boards -> EnumIO

Previous chapter Next chapter Show all Show all Hide all Hide all

EnumIO - Enumerate IO boards

Syntax:

EnumIO

info Info

This command cannot be used in a FOR loop.

seealso See also

CreateIO - Create an instance of an IO device

IOParam - Set a parameter of an IO board

IOAlias - Give an alias to an IO channel

DeleteIO - Delete an instance of an IO device

GetIO - Get information about an IO board

Special commands

Managing programs

Managing program folders

Managing variables

Managing data types

Managing comment texts

The console


GetIO

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing I/O boards -> GetIO

Previous chapter Next chapter Show all Show all Hide all Hide all

GetIO - Get information about an IO board

Syntax:

GetIO <%board>

Arguments:

%board : address of the IO board (e.g. %QX0)

info Info

This command cannot be used in a FOR loop.

seealso See also

CreateIO - Create an instance of an IO device

IOParam - Set a parameter of an IO board

IOAlias - Give an alias to an IO channel

DeleteIO - Delete an instance of an IO device

EnumIO - Enumerate IO boards

Special commands

Managing programs

Managing program folders

Managing variables

Managing data types

Managing comment texts

The console


Managing comment texts

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing comment texts

Previous chapter Next chapter Show all Show all Hide all Hide all

seealso See also

Special commands

Managing programs

Managing program folders

Managing variables

Managing data types

Managing IO boards

The console

In this section

Comm

Tag

GetComm

GetTag


Comm

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing comment texts -> Comm

Previous chapter Next chapter Show all Show all Hide all Hide all

Comm - Set comment text

Syntax:

Comm <X|P|S|V|B> <name> <comment>

Arguments:

name : object name

comment : comment text

info Info

Use the following values for the first argument that specifies the kind of object:

X : project
P : program or sub-program or UDFB
S : structure
V : variable
B : IO board

In case of a variable, the name must be prefixed by the group namle follosed by the '.' separator. Below are some examples:

Argument | Description
VarName | A global variable.
RETAIN.VarName | A RETAIN variable.
ProgName.LocVarName | A variable local to a program.
UDFBName.ParamName | A parameter of a UDFB.
StructName.Item | An item of a data structure.

This command can be used in a FOR loop, except or IO boards.

seealso See also

Tag - Set short comment text (tag) - variables only

GetComm - Display a comment text

GetTag - Display a short comment text (tag) - variables only

Special commands

Managing programs

Managing program folders

Managing variables

Managing data types

Managing IO boards

The console


Tag

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing comment texts -> Tag

Previous chapter Next chapter Show all Show all Hide all Hide all

Tag - Set short comment text (tag) - variables only

Syntax:

Tag V <name> <comment>

Arguments:

name : variable name (see notes)

comment : short comment text (tag)

info Info

The name of the variable must be prefixed by the group namle follosed by the '.' separator. Below are some examples:

Argument | Description
VarName | A global variable.
RETAIN.VarName | A RETAIN variable.
ProgName.LocVarName | A variable local to a program.
UDFBName.ParamName | A parameter of a UDFB.
StructName.Item | An item of a data structure.

This command can be used in a FOR loop, except or IO boards.

seealso See also

Comm - Set comment text

GetComm - Display a comment text

GetTag - Display a short comment text (tag) - variables only

Special commands

Managing programs

Managing program folders

Managing variables

Managing data types

Managing IO boards

The console


GetComm

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing comment texts -> GetComm

Previous chapter Next chapter Show all Show all Hide all Hide all

GetComm - Display a comment text

Syntax:

GetComm <X|P|S|V|B> <name>

Arguments:

name : object name

info Info

Use the following values for the first argument that specifies the kind of object:

X : project
P : program or sub-program or UDFB
S : structure
V : variable
B : IO board

In case of a variable, the name must be prefixed by the group namle follosed by the '.' separator. Below are some examples:

Argument | Description
VarName | A global variable.
RETAIN.VarName | A RETAIN variable.
ProgName.LocVarName | A variable local to a program.
UDFBName.ParamName | A parameter of a UDFB.
StructName.Item | An item of a data structure.

This command cannot be used in a FOR loop.

seealso See also

Comm - Set comment text

Tag - Set short comment text (tag) - variables only

GetTag - Display a short comment text (tag) - variables only

Special commands

Managing programs

Managing program folders

Managing variables

Managing data types

Managing IO boards

The console


GetTag

IEC 61131-3 Programming Environment -> Tools -> The console -> Managing comment texts -> GetTag

Previous chapter Next chapter Show all Show all Hide all Hide all

GetTag - Display a short comment text (tag) - variables only

Syntax:

GetTag V <name>

Arguments:

name : variable name (see notes)

info Info

The name of the variable must be prefixed by the group namle follosed by the '.' separator. Below are some examples:

Argument | Description
VarName | A global variable.
RETAIN.VarName | A RETAIN variable.
ProgName.LocVarName | A variable local to a program.
UDFBName.ParamName | A parameter of a UDFB.
StructName.Item | An item of a data structure.

This command can be used in a FOR loop, except or IO boards.

seealso See also

Comm - Set comment text

Tag - Set short comment text (tag) - variables only

GetComm - Display a comment text

Special commands

Managing programs

Managing program folders

Managing variables

Managing data types

Managing IO boards

The console


Code Checker

IEC 61131-3 Programming Environment -> Tools -> Code Checker

The Code Checker tool performs a scan of the project declarations and programs, in order to check conformity to a set of rules, motivated by integrity, safety and portability of the code. It is run from the "Code Checker" tab of the Output window.

Use the "Settings" button to select/configure the rules to be checked for violations.

Use the "Scan" button to start analysis. The project must be compiled without errors before being checked.

Double clicking on a violation report line in the output enables you to navigate to the corresponding location of the source code.

Use commands of the contextual popup menu to copy or export the report.

Note: an option is available in the "Compiler" section of the "Project Settings" box to systematically run the Code Checker after any successful build.

Rules configuration

Use the "Configure" button to select and configure rules to be checked. This is also available from the main tab of the "Project Settings" box. Rules are shown in a tree including check boxes. Unchecked rules will be skipped during scan. Double click on a rule to configure it.

You can select for each rule a severity level: "Not checked" or "Info" or "Warning" or "Error" or "Fatal". You can also enter for each rule a text reference that will be displayed in reports.

For rules referring to metrics (e.g. name length) you can enter a minimum and maximum value.

For rules concerning variables, you can specify a filter based on the "User's group" column of the variable editor: either check only in some user's groups, or check except in some user's groups. Please enter one user's group name per line

For rule 1.4, you have to enter in the "Data" box the list of forbidden names. Please enter one name per line.

In addition the rules configuration box enables you to export or import the configuration as XML file.

Rules

1.1

IO channels (%...) must have an alias

Default level = ERROR

Accept filtering by user’s group

All I/O board channels ("%..." variables created from the IO board editor) must have a readable alias defined in the variable editor. The "%..." names cannot be used in programs. Programs must always refer to aliases.

1.2

IO channels (%...) aliases should not reflect the hardware location

Default level = WARNING

Accept filtering by user’s group

Aliases of I/O board channels should not reflect the hardware location. For instance an alias for channel "%IX0.1" cannot be "DI0_1".

1.3

Names must respect a minimum and a maximum length

Default level = INFO

Accept filtering by user’s group in case of variables

Minimum and maximum values configurable

This applies to any declared variable or POU.

1.4

Names used during debug should not remain in the project

Default level = INFO

Accept filtering by user’s group in case of variables

Data = list of forbidden names, separated by comas.

The dummy variables used during debugging should be removed from the final project. The user should enter the list of forbidden names for this rule.

1.5

All given names must be conform to IEC standard

Default level = ERROR

Accept filtering by user’s group in case of variables

The Workbench proposes an option in order to accept variable names not compliant with the IEC standard (with punctuation, accents, spaces…). This option should not be used. Symbols of all variables and POUs are checked.

1.6

Names reserved for keywords should not be used

Default level = FATAL

Accept filtering by user’s group in case of variables

Reserved keywords from the IEC standard should not be used for naming variables, whatever is the programming language. For instance, the name "STEP" cannot be used.

1.7

POU information should be filled

Default level = WARNING

Does not accept filtering by user’s group

In the "POU Information" box, the items "Author", "Security Class" and "Project No" must be filled.

1.8

The case of variable names must be respected

Default level = INFO

Accept filtering by user’s group in case of variables

When a variable is used in programs, it must have exactly the same case as its declared name.

2.1

All declared objects must have a comment

Default level = ERROR

Accept filtering by user’s group in case of variables

This applies to all declared variables and POUs.

2.2

Comments must respect a minimum length

Default level = ERROR

Accept filtering by user’s group in case of variables

Minimum and maximum values configurable for the length

This applies to all declared variables and POUs.

2.3

The percentage of comments should be sufficient

Default level = WARNING

Accept filtering by user’s group in case of variables

Minimum value configurable as percent

This is the percentage of comments entered within the code of POU, whatever is the programming language. This percentage is tested individually for each POU and applies only to the code. Comments entered for local variables are not counted here.

2.4

Comments should not contain special characters

Default level = WARNING

Accept filtering by user’s group in case of variables

Minimum value configurable as percent

Characters with ASCII code greater than 127 (accents, special characters) should not be used in comments. This applies to both declared objects and comments entered in POUs.

3.x

XXX language should not be used for main programs

Default level = FATAL for IL – NOT CHECKED for others

Does not accept filtering by user’s group

This rule is derived for: IL, ST, LD, FBD and SFC languages

3.x

XXX language should not be used for UDFBs

Default level = FATAL for IL – NOT CHECKED for others

Does not accept filtering by user’s group

This rule is derived for: IL, ST, LD, FBD and SFC languages

3.x

XXX language should not be used for sub-programs

Default level = FATAL for IL – NOT CHECKED for others

Does not accept filtering by user’s group

This rule is derived for: IL, ST, LD and FBD languages.

4.1

All input parameters must be read out

Default level = FATAL

Accept filtering by user’s group in case of variables

Any IN parameter of a UDFB or sub-program must be read in its implementation.

4.2

All output parameters must be written before they are read out

Default level = FATAL

Accept filtering by user’s group in case of variables

Any OUT parameter of a UDFB or sub-program must be written in its implementation. It can be read, but only if it was written before.

4.3

All INOUT parameters must be written and read out

Default level = FATAL

Accept filtering by user’s group in case of variables

Any INOUT parameter of a UDFB or sub-program must be read and written in its implementation.

4.4

Forward and backward jumps should not be used

Default level = ERROR

Does not accept filtering by user’s group

This applies to jump and return instructions in LD, FBD and IL, plus RETURN, EXIT and GOTO statements in ST.

4.5

ST expressions should not be used in LD and FBD

Default level = FATAL

Does not accept filtering by user’s group

Text associated to graphic items in LD and FBD programs should not be complex expressions. For instance, associating "IntVar > iMax" to a LD contact is not accepted.

4.6

LD coils should be aligned on the right

Default level = WARNING

Does not accept filtering by user’s group

4.7

IF structures should include an ELSE section

Default level = WARNING

Does not accept filtering by user’s group

This applies to both "IF" and "CASE" statements in ST language.

4.8

There should not be dead code (uncalled UDFB or sub-program)

Default level = ERROR

Does not accept filtering by user’s group

Any declared UDFB or sub-program must be used at least once in the project. Conditional compiling is forbidden.

4.9

Equality tests should not be used with REAL and LREAL

Default level = FATAL

Does not accept filtering by user’s group

The option "Forbid equality tests between reals" must be checked in the "Compiler" section of the "Project Settings" box.

4.10

Nesting of ST structure should not exceed a complexity level

Default level = INFO

Does not accept filtering by user’s group

Maximum value configurable

This applies to nesting of any IF, WHILE, REPEAT, FOR, CASE structure in ST language.

4.11

The "WAIT" instructions of the ST language should not be used

Default level = ERROR

Does not accept filtering by user’s group

The instructions "WAIT", "WAIT_TIME" and "DO_WAIT" should not be used in ST.

4.12

The loop instructions of the ST language should not be used

Default level = ERROR

Does not accept filtering by user’s group

The instructions "WHILE", "REPEAT" and "FOR" should not be used in ST.

4.13

All block inputs should be connected in FBD diagrams

Default level = ERROR

Does not accept filtering by user’s group

This refers to an option in the "Project Settings" box. In the "Advanced" category, the "Deny unwired inputs in FBD" should be checked.

4.14

POUs in ST or IL should not exceed a number of lines

Default level = WARNING

Does not accept filtering by user’s group

Maximum value configurable

This applies to the entire POU contents, including comments and empty lines.

4.15

POUs in LD should not exceed a number of rungs

Default level = WARNING

Does not accept filtering by user’s group

Maximum value configurable

4.16

POUs in LD or FB should not exceed a number of blocks

Default level = WARNING

Does not accept filtering by user’s group

Maximum value configurable

Any function, operator or function block inserted in the diagram is counted.

4.17

POUs in SFC should not exceed a number of steps

Default level = WARNING

Does not accept filtering by user’s group

Maximum value configurable

5.1

All declared variables must be used in programs

Default level = ERROR

Accept filtering by user’s group in case of variables

Unused variables should not remain in the project.

5.2

Arrays of structures should not be used

Default level = WARNING

Accept filtering by user’s group in case of variables

5.3

All variables must be written before they are read out

Default level = ERROR

Accept filtering by user’s group in case of variables

This also applies to global variables read or written among several POUs, according to their execution order. This rule is not applied to variables declared as "Read only".

5.4

An instance of FB should be called only once

Default level = FATAL

Accept filtering by user’s group in case of variables

This regards calling of the same declared instance of the same function block.

5.5

A global variable should be written in only one POU

Default level = ERROR

Accept filtering by user’s group in case of variables

It is allowed that the global variable is read in other POUs.

5.6

A variable should be written only once among programs

Default level = FATAL

Accept filtering by user’s group in case of variables

This applies to both local variables used within one POU and global variables used in several POUs of the project.

5.7

Arrays should not be used

Default level = WARNING

Accept filtering by user’s group in case of variables

5.8

Parallel branches should not be used in SFC

Default level = WARNING

Does not accept filtering by user’s group

The use of parallel branches (AND divergences) in SFC programs is not allowed.

5.9

SFC charts should be checked

Default level = FATAL

Does not accept filtering by user’s group

In the "Project Settings" box, the compiling option "Check safety of SFC charts" must be enabled.

5.10

All declared variables with single data type must have an initial value

Default level = WARNING

Accept filtering by user’s group in case of variables

This rule does not apply to: channels of an input board (%), arrays, structures, instances of function block, input or output parameters of UDFBs and sub-programs.

6.1

The code should not be built with debugging options checked

Default level = FATAL

Does not accept filtering by user’s group

This rule refers to compiling options set from the "Project Settings" box. The code should not be compiled in DEBUG mode. The "Variable Locking" feature should not be enabled. On Line Change should not be enabled.

6.2

Arrays indexes should be checked at runtime

Default level = FATAL

Does not accept filtering by user’s group

This rule refers to compiling options set from the "Project Settings" box. The compiling option "Check array indexes at runtime" should be checked.

6.3

Dynamic memory allocation should be configured with limited size

Default level = FATAL

Does not accept filtering by user’s group

This rule refers to compiling options set from the "Project Settings" box. In the settings of the "Enable Dynamic memory allocation" or the "Runtime" memory should not be configured to use Operating System dynamic memory.

© ICP DAS. Please contact us for any questions or comments: service@icpdas.com


Resources

IEC 61131-3 Programming Environment -> Resources

In addition to IEC-1131 programming, the workbench enables you to design some configuration data to be embedded together with the application code and used at runtime using related functions or function blocks.

The system supports the following kinds of resources

String tables: statically defined tables of texts to be used at runtime with STRING variables.
Signals: analog signals to be played at runtime for generating a setpoint.

To create a new resource, run the Insert New Item command from the workspace area and then select the Resources category. Double click on a resource from the workspace to open it.

In this section

String table resources

Analog signals resources


String table resources

IEC 61131-3 Programming Environment -> Resources -> String table resources

Previous chapter Next chapter Show all Show all Hide all Hide all

String tables are resources (embedded configuration data) edited with the Workbench. A string table is a list of items identified by a name and referring to one or more character strings.

String tables are typically used for defining static texts to be used in the application. The following functions can be used for getting access to string tables in the programs:

StringTable: selects the active string table.
LoadString: Load a string from the active table.

In addition, each string table may contain several columns of texts for each item, and thus ease the localization of application, simply by defining a column for each language. This way the language can be selected dynamically at runtime, simply by specifying the active language (as a column) in the StringTable() function.

The name entered in the string table as an "ID" is automatically declared for the compiler and can directly be passed to the LoadString() function without re-declaring it. The name must conform to IEC standard naming rules.

Obviously, you could do the same by declaring an array of STRING variables and enter some initial values for all items in the array. By the way, string tables provide significant advantages compared to arrays:

  • The editor provides a comfortable view of multiple columns at editing.
  • String tables are loaded in the application code and does not require any further RAM memory unlike declared arrays.
  • The string table editor automatically declares for you readable IDs for any string item to be used in programs instead of working with hard-coded index values.

info Info

If the text is too long for the STRING variable when used at runtime, it is truncated.

You can use special '$' sequences in strings in order to specify non printable characters, according to the IEC standard:

Code | Meaning
$$ $' $T $R $L $N $P $xx | A "$" character. A single quote. A tab stop (ASCII code 9). A carriage return character (ASCII code 13). A line feed character (ASCII code 10). Carriage return plus line feed characters (ASCII codes 13 and 10). A page break character (ASCII code 12). Any character (xx is the ASCII code expressed on two hexadecimal digits.


Analog signals resources

IEC 61131-3 Programming Environment -> Resources -> Analog signals resources

Previous chapter Next chapter Show all Show all Hide all Hide all

Analog signals are resources (embedded configuration data) edited with the Workbench. An analog signal is entered as a list of analog points among a time X-axis.

Signals are typically used for statically designing a set-point signal to be played at runtime using the following functions and blocks:

SigID: Get the identifier of a signal resource (to be passed to other blocks).
SigPlay: Plays a signal.
SigScale: Get a point value from a signal.

A signal is entered in the editor as a list of point. Each point refers to a 0-based time value (X axis) and a REAL analog value (Y axis).

Example Example

Points | Signal

In between two consecutive points, the signal must be understood as an analog ramp. If you need to represent a discontiguous change (vertical segment), specify the same time value (X axis) for two consecutive points. The number of points is not limited.


Networked applications - Binding

IEC 61131-3 Programming Environment -> Networked applications - Binding

Previous chapter Next chapter Show all Show all Hide all Hide all

The Win-GRAF PAC driver version 2.10 or later provides an event driven protocol on TCP-IP for exchanging real time data among runtime systems. As the protocol is purely event-based, it ensures high performances and very low network traffic at runtime. This section explains how to use the T5 event-based protocol for binding variables of runtime systems in order to build a distributed application. Binding is not supported by the Workbench Simulator.

seealso See also

Dual binding on redundant ETHERNET

New! The EnableEvents function can be used to enable or disable the production of events for binding.

Exchange mechanism

The T5 protocol is based on a "publish-subscribe" model. Each runtime system may publish some variables on the network and consume variables from other runtime systems. Each produced variable is identified by a number. This identifier is used for linking the source and destination variables in the projects. The same published variable can be consumed in several destination projects.

Example Example

In this example, the variable VarP1 of project Proj1 will be bound (copied) at runtime to the variable VarP2 of project Proj2 and to the variable VarP3 or project Proj3.

Exchanges

The value variable is sent on the network only when it changes. For each produced variable, you can define a positive and negative hysteresis in order to adjust the network traffic according to the needs of your application. Each new value sent on the network is qualified with a date and time stamp. For each consumed variable in destination projects, you can have access to its date/time stamping and to its quality flag. You can also have a global information about the status of the connection with each producer.

Limitations

The maximum number of produced variable is limited. Refer to your OEM instructions for more information about the binding limitations imposed by the Win-GRAF PAC driver implementation.

Only boolean, numerical and TIME variables can be exchanged. STRING variables, function block instances cannot be exchanged on the network.

Using the global binding editor

The system offers a global tool for defining the data exchange among several projects. To build a distributed application, you need to:

  • Create all source and destination projects,
  • from the main window, run the Tools / Global Binding Editor menu command.

The Global Binding Editor can also be launched directly from the Workbench group in the Windows Start menu, without opening the Workbench.

Defining the network nodes

Run the File / New menu command of the Global Binding Editor to initiate a new distributed configuration and define the nodes linked in the configuration. Then at any time you can run the File / Projects menu command to change the list of nodes defined. A dialog box shows all the projects (nodes) included in the configuration.

Each node is referred to as a "project" in the global binding editor, and is identified by a name, an IP address and an ETHERNET port number. Refer to your OEM instructions for knowing the port number used for publishing variables.

Press the Browse button for adding in the configuration a project. You simply need to select the folder where the project is stored.

Press the Import button for adding in the configuration the published variable of a project. In that case, you just have to select the APPLI.EVT file located in the project, that contains all binding information. Other files of the project are not needed in that case. The APPLI.EVT file can also be exchanged alone among users without need of exchanging the whole project. You will not be allowed to change the published and consumed variables of such a project in the binding editor.

Press the Declare button for declaring in the configuration a node with no project associated with. In that case, you will have to manually declare in the binding editor the variables published by the node and specify the link identifier for each variable produced.

The editor workspace

Below is the general form of the global binding editor:

  1. Editing grid.
  2. Output window for reports.
  3. List of variables in the source project for the selected cell.
  4. List of variables in the destination project for the selected cell.

The editing grid

The first column of the editing grid list all the variables produced in the source projects. Other columns show variables consumed in the destination projects.

Example Example

This example shows that the project EvPing produces its variables Sent1 and BSent1. The selected cell shows that the variable Sent1 of source project EvPing is bound to the variable Received1 of destination project EvPong. The link identifier of the source variable is 1.

You can at any time double click on the name of a source project in the first column for setting its IP address and ETHERNET port number.

Produced variables

To add a published variable in a project, select the project name in the first column, and double click on the wished variable in the list of source project variables (in the top/right window).

When a source variable is selected in the first column, run the Edit / Properties menu command to define an hysteresis for its change detection.

Consumed variables

To add a consumed variable, select the cell with we wished source variable and destination project, and then double click on a variable of the destination project in the bottom/right window.

If you put a variable in a destination project in front of the "Connection Status" line of a source project, this variable will contain the possible error status of this connection. Value 0 (or FALSE for a boolean) indicates that the connection is OK.

The line with the source variable name indicates an exchange of its value. If you expand the variable in the first column, then extra information about this variable is shown and can be linked to destination variables.

Example Example

This example shows that the Sent1 variable of source project EvPing is bound to the following variables in the destination project EvPong:

  • Variable Received1 will contain the last value.
  • Variable Rcv_error will contain possible error status (0 or FALSE means OK).
  • Variable Rcv_date will contain the date stamp of the last change.
  • Variable RCV_time will contain the time stamp of the last change.

Declaring variables

The global binding editor enables you to declare new variables in source and destination projects without need of opening the Workbench. For that, when a source or destination cell is selected, run the Edit / Insert variable menu command and enter the name of a new variable.

If the Workbench is opened when you declare a variable in the binding editor, it is automatically updated with the new created variable.

If you create, change or remove variables from the workbench when the global binding editor is opened, a "!" sign appears in the corresponding variable list. Click on the "!" sign to actuate the list:

Link identifiers

The global binding editor automatically allocate identifiers for each produced variables. However you can use the Edit / Property menu command when a published variable is selected for changing its identifier.

Using the local editor within the Workbench

If you do not use the global binding editor, you can enter the network configuration locally in each project. For that, run the File / Open / Binding configuration menu command form the main window.

Produced and consumed variables of the project are entered in a tree.

The first main node of the tree is called "PUBLIC" and groups all produced variables. Use the Insert Variable toolbar command or drag a variable on the PUBLIC node to define a new produced variable. For each variable you must specify its name, its link identifier, and possibly positive and negative hysteresis.

The Insert Master - Port toolbar command enables you to define external nodes (other runtime systems). Each node is identified by a name, an IP address and a ETHERNET port number. Then you can define within external nodes consumed variables.

A consumed variale refers to a link identifier, and represents the kind of network operation performed on the variable of the project:

  • Get external variable value.
  • Get error status.
  • Get date of time stamp.

In this section

Networked applications - Dual binding on redundant ETHERNET


Networked applications - Dual binding on redundant ETHERNET

IEC 61131-3 Programming Environment -> Networked applications - Binding -> Networked applications - Dual binding on redundant ETHERNET

Previous chapter Next chapter Show all Show all Hide all Hide all

The Win-GRAF PAC driver version SR5 or later enables the use of the event driven protocol for binding variables with two redundant ETHERNET networks. This provide high security level for runtime exchanges over ETHERNET.

Dual binding is used in a redundancy network connection using 2 separate network segments. Both the unit publishing variables (producer) and the unit subscribing variables (consumer) has to be equipped with 2 Ethernet network interfaces:

Running dual binding on a Win-GRAF PAC driver require 2 separate Ethernet interfaces boards mounted in the runtime platform. Each Ethernet board must be setup separately to the 2 network segments used.

Configuration

Configuration of dual binding links is done using the Global binding Editor. To specify a dual link, you must specify for each related node two IP addresses instead of one. To do that, enter both IP addresses separated with a slash ("/") sign:

No further configuration is required. Both connections always refer to the same port number

Connection status

The "connection status" information remains available in case of dual binding configuration. In that case, the value of the connected variable reflects the status of both network connections.

The value stored in the variable is an integer with the status of the first connection in bits 0 to 3, and status of the second connection in bits 4 to 7:

Variable status

The "variable status" information remains available for each variable exchanged in a dual binding configuration. In that case, the value of the connected variable reflects the status of both network connections.

0 | OK
1 | Connection 1 fails
2 | Connection 2 fails
3 | Both connections fail


Uploading projects source code

IEC 61131-3 Programming Environment -> Uploading projects source code

Previous chapter Next chapter Show all Show all Hide all Hide all

The workbench enables you to embed on the target the source code of the project, so that it can be uploaded later. Source code is filtered and zipped in order to reduce backup memory requirements. As sending source to the target may involve a significant donwload time, it is up to you to explicitely activate the download command. Those commands are available from the contextual popup menu in the workspace window:

Save Project to Target: zip project source files and send them to the target.
Open project from Target: upload zipped source file from the target and rebuild the project.

Save to target (download)

When saving the project to the target you have to specify the address and communication parameters of the remote runtime system. The following options enable you to send more or less optional information with project source code:

  • Symbol table: the symbol table will be required after upload for monitoring variables. If you do not embed the symbol table, you will have to recompile the uploaded application for reading or writing variables.
  • Debug information: this file will be required after upload for step by step debugging and use of breakpoints. If you do not embed the symbol table, you will have to recompile the uploaded application for stepping the application.
  • Spy lists: these are all files created with the Watch Window, such as lists and recipes.
  • Wizard settings: these are current settings of wizards such as the Monitoring Application Builder.
  • Project history: this is the list of modifications entered in the project.
  • Comment texts: all comments entered for variables, programs. Comments within the programs are always saved.
  • Bitmaps and icons: these are all BMP, GIF, JPG or ICO files stored in the project folder and possibly used in monitoring views.
  • Referenced OEM library elements: definition of all the library elements ("C" functions and blocks, I/Os, profiles) actually used in the project.

In addition to standard files, you can specify some extra files to be downloaded. In that case, all of them will be located in the loaded project folder after upload, even if they are originally located in other folders.

Removing some options enables you to reduce the size of embedded source code.

Open from target (upload)

When uploading the application, you need to specify the address and communication parameters of the remote runtime system, plus a name and a location for the uploaded project on the PC. This function cannot be used to overwrite an existing project folder.


Libraries

IEC 61131-3 Programming Environment -> Libraries

The workbench provides various methods for sharing UDFBs, sub-programs and data types (structures) among projects:

  • Use the Export and Import commands of the Tools menu for exchanging items:

    Program, sub-programs, UDFBs and structures can be exported as single files, suffixed with ".XK5". This enables you to manage in a shared folder a collection of export files to be imported in later projects. Doing that, you also can create several .XK5 files for various versions of the same item

  • Use in a project items from another project (external objects)

    The wokbench enables you to use in a projects some objects defined in other projects, such as UDFBs. This feature is available from the "Project / Settings" dialog box. This provides an easy way to manage libraries of IEC written function blocks that can be re-used in various projects. In addition to this feature, the workbench provides an easy way to safely handle externally defined objects in the local project. External objects are copied locally in the project so that the project remains consistent if the library folder disappears or changes.

  • Work with true libraries

    Alternatively you can create pure "libraries" to be referenced in projects. The link with libraries is automatically performed each time the project is open or re-built. This ensures you that your project always use the latest version of library objects, but it imposes that the library folder is found at build time.

In this section

Working with external objects

Libraries of sub-programs and UDFBs


Working with external objects

IEC 61131-3 Programming Environment -> Libraries -> Working with external objects

Previous chapter Next chapter Show all Show all Hide all Hide all

The workbench enables you to use in a projects some objects defined in other projects, such as UDFBs. This provides an easy way to manage libraries of IEC written function blocks that can be re-used in various projects. In addition to this feature, the workbench provides an easy way to safely handle externally defined objects in the local project.

Principle

You can use in your local project some items from one or several external projects. They can be:

  • sub-programs
  • user defined function blocks (UDFBs)
  • structures

When you select some external objects, they are saved locally in the project. This enables safe maintenance of the local project even in case external projects are modified or deleted. The workbench also provides you some comparison tools so that you can check possible modifications of external objects before you update them in your local project.

Included external objects cannot be modified in the local Workbench, and are highlighted with a special color in the project workspace. By the way, external objects can be open so that you can explore them during editing or debugging.

Use

Icon | Description
 | Run the Project / Settings menu command and press the Edit button in the External Objects group of the project settings dialog box.

The following dialog box is then open and enables you to manage used external objects:

Press the Add... button to add in the list an external project. You have to select the folder where this project is located. Then you have to check each object in this external project you want to use in your local project.

Press the Compare button to visually compare items that are existing in both in local and external projects. The comparison is perfomed using the project comparison tool.

Press OK to validate the configuration. At this time:

  • Any newly checked item is added to the local project.
  • Any unchecked item is removed.
  • Any checked item already in the project is updated.

info Info

Some items may be marked in red if their name is already used by an item of the local project (in that case, using it is impossible).

It may happen that some external items previously added to the local project are no more existing in the external project. If you uncheck such items in the list, they will be definitively removed when pressing OK. If you keep them checked, they remain in the local project as they are so that you can still safely build your project.

It may also happen that a complete external project previously used is no more found on the disk. All used items are kept in the local project unless you uncheck them.


Libraries of sub-programs and UDFBs

IEC 61131-3 Programming Environment -> Libraries -> Libraries of sub-programs and UDFBs

Previous chapter Next chapter Show all Show all Hide all Hide all

The workbench enables you to create pure "libraries" of sub-programs, UDFBs and data structures to be referenced in projects. The link with libraries is automatically performed each time the project is open or re-built. This ensures you that your project always use the latest version of library objects, but it imposes that the library forlder is found at build time.

info Info

Alternatively, you can use other methods for sharing programs and sub-programs.

What is a library ?

A "library" is similar to a project, but has a special "mark" so that it can be used as a library. All sub-programs, UDFBs and data structures of a library can be used in projects referring to it. Additionnaly, the library can be open as a normal project, and may contain other material (main programs, global variables...) in order for the library designer to test and validate locally the shared objects of the library.

Creating a library

To create a library, use the File / New Project command, and select the Library choice in the upper side list of the project creation wizard. The Workbench uses different color settings when editing a library. You can also use the File / Save Project As menu command to save an existing project as a library or the opposite.

Linking a project to libraries

In order to use library items in a project, you must link it to the library. For that run the Project / Libraries menu command of the Workbench when editing the project. A box is open and shows the list of already linked libraries. Press the Add button to browse the disk for a library folder to be used in the project. Press the Remove button to unlink the project from the library selected in the list. Libraries are checked and scanned when you close the box.

A project can be linked to several libraries.

Library items (sub-programs and UDFBs) are not visible in the Workspace area, but can be selected from the bottom-right list area in the Workbench.

Any sub-program or UDFB of a linked library can be used in a program as any other block. The definition of the library blocks (their inputs and outputs) is refreshed automatically:

  • When the project is open.
  • Before the project is build.
  • When you close the library selection box (even with no change).

If the project refers to a library that actually does not exist, an error message is displayed. Compiling errors will happen in that case if you use in your programs items of the missing library.

info Info

A library can be linked to another library. But in that case, when used in a project, the project must be linked to both of them.

Tree | Description
Project1 | "Project1" must be linked to "LIB1" and LIB2"
uses LIB1 | "LIB1" must be linked to "LIB2"
uses LIB2 |

You can never open the contents (source code) of a library item from a project. When debugging, you cannot step into a UDFB or sub-program from a library. Library items are not scanned during a "Find in files" research.


Release notes

Release notes

Warnning : Not all functions and not all features listed in this document are all supported by ICP DAS Win-GRAF PACs. Some of them are not supported.
Please refer the PAC datasheet and Win-GRAF user manual for details.

From release to release, we add many new features to the Workbench. Some of these features may be not supported by old or restricted implementations of the Win-GRAF PAC driver.

Refer to the README help file installed with the Workbench to know the exact list of significant features added from release to release. Run the Readme command form the Workbench group in the Windows Start menu for opening this file.

Refer to your OEM to know:

  • Which is the version of the Win-GRAF PAC driver embedded in your system,
  • what are the limitations set by the OEM during the integration of the runtime.


Keyboard shortcuts

Keyboard shortcuts

This page lists the keyboard shortcuts available from various windows of the Workbench.

Common shortcuts

Shortcut | Command
Alt + Return | Edit properties
CTRL + A | Select All
CTRL + Alt + E | Open an Explorer window on the project
CTRL + C | Copy
CTRL + F | Find
CTRL + F3 | Find next assignment
CTRL + F4 | Close
CTRL + F7 | Build program
CTRL + G | Display / hide grid
CTRL + Insert | Copy
CTRL + L | List of windows
CTRL + N | New
CTRL + O | Open
CTRL + P | Print
CTRL + S | Save
CTRL + SHIFT + F6 | Previous tab
CTRL + F6 | Next tab
CTRL + V | Paste
CTRL + X | Cut
CTRL + Y | Redo
CTRL + Z | Undo
Del | Delete
F1 | Display the help
F2 | Rename
F3 | Find next
F6 | Next window
F7 | Build project
SHIFT + Del | Cut
SHIFT + F6 | Previous window
SHIFT + Insert | Paste

Debugging

Shortcut | Command
CTRL + Alt + F4 | On line change
CTRL + F5 | Debug
CTRL + F8 | Step Out
F4 | Pause/resume
F5 | Simulation
F8 | Step In
F9 | Set/Remove breakpoint
F11 | Download
SHIFT + CTRL + F4 | Start/stop application
SHIFT + F8 | Step Over

FBD Editor (common)

Shortcut | Command
Arrows | Scroll window
CTRL + d | Display FBD execution order
CTRL + F2 | Toggle bookmark
CTRL + page UP/DOWN | Go to previous/next section
Escape | Cancel linking/resizing/dragging if selection: deselect if no selection: select
Page UP/DOWN | Scroll page up/down
Return | Equivalent to double click
SHIFT + CTRL + End | Select all items from mouse to end of document
SHIFT + CTRL + Home | Select all items from begin to mouse position
SHIFT + F2 | Go to next bookmark
Tab | Select next position item
Tab + shift | Select previous position item

FBD Editor (when editing)

Shortcut | Command
char | Start editing a symbol (variable, constant, instance...) On jump/comment/break: open dialog box to enter text
CTRL + arrows | Align selected items
Del | Delete selection
SHIFT + arrows | Move selection
SHIFT + page UP/DOWN | Move selection (4 cells)
space | Swap item style
SHIFT + CTRL + down | Insert blank lines at the position of the mouse

FBD Editor (during debug)

Shortcut | Command
space | Swap TRUE/FALSE boolean value
* | Lock var
/ | Unlock var

LD Editor (common)

Shortcut | Command
arrows | Move caret
CTRL + F2 | Toggle bookmark
Page UP/DOWN | Scroll up/down
Return | Equivalent to double click
SHIFT + arrows | Multiselect cells
SHIFT + Home | Select all items form left to caret
SHIFT + Page Up/Down | Selection Up/Down
SHIFT + F2 | Go to next bookmark

LD Editor (when editing)

Shortcut | Command
char | Start editing a symbol
CTRL + D | Comment
CTRL + F8 | Function block parallel
CTRL + R | Rung
CTRL + Shift + F4 | Contact parallel
Del | Delete Selection
F4 | Contact after
F8 | Function block after
F9 | Coil
Shift + F4 | Contact before
Shift + F8 | function block before
Shift + F9 | Jump
Shift + Space | Horizontal line
space | swap item style

LD Editor (during debug)

Shortcut | Command
space | Swap TRUE/FALSE boolean value
* | Lock var
/ | Unlock var

SFC Editor

Shortcut | Command
? | Show/Hide notes
arrows | Move caret
Page UP/DOWN | Scroll page up/down
Return | Equivalent to mouse double click
SHIFT + arrows | Select multiple cells
SHIFT + Home | Select from left to caret
SHIFT + Page Up/Down | Selection Page Up/Down
b or B | Insert macro body
c or C | Insert convergence
CTRL + return | Edit reference
d or D | Insert divergence
Del | Delete selection
i or I | Insert step initial
j or J | Insert jump
m or M | Insert macro
s or S | Insert Step
space | Swap item style
t or T | Insert Transition
x or X | Insert the left side corner of a divergence/convergence

ST Editor (common)

Shortcut | Command
Arrows | Move caret
CTRL + F2 | Toggle bookmark
CTRL + left/right arrow | Go to previous/next word
SHIFT + arrows | Selection
SHIFT + F2 | Go to next bookmark
SHIFT + CTRL + left/right arrow | Select previous/next word

ST Editor (when editing)

Shortcut | Command
. | Select member of a structure or instance
CTRL + space | Auto completion / select a variable
SHIFT + CTRL + space | Select a function or keyword

ST Editor (during debug)

Shortcut | Command
* | Lock variable
/ | Unlock variable
Shift + double click | Force a variable
Space | Toggle boolean value

Variable Editor (common)

Shortcut | Command
- | Collapse
+ | Expand
Arrows | Move selection
CTRL + Home/End | Go to previous/next group
F12 | Show/Hide columns
Page Up/Down | Scroll Page up/down
SHIFT + Tab | Move selection
Space | Line Selection/cell selection
Tab | Move selection to the right

Variable Editor (when editing)

Shortcut | Command
char | Start entering the contents of a cell
Del | Delete item
Insert | Inser new variable
Return | Enter new cell value

Variable Editor (during debug)

Shortcut | Command
* | Lock variable
/ | Unlcok variable
Return | Open Control dialog box

Graphic Editor

Shortcut | Command
- | Zoom out
+ | Zoom in
Arrow | Scroll
CTRL + F2 | Toggle bookmark
CTRL + Page UP/DOWN | Resize selected items
CTRL + arrow | Align on main selected item
Del | Delete selection
escape | Cancel resizing/dragging if selection: unselect if no selection: select
SHIFT + CTRL + End | Select all items from mouse to end of document
SHIFT + CTRL + Home | Select all items from begin to mouse position
SHIFT + F2 | Go to next bookmark
SHIFT + Page UP/DOWN | Offset selection
SHIFT + Arrow | Move selection
SHIFT + CTRL + Arrow | Resize selected items
Tab | Select next position item
Tab + Shift | Select previous position item


Programming languages - Reference guide

Programming languages - Reference guide

Refer to the following pages for an overview of the IEC61131-3 programming languages:

Program organization units
Data types
Variables
Arrays
Constant expressions
Conditional compiling
Handling exceptions
Variable status bits

SFC: Sequential Function Chart
FBD: Function Block Diagram
LD: Ladder Diagram
ST: Structured Text
IL: Instruction List
Use of ST instructions in graphic languages

The following topics detail the set of programming features and standard blocks:

Basic operations
Boolean operations
Arithmetic operations
Comparisons
Type conversion functions
Selectors
Registers
Counters
Timers
Maths
Trigonometrics
String operations
Advanced

info Info

Some other functions not documented here are reserved for diagnostics and special operations. Please contact your technical support for further information.

In this section

Programming languages - Overview

Program organization units

Data types

Variables

Arrays

Constant expressions

Conditional compiling

Handling exceptions

Variable status bits

Basic Operations

Boolean Operations

Arithmetic operations

Comparison operations

Type conversion functions

Selectors

Registers

Counters

Timers

Mathematic operations

Trigonometric functions

String operations

Advanced operations


Programming languages - Overview

Programming languages - Reference guide -> Programming languages - Overview

Previous chapter Next chapter Show all Show all Hide all Hide all

Below are the available programming languages of the IEC61131-3 standard:

SFC: Sequential Function Chart
FBD: Function Block Diagram
LD: Ladder Diagram
ST: Structured Text
IL: Instruction List

Use of ST instructions in graphic languages

You have to select a language for each program or User Defined Function Block of the application.

In this section

Sequential Function Chart (SFC)

Function Block Diagram (FBD)

Ladder Diagram (LD)

Structured Text (ST)

Instruction List (IL)

Use of ST expressions in graphic language


Sequential Function Chart (SFC)

Programming languages - Reference guide -> Programming languages - Overview -> Sequential Function Chart (SFC)

Previous chapter Next chapter Show all Show all Hide all Hide all

The SFC language is a state diagram. Graphical steps are used to represent stable states, and transitions describe the conditions and events that lead to a change of state. Using SFC highly simplifies the programming of sequential operations as it saves a lot of variables and tests just for maintaining the program context.

attention Attention

You must not use SFC as a decision diagram. Using a step as a point of decision and transitions as conditions in an algorithm should never appear in a SFC chart. Using SFC as a decision language leads to poor performance and complicate charts. ST must be preferred when programming a decision algorithm that has no sense in term of "program state".

Below are basic components of an SFC chart:

Chart | Programming
Steps and initial steps Transitions and divergences Parallel branches Jump to a step | Actions within a step. Timeout on a step. Programming a transition condition. How SFC is executed. UDFBs programmed in SFC.

The workbench fully supports SFC programming with several hierarchical levels of charts: i.e. a chart that controls another chart. Working with a hierarchy of SFC charts is an easy and powerful way for managing complex sequences and saves performances at run time. Refer to the following sections for further details:

Defining a hierarchy of SFC programs
How to control a SFC child

In this section

SFC Steps

SFC Transitions

SFC parallel branches

Jump to a SFC step

Actions in a SFC step

Check timeout on a SFC step

Condition of a SFC transition

SFC execution at run time

Hierarchy of SFC programs

Controlling a SFC child program

User Defined Function Blocks programmed in SFC


SFC Steps

Programming languages - Reference guide -> Programming languages - Overview -> Sequential Function Chart (SFC) -> SFC Steps

Previous chapter Next chapter Show all Show all Hide all Hide all

A step represents a stable state. It is drawn as a square box in the SFC chart. Each must step of a program is identified by a unique number. At run time, a step can be either active or inactive according to the state of the program.

info Info

To change the number of a step, transition or jump, select it and hit Ctrl+ENTER keys.

All actions linked to the steps are executed according to the activity of the step.

Inactive step | Active step

In conditions and actions of the SFC program, you can test the step activity by specifying its name ("GS" plus the step number) followed by ".X".

Example Example

GS100.X Is TRUE if step 100 is active.
(expression has the BOOL data type).

You can also test the activity time of a step, by specifying the step name followed by ".T". It is the time elapsed since the activation of the step. When the step is de-activated, this time remains unchanged. It will be reset to 0 on the next step activation.

Example Example

GS100.T Is the time elapsed since step 100 was activated.
(expression has the TIME data type).

Initial steps

Initial steps represent the initial situation of the chart when the program is started. There must be at least one initial step in each SFC chart. An initial step is marked with a double line:


SFC Transitions

Programming languages - Reference guide -> Programming languages - Overview -> Sequential Function Chart (SFC) -> SFC Transitions

Previous chapter Next chapter Show all Show all Hide all Hide all

Transitions represent a condition that changes the program activity from a step to another.

info Info

To change the number of a step, transition or jump, select it and hit Ctrl+ENTER keys.

The transition is marked by a small horizontal line that crosses a link drawn between the two steps:

Each transition is identified by a unique number in the SFC program.

Each transition must be completed with a boolean condition that indicates if the transition can be crossed. The condition is a BOOL expression.

In order to simplify the chart and reduce the number of drawn links, you can specify the activity flag of a step (GSnnn.X) in the condition of the transition.

Transitions define the dynamic behaviour of the SFC chart, according to the following rules:

  • A transition in crossed if:
    • its condition is TRUE.
    • and if all steps linked to the top of the transition (before) are active.
  • When a transition is crossed:
    • all steps linked to the top of the transition (before) are de-activated.
    • all steps linked to the bottom of the transition (after) are activated.

Divergences

It is possible to link a step to several transitions and thus create a divergence. The divergence is represented by a horizontal line. Transitions after the divergence represent several possible changes in the situation of the program.

All conditions are considered as exclusive, according to a left to right priority order. It means that a transition is considered as FALSE if at least one of the transitions connected to the same divergence on its left side is TRUE.

Example Example

Transition 1 is crossed if:
step 1 is active
and Cond1 is TRUE

Transition 2 is crossed if:
step 1 is active
and Cond2 is TRUE
and Cond1 is FALSE

attention Attention

Some run-time systems may not support exclusivity of the transitions within a divergence. Please refer to OEM instructions for further information about SFC support.


SFC parallel branches

Programming languages - Reference guide -> Programming languages - Overview -> Sequential Function Chart (SFC) -> SFC parallel branches

Previous chapter Next chapter Show all Show all Hide all Hide all

Parallel branches are used in SFC charts to represent parallel operations. Parallel branches occur when more than several steps are connected after the same transition. Parallel branches are drawn as double horizontal lines:

When the transition before the divergence (1 on this example) is crossed, all steps beginning the parallel branches (101 and 201 here) are activated.

Processing of parallel branches may take different timing according to each branch execution.

The transition after the convergence (2 on this example) is crossed when all the steps connected before the convergence line (last step of each branch) are active. The transition indicates a synchronization of all parallel branches.

If needed, a branch may be finished with an empty step (with no action). It represents the state where the branch "waits" for the other ones to be completed.

You must take care of the following rules when drawing parallel lines in order to avoid dead locks in the execution of the program:

  • All branches must be connected to the divergence and the convergence.
  • An element of a branch must not be connected to an element outside the divergence.


Jump to a SFC step

Programming languages - Reference guide -> Programming languages - Overview -> Sequential Function Chart (SFC) -> Jump to a SFC step

Previous chapter Next chapter Show all Show all Hide all Hide all

Jump symbols can be used in SFC charts to represent a link from a transition to a step without actually drawing it. The jump is represented by an arrow identified with the number of the target step.

info Info

To change the number of a step, transition or jump, select it and hit Ctrl+ENTER keys.

You cannot insert a jump to a transition as it may lead to a non explicit convergence of parallel branches (several steps leading to the same transition) and generally leads to mistakes due to a bad understanding of the chart.


Actions in a SFC step

Programming languages - Reference guide -> Programming languages - Overview -> Sequential Function Chart (SFC) -> Actions in a SFC step

Previous chapter Next chapter Show all Show all Hide all Hide all

Each step has a list of action blocks, that are instructions to be executed according to the activity of the step. Actions can be simple boolean or SFC actions, that consists in assigning a boolean variable or control a child SFC program using the step activity, or action blocks entered using another language (FBD, LD, ST or IL).

Runtime check

Below are the possible syntaxes you can use within an SFC step to perform runtime safety checks:

Syntax | Description
StepTimeout (...); | Check for a timeout on the step activity duration.

Simple boolean actions

Below are the possible syntaxes you can use within an SFC step to perform a simple boolean action:

Syntax | Description
BoolVar (N); | Forces the variable BoolVar to TRUE when the step is activated, and to FALSE when the step is de-activated.
BoolVar (S); | Sets the variable BoolVar to TRUE when step is activated
BoolVar (R); | Sets the variable BoolVar to FALSE when step is activated
/ BoolVar; | Forces the variable BoolVar to FALSE when the step is activated, and to TRUE when the step is de-activated.

Alarms

The following syntax enables you to manage timeout alarm variables:

Syntax

Description

BoolVar (A, duration);

Specifies a timeout variable to be associated to the step.

  • BoolVar must be a simple boolean variable
  • duration is the timeout, expressed eiter as a constant or as a single TIME variable
    (complex expressions cannot be used for this parameter)

When the timeout is elapsed, the alarm variable is turned to TRUE, and the transition(s) following the step cannot be crossed until the alarm variable is reset.

Simple SFC actions

Below are the possible syntaxes you can use within an SFC step to control a child SFC program:

Syntax | Description
Child (N); | Starts the child program when the step is activated and stops (kills) it when the step is de-activated.
Child (S); | Starts the child program when the step is activated
Child (R); | Stops (kills) the child program when the step is activated

Programmed action blocks

Programs in other languages (FBD, LD, ST or IL) can be entered to describe an SFC step action. There are three main types of programmed action blocks, that correspond to the following identifiers:

Identifier | Description
P1 | Executed only once when the step becomes active.
N | Executed on each cycle while the step is active.
P0 | Executed only once when the step becomes inactive.

The workbench provides you templates for entering P1, N and P0 action blocks in either ST, LD or FBD language. Alternatively, you can insert action blocks programmed in ST language directly in the list of simple actions, using the following syntax:

ACTION ( qualifier ) :
statements...
END_ACTION;

Where qualifier is P1, 0 or P0.


Check timeout on a SFC step

Programming languages - Reference guide -> Programming languages - Overview -> Sequential Function Chart (SFC) -> Check timeout on a SFC step

Previous chapter Next chapter Show all Show all Hide all Hide all

The system can check timeout on any SFC step activity duration. For that you need to enter the following instruction in the main "Action" list of the step:

__StepTimeout ( timeOut , errString );

Where:

timeout is a time constant or a time variable specifying the timeout duration.
errString is a string constant or a string variable specifying the error message to be output.

At runtime, each time the activation time of the step becomes greater than the specified timeout, the error string is sent to the Workbench and displayed in the Log window.

attention Attention

Sending log message strings to the log window requires the runtime to be connected through ETHERNET, and that your Win-GRAF PAC driver system supports plain text trace messages.

info Info

You can also put this statement within a #ifdef __DEBUG test so that timeout checking is enabled only in debug mode.

Alternatively, if you need to make more specific handling of timeouts, you can enter the following ST program in the "N" action block of the step:

if GSn.T > timeout then /* 'n' is the number of the step */
...statements...
end_if;


Condition of a SFC transition

Programming languages - Reference guide -> Programming languages - Overview -> Sequential Function Chart (SFC) -> Condition of a SFC transition

Previous chapter Next chapter Show all Show all Hide all Hide all

Each SFC transitions must have a boolean condition that indicates if the transition can be crossed. The condition is a boolean expression that can be programmed either in ST or LD language.

In ST language, enter a boolean expression. In can be a complex expression including function calls and parenthesis.

Example Example

bForce AND (bAlarm OR min (iLevel, 1) <> 1)

In LD language, the condition is represented by a single rung. The coil at the end of the rung represents the transition and should have no symbol attached.

Example Example


SFC execution at run time

Programming languages - Reference guide -> Programming languages - Overview -> Sequential Function Chart (SFC) -> SFC execution at run time

Previous chapter Next chapter Show all Show all Hide all Hide all

SFC programs are executed sequentially within a target cycle, according to the order defined when entering programs in the hierarchy tree. A parent SFC program is executed before its children. This implies that when a parent starts or stops a child, the corresponding actions in the child program are performed during the same cycle.

Within a chart, all valid transitions are evaluated first, and then actions of active steps are performed. The chart is evaluated from the left to the right and from the top to the bottom.

Example Example

Execution order:

  • Evaluate transitions:

1, 101, 2

  • Manage steps:

1, 101, 201, 102

In case of a divergence, all conditions are considered as exclusive, according to a left to right priority order. It means that a transition is considered as FALSE if at least one of the transitions connected to the same divergence on its left side is TRUE.

The initial steps define the initial status of the program when it is started. All top level (main) programs are started when the application starts. Child programs are explicitly started from action blocks within the parent programs.

The evaluation of transitions leads to changes of active steps, according to the following rules:

  • A transition is crossed if:
    • its condition is TRUE.
    • and if all steps linked to the top of the transition (before) are active.
  • When a transition is crossed:
    • all steps linked to the top of the transition (before) are de-activated.
    • all steps linked to the bottom of the transition (after) are activated.

attention Attention

Execution of SFC within the Win-GRAF PAC target is sampled according to the target cycles. When a transition is crossed within a cycle, the following steps are activated, and the evaluation of the chart will continue on the next cycle. If several consecutive transitions are TRUE within a branch, only one of them is crossed within one target cycle.

attention Attention
  • This section describes the execution model of a standard Win-GRAF PAC target. SFC execution rules may differ for other target systems. Please refer to OEM instructions for further details about SFC execution at run time.
  • Some run-time systems may not support exclusivity of the transitions within a divergence. Please refer to OEM instructions for further information about SFC support.


Hierarchy of SFC programs

Programming languages - Reference guide -> Programming languages - Overview -> Sequential Function Chart (SFC) -> Hierarchy of SFC programs

Previous chapter Next chapter Show all Show all Hide all Hide all

Each SFC program may have one or more "child programs". Child programs are written in SFC and are started (launched) or stopped (killed) in the actions of the father program. A child program may also have children. The number of hierarchy levels should not exceed 19.

When a child program is stopped, its children are also implicitly stopped.

When a child program is started, it must excplicitly in its actions start its children.

A child program is controlled (started or stopped) from the action blocks of its parent program. Designing a child program is a simple way to program an action block in SFC language.

Using child programs is very useful for designing a complex process and separate operations due to different aspects of the process. For instance, it is common to manage the execution modes in a parent program and to handle details of the process operations in child programs.


Controlling a SFC child program

Programming languages - Reference guide -> Programming languages - Overview -> Sequential Function Chart (SFC) -> Controlling a SFC child program

Previous chapter Next chapter Show all Show all Hide all Hide all

Controlling a child program may be simply achieved by specifying the name of the child program as an action block in a step of its parent program. Below are possible qualifiers that can be applied to an action block for handling a child program:

Qualifier | Description
Child (N); | Starts the child program when the step is activated and stops (kills) it when the step is de-activated.
Child (S); | Starts the child program when the step is activated. (Inital steps of the child program are activated)
Child (R); | Stops (kills) the child program when the step is activated. (All active steps of the child program are deactivated)

Alternatively, you can use the following statements in an action block programmed in ST language. In the following table, prog represents the name of the child program:

Statement | Description
GSTART (prog); | Starts the child program when the step is activated. (Inital steps of the child program are activated)
GKILL (prog); | Stops (kills) the child program when the step is activated. (All active steps of the child program are deactivated)
GFREEZE (prog); | Suspends the execution of a child program.
GRST (prog); | Restarts a program suspended by a GFREEZE command.

You can also use the "GSTATUS" function in expressions. This function returns the current state of a child SFC program:

Statement | Description
GSTATIS (prog); | Returns the current state of a child SFC program: 0: program is inactive 1: program is active 2: program is suspended

info Info

When a child program is started by its parent program, it keeps the inactive status until it is executed (further in the cycle). If you start a child program in a SFC chart, GSTATUS will return 1 (active) on the next cycle.


User Defined Function Blocks programmed in SFC

Programming languages - Reference guide -> Programming languages - Overview -> Sequential Function Chart (SFC) -> User Defined Function Blocks programmed in SFC

Previous chapter Next chapter Show all Show all Hide all Hide all

The Workbench enables you to create User Defined Function Blocks (UDFBs) programmed with SFC language. This section details specific features related to such function blocks.

The execution of UDFBs written in SFC requires a runtime system version SR7-1 or later.

Declaration

From the Workspace context menu, run the Insert New Program command. Then specify a valid name for the function block. Select "SFC" language and "UDFB" execution style.

Parameters

When a UDFB programmed in SFC is created, the Workbench automatically declares 3 special inputs to the block:

RUN: The SFC state machine is not activated when this input is FALSE.
RESET: The SFC chart is reset to its initial situation when this input is TRUE.
KILL: Any active step of the SFC chart is deactivated when this input is TRUE.

You can freely add other input and output variables to the UDFB. You can also remove any of the automatically created input if not needed. If the RUN input is removed, then it is considered as always TRUE. If RESET or KILL inputs are removed, then they are considered as always FALSE.

Below is the truth table showing priorities among special input:

RUN | RESET | KILL | Description
FALSE | FALSE | FALSE | do nothing
FALSE | FALSE | TRUE | kill the SFC chart
FALSE | TRUE | TRUE | kill the SFC chart
FALSE | TRUE | FALSE | reset the SFC chart
TRUE | FALSE | TRUE | kill the SFC chart
TRUE | FALSE | FALSE | activate the SFC chart
TRUE | TRUE | TRUE | kill the SFC chart
TRUE | TRUE | FALSE | reset the SFC chart

Steps

All steps inserted in the SFC chart of the UDFB are automatically declared as local instances of special reserved function blocks with the local variables of the UDFBs. The following FB types are used:

isfcSTEP : a normal step
isfcINITSTEP : an initial step

The editor takes care of updating the list of declared step instances. You should never remove, rename or change them in the variable editor. All steps are named with GS followed by their number.

Execution

The SFC chart is operated only when the UDFB is called by its parent program.

If the RESET input is TRUE, the SFC chart is reset to its initial situation. If the KILL input is TRUE, any active step of the SFC chart is deactivated.

When the RUN input is TRUE and KILL/RESET are FALSE, the SFC chart is operated in the same way as for other SFC programs:

  1. Check valid transitions and evaluate related conditions.
  2. Cross TRUE valid transitions.
  3. Execute relevant actions of the active steps.

info Info

In a UDFB programmed in SFC, you cannot use SFC actions to pilot a "child SFC program". This feature is reserved for SFC programs only. Instead, a UDFB programmed in SFC can pilot from its actions another UDFB programmed in SFC.


Function Block Diagram (FBD)

Programming languages - Reference guide -> Programming languages - Overview -> Function Block Diagram (FBD)

Previous chapter Next chapter Show all Show all Hide all Hide all

A Function Block Diagram is a data flow between constant expressions or variables and operations represented by rectangular blocks. Operations can be basic operations, function calls, or function block calls.

Use of ST instructions in graphic languages

The name of the operation or function, or the type of function block is written within the block rectangle. In case of a function block call, the name of the called instance must be written upon the block rectangle, such as in the example below:

Example Example

The data flow may represent values of any data type. All connections must be from input and outputs points having the same data type. In case of a boolean connection, you can use a connection link terminated by a small circle, tat indicates a boolean negation of the data flow.

Example Example

Use of a negated link: Q is IN1 AND NOT IN2!

The data flow must be understood from the left to the right and from the top to the bottom. It is possible to use labels and jumps to change the default data flow execution.

LD symbols

LD symbols may also be entered in FBD diagrams and linked to FBD objects. Refer to the following sections for further information about components of the LD language:

Contacts
Coils
Power Rails

Special vertical lines are available in FBD language for representing the merging of LD parallel lines. Such vertical lines represent a OR operation between the connected inputs. Below is an example of an OR vertical line used in a FBD diagram:

Example Example


Ladder Diagram (LD)

Programming languages - Reference guide -> Programming languages - Overview -> Ladder Diagram (LD)

Previous chapter Next chapter Show all Show all Hide all Hide all

A Ladder Diagram is a list of rungs. Each rung represents a boolean data flow from a power rail on the left to a power rail on the right. The left power rail represents the TRUE state. The data flow must be understood from the left to the right. Each symbol connected to the rung either changes the rung state or performs an operation. Below are possible graphic items to be entered in LD diagrams:

Power Rails
Contacts and Coils
Operations, Functions and Function blocks, represented by rectangular blocks
Labels and Jumps
Use of ST instructions in graphic languages

Use of the EN input and the ENO output for blocks

The rung state in a LD diagram is always boolean. Blocks are connected to the rung with their first input and output. This implies that special EN and ENO input and output are added to the block if its first input or output is not boolean.

The EN input is a condition. It means that the operation represented by the block is not performed if the rung state (EN) is FALSE. The ENO output always represents the sane status as the EN input: the rung state is not modified by a block having an ENO output.

Below is the example of the XOR block, having boolean inputs and outputs, and requiring no EN or ENO pin:

info Info

First input is the rung. The rung ist the output.

Below is the example of the > (greater than) block, having non boolean inputs and a boolean output. This block has an EN input in LD language:

info Info

The comparison is executed only if EN is TRUE.

Below is the example of the SEL function, having a first boolean input, but an integer output. This block has an ENO output in LD language:

info Info

The input rung is the selector.

ENO has the same value as SELECT.

Finally, below is the example of an addition, having only numerical arguments. This block has both EN and ENO pins in LD language:

info Info

The addition is executed only if EN is TRUE.

ENO is equal to EN.

In this section

Contacts

Coils

Power Rails


Contacts

Programming languages - Reference guide -> Programming languages - Overview -> Ladder Diagram (LD) -> Contacts

Previous chapter Next chapter Show all Show all Hide all Hide all

Contacts are basic graphic elements of the LD language. A contact is associated to a boolean variable written upon its graphic symbol. A contact sets the state of the rung on its right side, according to the value of the associated variable and the rung state on its left side.

Below are the possible contact symbols and how they change the rung state:

Symbol

Description

Normal: the rung state on the right is the boolean AND between the rung state on the left and the associated variable.

Negated: the rung state on the right is the boolean AND between the rung state on the left and the negation of the associated variable.

Positive pulse: the rung state on the right is TRUE only when the rung state on the left is TRUE and the associated variable changes from FALSE to TRUE (rising edge).

Negative pulse: the rung state on the right is TRUE only when the rung state on the left is TRUE and the associated variable changes from TRUE to FALSE (falling edge).

info Info

When a contact or a coil is selected, You can press the SPACE bar to change its type (normal, negated, pulse...).

Two serial normal contacts represent an AND operation.
Two contacts in parallel represent an OR operation.

seealso See also

Coils

Power Rails


Coils

Programming languages - Reference guide -> Programming languages - Overview -> Ladder Diagram (LD) -> Coils

Previous chapter Next chapter Show all Show all Hide all Hide all

Coils are basic graphic elements of the LD language. A coil is associated to a boolean variable written upon its graphic symbol. A coil performs a change of the associated variable according to the rung state on its left side.

Below are the possible coil symbols and how they change the rung state:

Symbol | Beschreibung
 | Normal: the associated variable is forced to the value of the rung state on the left of the coil.
 | Negated: the associated variable is forced to the negation of the rung state on the left of the coil.
 | Set: the associated variable is forced to TRUE if the rung state on the left is TRUE. (no action if the rung state is FALSE)
 | Reset: the associated variable is forced to FALSE if the rung state on the left is TRUE. (no action if the rung state is FALSE)

info Info

When a contact or a coil is selected. You can press the SPACE bar to change its type (normal, negated, pulse...).

attention Attention

Even though coils are commonly connected to a power rail on the right, the rung may be continued after a coil. The rung state is never changed by a coil symbol.

seealso See also

Contacts

Power Rails


Power Rails

Programming languages - Reference guide -> Programming languages - Overview -> Ladder Diagram (LD) -> Power Rails

Previous chapter Next chapter Show all Show all Hide all Hide all

Vertical power rails are used in LD language for representing the limits of a rung.

The power rail on the left represents the TRUE value and initiates the rung state. The power rail on the right receives connections from the coils and has no influence on the execution of the program.

Power rails can also be used in FBD language. Only boolean objects can be connected to left and right power rails.

seealso See also

Contacts

Coils


Structured Text (ST)

Programming languages - Reference guide -> Programming languages - Overview -> Structured Text (ST)

Previous chapter Next chapter Show all Show all Hide all Hide all

ST is a structured literal programming language. A ST program is a list of statements. Each statement describes an action and must end with a semicolon (";").

The presentation of the text has no meaning for a ST program. You can insert blank characters and line breaks where you want in the program text.

Comments

Comment texts can be entered anywhere in a ST program. Comment texts have no meaning for the execution of the program. A comment text must begin with "(*" and end with "*)". Comments can be entered on several lines (i.e. a comment text may include line breaks). Comment texts cannot be nested.

Expressions

Each statement describes an action and may include evaluation of complex expressions. An expression is evaluated:

  • From the left to the right.
  • According to the default priority order of operators.
  • The default priority can be changed using parenthesis.

Arguments of an expression can be:

  • Declared variables.
  • Constant expressions.
  • Function calls.

Statements

Below are available basic statements that can be entered in a ST program:

  • assignment.
  • function block calling.

Below are the available conditional statements in ST language:

  • IF / THEN / ELSE (simple binary switch).
  • CASE (enumerated switch).

Below are the available statements for describing loops in ST language:

  • WHILE (with test on loop entry).
  • REPEAT (with test on loop exit).
  • FOR (enumeration).


Instruction List (IL)

Programming languages - Reference guide -> Programming languages - Overview -> Instruction List (IL)

Previous chapter Next chapter Show all Show all Hide all Hide all

A program written in IL language is a list of instructions. Each instruction is written on one line of text. An instruction may have one or more operands. Operands are variables or constant expressions. Each instruction may begin with a label, followed by the ":" character. Labels are used as destination for jump instructions.

The Workbench allows you to mix ST and IL languages in textual program. ST is the default language. When you enter IL instructions, the program must be entered between BEGIN_IL and END_IL keywords, such as in the following example:

Example Example

BEGIN_IL
LD var1
ST var2
END_IL

Comments

Comment texts can be entered at the end of a line containing an instruction. Comment texts have no meaning for the execution of the program. A comment text must begin with "(*" and end with "*)". Comments may also be entered on empty lines (with no instruction), and on several lines (i.e. a comment text may include line breaks). Comment texts cannot be nested.

Data flow

An IL complete statement is made of instructions for:

  • first: evaluating an expression (called current result).
  • then: use the current result for performing actions.

Evaluation of expressions

The order of instructions in the program is the one used for evaluating expressions, unless parenthesis are inserted. Below are the available instructions for evaluation of expressions:

Instruction | Operand | Meaning
LD / LDN | any type | Loads the operand in the current result.
AND (&) | boolean | AND between the operand and the current result.
OR / ORN | boolean | OR between the operand and the current result.
XOR / XORN | boolean | XOR between the operand and the current result.
ADD | numerical | Adds the operand and the current result.
SUB | numerical | Subtract the operand from the current result.
MUL | numerical | Multiply the operand and the current result.
DIV | numerical | Divide the current result by the operand.
GT | numerical | Compares the result with the operand.
GE | numerical | Compares the result with the operand.
LT | numerical | Compares the result with the operand.
LE | numerical | Compares the result with the operand.
EQ | numerical | Compares the result with the operand.
NE | numerical | Compares the result with the operand.
Function call | func. arguments | Calls a function.
Parenthesis |  | Changes the execution folder.

info Info

Instructions suffixed by N uses the boolean negation of the operand.

Actions

The following instructions perform actions according to the value of currrent result. Some of these instructions do not need a current result to be evaluated:

Instruction | Operand | Meaning
ST / STN | any type | Stores the current result in the operand.
JMP | label | Jump to a label - no current result needed.
JMPC | label | Jump to a label if the current result is TRUE.
JMPNC / JMPCN | label | Jump to a label if the current result is FALSE.
S | boolean | Sets the operand to TRUE if the current result is TRUE.
R | boolean | Sets the operand to FALSE if the current result is TRUE.
CAL | f. block | Calls a function block (no current result needed).
CALC | f. block | Calls a function block if the current result is TRUE.
CALNC / CALCN | f. block | Calls a function block if the current result is FALSE.

info Info

Instructions suffixed by N uses the boolean negation of the operand.


Use of ST expressions in graphic language

Programming languages - Reference guide -> Programming languages - Overview -> Use of ST expressions in graphic language

Previous chapter Next chapter Show all Show all Hide all Hide all

The workbench enables any complex ST expression to be associated with a graphic element in either LD or FBD language. This feature makes possible to simplify LD and FBD diagrams when some trivial calculation has to be entered. It also enables you to use graphic features for representing a main algorithm as text is used for details of implementation.

Expression must be written in ST language. An expression is anything you can imagine between parenthesis in a ST program. Obviously the ST expression must fit the data type required by the diagram (e.g. an expression put on a contact must be boolean).

FBD language

A complex ST expression can be entered in any variable box of a FBD diagram, if the box is not connected on its input.

Example Example

LD language

A complex ST expression can be entered on any kind of contact, and on any input of a function or function block.

Example Example


Program organization units

Programming languages - Reference guide -> Program organization units

Previous chapter Next chapter Show all Show all Hide all Hide all

An application is a list of programs. Programs are executed sequentially within the target cycle, according to the following model:

Begin cycle

| exchange I/Os
| execute first program
| ...
| execute last program
| wait for cycle time to be elapsed

End Cycle

Programs are executed according to the order defined by the user. All SFC programs must be grouped (it is not possible to insert a program in FBD, LD, ST or IL in between two SFC programs). The number of programs in an application is limited to 32767. Each program is entered using a language chosen when the program is created. Possible languages are Sequential Function Chart (SFC), Function Block Diagram (FBD), Ladder Diagram (LD), Structured Text (ST) or Instruction List (IL).

Programs must have unique names. The name cannot be a reserved keyword of the programming languages and cannot have the same name as a standard or "C" function or function block. A program should not have the same name as a declared variable. The name of a program should begin by a letter or an underscore ("_") mark, followed by letters, digits or underscore marks. It is not allowed to put two consecutive underscores within a name. Naming is case insensitive. Two names with different cases are considered as the same.

Child SFC programs

You can define a hierarchy of SFC programs, entered as a tree in the list of programs. A child program is controlled within action blocks of the parent SFC program.

User Defined Function Blocks

The list of programs may be completed by User Defined Function Blocks (UDFBs). UDFBs are described using SFC, FBD, LD, ST or IL language, and can be used as other function blocks in the programs of the application. Input and output parameters plus private variables of a UDFB are declared in the variable editor as local variables of the UDFB.

There is no restriction using any operation in a UDFB. A UDFB can call standard functions and function blocks.

A UDFB can call another UDFB. The called UDFB must be declared before the calling one in the program list.

Each time a UDFB is instantiated, its private variables are duplicated for the declared instance. The code of the UDFB is duplicated on each call in parent programs. This leads to higher performances at run time, but consumes code space. It is advised recommended to package small algorithms in UDFBs. Large parts of code should be managed in programs.

A UDFB cannot have more than 32 input parameters or 32 output parameters.

Sub-programs

The list of programs may be completed by Sub-programs. Sub-programs are described using FBD, LD, ST or IL language, and can be called by the programs of the application. Input and output parameters plus local variables of a sub-program are declared in the variable editor as local variables of the sub-program.

A sub-program may call another sub-program or a UDFB.

Unlike UDFB, local variables of a sub program are not instantiated. This means that the sub-program always work on the same set of local variables. Local variables of a sub-program keep their value among various calls. The code of a sub-program is not duplicated when called several times by parent programs.

A sub-program cannot have more than 32 input parameters or 32 output parameters.


Data types

Programming languages - Reference guide -> Data types

Basic data types

Below are the available basic data types:

Type | Description
BOOL | Boolean (bit) - can be FALSE or TRUE - stored on 1 bit.
SINT (*) | Small signed integer on 8 bits (from -128 to +127).
USINT (*) | Small unsigned integer on 8 bits (from 0 to +255).
BYTE | Same as USINT.
INT (*) | Signed integer on 16 bits (from -32768 to +32767).
UINT (*) | Unsigned integer on 16 bits (from 0 to +65535).
WORD | Same as UINT.
DINT | Signed integer on 32 bits (from -2147483648 to +2147483647).
UDINT (*) | Unsigned integer on 32 bits (from 0 to +4294967295).
DWORD | Same as UDINT.
LINT (*) | Long signed integer on 64 bits.
REAL (*) | Single precision floating point - stored on 32 bits.
LREAL (*) | Double precision floating point - stored on 64 bits.
TIME | Time of day - less than 24h - accuracy is 1ms.
STRING (*) | Variable length string with declared maximum length. The declared maximum length cannot exceed 255 characters.

(*) Some of those data types may be not supported by all targets.

Structures

A structure is a complex data type defined as a set of members. Members of a structure may have various data types. A member of a structure may have dimensions or may be an instance of another structure.

When a structure is defined, it may be used as other data types to declare variables.

Members of a structure may have an initial value. In that case, corresponding members of all declared variable having this structure type will be initialized with the initial value of the member.

For specifying a member of a structured variable in languages, use the following notation:

VariableName.MemberName

Enumerated data types

You can define some new data types that are enumaration of named values. For example:

type: LIGHT

values: GREEN, ORANGE, RED

Then in programs, you can use one of the enumerated values, prefixed by the type name:

Light1 := LIGHT#RED;

Variables having enumerated data types can only be used for assignment, comparison, and SEL/MUX functions.

"Bit fields" data types

You can define new data types derived from integer data types, that have some readable names for some of their bits. Thus you can use VarName.BitName notations in programs. Such data types cannot be derived from the LINT type.


Variables

Programming languages - Reference guide -> Variables

All variables used in programs must be first declared in the variable editor. Each variable belongs to a group and is must be identified by a unique name within its group.

Groups

A group is a set of variables. A group either refers to a physical class of variables, or identifies the variables local to a program or user defined function block. Below are the possible groups:

Group | Description
GLOBAL | Internal variables known by all programs.
RETAIN | Non volatile internal variables known by all programs.
%I... | Channels of an input board - variables with same data type linked to a physical input device.
%Q... | Channels of an output board - variables with same data type linked to a physical output device.
PROGRAMxxx | All internal variables local to a program. (the name of the group is the name of the program)
UDFBxxx | All internal variables local to a User Defined Function Block plus its IN and OUT parameters. (the name of the group is the name of the program)

Data type and dimension

Each variable must have a valid data type. It can be either a basic data type or a function block. In that case the variable is an instance of the function block. Physical I/Os must have a basic data type. Instances of function blocks can refer either to a standard or "C" embedded block, or to a User Defined Function Block.

If the selected data type is STRING, you must specify a maximum length, that cannot exceed 255 characters.

Refer to the list of available data types for more information. Refer to the section describing function blocks for further information about how to use a function instance.

Additionally, you can specify dimension(s) for an internal variable, in order to declare an array. Arrays have at most 3 dimensions. All indexes are 0 based. For instance, in case of single dimension array, the first element is always identified by ArrayName[0]. The total number of items in an array (merging all dimensions) cannot exceed 65535.

Naming a variable

A variable must be identified by a unique name within its parent group. The variable name cannot be a reserved keyword of the programming languages and cannot have the same name as a standard or "C" function or function block. A variable should not have the same name as a program or a user defined function block.

The name of a variable should begin by a letter or an underscore ("_") mark, followed by letters, digits or underscore marks. It is not allowed to put two consecutive underscores within a variable name. Naming is case insensitive. Two names with different cases are considered as the same.

Naming Physical I/Os

Each I/O channel has a predefined symbol that reflects its physical location. This symbol begins with %I for an input and %Q for an output, followed by a letter identifying the physical size of the data. Then comes the location of the board, expressed on 1 or two numbers, and finally the 0 based index of the channel within the board. All numbers are separated by dots. Below are the possible prefixes for IO symbols:

Prefix | Description
%IX | 1 byte input - BOOL or SINT
%QX | 1 byte output - BOOL or SINT
%IW | 2 bytes input - INT
%QW | 2 bytes output - INT
%ID | 4 bytes input - DINT or REAL
%QD | 4 bytes input - DINT or REAL
%IL | 8 bytes input - LINT or LEAL
%QL | 8 bytes output - LINT or LEAL
%IS | STRING input
%QS | STRING output

Additionally, you can give an alias (a readable name) to each I/O channel. In that case, either the "%" name or the alias can be used in programs with no difference. The alias must fit to the same rules as a variable name.

Attributes of a variable

Physical I/Os are marked as either Input or Output. Inputs are read-only variables. For each internal variable, you can select the Read Only.

Parameters of User Defined Function Blocks and sub-programs are marked as either IN or OUT.

Parameters of sub-programs and UDFBs

Sub-programs and UDFBs may have parameters on input or ou output. Output parameters cannot be arrays of data structures but only single data. When an array is passed as an inupt parameter to a UDFB, it is considered as INOUT so the UDFB can read or write in it. The support of complex data types for input parameters may depend on selected compiling options.


Arrays

Programming languages - Reference guide -> Arrays

You can specify dimension(s) for internal variables, in order to declare arrays. All indexes are 0 based. For instance, in case of single dimension array, the first element is always identified by ArrayName[0].

To declare an array, enter its dimension in the corresponding column of the variable editor. For a multi-dimension array, enter dimensions separated by comas (ex: 2,10,4).

Use in ST and IL languages

To specify an item of an array in ST and IL language, enter the mane of the array followed by the index(es) entered between "[" and "]" characters. For multi-dimension arrays, enter indexes separated by comas. Indexes may be either constant or complex expressions.

Example Example

TheArray[1,7] := value;
result := SingleArray[i + 2];

Use in FBD and LD languages

In graphical languages, the following blocks are available for managing array elements:

Block | Description
[I]>> | Get value of an item in a single dimension array.
[I,J]>> | Get value of an item in a two dimension array.
[I,J,K]>> | Get value of an item in a three dimension array.
>>[I] | Set value of an item in a single dimention array.
>>[I,J] | Set value of an item in a two dimension array.
>>[I,J,K] | Set value of an item in a three dimension array.

For get blocks, the first input is the array and the output is the value of the item. Other inputs are indexes in the array.

For put blocks, the first input is the forced value and the second input is the array. Other inputs are indexes in the array.

attention Attention
  • Arrays have at most 3 dimensions.
  • All indexes are 0 based.
  • The total number of items in an array (merging all dimensions) cannot exceed 65535.


Constant expressions

Programming languages - Reference guide -> Constant expressions

Previous chapter Next chapter Show all Show all Hide all Hide all

Constant expressions can be used in all languages for assigning a variable with a value. All constant expressions have a well defined data type according to their semantics. If you program an operation between variables and constant expressions having inconsistent data types, it will lead to syntactic errors when the program is compiled. Below are the syntactic rules for constant expressions according to possible data types:

BOOL: Boolean

There are only two possible boolean constant expressions. They are reserved keywords TRUE and FALSE.

SINT: Small (8 bit) Integer

Small integer constant expressions are valid integer values (between -128 and 127) and must be prefixed with SINT#. All integer expressions having no prefix are considered as DINT integers.

USINT / BYTE: Unsigned 8 bit Integer

Unsigned small integer constant expressions are valid integer values (between 0 and 255) and must be prefixed with USINT#. All integer expressions having no prefix are considered as DINT integers.

INT: 16 bit integer

16 bit integer constant expressions are valid integer values (between -32768 and 32767) and must be prefixed with INT#. All integer expressions having no prefix are considered as DINT integers.

UINT / WORD: Unsigned 16 bit integer

Unsigned 16 bit integer constant expressions are valid integer values (between 0 and 255) and must be prefixed with UINT#. All integer expressions having no prefix are considered as DINT integers.

DINT: 32 bit (default) integer

32 bit integer constant expressions must be valid numbers between -2147483648 to +2147483647. DINT is the default size for integers: such constant expressions do not need any prefix. You can use 2#, 8# or 16# prefixes for specifying a number in respectively binary, octal or hexadecimal basis.

UDINT / DWORD: Unsigned 32 bit integer

Unsigned 32 bit integer constant expressions are valid integer values (between 0 and 4294967295) and must be prefixed with UDINT#. All integer expressions having no prefix are considered as DINT integers.

LINT: Long (64 bit) integer

Long integer constant expressions are valid integer values and must be prefixed with LINT#. All integer expressions having no prefix are considered as DINT integers.

REAL: Single precision floating point value

Real constant expressions must be valid number, and must include a dot ("."). If you need to enter a real expression having an integer value, add .0 at the end of the number. You can use F or E separators for specifying the exponent in case of a scientist representation. REAL is the default precision for floating points: such expressions do not need any prefix.

LREAL: Double precision floating point value

Real constant expressions must be valid number, and must include a dot ("."), and must be prefixed with LREAL#. If you need to enter a real expression having an integer value, add .0 at the end of the number. You can use F or E separators for specifying the exponent in case of a scientist representation.

TIME: Time of day

Time constant expressions represent durations that must be less than 24 hours. Expressions must be prefixed by either TIME# or T#. They are expressed as a number of hours followed by h, a number of minutes followed by m, a number of seconds followed by s, and a number of milliseconds followed by ms. The order of units (hour, minutes, seconds, milliseconds) must be respected. You cannot insert blank characters in the time expression. There must be at least one valid unit letter in the expression.

STRING: Character string

String expressions must be written between single quote marks. The length of the string cannot exceed 255 characters. You can use the following sequences to represent a special or not printable character within a string:

Sequence | Description
$$ $' $T $R $L $N $P $xx | a "$" character a single quote a tab stop (ASCII code 9) a carriage return character (ASCII code 13) a line feed character (ASCII code 10) carriage return plus line feed characters (ASCII codes 13 and 10) a page break character (ASCII code 12) any character (xx is the ASCII code expressed on two hexadecimal digits

Example Example

Below are some examples of valid constant expressions:

Expression | Description
TRUE FALSE SINT#127 INT#2000 123456 16#abcd LINT#1 0.0 1.002E3 LREAL#1E-200 T#23h59m59s999ms TIME#0s T#1h123ms 'hello' 'name$Tage' 'I$'m here' 'x$00y' | TRUE boolean expression FALSE boolean expression small integer 16 bit integer DINT (32 bit) integer DINT integer in hexadecimal basis long (64 bit) integer having the value "1" 0 expressed as a REAL number 1002 expressed as a REAL number in scientist format Double precision real number maximum TIME value null TIME value TIME value with some units missing character string character string with two words separated by a tab character string with a quote inside (I'm here) character string with two characters separated by a null character (ASCII code 0)

Below are some examples of typical errors in constant expressions:

Expression | Error-Description
1a2b 1E-200 T#12 'I'm here' hello | basis prefix omitted for a double precision float Time unit missing quote within a string with "$" mark omitted quotes omitted around a character string


Conditional compiling

Programming languages - Reference guide -> Conditional compiling

Previous chapter Next chapter Show all Show all Hide all Hide all

The compiler supports conditional compiling directives in ST, IL, LD, and FBD languages. Conditional compiling directives condition the inclusion of a part of the program in the generated code. Conditional compiling is an easy way to manage several various configurations and options in a unique application programming.

Conditional compiling uses definitions as conditions. Below is the main syntax:

#ifdef CONDITION

statementsYES...

#else

statementsNO...

#endif

If CONDITION has been defined using #define syntax, then the statementsYES part is included in the code, else the statementsNO part is included. The #else statement is optional.

In ST and IL text languages, directives must be entered alone on one line line of text. In FBD language, directives must be entered as the text of network breaks. In LD language, directives must be entered on comment lines.

The condition __DEBUG is automatically defined when the application is compiled in DEBUG mode. This allows you to incorporate some additional statements (such as trace outputs) in your code that are not included in RELEASE mode.


Handling exceptions

Programming languages - Reference guide -> Handling exceptions

Previous chapter Next chapter Show all Show all Hide all Hide all

The compiler enables you to write your own exception programs for handling particular system events. The following exceptions can be handled:

  • Startup (before the first cycle)
  • Shutdown (after the last cycle)
  • Division by zero

Startup

You can write your own exception program to be executed before the first application cycle is executed:

  1. Create a new main program that will handle the exception. It cannot be a SFC program.
  2. In the editor of global defines, insert the following line:

#OnStartup ProgramName

attention Attention

The program is executed before all other programs within the fisrt cycle. This implies that the cycle timing may be longer during the first cycle. You cannot put breakpoints in the Startup program.

Shutdown

You can write your own exception program to be executed after the last application cycle when the runtime system is cleanly stopped:

  1. Create a new main program that will handle the exception. It cannot be a SFC program.
  2. In the editor of global defines, insert the following line:

#OnShutdown ProgramName

attention Attention

You cannot put breakpoints in the Shutdown program.

Division by zero

You can write your own exception program for handling the "Division by zero" exception. Below is the procedure you must follow for setting an exception handler:

  1. Create a new sub-program without any parameter that will handle the exception
  2. In the editor of global defines, insert the following line:

#OnDivZero SubProgramName

In the sub-program that handles the exception you can perform any safety or trace operation. You then have the selection between the following possibilities:

  • Return without any special call. In that case the standard handling will be performed: a system error message is generated, the result of the division is replaced by a maximum value and the application continues.
  • Call the FatalStop function. The runtime then stops immediately in Fatal Error mode.
  • Call the CycleStop function. The runtime finishes the current program and then turns in cycle setting mode.

Handlers can also be used in DEBUG mode for tracking the bad operation. Just put a breakpoint in your handler. When stopped, the call stack will show you the location of the division in the source code of the program.

Array index out of bounds

You can write your own exception program for handling the "Array index out of bounds" exception. Below is the procedure you must follow for setting an exception handler:

  1. Create a new sub-program without any parameter that will handle the exception
  2. In the editor of global defines, insert the following line:

#OnBadArrayIndex SubProgramName

Note: this is anyway a fatal error. If the "Check array bounds" compiling option is set, the runtime goes in "fatal error" mode after calling your sub-program.


Variable status bits

Programming languages - Reference guide -> Variable status bits

Previous chapter Next chapter Show all Show all Hide all Hide all

The workbench enables you to associate status bits to declared variables. Each variable may have, in addition to its real time value:

  • 64 status bits
  • a date and time stamp

Status bits and time stamps are generally set by input drivers taking care of hardware inputs, but may also be transported together with the value of the variable on some network protocols. In addition, the IEC 61131-3 programs may access to the status bits of variables.

attention Attention
  • Status bit management may be not available on some targets. Please refer to OEM instructions for further details about available features.
  • Status bit management is CPU and memory consuming and may reduce the performances of your applications.

Enabling status bits

In order to enable the management of status bits and time/date stamps by the runtime, you must check the following option in the list of compiler options from the Project Settings wizard:

Allocate status flags for variables with embedded properties

Only variables having some properties defined (either a profile attached or embedded symbol) will get status bits. Status bits are available only for global scope variables (global, retain, IOs...) with a single data type (cannot be array or structure).

Reading and writing status from programs

The following functions are available for managing status information in the programs:

vsiGetBit : get a status bit of a variable
vsiGetDate : get the date stamp of a variable
vsiGetTime : get the time stamp of a variable
vsiSetBit : set a status bit of a variable
vsiSetDate : set the date stamp of a variable
vsiSetTime : set the time stamp of a variable
vsiStamp / VsiStampGMT : update the stamp of a variable according to the current time
vsiCopy : copy status bits and stamp of a variable to another variable

Below is the syntax of the functions:

bBit := vsiGetBit ( variable, bitID );
iDate := vsiGetDate ( variable );
iTime := vsiGetTime ( variable );
bOK := vsiSetBit ( variable, bitID, bBit );
bOK := vsiSetDate ( variable, iDate );
bOK := vsiSetTime ( variable, iTime );
bOK := vsiStamp ( variable );

The functions use the following arguments:

Argument | Description
variable | Variable having embedded profile or symbol.
bitID : DINT | ID of a status bit (see list of IDs in the section below).
bBit : BOOL | Value of the status bit.
iDate : DINT | Date stamp according to real time clock functions conventions.
iTime : DINT | Time stamp according to real time clock functions conventions.
bOK : BOOL | TRUE if successful.

See the description of real time clock functions for further information about time and date stamps.

Drivers supporting status bits

Below are runtime drivers taking care of status bits and date/time stamping:

Driver | Description
Variable binding (ETHERNET) | Binding (spontaneous protocol) is used for real time exchange of variable values among runtimes over ETHERNET. The protocol takes care of carrying status bits. The protocol updates the date and time stamps of variables updated by the network.
MODBUS Master | The MODBUS master protocols (RTU / TCP / UDP) takes care of updating the date and time stamp of all variables updated by the network. The MODBUS stack also sets the _VSB_I_BIT status bits of received variables according to the exchange error status.
MODBUS Slave | The MODBUS slave protocols (RTU / TCP / UDP) takes care of updating the date and time stamp of all variables updated by the network.
DNP3 Master | The DNP3 protocol handles the time stamps and the following status bits: _VSB_SPONT, _VSB_I_BIT, _VSB_ST_M1, _VSB_ST_M3, _VSB_ST_M2, _VSB_OV_BIT, _VSB_SP_BIT
DNP3 Slave | The DNP3 protocol handles the time stamps and the following status bits: _VSB_SPONT, _VSB_I_BIT, _VSB_ST_M1, _VSB_ST_M3, _VSB_ST_M2, _VSB_OV_BIT, _VSB_SP_BIT
IEC 60870-5 Slave | The IEC 60870-5-101 and IEC 60870-5-104 slave protocols send the _VSB_I_BIT, _VSB_OV_BIT, _VSB_BL_BIT, _VSB_SP_BIT and _VSB_NT_BIT in the protocol telegrams for points and measures. Update of date/time stamp included.
IEC 61850 Server | Variable status bits are not supported by the IEC 61850 Server.
IEC 61850 Client | The IEC 61850 Client can read the _VSB_I_BIT from the IEC 61850 Server. Update of date/time stamp included.
zenon RT to Win-GRAF connection | The zenon RT to Win-GRAF connection can read all 64 status bits. Update of date/time stamp included.

In this section

List of status bits


List of status bits

Programming languages - Reference guide -> Variable status bits -> List of status bits

Previous chapter Next chapter Show all Show all Hide all Hide all

Below is the list of available status bits. Identifiers (_VSB_...) are predefined in the compiler and can be directly used in the programs:

bit | identifier | description
0 | _VSB_ST_M1 | user defined status
1 | _VSB_ST_M2 | user defined status
2 | _VSB_ST_M3 | user defined status
3 | _VSB_ST_M4 | user defined status
4 | _VSB_ST_M5 | user defined status
5 | _VSB_ST_M6 | user defined status
6 | _VSB_ST_M7 | user defined status
7 | _VSB_ST_M8 | user defined status
8 | _VSB_SELEC | Select
9 | _VSB_REV | Revision
10 | _VSB_DIREC | Desired direction
11 | _VSB_RTE | Runtime exceeded
12 | _VSB_MVALUE | Manual value
13 | _VSB_ST_14 | user defined status
14 | _VSB_ST_15 | user defined status
15 | _VSB_ST_16 | user defined status
16 | _VSB_GR | General request
17 | _VSB_SPONT | Spontaneous
18 | _VSB_I_BIT | Invalid
19 | _VSB_SUWI | Summer/Winter time announcement
20 | _VSB_N_UPD | Switched off
21 | _VSB_RT_E | Realtime external
22 | _VSB_RT_I | Realtime internal
23 | _VSB_NSORT | Not sortable
24 | _VSB_DM_TR | Default message trafo value
25 | _VSB_RM_TR | Run message trafo value
26 | _VSB_INFO | Info for variable
27 | _VSB_AVALUE | Alternative value
28 | _VSB_RES28 | reserved
29 | _VSB_ACTUAL | Not updated
30 | _VSB_WINTER | Winter time
31 | _VSB_RES31 | reserved
32 | _VSB_TCB0 | Transmission cause
33 | _VSB_TCB1 | Transmission cause
34 | _VSB_TCB2 | Transmission cause
35 | _VSB_TCB3 | Transmission cause
36 | _VSB_TCB4 | Transmission cause
37 | _VSB_TCB5 | Transmission cause
38 | _VSB_PN_BIT | P/N bit
39 | _VSB_T_BIT | Test bit
40 | _VSB_WR_ACK | Acknoledge writing
41 | _VSB_WR_SUC | Writing successful
42 | _VSB_NORM | Normal status
43 | _VSB_ABNORM | Deviation normal status
44 | _VSB_BL_BIT | IEC status: blocked
45 | _VSB_SP_BIT | IEC status: substituted
46 | _VSB_NT_BIT | IEC status: not typical
47 | _VSB_OV_BIT | IEC status: overflow
48 | _VSB_SE_BIT | IEC status: select
49 | not defined |
50 | not defined |
51 | not defined |
52 | not defined |
53 | not defined |
54 | not defined |
55 | not defined |
56 | not defined |
57 | not defined |
58 | not defined |
59 | not defined |
60 | not defined |
61 | not defined |
62 | not defined |
63 | not defined |


Basic Operations

Programming languages - Reference guide -> Basic Operations

Below are the language features for basic data manipulation:

Variable assignment
Bit access
Parenthesis
Calling a function
Calling a function block
Calling a sub-program
MOVEBLOCK: Copying/moving array items
COUNTOF: Number of items in an array
INC: Increase a variable
DEC: decrease a variable

Below are the language features for controlling the execution of a program:

Labels
Jumps
RETURN

Below are the structured statements for controlling the execution of a program:

Statement | Description
IF WHILE REPEAT FOR CASE EXIT WAIT ON | Conditional execution of statements. Repeat statements while a condition is TRUE. Repeat statements until a condition is TRUE. Execute iterations of statements. Switch to one of various possible statements. Exit from a loop instruction. Delay program execution Conditional execution

In this section

Assignment

Access to bits of an integer

Calling a function

Calling a function block

Calling a sub-program

CASE OF ELSE END_CASE

CountOf

DEC

EXIT

FOR TO BY END_FOR

IF THEN ELSE ELSIF END_IF

INC

Jumps JMP JMPC JMPNC JMPCN

Labels

MOVEBLOCK

Parenthesis ( )

REPEAT UNTIL END_REPEAT

RETURN RET RETC RETNC RETCN

WHILE DO END_WHILE

ON

WAIT / WAIT_TIME


Assignment

Programming languages - Reference guide -> Basic Operations -> Assignment

Previous chapter Next chapter Show all Show all Hide all Hide all

:= LD LDN ST STN

Operator - variable assignment.

Inputs

IN : ANY Any variable or complex expression

Outputs

Q : ANY Forced variable

Remarks

The output variable and the input expression must have the same type. The forced variable cannot have the read only attribute. In LD and FBD languages, the 1 block is available to perform a "1 gain" data copy. In LD language, the input rung (EN) enables the assignment, and the output rung keeps the state of the input rung. In IL language, the LD instruction loads the first operand, and the ST instruction stores the current result into a variable. The current result and the operand of ST must have the same type. Both LD and ST instructions can be modified by N in case of a boolean operand for performing a boolean negation.

ST Language

Q := IN; (* copy IN into variable Q *)
Q := (IN1 + (IN2 / IN 3)) * IN4; (* assign the result of a complex expression *)
result := SIN (angle); (* assign a variable with the result of a function *)
time := MyTon.ET; (* assign a variable with an output parameter of a function block *)

FBD Language

LD Language

The copy is executed only if EN is TRUE.
ENO has the same value as EN.

IL Language

Op1: LD IN (* current result is: IN *)
ST Q (* Q is: IN *)
LDN IN1 (* current result is: NOT (IN1) *)
ST Q (* Q is: NOT (IN1) *)
LD IN2 (* current result is: IN2 *)
STN Q (* Q is: NOT (IN2) *)

seealso See also

Parenthesis


Access to bits of an integer

Programming languages - Reference guide -> Basic Operations -> Access to bits of an integer

Previous chapter Next chapter Show all Show all Hide all Hide all

You can directly specify a bit within n integer variable in expressions and diagrams, using the following notation:

Variable.BitNo

Where:

Variable: is the name of an integer variable.
BitNo: is the number of the bit in the integer.

The variable can have one of the following data types:

SINT, USINT, BYTE (8 bits from .0 to .7)
INT, UINT, WORD (16 bits from .0 to .15)
DINT, UDINT, DWORD (32 bits from .0 to 31)
LINT (from 0 to 63)

0 always represents the less significant bit.


Calling a function

Programming languages - Reference guide -> Basic Operations -> Calling a function

Previous chapter Next chapter Show all Show all Hide all Hide all

A function calculates a result according to the current value of its inputs. Unlike a function block, a function has no internal data and is not linked to declared instances. A function has only one output: the result of the function. A function can be:

  • Astandard function (SHL, SIN...).
  • A function written in "C" language and embedded on the target.

ST Language

To call a function block in ST, you have to enter its name, followed by the input parameters written between parenthesis and separated by comas. The function call may be inserted into any complex expression. a function call can be used as an input parameter of another function. The following example demonstrates a call to ODD and SEL functions:

Example Example

(* The following statement converts any odd integer value into the nearest even integer: *)

iEvenVal := SEL ( ODD( iValue ), iValue, iValue+1 );

FBD and LD Languages

To call a function block in FBD or LD languages, you just need to insert the function in the diagram and to connect its inputs and output.

IL Language

To call a function block in IL language, you must load its first input parameter before the call, and then use the function name as an instruction, followed by the other input parameters, separated by comas. The result of the function is then the current result. The following example demonstrates a call to ODD and SEL functions:

Example Example

(* The following statement converts any odd integer into 0: *)

Op1: LD iValue
ODD
SEL iValue, 0
ST iResult


Calling a function block

Programming languages - Reference guide -> Basic Operations -> Calling a function block

Previous chapter Next chapter Show all Show all Hide all Hide all

CAL CALC CALNC CALCN

A function block groups an algorithm and a set of private data. It has inputs and outputs. A function block can be:

  • A standard function block (RS, TON...).
  • A block written in "C" language and embedded on the target.
  • A User Defined Function Block (UDFB) written in ST, FBD, LD or IL.

To use a function block, you have to declare an instance of the block as a variable, identified by a unique name. Each instance of a function block as its own set of private data and can be called separately. A call to a function block instance processes the block algorithm on the private data of the instance, using the specified input parameters.

ST Language

To call a function block in ST, you have to specify the name of the instance, followed by the input parameters written between parenthesis and separated by comas. To have access to an output parameter, use the name of the instance followed by a dot '.' and the name of the wished parameter. The following example demonstrates a call to an instance of TON function block (MyTimer is declared as an instance of TON):

Example Example

MyTimer (bTrig, t#2s);
TimerOutput := MyTimer.Q;
ElapsedTime := MyTimer.ET;

FBD and LD Languages

To call a function block in FBD or LD languages, you just need to insert the block in the diagram and to connect its inputs and outputs. The name of the instance must be specified upon the rectangle of the block.

IL Language

To call a function block in IL language, you must use the CAL instruction, and use a declared instance of the function block. The instance name is the operand of the CAL instruction, followed by the input parameters written between parenthesis and separated by comas. Alternatively the CALC, CALCN or CALNC conditional instructions can be used:

CAL Calls the function block.
CALC Calls the function block if the current result is TRUE.
CALNC Calls the function block if the current result is FALSE.
CALCN same as CALNC.

The following example demonstrates a call to an instance of TON function block (MyTimer is declared as an instance of TON):

Example Example

Op1: CAL MyTimer (bTrig, t#2s)
LD MyTimer.Q
ST TimerOutput
LD MyTimer.ET
ST ElapsedTimer

Op2: LD bCond
CALC MyTimer (bTrig, t#2s) (* called only if bCond is TRUE *)
Op3: LD bCond
CALNC MyTimer (bTrig, t#2s) (* called only if bCond is FALSE *)


Calling a sub-program

Programming languages - Reference guide -> Basic Operations -> Calling a sub-program

Previous chapter Next chapter Show all Show all Hide all Hide all

A sub-program is called by another program. Unlike function blocks, local variables of a sub-program are not instantiated, and thus you do not need to declare instances. A call to a sub-program processes the block algorithm using the specified input parameters. Output parameters can then be accessed.

ST Language

To call a sub-program in ST, you have to specify its name, followed by the input parameters written between parenthesis and separated by comas. To have access to an output parameter, use the name of the sub-program followed by a dot '.' and the name of the wished parameter:

MySubProg (i1, i2); (* calls the sub-program *)
Res1 := MySubProg.Q1;
Res2 := MySubProg.Q2;

Alternatively, if a sub-program has one and only one output parameter, it can be called as a function in ST language:

Res := MySubProg (i1, i2);

FBD and LD Languages

To call a sub-program in FBD or LD languages, you just need to insert the block in the diagram and to connect its inputs and outputs.

IL Language

To call a sub-program in IL language, you must use the CAL instruction with the name of the sub-program, followed by the input parameters written between parenthesis and separated by comas. Alternatively the CALC, CALCN or CALNC conditional instructions can be used:

CAL Calls the sub-program.
CALC Calls the sub-program if the current result is TRUE.
CALNC Calls the sub-program if the current result is FALSE.
CALCN same as CALNC.

Example Example

Op1: CAL MySubProg (i1, i2)
LD MySubProg.Q1
ST Res1
LD MySubProg.Q2
ST Res2


CASE OF ELSE END_CASE

Programming languages - Reference guide -> Basic Operations -> CASE OF ELSE END_CASE

Previous chapter Next chapter Show all Show all Hide all Hide all

Statement - switch between enumerated statements.

Syntax

CASE <DINT expression> OF
<value> :
<statements>
<value> , <value> :
<statements>;
<value> .. <value> :
<statements>;
ELSE
<statements>
END_CASE;

Remarks

All enumerated values correspond to the evaluation of the DINT expression and are possible cases in the execution of the statements. The statements specified after the ELSE keyword are executed if the expression takes a value that is not enumerated in the switch. For each case, you must specify either a value, or a list of possible values separated by comas (",") or a range of values specified by a "min .. max" interval. You must enter space characters before and after the ".." separator.

ST Language

Example Example

This example checks the first prime numbers:
CASE iNumber OF
0 :
Alarm := TRUE;
AlarmText := '0 gives no result';
1 .. 3, 5 :
bPrime := TRUE;
4, 6 :
bPrime := FALSE;
ELSE
Alarm := TRUE;
AlarmText := 'I don't know after 6 !';
END_CASE;

FBD Language

Not available.

LD Language

Not available.

IL Language

Not available.

seealso See also

IF WHILE REPEAT FOR EXIT


CountOf

Programming languages - Reference guide -> Basic Operations -> CountOf

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Returns the number of items in an array.

Inputs

ARR : ANY Declared array.

Outputs

Q : DINT Total number of items in the array.

Remarks

The input must be an array and can have any data type. This function is particularly useful to avoid writing directly the actual size of an array in a program, and thus keep the program independent from the declaration.

Example Example

FOR i := 1 TO CountOf (MyArray) DO
MyArray[i-1] := 0;
END_FOR;

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung.

Example Example
Array | Return
Arr1 [ 0..9 ] | 10
Arr2 [ 0..4 , 0..9 ] | 50

ST Language

Q := CountOf (ARR);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Not available.


DEC

Programming languages - Reference guide -> Basic Operations -> DEC

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Decrease a numerical variable.

Inputs

IN : ANY Numerical variable (increased after call).

Outputs

Q : ANY Decreased value.

Remarks

When the function is called, the variable connected to the IN input is decreased and copied to Q. All data types are supported except BOOL and STRING: for these types, the output is the copy of IN.

For real values, variable is decreased by 1.0. For time values, variable is decreased by 1ms.

The IN input must be directly connected to a variable, and cannot be a constant or complex expression.

This function is particularly designed for ST language. It allows simplified writing as assigning the result of the function is not mandatory.

ST Language

IN := 2;
Q := DEC (IN);
(* now: IN = 1 ; Q = 1 *)

DEC (IN); (* simplified call *)

FBD Language

LD Language

IL Language

Not available.


EXIT

Programming languages - Reference guide -> Basic Operations -> EXIT

Previous chapter Next chapter Show all Show all Hide all Hide all

Statement - Exit from a loop statement.

Remarks

The EXIT statement indicates that the current loop (WHILE, REPEAT or FOR) must be finished. The execution continues after the END_WHILE, END_REPEAT or END_FOR keyword or the loop where the EXIT is. EXIT quits only one loop and cannot be used to exit at the same time several levels of nested loops.

attention Attention

Loop instructions may lead to infinite loops that block the target cycle.

ST Language

This program searches for the first non null item of an array:

iFound = -1; (* means: not found *)
FOR iPos := 0 TO (iArrayDim - 1) DO
IF iPos <> 0 THEN
iFound := iPos;
EXIT;
END_IF;
END_FOR;

FBD Language

Not available.

LD Language

Not available.

IL Language

Not available.

seealso See also

IF WHILE REPEAT FOR CASE


FOR TO BY END_FOR

Programming languages - Reference guide -> Basic Operations -> FOR TO BY END_FOR

Previous chapter Next chapter Show all Show all Hide all Hide all

Statement - Iteration of statement execution.

Syntax

FOR <index> := <minimum> TO <maximum> BY <step> DO
<statements>
END_FOR;

index = DINT internal variable used as index.
minimum = DINT expression: initial value for index.
maximum = DINT expression: maximum allowed value for index.
step = DINT expression: increasing step of index after each iteration (default is 1).

Remarks

The BY <step> statement can be omitted. The default value for the step is 1.

ST Language

iArrayDim := 10;

(* resets all items of the array to 0 *)
FOR iPos := 0 TO (iArrayDim - 1) DO
MyArray[iPos] := 0;
END_FOR;

(* set all items with odd index to 1 *)
FOR iPos := 1 TO 9 BY 2 DO
MyArray[ipos] := 1;
END_FOR;

FBD Language

Not available.

LD Language

Not available.

IL Language

Not available.

seealso See also

IF WHILE REPEAT CASE EXIT


IF THEN ELSE ELSIF END_IF

Programming languages - Reference guide -> Basic Operations -> IF THEN ELSE ELSIF END_IF

Previous chapter Next chapter Show all Show all Hide all Hide all

Statement - Conditional execution of statements.

Syntax

IF <BOOL expression> THEN
<statements>
ELSIF <BOOL expression> THEN
<statements>
ELSE
<statements>
END_IF;

Remarks

The IF statement is available in ST only. The execution of the statements is conditioned by a boolean expression. ELSIF and ELSE statements are optional. There can be several ELSIF statements.

ST Language

(* simple condition *)
IF bCond THEN
Q1 := IN1;
Q2 := TRUE;
END_IF;

(* binary selection *)
IF bCond THEN
Q1 := IN1;
Q2 := TRUE;
ELSE
Q1 := IN2;
Q2 := FALSE;
END_IF;

(* enumerated conditions *)
IF bCond1 THEN
Q1 := IN1;
ELSIF bCond2 THEN
Q1 := IN2;
ELSIF bCond3 THEN
Q1 := IN3;
ELSE
Q1 := IN4;
END_IF;

FBD Language

Not available.

LD Language

Not available.

IL Language

Not available.

seealso See also

WHILE REPEAT FOR CASE EXIT


INC

Programming languages - Reference guide -> Basic Operations -> INC

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Increase a numerical variable:

Inputs

IN : ANY Numerical variable (increased after call).

Outputs

Q : ANY Increased value.

Remarks

When the function is called, the variable connected to the IN input is increased and copied to Q. All data types are supported except BOOL and STRING: for these types, the output is the copy of IN.

For REAL values, variable is increased by 1.0. For TIME values, variable is increased by 1ms.

The IN input must be directly connected to a variable, and cannot be a constant or complex expression.

This function is particularly designed for ST language. It allows simplified writing as assigning the result of the function is not mandatory.

ST Language

IN := 1;
Q := INC (IN);
(* now: IN = 2 ; Q = 2 *)

INC (IN); (* simplified call *)

FBD Language

LD Language

IL Language

Not available.


Jumps JMP JMPC JMPNC JMPCN

Programming languages - Reference guide -> Basic Operations -> Jumps JMP JMPC JMPNC JMPCN

Previous chapter Next chapter Show all Show all Hide all Hide all

Statement - Jump to a label.

Remarks

A jump to a label branches the execution of the program after the specified label. Labels and jumps cannot be used in structured ST language. In FBD language, a jump is represented by the >> symbol followed by the label name. The input of the >> symbol must be connected to a valid boolean signal. The jump is performed only if the input is TRUE. In LD language, the >> symbol, followed by the target label name, is used as a coil at the end of a rung. The jump is performed only if the rung state is TRUE. In IL language, JMP, JMPC, JMPCN and JMPNC instructions are used to specify a jump. The destination label is the operand of the jump instruction.

attention Attention

Backward jumps may lead to infinite loops that block the target cycle.

ST Language

Not available.

FBD Language

In this example the TON block will not be called if bEnable is TRUE:

Example Example

LD Language

In this example the second rung will be skipped if IN1 is TRUE:

Example Example

IL Language

Below is the meaning of possible jump instructions:
JMP Jump always
JMPC Jump if the current result is TRUE
JMPNC Jump if the current result is FALSE
JMPCN Same as JMPNC

Start: LD IN1
JMPC TheRest (* Jump to "TheRest" if IN1 is TRUE *)

LD IN2 (* these three instructions are not executed *)
ST Q2 (* if IN1 is TRUE *)
JMP TheEnd (* unconditional jump to "TheEnd" *)

TheRest: LD IN3
ST Q3
TheEnd:

seealso See also

Labels RETURN


Labels

Programming languages - Reference guide -> Basic Operations -> Labels

Previous chapter Next chapter Show all Show all Hide all Hide all

Statement - Destination of a Jump instruction.

Remarks

Labels are used as a destination of a jump instruction in FDB, LD or IL language. Labels and jumps cannot be used in structured ST language. A label must be represented by a unique name, followed by a colon (":"). In FBD language, labels can be inserted anywhere in the diagram, and are connected to nothing. In LD language, a label must identify a rung, and is shown on the left side of the rung. In IL language, labels are destination for JMP, JMPC, JMPCN and JMPNC instructions. They must be written before the instruction at the beginning of the line, and should index the beginning of a valid IL statement: LD (load) instruction, or unconditional instructions such as CAL, JMP or RET. The label can also be written alone on a line before the indexed instruction. In all languages, it is not mandatory that a label be a target of a jump instruction. You can also use label for marking parts of the programs in order to increase its readability.

ST Language

Not available.

FBD Language

In this example the TON block will not be called if bEnable is TRUE:

Example Example

LD Language

In this example the second rung will be skipped if IN1 is TRUE:

Example Example

IL Language

Start: LD IN1 (* unused label - just for readability *)
JMPC TheRest (* Jump to "TheRest" if IN1 is TRUE *)

LD IN2 (* these two instructions are not executed *)
ST Q2 (* if IN1 is TRUE *)

TheRest: LD IN3 (* label used as the jump destination *)
ST Q3

seealso See also

Jumps RETURN


MOVEBLOCK

Programming languages - Reference guide -> Basic Operations -> MOVEBLOCK

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Move/Copy items of an array.

Inputs

SRC : ANY (*) Array containing the source of the copy.
DST : ANY (*) Array containing the destination of the copy.
PosSRC : DINT Index of the first character in SRC.
PosDST : DINT Index of the destination in DST.
NB : DINT Number of items to be copied.

(*) SRC/DST cannot be a STRING.

Outputs

OK : BOOL TRUE if successful.

Remarks

Arrays of string are not supported by this function.

In LD language, the operation is executed only if the input rung (EN) is TRUE. The function is not available in IL language.

The function copies NB consecutive items starting at the PosSRC index in SRC array to PosDST position in DST array. SRC and DST can be the same array. In that case, the function avoids lost items when source and destination areas overlap.

This function checks array bounds and is always safe. The function returns TRUE if successful. It returns FALSE if input positions and number do not fit the bounds of SRC and DST arrays.

ST Language

OK := MOVEBLOCK (SRC, DST, PosSRS, PosDST, NB);

FBD Language

LD Language

The function is executed only if EN is TRUE:

IL Language

Not available.


Parenthesis ( )

Programming languages - Reference guide -> Basic Operations -> Parenthesis ( )

Previous chapter Next chapter Show all Show all Hide all Hide all

Operator - force the evaluation order in a complex expression.

Remarks

Parenthesis are used in ST and IL language for changing the default evaluation order of various operations within a complex expression. For instance, the default evaluation of "2 * 3 + 4" expression in ST language gives a result of 10 as "*" operator has highest priority. Changing the expression as "2 * ( 3 + 4 )" gives a result of 14. Parenthesis can be nested in a complex expression.

Below is the default evaluation order for ST language operations (first is highest priority):

Unary operators: - NOT
Multiply/Divide: * /
Add/Subtract: + -
Comparisons: < > <= >= = <>
Boolean And: & AND
Boolean Or: OR
Exclusive OR: XOR

In IL language, the default order is the sequence of instructions. Each new instruction modifies the current result sequentially. In IL language, the opening parenthesis "(" is written between the instruction and its operand. The closing parenthesis ")" must be written alone as an instruction without operand.

ST Language

Q := (IN1 + (IN2 / IN 3)) * IN4;

FBD Language

Not available.

LD Language

Not available.

IL Language

Op1: LD( IN1
ADD( IN2
MUL IN3
)
SUB IN4
)
ST Q (* Q is: (IN1 + (IN2 * IN3) - IN4) *)

seealso See also

Assignment


REPEAT UNTIL END_REPEAT

Programming languages - Reference guide -> Basic Operations -> REPEAT UNTIL END_REPEAT

Previous chapter Next chapter Show all Show all Hide all Hide all

Statement - Repeat a list of statements.

Syntax

REPEAT
<statements>
UNTIL <BOOL expression> END_REPEAT;

Remarks

The statements between REPEAT and UNTIL are executed until the boolean expression is TRUE. The condition is evaluated after the statements are executed. Statements are executed at least once.

attention Attention

Loop instructions may lead to infinite loops that block the target cycle. Never test the state of an input in the condition as the input will not be refreshed before the next cycle.

ST Language

iPos := 0;
REPEAT
MyArray[iPos] := 0;
iNbCleared := iNbCleared + 1;
iPos := iPos + 1;
UNTIL iPos = iMax END_REPEAT;

FBD Language

Not available.

LD Language

Not available.

IL Language

Not available.

seealso See also

IF WHILE FOR CASE EXIT


RETURN RET RETC RETNC RETCN

Programming languages - Reference guide -> Basic Operations -> RETURN RET RETC RETNC RETCN

Previous chapter Next chapter Show all Show all Hide all Hide all

Statement - Jump to the end of the program.

Remarks

The RETURN statement jumps to the end of the program. In FBD language, the return statement is represented by the "<RETURN>" symbol. The input of the symbol must be connected to a valid boolean signal. The jump is performed only if the input is TRUE. In LD language, the "<RETURN>" symbol is used as a coil at the end of a rung. The jump is performed only if the rung state is TRUE. In IL language, RET, RETC, RETCN and RETNC instructions are used.

When used within an action block of a SFC step, the RETURN statement jumps to the end of the action block.

ST Language

IF NOT bEnable THEN
RETURN;
END_IF;

The rest of the program will not be executed if bEnabled is FALSE.

FBD Language

Example Example

In this example the TON block will not be called if bIgnore is TRUE:

LD Language

Example Example

In this example the second rung will be skipped if ENABLE is FALSE:

IL Language

Below is the meaning of possible instructions:
RET Jump to the end always.
RETC Jump to the end if the current result is TRUE.
RETNC Jump to the end if the current result is FALSE.
RETCN Same as RETNC.

Start: LD IN1
RETC (* Jump to the end if IN1 is TRUE *)

LD IN2 (* these instructions are not executed *)
ST Q2 (* if IN1 is TRUE *)
RET (* Jump to the end unconditionally *)

LD IN3 (* these instructions are never executed *)
ST Q3

seealso See also

Labels Jumps


WHILE DO END_WHILE

Programming languages - Reference guide -> Basic Operations -> WHILE DO END_WHILE

Previous chapter Next chapter Show all Show all Hide all Hide all

Statement - Repeat a list of statements.

Syntax

WHILE <BOOL expression> DO
<statements>
END_WHILE ;

Remarks

The statements between DO and END_WHILE are executed while the boolean expression is TRUE. The condition is evaluated before the statements are executed. If the condition is FALSE when WHILE is first reached, statements are never executed.

attention Attention

Loop instructions may lead to infinite loops that block the target cycle. Never test the state of an input in the condition as the input will not be refreshed before the next cycle.

ST Language

iPos := 0;
WHILE iPos < iMax DO
MyArray[iPos] := 0;
iNbCleared := iNbCleared + 1;
END_WHILE;

FBD Language

Not available.

LD Language

Not available.

IL Language

Not available.

seealso See also

IF REPEAT FOR CASE EXIT


ON

Programming languages - Reference guide -> Basic Operations -> ON

Previous chapter Next chapter Show all Show all Hide all Hide all

Statement - Conditional execution of statements.

Syntax

ON <BOOL expression> DO
<statements>
END_DO;

Remarks

Statements within the ON structure are executed only when the boolean expression rises from FALSE to TRUE. The ON instruction avoids systematic use of the R_TRIG function block or other "last state" flags.

The ON syntax is available in any program, sub-program or UDFB. It is available in both Win-GRAF PAC p-code or native code compilation modes.

This statement is an extension to the standard and is not IEC61131-3 compliant.

ST Language

(* This example counts the rising edges of variable bIN *)
ON bIN DO
diCount := diCount + 1;
END_DO;


WAIT / WAIT_TIME

Programming languages - Reference guide -> Basic Operations -> WAIT / WAIT_TIME

Previous chapter Next chapter Show all Show all Hide all Hide all

Statement - Suspend the execution of a ST program.

Syntax

WAIT <BOOL expression> ;

WAIT_TIME <TIME expression> ;

Remarks

The WAIT statement checks the attached boolean expression and does the following:

- If the expression is TRUE, the program continues normally.

- If the expression is FALSE, then the execution of the program is suspended up to the next PLC cycle. The boolean expression will be checked again during next cycles until it becomes TRUE. The execution of other programs is not affected.

The WAIT_TIME statement suspends the execution of the program for the specified duration. The execution of other programs is not affected.

These instructions are available in ST language only and has no correspondence in other languages. These instructions cannot be called in a User Defined Function Block (UDFB). The use of WAIT or WAIT_TIME in a UDFB provokes a compile error.

WAIT and WAIT_TIME instructions can be called in a sub-program. However, this may lead to some unsafe situation if the same sub program is called from various programs. Re-entrancy is not supported by WAIT and WAIT_TIME instructions. Avoiding this situation is the responsibility of the programmer. The compiler outputs some warning messages if a sub-program containing a WAIT or WAIT_TIME instruction is called from more than one program.

These instructions should not be called from ST parts of SFC programs. This makes no sense as SFC is already a state machine. The use of WAIT or WAIT_TME in SFC or in a sub-program called from SFC provokes a compile error.

These instructions are not available when the code is compiled through a "C" compiler. Using "C" code generation with a program containing a WAIT or WAIT_TIME instruction provokes an error during post-compiling.

These statement are extensions to the standard and are not IEC61131-3 compliant.

ST Language

(* use of WAIT with different kinds of BOOL expressions *)
WAIT BoolVariable;
WAIT (diLevel > 100) AND NOT bAlarm;

WAIT SubProgCall ();

(* use of WAIT_TIME with different kinds of TIME expressions *)
WAIT_TIME t#2s;
WAIT_TIME TimeVariable;


Boolean Operations

Programming languages - Reference guide -> Boolean Operations

Previous chapter Next chapter Show all Show all Hide all Hide all

Below are the standard operators for managing booleans:

Operator | Description
AND OR XOR NOT S R QOR | performs a boolean AND performs a boolean OR performs an exclusive OR performs a boolean negation of its input force a boolean output to TRUE force a boolean output to FALSE Qualified OR

Below are the available blocks for managing boolean signals:

Block | Description
RS SR R_TRIG F_TRIG SEMA FLIPFLOP | reset dominant bistable set dominant bistable rising pulse detection falling pulse detection semaphore flipflop^bistable

In this section

AND ANDN &

FLIPFLOP

F_TRIG

NOT

OR ORN

R

RS

R_TRIG

S

SEMA

SR

XOR XORN

QOR


AND ANDN &

Programming languages - Reference guide -> Boolean Operations -> AND ANDN &

Previous chapter Next chapter Show all Show all Hide all Hide all

Operator - Performs a logical AND of all inputs.

Inputs

IN1 : BOOL First boolean input.
IN2 : BOOL Second boolean input.

Outputs

Q : BOOL Boolean AND of all inputs.

Truth table

IN1 | IN2 | Q
0 | 0 | 0
0 | 1 | 0
1 | 0 | 0
1 | 1 | 1

Remarks

In FBD language, the block may have up to 16 inputs. The block is called "&" in FBD language. In LD language, an AND operation is represented by serialized contacts. In IL language, the AND instruction performs a logical AND between the current result and the operand. The current result must be boolean. The ANDN instruction performs an AND between the current result and the boolean negation of the operand. In ST and IL languages, "&" can be used instead of "AND".

ST Language

Q := IN1 AND IN2;
Q := IN1 & IN2 & IN3;

FBD Language

The block may have up to 16 inputs:

LD Language

Serialized contacts:

IL Language

Op1: LD IN1
& IN2 (* "&" or "AND" can be used *)
ST Q (* Q is equal to: IN1 AND IN2 *)
Op2: LD IN1
AND IN2
&N IN3 (* "&N" or "ANDN" can be used *)
ST Q (* Q is equal to: IN1 AND IN2 AND (NOT IN3) *)

seealso See also

OR XOR NOT


FLIPFLOP

Programming languages - Reference guide -> Boolean Operations -> FLIPFLOP

Previous chapter Next chapter Show all Show all Hide all Hide all

Function Block - Flipflop bistable.

Inputs

IN : BOOL Swap command (on rising edge).
RST : BOOL Reset to FALSE.

Outputs

Q : BOOL Output.

Remarks

The output is systematically reset to FALSE if RST is TRUE.
The output changes on each rising edge of the IN input, if RST is FALSE.

ST Language

MyFlipFlop is declared as an instance of FLIPFLOP function block:

MyFlipFlop (IN, RST);

Q := MyFlipFlop.Q;

FBD Language

LD Language

The IN command is the rung - the rung is the output:

IL Language

MyFlipFlop is declared as an instance of FLIPFLOP function block:

Op1: CAL MyFlipFlop (IN, RST)
LD MyFlipFlop.Q
ST Q1

seealso See also

R S SR


F_TRIG

Programming languages - Reference guide -> Boolean Operations -> F_TRIG

Previous chapter Next chapter Show all Show all Hide all Hide all

Function Block - Falling pulse detection.

Inputs

CLK : BOOL Boolean signal.

Outputs

Q : BOOL TRUE when the input changes from TRUE to FALSE.

Truth table

CLK | CLK prev | Q
0 | 0 | 0
0 | 1 | 1
1 | 0 | 0
1 | 1 | 0

Remarks

Although ]P[ an ]N[ contacts may be used in LD language, it is recommended to use declared instances of R_TRIG or F_TRIG function blocks in order to avoid unexpected behaviour during an On Line change.

ST Language

MyTrigger is declared as an instance of F_TRIG function block:

MyTrigger (CLK);
Q := MyTrigger.Q;

FBD Language

LD Language

The input signal is the rung - the rung is the output:

IL Language

MyTrigger is declared as an instance of F_TRIG function block:

Op1: CAL MyTrigger (CLK)
LD MyTrigger.Q
ST Q

seealso See also

R_TRIG


NOT

Programming languages - Reference guide -> Boolean Operations -> NOT

Previous chapter Next chapter Show all Show all Hide all Hide all

Operator - Performs a boolean negation of the input.

Inputs

IN : BOOL Boolean value.

Outputs

Q : BOOL Boolean negation of the input.

Truth table

IN | Q
0 | 1
1 | 0

Remarks

In FBD language, the block NOT can be used. Alternatively, you can use a link terminated by a o negation. In LD language, negated contacts and coils can be used. In IL language, the N modifier can be used with instructions LD, AND, OR, XOR and ST. It represents a negation of the operand. In ST language, NOT can be followed by a complex boolean expression between parenthesis.

ST Language

Q := NOT IN;
Q := NOT (IN1 OR IN2);

FBD Language

Explicit use of the NOT block:

Use of a negated link: Q is IN1 AND NOT IN2:

LD Language

Negated contact: Q is: IN1 AND NOT IN2:

Negated coil: Q is NOT (IN1 AND IN2):

IL Language

Op1: LDN IN1
OR IN2
ST Q (* Q is equal to: (NOT IN1) OR IN2 *)
Op2: LD IN1
AND IN2
STN Q (* Q is equal to: NOT (IN1 AND IN2) *)

seealso See also

AND OR XOR


OR ORN

Programming languages - Reference guide -> Boolean Operations -> OR ORN

Previous chapter Next chapter Show all Show all Hide all Hide all

Operator - Performs a logical OR of all inputs.

Inputs

IN1 : BOOL First boolean input.
IN2 : BOOL Second boolean input.

Outputs

Q : BOOL Boolean OR of all inputs.

Truth table

IN1 | IN2 | Q
0 | 0 | 0
0 | 1 | 1
1 | 0 | 1
1 | 1 | 1

Remarks

In FBD language, the block may have up to 16 inputs. The block is called >=1 in FBD language. In LD language, an OR operation is represented by contacts in parallel. In IL language, the OR instruction performs a logical OR between the current result and the operand. The current result must be boolean. The ORN instruction performs an OR between the current result and the boolean negation of the operand.

ST Language

Q := IN1 OR IN2;
Q := IN1 OR IN2 OR IN3;

FBD Language

The block may have up to 16 inputs:

LD Language

Parallel contacts:

IL Language

Op1: LD IN1
OR IN2
ST Q (* Q is equal to: IN1 OR IN2 *)
Op2: LD IN1
ORN IN2
ST Q (* Q is equal to: IN1 OR (NOT IN2) *)

seealso See also

AND XOR NOT


R

Programming languages - Reference guide -> Boolean Operations -> R

Previous chapter Next chapter Show all Show all Hide all Hide all

Operator - Force a boolean output to FALSE.

Inputs

RESET : BOOL Condition.

Outputs

Q : BOOL Output to be forced.

Truth table

RESET | Q prev | Q
0 | 0 | 0
0 | 1 | 1
1 | 0 | 0
1 | 1 | 0

Remarks

S and R operators are available as standard instructions in the IL language. In LD languages they are represented by (S) and (R) coils. In FBD language, you can use (S) and (R) coils, but you should prefer RS and SR function blocks. Set and reset operations are not available in ST language.

ST Language

Not available.

FBD Language

Not available. Use RS or SR function blocks.

LD Language

Use of "R" coil:

IL Language

Op1: LD RESET
R Q (* Q is forced to FALSE if RESET is TRUE *)
(* Q is unchanged if RESET is FALSE *)

seealso See also

S RS SR


RS

Programming languages - Reference guide -> Boolean Operations -> RS

Previous chapter Next chapter Show all Show all Hide all Hide all

Function Block - Reset dominant bistable.

Inputs

SET : BOOL Condition for forcing to TRUE.
RESET1 : BOOL Condition for forcing to FALSE (highest priority command).

Outputs

Q1 : BOOL Output to be forced.

Truth table

SET | RESET1 | Q1 prev | Q1
0 | 0 | 0 | 0
0 | 0 | 1 | 1
0 | 1 | 0 | 0
0 | 1 | 1 | 0
1 | 0 | 0 | 1
1 | 0 | 1 | 1
1 | 1 | 0 | 0
1 | 1 | 1 | 0

Remarks

The output is unchanged when both inputs are FALSE. When both inputs are TRUE, the output is forced to FALSE (reset dominant).

ST Language

MyRS is declared as an instance of RS function block:

MyRS (SET, RESET1);
Q1 := MyRS.Q1;

FBD Language

LD Language

The SET command is the rung - the rung is the output:

IL Language

MyRS is declared as an instance of RS function block:

Op1: CAL MyRS (SET, RESET1)
LD MyRS.Q1
ST Q1

seealso See also

R S SR


R_TRIG

Programming languages - Reference guide -> Boolean Operations -> R_TRIG

Previous chapter Next chapter Show all Show all Hide all Hide all

Function Block - Rising pulse detection.

Inputs

CLK : BOOL Boolean signal.

Outputs

Q : BOOL TRUE when the input changes from FALSE to TRUE.

Truth table

CLK | CLK prev | Q
0 | 0 | 0
0 | 1 | 0
1 | 0 | 1
1 | 1 | 0

Remarks

Although ]P[ an ]N[ contacts may be used in LD language, it is recommended to use declared instances of R_TRIG or F_TRIG function blocks in order to avoid unexpected behaviour during an On Line change.

ST Language

MyTrigger is declared as an instance of R_TRIG function block:

MyTrigger (CLK);
Q := MyTrigger.Q;

FBD Language

LD Language

The input signal is the rung - the rung is the output:

IL Language

MyTrigger is declared as an instance of R_TRIG function block:

Op1: CAL MyTrigger (CLK)
LD MyTrigger.Q
ST Q

seealso See also

F_TRIG


S

Programming languages - Reference guide -> Boolean Operations -> S

Previous chapter Next chapter Show all Show all Hide all Hide all

Operator - Force a boolean output to TRUE.

Inputs

SET : BOOL Condition.

Outputs

Q : BOOL Output to be forced.

Truth table

SET | Q prev | Q
0 | 0 | 0
0 | 1 | 1
1 | 0 | 1
1 | 1 | 1

Remarks

S and R operators are available as standard instructions in the IL language. In LD languages they are represented by (S) and (R) coils In FBD language, you can use (S) and (R) coils, but you should prefer RS and SR function blocks. Set and reset operations are not available in ST language.

ST Language

Not available.

FBD Language

Not available. Use RS or SR function blocks.

LD Language

Use of S coil:

IL Language

Op1: LD SET
S Q (* Q is forced to TRUE if SET is TRUE *)
(* Q is unchanged if SET is FALSE *)

seealso See also

R RS SR


SEMA

Programming languages - Reference guide -> Boolean Operations -> SEMA

Previous chapter Next chapter Show all Show all Hide all Hide all

Function Block - Semaphore.

Inputs

CLAIM : BOOL Takes the semaphore.
RELEASE : BOOL Releases the semaphore.

Outputs

BUSY : BOOL TRUE if semaphore is busy.

Remarks

The function block implements the following algorithm:

BUSY := mem;
if CLAIM then
mem := TRUE;
else if RELEASE then
BUSY := FALSE;
mem := FALSE;
end_if;

In LD language, the input rung is the CLAIM command. The output rung is the BUSY output signal.

ST Language

MySema is a declared instance of SEMA function block:

MySema (CLAIM, RELEASE);
BUSY := MySema.BUSY;

FBD Language

LD Language

IL Language

MySema is a declared instance of SEMA function block:

Op1: CAL MySema (CLAIM, RELEASE)
LD MySema.BUSY
ST BUSY


SR

Programming languages - Reference guide -> Boolean Operations -> SR

Previous chapter Next chapter Show all Show all Hide all Hide all

Function Block - Set dominant bistable.

Inputs

SET1 : BOOL Condition for forcing to TRUE (highest priority command).
RESET : BOOL Condition for forcing to FALSE.

Outputs

Q1 : BOOL Output to be forced.

Truth table

SET1 | RESET | Q1 prev | Q1
0 | 0 | 0 | 0
0 | 0 | 1 | 1
0 | 1 | 0 | 0
0 | 1 | 1 | 0
1 | 0 | 0 | 1
1 | 0 | 1 | 1
1 | 1 | 0 | 1
1 | 1 | 1 | 1

Remarks

The output is unchanged when both inputs are FALSE. When both inputs are TRUE, the output is forced to TRUE (set dominant).

ST Language

MySR is declared as an instance of SR function block:

MySR (SET1, RESET);
Q1 := MySR.Q1;

FBD Language

LD Language

The SET1 command is the rung - the rung is the output:

IL Language

MySR is declared as an instance of SR function block:

Op1: CAL MySR (SET1, RESET)
LD MySR.Q1
ST Q1

seealso See also

R S RS


XOR XORN

Programming languages - Reference guide -> Boolean Operations -> XOR XORN

Previous chapter Next chapter Show all Show all Hide all Hide all

Operator - Performs an exclusive OR of all inputs.

Inputs

IN1 : BOOL First boolean input.
IN2 : BOOL Second boolean input.

Outputs

Q : BOOL Exclusive OR of all inputs.

Truth table

IN1 | IN2 | Q
0 | 0 | 0
0 | 1 | 1
1 | 0 | 1
1 | 1 | 0

Remarks

The block is called =1 in FBD and LD languages. In IL language, the XOR instruction performs an exclusive OR between the current result and the operand. The current result must be boolean. The XORN instruction performs an exclusive between the current result and the boolean negation of the operand.

ST Language

Q := IN1 XOR IN2;
Q := IN1 XOR IN2 XOR IN3;

FBD Language

LD Language

First input is the rung. The rung is the output:

IL Language

Op1: LD IN1
XOR IN2
ST Q (* Q is equal to: IN1 XOR IN2 *)
Op2: LD IN1
XORN IN2
ST Q (* Q is equal to: IN1 XOR (NOT IN2) *)

seealso See also

AND OR NOT


QOR

Programming languages - Reference guide -> Boolean Operations -> QOR

Previous chapter Next chapter Show all Show all Hide all Hide all

Operator - Count the number of TRUE inputs.

Inputs

IN1 .. INn : BOOL Boolean inputs

Outputs

Q : DINT Number of inputs being TRUE

Remarks

The block accept a non fixed number of inputs.

ST Language

Q := QOR (IN1, IN2);

Q := QOR (IN1, IN2, IN3, IN4, IN5, IN6);

FBD Language

The block may have up to 16 inputs:

LD Language

The block may have up to 16 inputs:

IL Language

Op1: LD IN1
QOR IN2, IN3
ST Q


Arithmetic operations

Programming languages - Reference guide -> Arithmetic operations

Previous chapter Next chapter Show all Show all Hide all Hide all

Below are the standard operators that perform arithmetic operations:

Operator | Description
+ - * / - (NEG) | addition subtraction multiplication division integer negation (unary operator)

Below are the standard functions that perform arithmetic operations:

Function | Description
MIN MAX LIMIT MOD ODD SetWithin | get the minimum of two values get the maximum of two values bound an integer to low and high limits modulo test if an integer is odd force a value when inside an interval

In this section

+ ADD

/ DIV

NEG -

LIMIT

MAX

MIN

MOD / MODR / MODLR

* MUL

ODD

- SUB

SetWithin


+ ADD

Programming languages - Reference guide -> Arithmetic operations -> + ADD

Previous chapter Next chapter Show all Show all Hide all Hide all

Operator - Performs an addition of all inputs.

Inputs

IN1 : ANY First input.
IN2 : ANY Second input.

Outputs

Q : ANY Result: IN1 + IN2.

Remarks

All inputs and the output must have the same type. In FBD language, the block may have up to 16 inputs. In LD language, the input rung (EN) enables the operation, and the output rung keeps the same value as the input rung. In IL language, the ADD instruction performs an addition between the current result and the operand. The current result and the operand must have the same type.

The addition can be used with strings. The result is the concatenation of the input strings.

ST Language

Q := IN1 + IN2;
MyString := 'He' + 'll ' + 'o'; (* MyString is equal to 'Hello' *)

FBD Language

The block may have up to 16 inputs:

LD Language

The addition is executed only if EN is TRUE.
ENO is equal to EN.

IL Language:

Op1: LD IN1
ADD IN2
ST Q (* Q is equal to: IN1 + IN2 *)
Op2: LD IN1
ADD IN2
ADD IN3
ST Q (* Q is equal to: IN1 + IN2 + IN3 *)

seealso See also

- * /


/ DIV

Programming languages - Reference guide -> Arithmetic operations -> / DIV

Previous chapter Next chapter Show all Show all Hide all Hide all

Operator - Performs a division of inputs.

Inputs

IN1 : ANY_NUM First input.
IN2 : ANY_NUM Second input.

Outputs

Q : ANY_NUM Result: IN1 / IN2.

Remarks

All inputs and the output must have the same type. In LD language, the input rung (EN) enables the operation, and the output rung keeps the same value as the input rung. In IL language, the DIV instruction performs a division between the current result and the operand. The current result and the operand must have the same type.

ST Language

Q := IN1 / IN2;

FBD Language

LD Language

The division is executed only if EN is TRUE.
ENO is equal to EN.

IL Language

Op1: LD IN1
DIV IN2
ST Q (* Q is equal to: IN1 / IN2 *)
Op2: LD IN1
DIV IN2
DIV IN3
ST Q (* Q is equal to: IN1 / IN2 / IN3 *)

seealso See also

+ - *


NEG -

Programming languages - Reference guide -> Arithmetic operations -> NEG -

Previous chapter Next chapter Show all Show all Hide all Hide all

Operator - Performs an integer negation of the input.

Inputs

IN : DINT Integer value.

Outputs

Q : DINT Integer negation of the input.

Truth table (examples)

IN | Q
0 | 0
1 | -1
-123 | 123

Remarks

In FBD and LD language, the block NEG can be used. In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. This feature is not available in IL language. In ST language, "-" can be followed by a complex boolean expression between parenthesis.

ST Language

Q := -IN;
Q := - (IN1 + IN2);

FBD Language

LD Language

The negation is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Not available.


LIMIT

Programming languages - Reference guide -> Arithmetic operations -> LIMIT

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Bounds an integer between low and high limits.

Inputs

IMIN : DINT Low bound.
IN : DINT Input value.
IMAX : DINT High bound.

Outputs

Q : DINT IMIN if IN < IMIN; IMAX if IN > IMAX; IN otherwise.

Function diagram

Remarks

In LD language, the input rung (EN) enables the operation, and the output rung keeps the state of the input rung. In IL language, the first input must be loaded before the function call. Other inputs are operands of the function, separated by a coma.

ST Language

Q := LIMIT (IMIN, IN, IMAX);

FBD Language

LD Language

The comparison is executed only if EN is TRUE.
ENO has the same value as EN.

IL Language

Op1: LD IMIN
LIMIT IN, IMAX
ST Q

seealso See also

MIN MAX MOD ODD


MAX

Programming languages - Reference guide -> Arithmetic operations -> MAX

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Get the maximum of two values.

Inputs

IN1 : ANY First input.
IN2 : ANY Second input.

Outputs

Q : ANY IN1 if IN1 > IN2; IN2 otherwise.

Remarks

In LD language, the input rung (EN) enables the operation, and the output rung keeps the state of the input rung. In IL language, the first input must be loaded before the function call. The second input is the operand of the function.

ST Language

Q := MAX (IN1, IN2);

FBD Language

LD Language

The comparison is executed only if EN is TRUE.
ENO has the same value as EN.

IL Language

Op1: LD IN1
MAX IN2
ST Q (* Q is the maximum of IN1 and IN2 *)

seealso See also

MIN LIMIT MOD ODD


MIN

Programming languages - Reference guide -> Arithmetic operations -> MIN

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Get the minimum of two values.

Inputs

IN1 : ANY First input.
IN2 : ANY Second input.

Outputs

Q : ANY IN1 if IN1 < IN2; IN2 otherwise.

Remarks

In LD language, the input rung (EN) enables the operation, and the output rung keeps the state of the input rung. In IL language, the first input must be loaded before the function call. The second input is the operand of the function.

ST Language

Q := MIN (IN1, IN2);

FBD Language

LD Language

The comparison is executed only if EN is TRUE.
ENO has the same value as EN.

IL Language

Op1: LD IN1
MIN IN2
ST Q (* Q is the minimum of IN1 and IN2 *)

seealso See also

MAX LIMIT MOD ODD


MOD / MODR / MODLR

Programming languages - Reference guide -> Arithmetic operations -> MOD / MODR / MODLR

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Calculation of modulo.

Inputs

IN : DINT/REAL/LREAL Input value.
BASE : DINT/REAL/LREAL Base of the modulo.

Outputs

Q : DINT/REAL/LREAL Modulo: rest of the integer division (IN / BASE).

Remarks

In LD language, the input rung (EN) enables the operation, and the output rung keeps the state of the input rung. In IL language, the first input must be loaded before the function call. The second input is the operand of the function.

ST Language

Q := MOD (IN, BASE);

FBD Language

LD Language

The comparison is executed only if EN is TRUE.
ENO has the same value as EN.

IL Language

Op1: LD IN
MOD BASE
ST Q (* Q is the rest of integer division: IN / BASE *)

seealso See also

MIN MAX LIMIT ODD


* MUL

Programming languages - Reference guide -> Arithmetic operations -> * MUL

Previous chapter Next chapter Show all Show all Hide all Hide all

Operator - Performs a multiplication of all inputs.

Inputs

IN1 : ANY_NUM First input.
IN2 : ANY_NUM Second input.

Outputs

Q : ANY_NUM Result: IN1 * IN2.

Remarks

All inputs and the output must have the same type. In FBD language, the block may have up to 16 inputs. In LD language, the input rung (EN) enables the operation, and the output rung keeps the same value as the input rung. In IL language, the MUL instruction performs a multiplication between the current result and the operand. The current result and the operand must have the same type.

ST Language

Q := IN1 * IN2;

FBD Language

The block may have up to 16 inputs:

LD Language

The multiplication is executed only if EN is TRUE.
ENO is equal to EN.

IL Language

Op1: LD IN1
MUL IN2
ST Q (* Q is equal to: IN1 * IN2 *)
Op2: LD IN1
MUL IN2
MUL IN3
ST Q (* Q is equal to: IN1 * IN2 * IN3 *)

seealso See also

+ - /


ODD

Programming languages - Reference guide -> Arithmetic operations -> ODD

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Test if an integer is odd.

Inputs

IN : DINT Input value.

Outputs

Q : BOOL TRUE if IN is odd. FALSE if IN is even.

Remarks

In LD language, the input rung (EN) enables the operation, and the output rung is the result of the function. In IL language, the input must be loaded before the function call.

ST Language

Q := ODD (IN);

FBD Language

LD Language

The function is executed only if EN is TRUE.

IL Language

Op1: LD IN
ODD
ST Q (* Q is TRUE if IN is odd *)

seealso See also

MIN MAX LIMIT MOD


- SUB

Programming languages - Reference guide -> Arithmetic operations -> - SUB

Previous chapter Next chapter Show all Show all Hide all Hide all

Operator - Performs a subtraction of inputs.

Inputs

IN1 : ANY_NUM / TIME First input.
IN2 : ANY_NUM / TIME Second input.

Outputs

Q : ANY_NUM / TIME Result: IN1 - IN2.

Remarks

All inputs and the output must have the same type. In LD language, the input rung (EN) enables the operation, and the output rung keeps the same value as the input rung. In IL language, the SUB instruction performs a subtraction between the current result and the operand. The current result and the operand must have the same type.

ST Language

Q := IN1 - IN2;

FBD Language

LD Language

The subtraction is executed only if EN is TRUE.
ENO is equal to EN.

IL Language

Op1: LD IN1
SUB IN2
ST Q (* Q is equal to: IN1 - IN2 *)
Op2: LD IN1
SUB IN2
SUB IN3
ST Q (* Q is equal to: IN1 - IN2 - IN3 *)

seealso See also

+ * /


SetWithin

Programming languages - Reference guide -> Arithmetic operations -> SetWithin

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Force a value when inside an interval

Inputs

IN : ANY Input
MIN : ANY Low limit of the interval
MAX : ANY High limit of the interval
VAL : ANY Value to apply when inside the interval

Outputs

Q : BOOL Result

Truth table

IN | Q
IN < MIN | IN
IN > MAX | IN
MIN < IN < MAX | VAL

Remarks

The output is forced to VAL when the IN value is within the [MIN .. MAX] interval. It is set to IN when outside the interval.


Comparison operations

Programming languages - Reference guide -> Comparison operations

Previous chapter Next chapter Show all Show all Hide all Hide all

Below are the standard operators and blocks that perform comparisons:

Operator | Meaning
< > <= >= = <> CMP | less than greater than less or equal greater or equal is equal is not equal detailed comparison

In this section

CMP

>= GE

> GT

= EQ

<> NE

<= LE

< LT


CMP

Programming languages - Reference guide -> Comparison operations -> CMP

Previous chapter Next chapter Show all Show all Hide all Hide all

Function Block - Comparison with detailed outputs for integer inputs.

Inputs

IN1 : DINT First value.
IN2 : DINT Second value.

Outputs

LT : BOOL TRUE if IN1 < IN2.
EQ : BOOL TRUE if IN1 = IN2.
GT : BOOL TRUE if IN1 > IN2.

Remarks

In LD language, the rung input (EN) validates the operation. The rung output is the result of LT (lower than comparison).

ST Language

MyCmp is declared as an instance of CMP function block:

MyCMP (IN1, IN2);
bLT := MyCmp.LT;
bEQ := MyCmp.EQ;
bGT := MyCmp.GT;

FBD Language

LD Language

The comparison is performed only if EN is TRUE:

IL Language

MyCmp is declared as an instance of CMP function block:

Op1: CAL MyCmp (IN1, IN2)
LD MyCmp.LT
ST bLT
LD MyCmp.EQ
ST bEQ
LD MyCmp.GT
ST bGT

seealso See also

> < >= <= = <>


>= GE

Programming languages - Reference guide -> Comparison operations -> >= GE

Previous chapter Next chapter Show all Show all Hide all Hide all

Operator - Test if first input is greater than or equal to second input.

Inputs

IN1 : ANY First input.
IN2 : ANY Second input.

Outputs

Q : BOOL TRUE if IN1 >= IN2.

Remarks

Both inputs must have the same type. In LD language, the input rung (EN) enables the operation, and the output rung is the result of the comparison. In IL language, the GE instruction performs the comparison between the current result and the operand. The current result and the operand must have the same type.

Comparisons can be used with strings. In that case, the lexical order is used for comparing the input strings. For instance, "ABC" is less than "ZX" ; "ABCD" is greater than "ABC".

ST Language

Q := IN1 >= IN2;

FBD Language

LD Language

The comparison is executed only if EN is TRUE.

IL Language

Op1: LD IN1
GE IN2
ST Q (* Q is true if IN1 >= IN2 *)

seealso See also

> < <= = <> CMP


> GT

Programming languages - Reference guide -> Comparison operations -> > GT

Previous chapter Next chapter Show all Show all Hide all Hide all

Operator - Test if first input is greater than second input.

Inputs

IN1 : ANY First input.
IN2 : ANY Second input.

Outputs

Q : BOOL TRUE if IN1 > IN2.

Remarks

Both inputs must have the same type. In LD language, the input rung (EN) enables the operation, and the output rung is the result of the comparison. In IL language, the GT instruction performs the comparison between the current result and the operand. The current result and the operand must have the same type.

Comparisons can be used with strings. In that case, the lexical order is used for comparing the input strings. For instance, "ABC" is less than "ZX" ; "ABCD" is greater than "ABC".

ST Language

Q := IN1 > IN2;

FBD Language

LD Language

The comparison is executed only if EN is TRUE.

IL Language

Op1: LD IN1
GT IN2
ST Q (* Q is true if IN1 > IN2 *)

seealso See also

< >= <= = <> CMP


= EQ

Programming languages - Reference guide -> Comparison operations -> = EQ

Previous chapter Next chapter Show all Show all Hide all Hide all

Operator - Test if first input is equal to second input.

Inputs

IN1 : ANY First input.
IN2 : ANY Second input.

Outputs

Q : BOOL TRUE if IN1 = IN2.

Remarks

Both inputs must have the same type. In LD language, the input rung (EN) enables the operation, and the output rung is the result of the comparison. In IL language, the EQ instruction performs the comparison between the current result and the operand. The current result and the operand must have the same type.

Comparisons can be used with strings. In that case, the lexical order is used for comparing the input strings. For instance, "ABC" is less than "ZX" ; "ABCD" is greater than "ABC".

Equality comparisons cannot be used with TIME variables. The reason why is that the timer actually has the resolution of the target cycle and test may be unsafe as some values may never be reached.

ST Language

Q := IN1 = IN2;

FBD Language

LD Language

The comparison is executed only if EN is TRUE:

IL Language

Op1: LD IN1
EQ IN2
ST Q (* Q is true if IN1 = IN2 *)

seealso See also

> < >= <= <> CMP


<> NE

Programming languages - Reference guide -> Comparison operations -> <> NE

Previous chapter Next chapter Show all Show all Hide all Hide all

Operator - Test if first input is not equal to second input.

Inputs

IN1 : ANY First input.
IN2 : ANY Second input.

Outputs

Q : BOOL TRUE if IN1 is not equal to IN2.

Remarks

Both inputs must have the same type. In LD language, the input rung (EN) enables the operation, and the output rung is the result of the comparison. In IL language, the NE instruction performs the comparison between the current result and the operand. The current result and the operand must have the same type.

Comparisons can be used with strings. In that case, the lexical order is used for comparing the input strings. For instance, "ABC" is less than "ZX" ; "ABCD" is greater than "ABC".

Equality comparisons cannot be used with TIME variables. The reason why is that the timer actually has the resolution of the target cycle and test may be unsafe as some values may never be reached

ST Language

Q := IN1 <> IN2;

FBD Language

LD Language

The comparison is executed only if EN is TRUE:

IL Language

Op1: LD IN1
NE IN2
ST Q (* Q is true if IN1 is not equal to IN2 *)

seealso See also

> < >= <= = CMP


<= LE

Programming languages - Reference guide -> Comparison operations -> <= LE

Previous chapter Next chapter Show all Show all Hide all Hide all

Operator - Test if first input is less than or equal to second input.

Inputs

IN1 : ANY First input.
IN2 : ANY Second input.

Outputs

Q : BOOL TRUE if IN1 <= IN2.

Remarks

Both inputs must have the same type. In LD language, the input rung (EN) enables the operation, and the output rung is the result of the comparison. In IL language, the LE instruction performs the comparison between the current result and the operand. The current result and the operand must have the same type.

Comparisons can be used with strings. In that case, the lexical order is used for comparing the input strings. For instance, "ABC" is less than "ZX" ; "ABCD" is greater than "ABC".

ST Language

Q := IN1 <= IN2;

FBD Language

LD Language

The comparison is executed only if EN is TRUE:

IL Language

Op1: LD IN1
LE IN2
ST Q (* Q is true if IN1 <= IN2 *)

seealso See also

> < >= = <> CMP


< LT

Programming languages - Reference guide -> Comparison operations -> < LT

Previous chapter Next chapter Show all Show all Hide all Hide all

Operator - Test if first input is less than second input.

Inputs

IN1 : ANY First input.
IN2 : ANY Second input.

Outputs

Q : BOOL TRUE if IN1 < IN2.

Remarks

Both inputs must have the same type. In LD language, the input rung (EN) enables the operation, and the output rung is the result of the comparison. In IL language, the LT instruction performs the comparison between the current result and the operand. The current result and the operand must have the same type.

Comparisons can be used with strings. In that case, the lexical order is used for comparing the input strings. For instance, "ABC" is less than "ZX" ; "ABCD" is greater than "ABC".

ST Language

Q := IN1 < IN2;

FBD Language

LD Language

The comparison is executed only if EN is TRUE:

IL Language

Op1: LD IN1
LT IN2
ST Q (* Q is true if IN1 < IN2 *)

seealso See also

> >= <= = <> CMP


Type conversion functions

Programming languages - Reference guide -> Type conversion functions

Previous chapter Next chapter Show all Show all Hide all Hide all

Below are the standard functions for converting a data into another data type:

Function | Conversion
ANY_TO_BOOL ANY_TO_SINT ANY_TO_INT ANY_TO_DINT ANY_TO_LINT ANY_TO_REAL ANY_TO_LREAL ANY_TO_TIME ANY_TO_STRING NUM_TO_STRING | converts to boolean converts to small (8 bit) integer converts to 16 bit integer converts to integer (32 bit - default) converts to long (64 bit) integer converts to real converts to double precicion real converts to time converts to character string converts a number to a string

Below are the standard functions performing conversions in BCD format (*):

Function | Conversion
BIN_TO_BCD BCD_TO_BIN | converts a binary value to a DCB value converts a BCD value to a binary value

(*) BCD conversion functions may not be supported by all targets.

In this section

ANY_TO_BOOL

ANY_TO_DINT / ANY_TO_UDINT

ANY_TO_INT / ANY_TO_UINT

ANY_TO_LINT

ANY_TO_LREAL

ANY_TO_REAL

ANY_TO_TIME

ANY_TO_SINT

ANY_TO_STRING

NUM_TO_STRING

BCD_TO_BIN

BIN_TO_BCD


ANY_TO_BOOL

Programming languages - Reference guide -> Type conversion functions -> ANY_TO_BOOL

Previous chapter Next chapter Show all Show all Hide all Hide all

Operator - Converts the input into boolean value.

Inputs

IN : ANY Input value.

Outputs

Q : BOOL Value converted to boolean.

Remarks

For DINT, REAL and TIME input data types, the result is FALSE if the input is 0. The result is TRUE in all other cases. For STRING inputs, the output is TRUE if the input string is not empty, and FALSE if the string is empty. In LD language, the conversion is executed only if the input rung (EN) is TRUE. The output rung is the result of the conversion. In IL Language, the ANY_TO_BOOL function converts the current result.

ST Language

Q := ANY_TO_BOOL (IN);

FBD Language

LD Language

The conversion is executed only if EN is TRUE.
The output rung is the result of the conversion.
The output rung is FALSE if the EN is FALSE.

IL Language

Op1: LD IN
ANY_TO_BOOL
ST Q

seealso See also

ANY_TO_SINT ANY_TO_INT ANY_TO_DINT ANY_TO_LINT ANY_TO_REAL ANY_TO_LREAL ANY_TO_TIME ANY_TO_STRING


ANY_TO_DINT / ANY_TO_UDINT

Programming languages - Reference guide -> Type conversion functions -> ANY_TO_DINT / ANY_TO_UDINT

Previous chapter Next chapter Show all Show all Hide all Hide all

Operator - Converts the input into integer value.

Inputs

IN : ANY Input value.

Outputs

Q : DINT Value converted to integer.

Remarks

For BOOL input data types, the output is 0 or 1. For REAL input data type, the output is the integer part of the input real. For TIME input data types, the result is the number of milliseconds. For STRING inputs, the output is the number represented by the string, or 0 if the string does not represent a valid number. In LD language, the conversion is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL Language, the ANY_TO_DINT function converts the current result.

ST Language

Q := ANY_TO_DINT (IN);

FBD Language

LD Language

The conversion is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
ANY_TO_DINT
ST Q

seealso See also

ANY_TO_BOOL ANY_TO_SINT ANY_TO_INT ANY_TO_LINT ANY_TO_REAL ANY_TO_LREAL ANY_TO_TIME ANY_TO_STRING


ANY_TO_INT / ANY_TO_UINT

Programming languages - Reference guide -> Type conversion functions -> ANY_TO_INT / ANY_TO_UINT

Previous chapter Next chapter Show all Show all Hide all Hide all

Operator - Converts the input into 16 bit integer value.

Inputs

IN : ANY Input value.

Outputs

Q : INT Value converted to 16 bit integer.

Remarks

For BOOL input data types, the output is 0 or 1. For REAL input data type, the output is the integer part of the input real. For TIME input data types, the result is the number of milliseconds. For STRING inputs, the output is the number represented by the string, or 0 if the string does not represent a valid number. In LD language, the conversion is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL Language, the ANY_TO_INT function converts the current result.

ST Language

Q := ANY_TO_INT (IN);

FBD Language

LD Language

The conversion is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
ANY_TO_INT
ST Q

seealso See also

ANY_TO_BOOL ANY_TO_SINT ANY_TO_DINT ANY_TO_LINT ANY_TO_REAL ANY_TO_LREAL ANY_TO_TIME ANY_TO_STRING


ANY_TO_LINT

Programming languages - Reference guide -> Type conversion functions -> ANY_TO_LINT

Previous chapter Next chapter Show all Show all Hide all Hide all

Operator - Converts the input into long (64 bit) integer value.

Inputs

IN : ANY Input value.

Outputs

Q : LINT Value converted to long (64 bit) integer.

Remarks

For BOOL input data types, the output is 0 or 1. For REAL input data type, the output is the integer part of the input real. For TIME input data types, the result is the number of milliseconds. For STRING inputs, the output is the number represented by the string, or 0 if the string does not represent a valid number. In LD language, the conversion is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL Language, the ANY_TO_LINT function converts the current result.

ST Language

Q := ANY_TO_LINT (IN);

FBD Language

LD Language

The conversion is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
ANY_TO_LINT
ST Q

seealso See also

ANY_TO_BOOL ANY_TO_SINT ANY_TO_INT ANY_TO_DINT ANY_TO_REAL ANY_TO_LREAL ANY_TO_TIME ANY_TO_STRING


ANY_TO_LREAL

Programming languages - Reference guide -> Type conversion functions -> ANY_TO_LREAL

Previous chapter Next chapter Show all Show all Hide all Hide all

Operator - Converts the input into double precision real value.

Inputs

IN : ANY Input value.

Outputs

Q : LREAL Value converted to double precision real.

Remarks

For BOOL input data types, the output is 0.0 or 1.0. For DINT input data type, the output is the same number. For TIME input data types, the result is the number of milliseconds. For STRING inputs, the output is the number represented by the string, or 0.0 if the string does not represent a valid number. In LD language, the conversion is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL Language, the ANY_TO_LREAL function converts the current result.

ST Language

Q := ANY_TO_LREAL (IN);

FBD Language

LD Language

The conversion is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
ANY_TO_LREAL
ST Q

seealso See also

ANY_TO_BOOL ANY_TO_SINT ANY_TO_INT ANY_TO_DINT ANY_TO_LINT ANY_TO_REAL ANY_TO_TIME ANY_TO_STRING


ANY_TO_REAL

Programming languages - Reference guide -> Type conversion functions -> ANY_TO_REAL

Previous chapter Next chapter Show all Show all Hide all Hide all

Operator - Converts the input into real value.

Inputs

IN : ANY Input value.

Outputs

Q : REAL Value converted to real.

Remarks

For BOOL input data types, the output is 0.0 or 1.0. For DINT input data type, the output is the same number. For TIME input data types, the result is the number of milliseconds. For STRING inputs, the output is the number represented by the string, or 0.0 if the string does not represent a valid number. In LD language, the conversion is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL Language, the ANY_TO_REAL function converts the current result.

ST Language

Q := ANY_TO_REAL (IN);

FBD Language

LD Language

The conversion is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
ANY_TO_REAL
ST Q

seealso See also

ANY_TO_BOOL ANY_TO_SINT ANY_TO_INT ANY_TO_DINT ANY_TO_LINT ANY_TO_LREAL ANY_TO_TIME ANY_TO_STRING


ANY_TO_TIME

Programming languages - Reference guide -> Type conversion functions -> ANY_TO_TIME

Previous chapter Next chapter Show all Show all Hide all Hide all

Operator - Converts the input into time value.

Inputs

IN : ANY Input value.

Outputs

Q : TIME Value converted to time.

Remarks

For BOOL input data types, the output is t#0ms or t#1ms. For DINT or REAL input data type, the output is the time represented by the input number as a number of milliseconds. For STRING inputs, the output is the time represented by the string, or t#0ms if the string does not represent a valid time. In LD language, the conversion is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL Language, the ANY_TO_TIME function converts the current result.

ST Language

Q := ANY_TO_TIME (IN);

FBD Language

LD Language

The conversion is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
ANY_TO_TIME
ST Q

seealso See also

ANY_TO_BOOL ANY_TO_SINT ANY_TO_INT ANY_TO_DINT ANY_TO_LINT ANY_TO_REAL ANY_TO_LREAL ANY_TO_STRING


ANY_TO_SINT

Programming languages - Reference guide -> Type conversion functions -> ANY_TO_SINT

Previous chapter Next chapter Show all Show all Hide all Hide all

Operator - Converts the input into a small (8 bit) integer value.

Inputs

IN : ANY Input value.

Outputs

Q : SINT Value converted to a small (8 bit) integer.

Remarks

For BOOL input data types, the output is 0 or 1. For REAL input data type, the output is the integer part of the input real. For TIME input data types, the result is the number of milliseconds. For STRING inputs, the output is the number represented by the string, or 0 if the string does not represent a valid number. In LD language, the conversion is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL Language, the ANY_TO_SINT function converts the current result.

ST Language

Q := ANY_TO_SINT (IN);

FBD Language

LD Language

The conversion is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
ANY_TO_SINT
ST Q

seealso See also

ANY_TO_BOOL ANY_TO_INT ANY_TO_DINT ANY_TO_LINT ANY_TO_REAL ANY_TO_LREAL ANY_TO_TIME ANY_TO_STRING


ANY_TO_STRING

Programming languages - Reference guide -> Type conversion functions -> ANY_TO_STRING

Previous chapter Next chapter Show all Show all Hide all Hide all

Operator - Converts the input into string value.

Inputs

IN : ANY Input value.

Outputs

Q : STRING Value converted to string.

Remarks

For BOOL input data types, the output is 1 or 0 for TRUE and FALSE respectively. For DINT, REAL or TIME input data types, the output is the string representation of the input number. This is a number of milliseconds for TIME inputs. In LD language, the conversion is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL language, the ANY_TO_STRING function converts the current result.

ST Language

Q := ANY_TO_STRING (IN);

FBD Language

LD Language

The conversion is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
ANY_TO_STRING
ST Q

seealso See also

ANY_TO_BOOL ANY_TO_SINT ANY_TO_INT ANY_TO_DINT ANY_TO_LINT ANY_TO_REAL ANY_TO_LREAL ANY_TO_TIME


NUM_TO_STRING

Programming languages - Reference guide -> Type conversion functions -> NUM_TO_STRING

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Converts a number into string value.

Inputs

IN : ANY Input number.
WIDTH : DINT Wished length for the output string (see remarks)
DIGITS : DINT Number of digits after decimal point

Outputs

Q : STRING Value converted to string.

Remarks

This function converts any numerical value to a string. Unlike the ANY_TO_STRING function, it allows you to specify a wished length and a number of digits after the decimal points.

If WIDTH is 0, the string is formatted with the necessary length.

If WIDTH is greater than 0, the string is completed with heading blank characters in order to match the value of WIDTH.

If WIDTH is greater than 0, the string is completed with trailing blank characters in order to match the absolute value of WIDTH.

If DIGITS is 0 then neither decimal part nor point are added.

If DIGITS is greater than 0, the corresponding number of decimal digits are added. '0' digits are added if necessary

If the value is too long for the specified width, then the string is filled with '*' characters.

Examples

Q := NUM_TO_STRING (123.4, 8, 2); (* Q is ' 123.40' *)

Q := NUM_TO_STRING (123.4, -8, 2); (* Q is '123.40 ' *)

Q := NUM_TO_STRING (1.333333, 0, 2); (* Q is '1.33' *)

Q := NUM_TO_STRING (1234, 3, 0); (* Q is '***' *)


BCD_TO_BIN

Programming languages - Reference guide -> Type conversion functions -> BCD_TO_BIN

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Converts a BCD (Binary Coded Decimal) value to a binary value.

Inputs

IN : DINT Integer value in BCD.

Outputs

Q : DINT Value converted to integer.
or 0 if IN is not a valid positive BCD value.

Truth table (examples)

IN | Q
-2 | 0 (invalid)
0 | 0
16 (16#10) | 10
15 (16#0F) | 0 (invalid)

Remarks

The input must be positive and must represent a valid BCD value. In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the input must be loaded in the current result before calling the function.

ST Language

Q := BCD_TO_BIN (IN);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
BCD_TO_BIN
ST Q

seealso See also

BIN_TO_BCD


BIN_TO_BCD

Programming languages - Reference guide -> Type conversion functions -> BIN_TO_BCD

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Converts a binary value to a BCD (Binary Coded Decimal) value.

Inputs

IN : DINT Integer value

Outputs

Q : DINT Value converted to BCD
or 0 if IN is less than 0

Truth table (examples)

IN | Q
-2 | 0 (invalid)
0 | 0
10 | 16 (16#10)
22 | 34 (16#34)

Remarks

The input must be positive. In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the input must be loaded in the current result before calling the function.

ST Language

Q := BIN_TO_BCD (IN);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
BIN_TO_BCD
ST Q

seealso See also

BCD_TO_BIN


Selectors

Programming languages - Reference guide -> Selectors

Below are the standard functions that perform data selection:

Function | Description
SEL MUX4 MUX8 | 2 integer inputs 4 integer input 8 integer input

In this section

MUX4

MUX8

SEL


MUX4

Programming languages - Reference guide -> Selectors -> MUX4

Function - Select one of the inputs - 4 inputs.

Inputs

SELECT : DINT Selection command.
IN1 : ANY First input.
IN2 : ANY Second input.
... :
IN4 : ANY Last input.

Outputs

Q : ANY IN1 or IN2 ... or IN4 depending on SELECT (see truth table).

Truth table

SELECT | Q
0 | IN1
1 | IN2
2 | IN3
3 | IN4
other | 0

Remarks

In LD language, the input rung (EN) enables the selection. The output rung keeps the same state as the input rung. In IL language, the first parameter (selector) must be loaded in the current result before calling the function. Other inputs are operands of the function, separated by comas.

ST Language

Q := MUX4 (SELECT, IN1, IN2, IN3, IN4);

FBD Language

LD Language

The selection is performed only if EN is TRUE.
ENO has the same value as EN .

IL Language

Op1: LD SELECT
MUX4 IN1, IN2, IN3, IN4
ST Q

seealso See also

SEL MUX8


MUX8

Programming languages - Reference guide -> Selectors -> MUX8

Function - Select one of the inputs - 8 inputs.

Inputs

SELECT : DINT Selection command.
IN1 : ANY First input.
IN2 : ANY Second input.
... :
IN8 : ANY Last input.

Outputs

Q : ANY IN1 or IN2 ... or IN8 depending on SELECT (see truth table).

Truth table

SELECT | Q
0 | IN1
1 | IN2
2 | IN3
3 | IN4
4 | IN5
5 | IN6
6 | IN7
7 | IN8
other | 0

Remarks

In LD language, the input rung (EN) enables the selection. The output rung keeps the same state as the input rung. In IL language, the first parameter (selector) must be loaded in the current result before calling the function. Other inputs are operands of the function, separated by comas.

ST Language

Q := MUX8 (SELECT, IN1, IN2, IN3, IN4, IN5, IN6, IN7, IN8);

FBD Language

LD Language

The selection is performed only if EN is TRUE.
ENO has the same value as EN.

IL Language

Op1: LD SELECT
MUX8 IN1, IN2, IN3, IN4, IN5, IN6, IN7, IN8
ST Q

seealso See also

SEL MUX4


SEL

Programming languages - Reference guide -> Selectors -> SEL

Function - Select one of the inputs - 2 inputs.

Inputs

SELECT : BOOL Selection command
IN0 : ANY First input
IN1 : ANY Second input

Outputs

Q : ANY IN1 if SELECT is FALSE; IN2 if SELECT is TRUE

Truth table

SELECT | Q
0 | IN0
1 | IN1

Remarks

In LD language, the selector command is the input rung. The output rung keeps the same state as the input rung. In IL language, the first parameter (selector) must be loaded in the current result before calling the function. Other inputs are operands of the function, separated by comas.

ST Language

Q := SEL (SELECT, IN0, IN1);

FBD Language

LD Language

The input rung is the selector.
ENO has the same value as SELECT.

IL Language

Op1: LD SELECT
SEL IN1, IN2
ST Q

seealso See also

MUX4 MUX8


Registers

Programming languages - Reference guide -> Registers

Below are the standard functions for managing 8 bit to 32 bit registers:

Function | Description
SHL SHR ROL ROR | shift left shift right rotation left rotation right

Below are advanced functions for register manipulation:

Function | Description
MBShift | multibyte shift / rotate

The following functions enable bit to bit operations on a 8 bit to 32 bit integers:

Function | Description
AND_MASK OR_MASK XOR_MASK NOT_MASK | boolean AND boolean OR exclusive OR boolean negation

The following functions enable to pack/unpack 8, 16 and 32 bit registers

Function | Description
LOBYTE HIBYTE LOWORD HIWORD MAKEWORD MAKEDWORD PACK8 UNPACK8 SWAB | Get the lowest byte of a word. Get the highest byte of a word. Get the lowest word of a double word. Get the highest word of a double word. Pack bytes to a word. Pack words to a double word. Pack bits in a byte. Extract bits from a byte. Swap the bytes of a integer

The following functions provide bit access in 8 bit to 32 bit integers:

Function | Description
SETBIT TESTBIT | Set a bit in a register. Test a bit of a register.

The following functions are kept for compatibility, but you should use the functions upper:

AND_DINT, AND_UDINT, AND_DWORD, NOT_DINT, NOT_UDINT, NOT_DWORD
OR_DINT, OR_UDINT, OR_DWORD, XOR_DINT, XOR_UDINT, XOR_DWORD
AND_INT, AND_UINT, AND_WORD, NOT_INT, NOT_UINT, NOT_WORD
OR_INT, OR_UINT, OR_WORD, XOR_INT, XOR_UINT, XOR_WORD
AND_SINT, AND_USINT, AND_BYTE, NOT_SINT, NOT_USINT, NOT_BYTE
OR_SINT, OR_USINT, OR_BYTE, XOR_SINT, XOR_USINT, XOR_BYTE
rolw, rorw, shlw, shrw, rolb, rorb, shlb, shrb
ROL_DINT, ROR_DINT, SHL_DINT, SHR_DINT
ROL_UDINT, ROR_UDINT, SHL_UDINT, SHR_UDINT
ROL_DWORD, ROR_DWORD, SHL_DWORD, SHR_DWORD
ROL_INT, ROR_INT, SHL_INT, SHR_INT
ROL_UINT, ROR_UINT, SHL_UINT, SHR_UINT
ROL_WORD, ROR_WORD, SHL_WORD, SHR_WORD
ROL_SINT, ROR_SINT, SHL_SINT, SHR_SINT
ROL_USINT, ROR_USINT, SHL_USINT, SHR_USINT
ROL_BYTE, ROR_BYTE, SHL_BYTE, SHR_BYTE

In this section

AND_MASK

HIBYTE

LOBYTE

HIWORD

LOWORD

MAKEDWORD

MAKEWORD

MBSHIFT

NOT_MASK

OR_MASK

PACK8

ROL

ROR

RORb / ROR_SINT / ROR_USINT / ROR_BYTE

RORw / ROR_INT / ROR_UINT / ROR_WORD

SETBIT

SHL

SHR

SWAB

TESTBIT

UNPACK8

XOR_MASK


AND_MASK

Programming languages - Reference guide -> Registers -> AND_MASK

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Performs a bit to bit AND between two integer values

Inputs

IN : ANY First input.
MSK : ANY Second input (AND mask).

Outputs

Q : ANY AND mask between IN and MSK inputs.

Remarks

Arguments can be signed or unsigned integers from 8 to 32 bits.

In LD language, the input rung (EN) enables the operation, and the output rung keeps the same value as the input rung. In IL language, the first parameter (IN) must be loaded in the current result before calling the function. The other input is the operands of the function.

ST Language

Q := AND_MASK (IN, MSK);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO is equal to EN.

IL Language

Op1: LD IN
AND_MASK MSK
ST Q

seealso See also

OR_MASK XOR_MASK NOT_MASK


HIBYTE

Programming languages - Reference guide -> Registers -> HIBYTE

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Get the most significant byte of a word

Inputs

IN : UINT 16 bit register.

Outputs

Q : USINT Most significant byte.

Remarks

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the input must be loaded in the current result before calling the function.

ST Language

Q := HIBYTE (IN);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
HIBYTE
ST Q

seealso See also

LOBYTE LOWORD HIWORD MAKEWORD MAKEDWORD


LOBYTE

Programming languages - Reference guide -> Registers -> LOBYTE

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Get the less significant byte of a word.

Inputs

IN : UINT 16 bit register.

Outputs

Q : USINT Lowest significant byte.

Remarks

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the input must be loaded in the current result before calling the function.

ST Language

Q := LOBYTE (IN);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
LOBYTE
ST Q

seealso See also

HIBYTE LOWORD HIWORD MAKEWORD MAKEDWORD


HIWORD

Programming languages - Reference guide -> Registers -> HIWORD

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Get the most significant word of a double word.

Inputs

IN : UDINT 32 bit register.

Outputs

Q : UINT Most significant word.

Remarks

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the input must be loaded in the current result before calling the function.

ST Language

Q := HIWORD (IN);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
HIWORD
ST Q

seealso See also

LOBYTE HIBYTE LOWORD MAKEWORD MAKEDWORD


LOWORD

Programming languages - Reference guide -> Registers -> LOWORD

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Get the less significant word of a double word.

Inputs

IN : UDINT 32 bit register.

Outputs

Q : UINT Lowest significant word.

Remarks

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the input must be loaded in the current result before calling the function.

ST Language

Q := LOWORD (IN);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
LOWORD
ST Q

seealso See also

LOBYTE HIBYTE HIWORD MAKEWORD MAKEDWORD


MAKEDWORD

Programming languages - Reference guide -> Registers -> MAKEDWORD

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Builds a double word as the concatenation of two words.

Inputs

HI : UINT Highest significant word.
LO : USINT Lowest significant word.

Outputs

Q : UDINT 32 bit register.

Remarks

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the first input must be loaded in the current result before calling the function.

ST Language

Q := MAKEDWORD (HI, LO);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD HI
MAKEDWORD LO
ST Q

seealso See also

LOBYTE HIBYTE LOWORD HIWORD MAKEWORD


MAKEWORD

Programming languages - Reference guide -> Registers -> MAKEWORD

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Builds a word as the concatenation of two bytes.

Inputs

HI : USINT Highest significant byte.
LO : USINT Lowest significant byte.

Outputs

Q : UINT 16 bit register.

Remarks

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the first input must be loaded in the current result before calling the function.

ST Language

Q := MAKEWORD (HI, LO);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD HI
MAKEWORD LO
ST Q

seealso See also

LOBYTE HIBYTE LOWORD HIWORD MAKEDWORD


MBSHIFT

Programming languages - Reference guide -> Registers -> MBSHIFT

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Multibyte shift / rotate.

Inputs

Buffer : SINT/USINT Array of bytes.
Pos : DINT Base position in the array.
NbByte : DINT Number of bytes to be shifted/rotated.
NbShift : DINT Number of shifts or rotations.
ToRight : BOOL TRUE for right / FALSE for left.
Rotate : BOOL TRUE for rotate / FALSE for shift.
InBit : BOOL Bit to be introduced in a shift.

Outputs

Q : BOOL TRUE if successful.

Remarks

Use the ToRight argument to specify a shift to the left (FALSE) or to the right (TRUE). Use the Rotate argument to specify either a shift (FALSE) or a rotation (TRUE). In case of a shift, the InBit argument specifies the value of the bit that replaces the last shifted bit.

In LD language, the rung input (EN) validates the operation. The rung output is the result (Q).

ST Language

Q := MBShift (Buffer, Pos, NbByte, NbShift, ToRight, Rotate, InBit);

FBD Language

LD Language

The function is called only if EN is TRUE:

IL Language

Not available.


NOT_MASK

Programming languages - Reference guide -> Registers -> NOT_MASK

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Performs a bit to bit negation of an integer value.

Inputs

IN : ANY Integer input.

Outputs

Q : ANY Bit to bit negation of the input.

Remarks

Arguments can be signed or unsigned integers from 8 to 32 bits.

In LD language, the input rung (EN) enables the operation, and the output rung keeps the same value as the input rung. In IL language, the parameter (IN) must be loaded in the current result before calling the function.

ST Language

Q := NOT_MASK (IN);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO is equal to EN.

IL Language

Op1: LD IN
NOT_MASK
ST Q

seealso See also

AND_MASK OR_MASK XOR_MASK


OR_MASK

Programming languages - Reference guide -> Registers -> OR_MASK

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Performs a bit to bit OR between two integer values.

Inputs

IN : ANY First input.
MSK : ANY Second input (OR mask).

Outputs

Q : ANY OR mask between IN and MSK inputs.

Remarks

Arguments can be signed or unsigned integers from 8 to 32 bits.

In LD language, the input rung (EN) enables the operation, and the output rung keeps the same value as the input rung. In IL language, the first parameter (IN) must be loaded in the current result before calling the function. The other input is the operands of the function.

ST Language

Q := OR_MASK (IN, MSK);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO is equal to EN.

IL Language

Op1: LD IN
OR_MASK MSK
ST Q

seealso See also

AND_MASK XOR_MASK NOT_MASK


PACK8

Programming languages - Reference guide -> Registers -> PACK8

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Builds a byte with bits.

Inputs

IN0 : BOOL Less significant bit.
...
IN7 : BOOL Most significant bit.

Outputs

Q : USINT Byte built with input bits.

Remarks

In LD language, the input rung is the IN0 input. The output rung (ENO) keeps the same value as the input rung. In IL, the input must be loaded in the current result before calling the function.

ST Language

Q := PACK8 (IN0, IN1, IN2, IN3, IN4, IN5, IN6, IN7);

FBD Language

LD Language

ENO keeps the same value as EN.

IL Language

Op1: LD IN0
PACK8 IN1, IN2, IN3, IN4, IN5, IN6, IN7
ST Q

seealso See also

UNPACK8


ROL

Programming languages - Reference guide -> Registers -> ROL

Function - Rotate bits of a register to the left.

Inputs

IN : ANY register.
NBR : ANY Number of rotations (each rotation is 1 bit).

Outputs

Q : ANY Rotated register.

Diagram

Remarks

Arguments can be signed or unsigned integers from 8 to 32 bits.

In LD language, the input rung (EN) enables the operation, and the output rung keeps the state of the input rung. In IL language, the first input must be loaded before the function call. The second input is the operand of the function.

ST Language

Q := ROL (IN, NBR);

FBD Language

LD Language

The rotation is executed only if EN is TRUE.
ENO has the same value as EN.

IL Language

Op1: LD IN
ROL NBR
ST Q

seealso See also

SHL SHR ROR SHLb SHRb ROLb RORb SHLw SHRw ROLw RORw


ROR

Programming languages - Reference guide -> Registers -> ROR

Function - Rotate bits of a register to the right.

Inputs

IN : ANY register.
NBR : ANY Number of rotations (each rotation is 1 bit).

Outputs

Q : ANY Rotated register.

Diagram

Remarks

Arguments can be signed or unsigned integers from 8 to 32 bits.

In LD language, the input rung (EN) enables the operation, and the output rung keeps the state of the input rung. In IL language, the first input must be loaded before the function call. The second input is the operand of the function.

ST Language

Q := ROR (IN, NBR);

FBD Language

LD Language

The rotation is executed only if EN is TRUE.
ENO has the same value as EN.

IL Language

Op1: LD IN
ROR NBR
ST Q

seealso See also

SHL SHR ROL SHLb SHRb ROLb RORb SHLw SHRw ROLw RORw


RORb / ROR_SINT / ROR_USINT / ROR_BYTE

Programming languages - Reference guide -> Registers -> RORb / ROR_SINT / ROR_USINT / ROR_BYTE

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Rotate bits of a register to the right.

Inputs

IN : SINT 8 bit register.
NBR : SINT Number of rotations (each rotation is 1 bit).

Outputs

Q : SINT Rotated register.

Diagram

Remarks

In LD language, the input rung (EN) enables the operation, and the output rung keeps the state of the input rung. In IL language, the first input must be loaded before the function call. The second input is the operand of the function.

ST Language

Q := RORb (IN, NBR);

FBD Language

LD Language

The rotation is executed only if EN is TRUE.
ENO has the same value as EN.

IL Language

Op1: LD IN
RORb NBR
ST Q

seealso See also

SHL SHR ROL ROR SHLb SHRb ROLb SHLw SHRw ROLw RORw


RORw / ROR_INT / ROR_UINT / ROR_WORD

Programming languages - Reference guide -> Registers -> RORw / ROR_INT / ROR_UINT / ROR_WORD

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Rotate bits of a register to the right.

Inputs

IN : INT 16 bit register.
NBR : INT Number of rotations (each rotation is 1 bit).

Outputs

Q : INT Rotated register.

Diagram

Remarks

In LD language, the input rung (EN) enables the operation, and the output rung keeps the state of the input rung. In IL language, the first input must be loaded before the function call. The second input is the operand of the function.

ST Language

Q := RORw (IN, NBR);

FBD Language

LD Language

The rotation is executed only if EN is TRUE.
ENO has the same value as EN.

IL Language

Op1: LD IN
RORw NBR
ST Q

seealso See also

SHL SHR ROL ROR SHLb SHRb ROLb RORb SHLw SHRw ROLw


SETBIT

Programming languages - Reference guide -> Registers -> SETBIT

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Set a bit in an integer register.

Inputs

IN : ANY 8 to 32 bit integer register.
BIT : DINT Bit number (0 = less significant bit).
VAL : BOOL Bit value to apply.

Outputs

Q : ANY Modified register.

Remarks

Types LINT, REAL, LREAL, TIME and STRING are not supported for IN and Q. IN and Q must have the same type. In case of invalid arguments (bad bit number or invalid input type) the function returns the value of IN without modification.

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung.

ST Language

Q := SETBIT (IN, BIT, VAL);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Not available.

seealso See also

TESTBIT


SHL

Programming languages - Reference guide -> Registers -> SHL

Function - Shift bits of a register to the left.

Inputs

IN : ANY register.
NBS : ANY Number of shifts (each shift is 1 bit).

Outputs

Q : ANY Shifted register.

Diagram

Remarks

Arguments can be signed or unsigned integers from 8 to 32 bits.

In LD language, the input rung (EN) enables the operation, and the output rung keeps the state of the input rung. In IL language, the first input must be loaded before the function call. The second input is the operand of the function.

ST Language

Q := SHL (IN, NBS);

FBD Language

LD Language

The shift is executed only if EN is TRUE.
ENO has the same value as EN.

IL Language

Op1: LD IN
SHL NBS
ST Q

seealso See also

SHR ROL ROR SHLb SHRb ROLb RORb SHLw SHRw ROLw RORw


SHR

Programming languages - Reference guide -> Registers -> SHR

Function - Shift bits of a register to the right.

Inputs

IN : ANY register.
NBS : ANY Number of shifts (each shift is 1 bit).

Outputs

Q : ANY Shifted register.

IMPORTANT!

If the option "SHR: do not duplicate the most significant bit" is checked in the "Project settings / Advanced" box, then the most significant bit is set to FALSE.

If the option is not checked, then the most significant bit is duplicated:

Remarks

Arguments can be signed or unsigned integers from 8 to 32 bits.

In LD language, the input rung (EN) enables the operation, and the output rung keeps the state of the input rung. In IL language, the first input must be loaded before the function call. The second input is the operand of the function.

ST Language

Q := SHR (IN, NBS);

FBD Language

LD Language

The shift is executed only if EN is TRUE.
ENO has the same value as EN.

IL Language

Op1: LD IN
SHR NBS
ST Q

seealso See also

SHL ROL ROR SHLb SHRb ROLb RORb SHLw SHRw ROLw RORw


SWAB

Programming languages - Reference guide -> Registers -> SWAB

Function - Swap the bytes of an integer.

Inputs

IN : ANY Any signed or unsigned integer of 16 or 32 bits

Outputs

Q : ANY Swapped value.

Remarks

Supported data types are INT, UINT, WORD, DINT, UDINT and DWORD. If the function is called for another data type the output takes the value of the input.

Examples

Type | IN | Q
WORD | 16#1A2B | 16#2B1A
DWORD | 16#1A2B3C4D | 16#4D3C2B1A


TESTBIT

Programming languages - Reference guide -> Registers -> TESTBIT

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Test a bit of an integer register.

Inputs

IN : ANY 8 to 32 bit integer register.
BIT : DINT Bit number (0 = less significant bit).

Outputs

Q : BOOL Bit value.

Remarks

Types LINT, REAL, LREAL, TIME and STRING are not supported for IN and Q. IN and Q must have the same type. In case of invalid arguments (bad bit number or invalid input type) the function returns FALSE.

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung is the output of the function.

ST Language

Q := TESTBIT (IN, BIT);

FBD Language

LD Language

The function is executed only if EN is TRUE.

IL Language

Not available.

seealso See also

SETBIT


UNPACK8

Programming languages - Reference guide -> Registers -> UNPACK8

Previous chapter Next chapter Show all Show all Hide all Hide all

Function block - Extract bits of a byte.

Inputs

IN : USINT 8 bit register.

Outputs

Q0 : BOOL Less significant bit.
...
Q7 : BOOL Most significant bit.

Remarks

In LD language, the output rung is the Q0 output. The operation is executed only in the input rung (EN) is TRUE.

ST Language

MyUnpack is a declared instance of the UNPACK8 function block.

MyUnpack (IN);

Q0 := MyUnpack.Q0;
Q1 := MyUnpack.Q1;
Q2 := MyUnpack.Q2;
Q3 := MyUnpack.Q3;
Q4 := MyUnpack.Q4;
Q5 := MyUnpack.Q5;
Q6 := MyUnpack.Q6;
Q7 := MyUnpack.Q7;

FBD Language

LD Language

The operation is performed if EN = TRUE:

IL Language

MyUnpack is a declared instance of the UNPACK8 function block.

Op1: CAL MyUnpack (IN)
LD MyUnpack.Q0
ST Q0
(* ... *)
LD MyUnpack.Q7
ST Q7

seealso See also

PACK8


XOR_MASK

Programming languages - Reference guide -> Registers -> XOR_MASK

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Performs a bit to bit exclusive OR between two integer values

Inputs

IN : ANY First input.
MSK : ANY Second input (XOR mask).

Outputs

Q : ANY Exclusive OR mask between IN and MSK inputs.

Remarks

Arguments can be signed or unsigned integers from 8 to 32 bits.

In LD language, the input rung (EN) enables the operation, and the output rung keeps the same value as the input rung. In IL language, the first parameter (IN) must be loaded in the current result before calling the function. The other input is the operands of the function.

ST Language

Q := XOR_MASK (IN, MSK);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO is equal to EN.

IL Language

Op1: LD IN
XOR_MASK MSK
ST Q

seealso See also

AND_MASK OR_MASK NOT_MASK


Counters

Programming languages - Reference guide -> Counters

Below are the standard blocks for managing counters:

Block | Description
CTU CTD CTUD | Up counter Down counter Up / Down counter

In this section

CTD / CTDr

CTU / CTUr

CTUD / CTUDr


CTD / CTDr

Programming languages - Reference guide -> Counters -> CTD / CTDr

Previous chapter Next chapter Show all Show all Hide all Hide all

Function Block - Down counter.

Inputs

CD : BOOL Enable counting. Counter is decreased on each call when CD is TRUE.
LOAD : BOOL Re-load command. Counter is set to PV when called with LOAD to TRUE.
PV : DINT Programmed maximum value.

Outputs

Q : BOOL TRUE when counter is empty, i.e. when CV = 0.
CV : DINT Current value of the counter.

Remarks

The counter is empty (CV = 0) when the application starts. The counter does not include a pulse detection for CD input. Use R_TRIG or F_TRIG function block for counting pulses of CD input signal. In LD language, CD is the input rung. The output rung is the Q output.

CTUr, CTDr, CTUDr function blocks operate exactly as other counters, except that all boolean inputs (CU, CD, RESET, LOAD) have an implicit rising edge detection included. Not that these counters may be not supported on some target systems.

ST Language

MyCounter is a declared instance of CTD function block.

MyCounter (CD, LOAD, PV);
Q := MyCounter.Q;
CV := MyCounter.CV;

FBD Language

LD Language

IL Language

MyCounter is a declared instance of CTD function block.

Op1: CAL MyCounter (CD, LOAD, PV)
LD MyCounter.Q
ST Q
LD MyCounter.CV
ST CV

seealso See also

CTU CTUD


CTU / CTUr

Programming languages - Reference guide -> Counters -> CTU / CTUr

Previous chapter Next chapter Show all Show all Hide all Hide all

Function Block - Up counter.

Inputs

CU : BOOL Enable counting. Counter is increased on each call when CU is TRUE.
RESET : BOOL Reset command. Counter is reset to 0 when called with RESET to TRUE.
PV : DINT Programmed maximum value.

Outputs

Q : BOOL TRUE when counter is full, i.e. when CV = PV.
CV : DINT Current value of the counter.

Remarks

The counter is empty (CV = 0) when the application starts. The counter does not include a pulse detection for CU input. Use R_TRIG or F_TRIG function block for counting pulses of CU input signal. In LD language, CU is the input rung. The output rung is the Q output.

CTUr, CTDr, CTUDr function blocks operate exactly as other counters, except that all boolean inputs (CU, CD, RESET, LOAD) have an implicit rising edge detection included. Not that these counters may be not supported on some target systems.

ST Language

MyCounter is a declared instance of CTU function block.

MyCounter (CU, RESET, PV);
Q := MyCounter.Q;
CV := MyCounter.CV;

FBD Language

LD Language

IL Language

MyCounter is a declared instance of CTU function block.

Op1: CAL MyCounter (CU, RESET, PV)
LD MyCounter.Q
ST Q
LD MyCounter.CV
ST CV

seealso See also

CTD CTUD


CTUD / CTUDr

Programming languages - Reference guide -> Counters -> CTUD / CTUDr

Previous chapter Next chapter Show all Show all Hide all Hide all

Function Block - Up/down counter.

Inputs

CU : BOOL Enable counting. Counter is increased on each call when CU is TRUE.
CD : BOOL Enable counting. Counter is decreased on each call when CD is TRUE.
RESET : BOOL Reset command. Counter is reset to 0 called with RESET to TRUE.
LOAD : BOOL Re-load command. Counter is set to PV when called with LOAD to TRUE.
PV : DINT Programmed maximum value.

Outputs

QU : BOOL TRUE when counter is full, i.e. when CV = PV.
QD : BOOL TRUE when counter is empty, i.e. when CV = 0.
CV : DINT Current value of the counter.

Remarks

The counter is empty (CV = 0) when the application starts. The counter does not include a pulse detection for CU and CD inputs. Use R_TRIG or F_TRIG function blocks for counting pulses of CU or CD input signals. In LD language, CU is the input rung. The output rung is the QU output.

CTUr, CTDr, CTUDr function blocks operate exactly as other counters, except that all boolean inputs (CU, CD, RESET, LOAD) have an implicit rising edge detection included. Not that these counters may be not supported on some target systems.

ST Language

MyCounter is a declared instance of CTUD function block.

MyCounter (CU, CD, RESET, LOAD, PV);
QU := MyCounter.QU;
QD := MyCounter.QD;
CV := MyCounter.CV;

FBD Language

LD Language

IL Language

MyCounter is a declared instance of CTUD function block.

Op1: CAL MyCounter (CU, CD, RESET, LOAD, PV)
LD MyCounter.QU
ST QU
LD MyCounter.QD
ST QD
LD MyCounter.CV
ST CV

seealso See also

CTU CTD


Timers

Programming languages - Reference guide -> Timers

Below are the standard functions for managing timers:

Function | Effect
TON TOF TP BLINK BLINKA PLS TMU TMD | On timer. Off timer. Pulse timer. Blinker. Asymetric blinker. Pulse signal generator. Up-coundting stop watch. Down-counting stop watch.

In this section

BLINK

BLINKA

PLS

TMD

TMU

TOF / TOFR

TON

TP / TPR


BLINK

Programming languages - Reference guide -> Timers -> BLINK

Function Block - Blinker.

Inputs

RUN : BOOL Enabling command.
CYCLE : TIME Blinking period.

Outputs

Q : BOOL Output blinking signal.

Time diagram

Remarks

The output signal is FALSE when the RUN input is FALSE. The CYCLE input is the complete period of the blinking signal. In LD language, the input rung is the IN command. The output rung is the Q output signal.

ST Language

MyBlinker is a declared instance of BLINK function block.

MyBlinker (RUN, CYCLE);
Q := MyBlinker.Q;

FBD Language

LD Language

IL Language

MyBlinker is a declared instance of BLINK function block.

Op1: CAL MyBlinker (RUN, CYCLE)
LD MyBlinker.Q
ST Q

seealso See also

TON TOF TP


BLINKA

Programming languages - Reference guide -> Timers -> BLINKA

Function Block - Asymetric blinker.

Inputs

RUN : BOOL Enabling command.
TM0 : TIME Duration of FALSE state on output.
TM1 : TIME Duration of TRUE state on output.

Outputs

Q : BOOL Output blinking signal.

Time diagram

Remarks

The output signal is FALSE when the RUN input is FALSE. In LD language, the input rung is the IN command. The output rung is the Q output signal.

ST Language

MyBlinker is a declared instance of BLINKA function block.

MyBlinker (RUN, TM0, TM1);
Q := MyBlinker.Q;

FBD Language

LD Language

IL Language

MyBlinker is a declared instance of BLINKA function block.

Op1: CAL MyBlinker (RUN, TM0, TM1)
LD MyBlinker.Q
ST Q

seealso See also

TON TOF TP


PLS

Programming languages - Reference guide -> Timers -> PLS

Function Block - Pulse signal generator:

Inputs

RUN : BOOL Enabling command.
CYCLE : TIME Signal period.

Outputs

Q : BOOL Output pulse signal.

Time diagram

Remarks

On every period, the output is set to TRUE during one cycle only. In LD language, the input rung is the IN command. The output rung is the Q output signal.

ST Language

MyPLS is a declared instance of PLS function block:

MyPLS (RUN, CYCLE);
Q := MyPLS.Q;

FBD Language

LD Language

IL Language

MyPLS is a declared instance of PLS function block:

Op1: CAL MyPLS (RUN, CYCLE)
LD MyPLS.Q
ST Q

seealso See also

TON TOF TP


TMD

Programming languages - Reference guide -> Timers -> TMD

Function Block - Down-counting stop watch.

Inputs

IN : BOOL The time counts when this input is TRUE.
RST : BOOL Timer is reset to PT when this input is TRUE.
PT : TIME Programmed time.

Outputs

Q : BOOL Timer elapsed output signal.
ET : TIME Elapsed time.

Time diagram

Remarks

The timer counts up when the IN input is TRUE. It stops when the programmed time is elapsed. The timer is reset when the RST input is TRUE. It is not reset when IN is false.

ST Language

MyTimer is a declared instance of TMD function block.

MyTimer (IN, RST, PT);
Q := MyTimer.Q;
ET := MyTimer.ET;

FBD Language

LD Language

IL Language

MyTimer is a declared instance of TMD function block.

Op1: CAL MyTimer (IN, RST, PT)
LD MyTimer.Q
ST Q
LD MyTimer.ET
ST ET

seealso See also

TMU


TMU

Programming languages - Reference guide -> Timers -> TMU

Function Block - Up-counting stop watch.

Inputs

IN : BOOL The time counts when this input is TRUE.
RST : BOOL Timer is reset to 0 when this input is TRUE.
PT : TIME Programmed time.

Outputs

Q : BOOL Timer elapsed output signal.
ET : TIME Elapsed time.

Time diagram

Remarks

The timer counts up when the IN input is TRUE. It stops when the programmed time is elapsed. The timer is reset when the RST input is TRUE. It is not reset when IN is false.

ST Language

MyTimer is a declared instance of TMU function block.

MyTimer (IN, RST, PT);
Q := MyTimer.Q;
ET := MyTimer.ET;

FBD Language

LD Language

IL Language

MyTimer is a declared instance of TMU function block.

Op1: CAL MyTimer (IN, RST, PT)
LD MyTimer.Q
ST Q
LD MyTimer.ET
ST ET

seealso See also

TMD


TOF / TOFR

Programming languages - Reference guide -> Timers -> TOF / TOFR

Previous chapter Next chapter Show all Show all Hide all Hide all

Function Block - Off timer.

Inputs

IN : BOOL Timer command.
PT : TIME Programmed time.

RST : BOOL Reset (TOFR only).

Outputs

Q : BOOL Timer elapsed output signal.
ET : TIME Elapsed time.

Time diagram

Remarks

The timer starts on a falling pulse of IN input. It stops when the elapsed time is equal to the programmed time. A rising pulse of IN input resets the timer to 0. The output signal is set to TRUE on when the IN input rises to TRUE, reset to FALSE when programmed time is elapsed.

TOFR is same as TOF but has an extra input for resetting the timer.

In LD language, the input rung is the IN command. The output rung is Q the output signal.

ST Language

MyTimer is a declared instance of TOF function block.

MyTimer (IN, PT);
Q := MyTimer.Q;
ET := MyTimer.ET;

FBD Language

LD Language

IL Language

MyTimer is a declared instance of TOF function block.

Op1: CAL MyTimer (IN, PT)
LD MyTimer.Q
ST Q
LD MyTimer.ET
ST ET

seealso See also

TON TP BLINK


TON

Programming languages - Reference guide -> Timers -> TON

Function Block - On timer.

Inputs

IN : BOOL Timer command.
PT : TIME Programmed time.

Outputs

Q : BOOL Timer elapsed output signal.
ET : TIME Elapsed time.

Time diagram

Remarks

The timer starts on a rising pulse of IN input. It stops when the elapsed time is equal to the programmed time. A falling pulse of IN input resets the timer to 0. The output signal is set to TRUE when programmed time is elapsed, and reset to FALSE when the input command falls.

In LD language, the input rung is the IN command. The output rung is Q the output signal.

ST Language

MyTimer is a declared instance of TON function block.

MyTimer (IN, PT);
Q := MyTimer.Q;
ET := MyTimer.ET;

FBD Language

LD Language

IL Language

MyTimer is a declared instance of TON function block.

Op1: CAL MyTimer (IN, PT)
LD MyTimer.Q
ST Q
LD MyTimer.ET
ST ET

seealso See also

TOF TP BLINK


TP / TPR

Programming languages - Reference guide -> Timers -> TP / TPR

Previous chapter Next chapter Show all Show all Hide all Hide all

Function Block - Pulse timer.

Inputs

IN : BOOL Timer command.
PT : TIME Programmed time.

RST : BOOL Reset (TPR only).

Outputs

Q : BOOL Timer elapsed output signal.
ET : TIME Elapsed time.

Time diagram

Remarks

The timer starts on a rising pulse of IN input. It stops when the elapsed time is equal to the programmed time. A falling pulse of IN input resets the timer to 0, only if the programmed time is elapsed. All pulses of IN while the timer is running are ignored. The output signal is set to TRUE while the timer is running.

TPR is same as TP but has an extra input for resetting the timer

In LD language, the input rung is the IN command. The output rung is Q the output signal.

ST Language

MyTimer is a declared instance of TP function block.

MyTimer (IN, PT);
Q := MyTimer.Q;
ET := MyTimer.ET;

FBD Language

LD Language

IL Language

MyTimer is a declared instance of TP function block.

Op1: CAL MyTimer (IN, PT)
LD MyTimer.Q
ST Q
LD MyTimer.ET
ST ET

seealso See also

TON TOF BLINK


Mathematic operations

Programming languages - Reference guide -> Mathematic operations

Previous chapter Next chapter Show all Show all Hide all Hide all

Below are the standard functions that perform mathematic calculation:

Function | Effect
ABS TRUNC LOG, LN POW, EXPT, EXP SQRT, ROOT SCALELIN | absolute value integer part logarithm power root extraction scaling - linear conversion

In this section

ABS

EXP / EXPL

EXPT

LOG

LN

POW ** POWL

ROOT

ScaleLin

SQRT / SQRTL

TRUNC / TRUNCL


ABS

Programming languages - Reference guide -> Mathematic operations -> ABS

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Returns the absolute value of the input.

Inputs

IN : ANY value.

Outputs

Q : ANY Result: absolute value of IN.

Remarks

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the input must be loaded in the current result before calling the function.

ST Language

Q := ABS (IN);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
ABS
ST Q (* Q is: ABS (IN) *)

seealso See also

TRUNC LOG POW SQRT


EXP / EXPL

Programming languages - Reference guide -> Mathematic operations -> EXP / EXPL

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Calculates the natural exponential of the input.

Inputs

IN : REAL/LREAL Real value.

Outputs

Q : REAL/LREAL Result: natural exponential of IN.

Remarks

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the input must be loaded in the current result before calling the function.

ST Language

Q := EXP (IN);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
EXP
ST Q (* Q is: EXP (IN) *)

seealso See also

ABS TRUNC POW SQRT


EXPT

Programming languages - Reference guide -> Mathematic operations -> EXPT

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Calculates a power.

Inputs

IN : REAL Real value.
EXP : DINT Exponent.

Outputs

Q : REAL Result: IN at the 'EXP' power.

Remarks

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the input must be loaded in the current result before calling the function. The exponent (second input of the function) must be the operand of the function.

ST Language

Q := EXPT (IN, EXP);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
EXPT EXP
ST Q (* Q is: (IN ** EXP) *)

seealso See also

ABS TRUNC LOG SQRT


LOG

Programming languages - Reference guide -> Mathematic operations -> LOG

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Calculates the logarithm (base 10) of the input.

Inputs

IN : REAL Real value.

Outputs

Q : REAL Result: logarithm (base 10) of IN.

Remarks

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the input must be loaded in the current result before calling the function.

ST Language

Q := LOG (IN);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
LOG
ST Q (* Q is: LOG (IN) *)

seealso See also

ABS TRUNC POW SQRT


LN

Programming languages - Reference guide -> Mathematic operations -> LN

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Calculates the natural logarithm of the input.

Inputs

IN : REAL/LREAL Real value.

Outputs

Q : REAL/LREAL Result: natural logarithm of IN.

Remarks

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the input must be loaded in the current result before calling the function.

ST Language

Q := LN (IN);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
LN
ST Q (* Q is: LN (IN) *)

seealso See also

ABS TRUNC POW SQRT


POW ** POWL

Programming languages - Reference guide -> Mathematic operations -> POW ** POWL

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Calculates a power.

Inputs

IN : REAL/LREAL Real value.
EXP : REAL/LREAL Exponent.

Outputs

Q : REAL/LREAL Result: IN at the 'EXP' power.

Remarks

Alternatively, in ST language, the ** operator can be used. In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the input must be loaded in the current result before calling the function. The exponent (second input of the function) must be the operand of the function.

ST Language

Q := POW (IN, EXP);
Q := IN ** EXP;

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
POW EXP
ST Q (* Q is: (IN ** EXP) *)

seealso See also

ABS TRUNC LOG SQRT


ROOT

Programming languages - Reference guide -> Mathematic operations -> ROOT

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Calculates the Nth root of the input.

Inputs

IN : REAL Real value

N : DINT Root level

Outputs

Q : REAL Result: Nth root of IN

Remarks

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the input must be loaded in the current result before calling the function.

ST Language

Q := ROOT (IN, N);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
ROOT N
ST Q (* Q is: ROOT (IN) *)


ScaleLin

Programming languages - Reference guide -> Mathematic operations -> ScaleLin

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Scaling - linear conversion.

Inputs

IN : REAL Real value.
IMIN : REAL Minimum input value.
IMAX : REAL Maximum input value.
OMIN : REAL Minimum output value.
OMAX : REAL Maximum output value.

Outputs

OUT : REAL Result: OMIN + IN * (OMAX - OMIN) / (IMAX - IMIN).

Truth table

Inputs | OUT
IMIN >= IMAX | = IN
IN < IMIN | = OMIN
IN > IMAX | = IMAX
other | = OMIN + IN * (OMAX - OMIN) / (IMAX - IMIN)

Remarks

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the input must be loaded in the current result before calling the function.

ST Language

OUT := ScaleLin (IN, IMIN, IMAX, OMIN, OMAX);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
ScaleLin IMAX, IMIN, OMAX, OMIN
ST OUT


SQRT / SQRTL

Programming languages - Reference guide -> Mathematic operations -> SQRT / SQRTL

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Calculates the square root of the input.

Inputs

IN : REAL/LREAL Real value.

Outputs

Q : REAL/LREAL Result: square root of IN.

Remarks

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the input must be loaded in the current result before calling the function.

ST Language

Q := SQRT (IN);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
SQRT
ST Q (* Q is: SQRT (IN) *)

seealso See also

ABS TRUNC LOG POW


TRUNC / TRUNCL

Programming languages - Reference guide -> Mathematic operations -> TRUNC / TRUNCL

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Truncates the decimal part of the input.

Inputs

IN : REAL/LREAL Real value.

Outputs

Q : REAL/LREAL Result: integer part of IN.

Remarks

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the input must be loaded in the current result before calling the function.

ST Language

Q := TRUNC (IN);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
TRUNC
ST Q (* Q is the integer part of IN *)

seealso See also

ABS LOG POW SQRT


Trigonometric functions

Programming languages - Reference guide -> Trigonometric functions

Previous chapter Next chapter Show all Show all Hide all Hide all

Below are the standard functions for trigonometric calculation:

Funktion | Effekt
SIN COS TAN ASIN ACOS ATAN ATAN2 | sine cosine tangent arc-sine arc-cosine arc-tangent arc-tangent of Y / X
seealso See also
UseDegrees

In this section

ACOS /ACOSL

ASIN / ASINL

ATAN / ATANL

ATAN2 / ATANL2

COS / COSL

SIN / SINL

TAN / TANL

UseDegrees


ACOS /ACOSL

Programming languages - Reference guide -> Trigonometric functions -> ACOS /ACOSL

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Calculate an arc-cosine.

Inputs

IN : REAL/LREAL Real value.

Outputs

Q : REAL/LREAL Result: arc-cosine of IN.

Remarks

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the input must be loaded in the current result before calling the function.

ST Language

Q := ACOS (IN);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
ACOS
ST Q (* Q is: ACOS (IN) *)

seealso See also

SIN COS TAN ASIN ATAN ATAN2


ASIN / ASINL

Programming languages - Reference guide -> Trigonometric functions -> ASIN / ASINL

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Calculate an arc-sine.

Inputs

IN : REAL/LREAL Real value.

Outputs

Q : REAL/LREAL Result: arc-sine of IN.

Remarks

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the input must be loaded in the current result before calling the function.

ST Language

Q := ASIN (IN);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
ASIN
ST Q (* Q is: ASIN (IN) *)

seealso See also

SIN COS TAN ACOS ATAN ATAN2


ATAN / ATANL

Programming languages - Reference guide -> Trigonometric functions -> ATAN / ATANL

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Calculate an arc-tangent.

Inputs

IN : REAL/LREAL Real value.

Outputs

Q : REAL/LREAL Result: arc-tangent of IN.

Remarks

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the input must be loaded in the current result before calling the function.

ST Language

Q := ATAN (IN);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
ATAN
ST Q (* Q is: ATAN (IN) *)

seealso See also

SIN COS TAN ASIN ACOS ATAN2


ATAN2 / ATANL2

Programming languages - Reference guide -> Trigonometric functions -> ATAN2 / ATANL2

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Calculate arc-tangent of Y/X.

Inputs

Y : REAL/LREAL Real value.
X : REAL/LREAL Real value.

Outputs

Q : REAL/LREAL Result: arc-tangent of Y / X.

Remarks

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the input must be loaded in the current result before calling the function.

ST Language

Q := ATAN2 (IN);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD Y
ATAN2 X
ST Q (* Q is: ATAN2 (Y / X) *)

seealso See also

SIN COS TAN ASIN ACOS ATAN


COS / COSL

Programming languages - Reference guide -> Trigonometric functions -> COS / COSL

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Calculate a cosine.

Inputs

IN : REAL/LREAL Real value.

Outputs

Q : REAL/LREAL Result: cosine of IN.

Remarks

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the input must be loaded in the current result before calling the function.

ST Language

Q := COS (IN);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
COS
ST Q (* Q is: COS (IN) *)

seealso See also

SIN TAN ASIN ACOS ATAN ATAN2


SIN / SINL

Programming languages - Reference guide -> Trigonometric functions -> SIN / SINL

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Calculate a sine.

Inputs

IN : REAL/LREAL Real value.

Outputs

Q : REAL/LREAL Result: sine of IN.

Remarks

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the input must be loaded in the current result before calling the function.

ST Language

Q := SIN (IN);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
SIN
ST Q (* Q is: SIN (IN) *)

seealso See also

COS TAN ASIN ACOS ATAN ATAN2


TAN / TANL

Programming languages - Reference guide -> Trigonometric functions -> TAN / TANL

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Calculate a tangent.

Inputs

IN : REAL/LREAL Real value.

Outputs

Q : REAL/LREAL Result: tangent of IN.

Remarks

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the input must be loaded in the current result before calling the function.

ST Language

Q := TAN (IN);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
TAN
ST Q (* Q is: TAN (IN) *)

seealso See also

SIN COS ASIN ACOS ATAN ATAN2


UseDegrees

Programming languages - Reference guide -> Trigonometric functions -> UseDegrees

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Sets the unit for angles in all trigonometric functions.

Inputs

IN : BOOL If TRUE, turn all trigonometric functions to use degrees.
If FALSE, turn all trigonometric functions to use radians (default).

Outputs

Q : BOOL TRUE if functions use degrees before the call.

Remarks

This function sets the working unit for the following functions:

Code | Function
SIN COS TAN ASIN ACOS ATAN ATAN2 | sine cosine tangent arc-sine arc-cosine arc-tangent arc-tangent of Y / X

ST Language

Q := UseDegrees (IN);

FBD Language

LD Language

Input is the rung. The rung is the output.

IL Language

Op1: LD IN
UseDegrees
ST Q


String operations

Programming languages - Reference guide -> String operations

Below are the standard operators and functions that manage character strings:

Code | Operator / Function
+ CONCAT MLEN LEN DELETE INSERT FIND REPLACE LEFT RIGHT MID CHAR ASCII ATOH HTOA CRC16 ArrayToString StringToArray | concatenation of strings concatenation of strings get string length delete characters in a string insert characters in a string find characters in a string replace characters in a string extract a part of a string on the left extract a part of a string on the right extract a part of a string build a single character string get the ASCII code of a character within a string converts string to integer using hexadecimal basis converts integer to string using hexadecimal basis CRC16 calculation copies elements of an SINT array to a STRING copies characters of a STRING to an SINT array

Other functions are available for managing string tables as resources:

Function | Description
StringTable LoadString | Select the active string table resource Load a string from the active string table

In this section

ArrayToString / ArrayToStringU

ASCII

ATOH

CHAR

CONCAT

CRC16

DELETE

FIND

HTOA

INSERT

LEFT

LEN

LoadString

MID

MLEN

REPLACE

RIGHT

StringTable

StringToArray / StringToArrayU


ArrayToString / ArrayToStringU

Programming languages - Reference guide -> String operations -> ArrayToString / ArrayToStringU

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Copy an array of SINT to a STRING.

Inputs

SRC : SINT Source array of SINT small integers (USINT for ArrayToStringU).
DST : STRING Destination STRING.
COUNT : DINT Numbers of characters to be copied.

Outputs

Q : DINT Number of characters copied.

Remarks

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung.

This function copies the COUNT first elements of the SRC array to the characters of the DST string. The function checks the maximum size of the destination string and adjust the COUNT number if necessary.

ST Language

Q := ArrayToString (SRC, DST, COUNT);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Not available.

seealso See also

StringToArray


ASCII

Programming languages - Reference guide -> String operations -> ASCII

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Get the ASCII code of a character within a string.

Inputs

IN : STRING Input string
POS : DINT Position of the character within the string.
(The first valid position is 1).

Outputs

CODE : DINT ASCII code of the selected character.
or 0 if position is invalid.

Remarks

In LD language, the input rung (EN) enables the operation, and the output rung keeps the same value as the input rung. In IL language, the first parameter (IN) must be loaded in the current result before calling the function. The other input is the operand of the function.

ST Language

CODE := ASCII (IN, POS);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO is equal to EN.

IL Language

Op1: LD IN
AND_MASK MSK
ST CODE

seealso See also

CHAR


ATOH

Programming languages - Reference guide -> String operations -> ATOH

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Converts string to integer using hexadecimal basis.

Inputs

IN : STRING String representing an integer in hexadecimal format.

Outputs

Q : DINT Integer represented by the string.

Truth table (examples)

IN | Q
'' | 0
'12' | 18
'a0' | 160
A0zzz' | 160

Remarks

The function is case insensitive. The result is 0 for an empty string. The conversion stops before the first invalid character. In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the input must be loaded in the current result before calling the function.

ST Language

Q := ATOH (IN);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
ATOH
ST Q

seealso See also

HTOA


CHAR

Programming languages - Reference guide -> String operations -> CHAR

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Builds a single character string.

Inputs

CODE : DINT ASCII code of the wished character.

Outputs

Q : STRING STRING containing only the specified character.

Remarks

In LD language, the input rung (EN) enables the operation, and the output rung keeps the same value as the input rung. In IL language, the input parameter (CODE) must be loaded in the current result before calling the function.

ST Language

Q := CHAR (CODE);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO is equal to EN.

IL Language

Op1: LD CODE
CHAR
ST Q

seealso See also

ASCII


CONCAT

Programming languages - Reference guide -> String operations -> CONCAT

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Concatenate strings.

Inputs

IN_1 : STRING Any string variable or constant expression.
...
IN_N : STRING Any string variable or constant expression.

Outputs

Q : STRING Concatenation of all inputs.

Remarks

In FBD or LD language, the block may have up to 16 inputs. In IL or ST, the function accepts a variable number of inputs (at least 2).

Note that you also can use the "+" operator to concatenate strings.

ST Language

Q := CONCAT ('AB', 'CD', 'E');
(* now Q is 'ABCDE' *)

FBD Language

LD Language

IL Language

Op1: LD 'AB'
CONCAT 'CD', 'E'
ST Q (* Q is now 'ABCDE' *)


CRC16

Programming languages - Reference guide -> String operations -> CRC16

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - calculates a CRC16 on the characters of a string.

Inputs

IN : STRING character string.

Outputs

Q : INT CRC16 calculated on all the characters of the string.

Remarks

In LD language, the input rung (EN) enables the operation, and the output rung keeps the same value as the input rung. In IL language, the input parameter (IN) must be loaded in the current result before calling the function.

The function calculates a MODBUS CRC16, initialized at 16#FFFF value.

ST Language

Q := CRC16 (IN);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO is equal to EN.

IL Language

Op1: LD IN
CRC16
ST Q


DELETE

Programming languages - Reference guide -> String operations -> DELETE

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Delete characters in a string.

Inputs

IN : STRING Character string.
NBC : DINT Number of characters to be deleted.
POS : DINT Position of the first deleted character (first character position is 1).

Outputs

Q : STRING Modified string.

Remarks

The first valid character position is 1. In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the first input (the string) must be loaded in the current result before calling the function. Other arguments are operands of the function, separated by comas.

ST Language

Q := DELETE (IN, NBC, POS);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
DELETE NBC, POS
ST Q

seealso See also

+ MLEN INSERT FIND REPLACE LEFT RIGHT MID


FIND

Programming languages - Reference guide -> String operations -> FIND

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Find position of characters in a string.

Inputs

IN : STRING Character string.
STR : STRING String containing searched characters.

Outputs

POS : DINT Position of the first character of STR in IN, or 0 if not found.

Remarks

The first valid character position is 1. A return value of 0 means that the STR string has not been found. Search is case sensitive. In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the first input (the string) must be loaded in the current result before calling the function. The second argument is the operand of the function.

ST Language

POS := FIND (IN, STR);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
FIND STR
ST POS

seealso See also

+ MLEN DELETE INSERT REPLACE LEFT RIGHT MID


HTOA

Programming languages - Reference guide -> String operations -> HTOA

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Converts integer to string using hexadecimal basis.

Inputs

IN : DINT Integer value.

Outputs

Q : STRING String representing the integer in hexadecimal format.

Truth table (examples)

IN | Q
0 | '0'
18 | '12'
160 | 'A0'

Remarks

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the input must be loaded in the current result before calling the function.

ST Language

Q := HTOA (IN);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
HTOA
ST Q

seealso See also

ATOH


INSERT

Programming languages - Reference guide -> String operations -> INSERT

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Insert characters in a string.

Inputs

IN : STRING Character string.
STR : STRING String containing characters to be inserted.
POS : DINT Position of the first inserted character (first character position is 1).

Outputs

Q : STRING Modified string.

Remarks

The first valid character position is 1. In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the first input (the string) must be loaded in the current result before calling the function. Other arguments are operands of the function, separated by comas.

ST Language

Q := INSERT (IN, STR, POS);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
INSERT STR, POS
ST Q

seealso See also

+ MLEN DELETE FIND REPLACE LEFT RIGHT MID


LEFT

Programming languages - Reference guide -> String operations -> LEFT

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Extract characters of a string on the left.

Inputs

IN : STRING Character string.
NBC : DINT Number of characters to extract.

Outputs

Q : STRING String containing the first NBC characters of IN.

Remarks

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the first input (the string) must be loaded in the current result before calling the function. The second argument is the operand of the function.

ST Language

Q := LEFT (IN, NBC);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
LEFT NBC
ST Q

seealso See also

+ MLEN DELETE INSERT FIND REPLACE RIGHT MID


LEN

Programming languages - Reference guide -> String operations -> LEN

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Get the number of characters in a string.

Inputs

IN : STRING Character string.

Outputs

NBC : INT Number of characters currently in the string. 0 if string is empty.

Remarks

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the input must be loaded in the current result before calling the function.

ST Language

NBC := LEN (IN);


LoadString

Programming languages - Reference guide -> String operations -> LoadString

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Load a string from the active string table.

Inputs

ID : DINT ID of the string as declared in the string table.

Outputs

Q : STRING Loaded string or empty string in case of error.

Remarks

This function loads a string from the active string table and stores it into a STRING variable. The StringTable() function is used for selecting the active string table.

The ID input (the string item identifier) is an identifier such as declared within the string table resource. You don't need to "define" again this identifier. The system does it for you.

ST Language

Q := LoadString (ID);

FBD Language

LD Language

IL Language

Op1: LD ID
LoadString
ST Q

seealso See also

StringTable String tables


MID

Programming languages - Reference guide -> String operations -> MID

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Extract characters of a string at any position.

Inputs

IN : STRING Character string.
NBC : DINT Number of characters to extract.
POS : DINT Position of the first character to extract (first character of IN is at position 1).

Outputs

Q : STRING String containing the first NBC characters of IN.

Remarks

The first valid position is 1. In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the first input (the string) must be loaded in the current result before calling the function. Other argument are operands of the function, separated by comas.

ST Language

Q := MID (IN, NBC, POS);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
MID NBC, POS
ST Q

seealso See also

+ MLEN DELETE INSERT FIND REPLACE LEFT RIGHT


MLEN

Programming languages - Reference guide -> String operations -> MLEN

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Get the number of characters in a string.

Inputs

IN : STRING Character string.

Outputs

NBC : DINT Number of characters currently in the string. 0 if string is empty.

Remarks

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the input must be loaded in the current result before calling the function.

ST Language

NBC := MLEN (IN);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
MLEN
ST NBC

seealso See also

+ DELETE INSERT FIND REPLACE LEFT RIGHT MID


REPLACE

Programming languages - Reference guide -> String operations -> REPLACE

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Replace characters in a string.

Inputs

IN : STRING Character string.
STR : STRING String containing the characters to be inserted.
in place of NDEL removed characters.
NDEL : DINT Number of characters to be deleted before insertion of STR.
POS : DINT Position where characters are replaced (first character position is 1).

Outputs

Q : STRING Modified string.

Remarks

The first valid character position is 1. In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the first input (the string) must be loaded in the current result before calling the function. Other arguments are operands of the function, separated by comas.

ST Language

Q := REPLACE (IN, STR, NDEL, POS);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
REPLACE STR, NDEL, POS
ST Q

seealso See also

+ MLEN DELETE INSERT FIND LEFT RIGHT MID


RIGHT

Programming languages - Reference guide -> String operations -> RIGHT

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Extract characters of a string on the right.

Inputs

IN : STRING Character string.
NBC : DINT Number of characters to extract.

Outputs

Q : STRING String containing the last NBC characters of IN.

Remarks

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the first input (the string) must be loaded in the current result before calling the function. The second argument is the operand of the function.

ST Language

Q := RIGHT (IN, NBC);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD IN
RIGHT NBC
ST Q

seealso See also

+ MLEN DELETE INSERT FIND REPLACE LEFT MID


StringTable

Programming languages - Reference guide -> String operations -> StringTable

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Selects the active string table.

Inputs

TABLE : STRING Name of the String Table resource - must be a constant.
COL : STRING Name of the column in the table - must be a constant.

Outputs

OK : BOOL TRUE if OK.

Remarks

This function selects a column of a valid String Table resource to become the active string table. The LoadString() function always refers to the active string table.

Arguments must be constant string expressions and must fit to a declared string table and a valid column name within this table.

If you have only one string table with only one column defined in your project, you do not need to call this function as it will be the default string table anyway.

ST Language

OK := StringTable ('MyTable', 'FirstColumn");

FBD Language

LD Language

IL Language

Op1: LD 'MyTable'
StringTable 'First Column'
ST OK

seealso See also

LoadString String tables


StringToArray / StringToArrayU

Programming languages - Reference guide -> String operations -> StringToArray / StringToArrayU

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Copies the characters of a STRING to an array of SINT.

Inputs

SRC : STRING Source STRING.
DST : SINT Destination array of SINT small integers (USINT for StringToArrayU).

Outputs

Q : DINT Number of characters copied.

Remarks

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the input must be loaded in the current result before calling the function.

This function copies the characters of the SRC string to the first characters of the DST array. The function checks the maximum size destination arrays and reduces the number of copied characters if necessary.

ST Language

Q := StringToArray (SRC, DST);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD SRC
StringToArray DST
ST Q

seealso See also

ArrayToString


Advanced operations

Programming languages - Reference guide -> Advanced operations

Previous chapter Next chapter Show all Show all Hide all Hide all

Below are the standard blocks that perform advanced operations.

Analog signal processing

Block | Description
Average Integral Derivate PID Ramp Lim_Alrm Hyster, HysterAcc SigPlay SigScale CurveLin SurfLin | Calculate the average of signal samples. Calculate the integral of a signal. Derive a signal. PID loop. Ramp signal. Low / High level detection. Hysteresis calculation. Play an analog signal from a resource. Get a point from a signal resource. Linear interpolation on a curve. Linear interpolation on a surface

Alarm management

Block | Description
Lim_Alrm Alarm_M Alarm_A | Low / High level detection. Alarm with manuel reset. Alarm with automatic reset.

Data collections and serialization

Block | Description
StackInt FIFO LIFO SerializeIn SerializeOut SerGetString SerPutString | Stack of integers. "First in / first out" list. "Last in / first out" stack. Extract data from a binary frame. Write data to a binary frame. Extract a string from a binary frame. Copies a string to a binary frame.

Data Logging

Block | Description
LogFileCSV | Log values of variables to a CSV file.

Special operations

Block | Description
GetSysInfo Printf CycleStop FatalStop EnableEvents ApplyRecipeColumn VLID SigID | Get system information. Trace messages. Sets the application in cycle stepping mode. Breaks the cycle and stop with fatal error. Enable / disable produced events for binding. Apply the values of a column from a recipe file. Get the ID of an embedded list of variables. Get the ID of a signal resource.

Communication

SERIO: serial communication SERIO_B
AS-interface
TCP-IP management functions
UDP management functions
MBSlaveRTU MBSlaveUDP MBMasterRTU MBMasterTCP
CanRcvMsg CanSndMsg
CANopen functions
DNP3 Master function blocks

Others

Arrays management functions
File management functions
Dynamic memory allocation functions
Real Time Clock
Variable size text buffers manipulation
XML writing and parsing
The Win-GRAF PAC Registry management functions

In this section

ALARM_A

ALARM_M

ApplyRecipeColumn

Arrays management functions

AS-interface functions

AVERAGE / AVERAGEL

CANopen functions

CanRcvMsg

CanSndMsg

CycleStop

CurveLin

DERIVATE

DNP3 Master function blocks

Dynamic memory allocation functions

EnableEvents

FatalStop

FIFO

File Management functions

GETSYSINFO

HYSTER

HYSTERacc

INTEGRAL

LIFO

LIM_ALRM

LogFileCSV

MBMasterRTU

MBMasterTCP

MBSlaveRTU / MBSlaveRTUex

MBSlaveUDP / MBSlaveUDPex

PID

printf

RAMP

Real Time Clock management functions

SerializeIn

SerializeOut

SerGetString

SerPutString

SERIO

SERIO_B

SigID

SigPlay

SigScale

STACKINT

SurfLin

TCP-IP Management functions

Text buffers manipulation

UDP Management functions

VLID

XML writing and parsing

The Win-GRAF PAC Registry management functions


ALARM_A

Programming languages - Reference guide -> Advanced operations -> ALARM_A

Previous chapter Next chapter Show all Show all Hide all Hide all

Function Block - Alarm with automatic reset.

Inputs

IN : BOOL Process signal.
ACK : BOOL Acknowledge command.

Outputs

Q : BOOL TRUE if alarm is active.
QACK : BOOL TRUE if alarm is acknowledged.

Sequence

Remarks

Combine this block with the LIM_ALRM block for managing analog alarms.

ST Language

MyALARM is declared as an instance of ALARM_A function block.

MyALARM (IN, ACK, RST);
Q := MyALARM.Q;
QACK := MyALARM.QACK;

FBD Language

LD Language

IL Language

MyALARM is declared as an instance of ALARM_A function block.

Op1: CAL MyALARM (IN, ACK, RST)
LD MyALARM.Q
ST Q
LD MyALARM.QACK
ST QACK

seealso See also

ALARM_M LIM_ALRM


ALARM_M

Programming languages - Reference guide -> Advanced operations -> ALARM_M

Previous chapter Next chapter Show all Show all Hide all Hide all

Function Block - Alarm with manual reset.

Inputs

IN : BOOL Process signal.
ACK : BOOL Acknowledge command.
RST : BOOL Reset command.

Outputs

Q : BOOL TRUE if alarm is active.
QACK : BOOL TRUE if alarm is acknowledged.

Sequence

Remarks

Combine this block with the LIM_ALRM block for managing analog alarms.

ST Language

MyALARM is declared as an instance of ALARM_M function block.

MyALARM (IN, ACK, RST);
Q := MyALARM.Q;
QACK := MyALARM.QACK;

FBD Language

LD Language

IL Language

MyALARM is declared as an instance of ALARM_M function block.

Op1: CAL MyALARM (IN, ACK, RST)
LD MyALARM.Q
ST Q
LD MyALARM.QACK
ST QACK

seealso See also

ALARM_A LIM_ALRM


ApplyRecipeColumn

Programming languages - Reference guide -> Advanced operations -> ApplyRecipeColumn

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Apply the values of a column from a recipe file.

Inputs

FILE : STRING Pathname of the recipe file (.RCP or .CSV) - must be a constant value!
COL : DINT Index of the column in the recipe (0 based).

Outputs

OK : BOOL TRUE if OK - FALSE if parameters are invalid.

Remarks

The 'FILE' input is a constant string expression specifying the path name of a valid .RCP or .CSV file. If no path is specified, the file is assumed to be located in the project folder. RCP files are created using the recipe editor. CSV files can be created using EXCEL or NOTEPAD.

In CSV files, the first line must contain column headers, and is ignored during compiling. There is one variable per line. The first column contains the symbol of the variable. Other columns are values.

If a cell is empty, it is assumed to be the same value as the previous (left side) cell. If it is the first cell of a raw, it is assumed to be null (0 or FALSE or empty string).

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung is the result of the function.

attention Attention

Recipe files are read at compiling time and are embedded into the downloaded application code. This implies that a modification performed in the recipe file after downloading will not be taken into account by the application.

ST Language

OK := ApplyRecipeColumn ('MyFile.rcp', COL);

FBD Language

LD Language

The function is executed only if EN is TRUE.

IL Language

Op1: LD 'MyFile.rcp'
ApplyRecipeColumn COL
ST OK


Arrays management functions

Programming languages - Reference guide -> Advanced operations -> Arrays management functions

Previous chapter Next chapter Show all Show all Hide all Hide all

The following functions enable the management of arrays:

attention Attention
  • These functions may be not available on some targets. Please refer to OEM instructions for further details about available features.

ARCOUNT: search for occurences of a value within an array

COUNT := ARCOUNT (ARR, PATTERN, STARTINDEX);

ARRAY : ANY single or multi dimension array.
PATTERN : ANY searched value.
STARTINDEX : DINT index of the position where to start - 0 to search in the complete array.

Return value

Number of occurrences found.

ARFILL: fill an array with a value

OK := ARFILL (ARR, VALUE);

ARRAY : ANY single or multi dimension array.
PATTERN : ANY value to be copied in all array elements.

Return value

TRUE if successful.

ARFIND: search for the first occurence of a value within an array

INDEX := ARFIND (ARR, PATTERN, STARTINDEX);

ARRAY : ANY single dimension array.
PATTERN : ANY searched value.
STARTINDEX : DINT index of the position where to start - 0 to search in the complete array.

Return values

Index of the first occurrence found.

ARMAX: search for the maximum value within an array

Q := ARMAX (ARR);

ARRAY : ANY single or multi dimension array.

Return value

Maximum value found found.

ARMIN: search for the minimum value within an array

Q := ARMIN (ARR);

ARRAY : ANY single or multi dimension array.

Return value

Minimum value found found.

ARSORT: sort items of an an array

OK := ARSORT (ARR);

ARRAY : ANY single dimension array.

Return value

TRUE if successful.


AS-interface functions

Programming languages - Reference guide -> Advanced operations -> AS-interface functions

Previous chapter Next chapter Show all Show all Hide all Hide all

The following functions enable special operation on AS-i networks:

ASiReadPP read permanent parameters of an AS-i slave.
ASiWritePP write permanent parameters of an AS-i slave.
ASiSendParam send parameters to an AS-i slave.
ASiReadPI read actual parameters of an AS-i slave.
ASiStorePI store actual parameters as permanent parameters.

attention Attention

AS-i networking may be not available on some targets. Please refer to OEM instructions for further details about available features.

Interface

Params := ASiReadPP (Master, Slave);
bOK := ASiWritePP (Master, Slave, Params);
bOK := ASiSendParam (Master, Slave, Params);
Params := ASiReadPI (Master, Slave);
bOK := ASiStorePI (Master);

Arguments

Master : DINT Index of the AS-i master (1..N) such as shown in configuration.
Slave : DINT Address of the AS-i slave (1..32 / 33..63).
Params : DINT Value of AS-i parameters.
bOK : BOOL TRUE if successful.


AVERAGE / AVERAGEL

Programming languages - Reference guide -> Advanced operations -> AVERAGE / AVERAGEL

Previous chapter Next chapter Show all Show all Hide all Hide all

Function Block - Calculates the average of signal samples.

Inputs

RUN : BOOL Enabling command.
XIN : REAL Input signal (*).
N : DINT Number of samples stored for average calculation - Cannot exceed 128.

Outputs

XOUT : REAL Average of the stored samples (*).

(*) AVERAGEL has LREAL arguments.

Remarks

The average is calculated according to the number of stored samples, that can be less that N when the block is enabled. In LD language, the input rung is the RUN command. The output rung keeps the state of the input rung.

The "N" input is take into account only when the RUN input is FALSE. So the "RUN" needs to be reset after a change.

ST Language

MyAve is a declared instance of AVERAGE function block.

MyAve (RUN, XIN, N);
XOUT := MyAve.XOUT;

FBD Language

LD Language

ENO has the same state as RUN.

IL Language

MyAve is a declared instance of AVERAGE function block.

Op1: CAL MyAve (RUN, XIN, N)
LD MyAve.XOUT
ST XOUT

seealso See also

INTEGRAL DERIVATE LIM_ALRM HYSTER STACKINT


CANopen functions

Programming languages - Reference guide -> Advanced operations -> CANopen functions

Previous chapter Next chapter Show all Show all Hide all Hide all

A set of functions and function blocks is available for management of CANopen devices. Such functions refer to the CANopen master configuration defined in the Fieldbus Configurator.

Sending NMT messages

The following functions are used to send a NMT message to a CANopen slave:

OK := coNmtReset (PORT, SLV); (* reset node *)

OK := coNmtStart (PORT, SLV); (* start node *)

OK := coNmtStop (PORT, SLV); (* stop node *)

OK := coNmtEnterPreop (PORT, SLV); (* enter peroperational *)

Arguments:

OK : BOOL; (* TRUE if successful - FALSE if busy or slave not configured *)

PORT : STRING; (* Name of the CAN port as specified in the CANopen master configuration *)

SLV : DINT; (* CANopen slave number *)

Note: You cannot sent more than one NMT message to the same slave during the same PLC cycle.

Reading a simple parameter (SDO) - coReadParam function block

The coReadParam function block is used for sending a simple SDO message to read a parameter from a slave.

Input arguments:

EN : BOOL; (* the message is sent on a rising edge of this input *)

PORT : STRING; (* Name of the CAN port as specified in the CANopen master configuration *)

SLV : DINT; (* CANopen slave number *)

Param : DINT; (* SDO parameter index *)

Sub : DINT; (* SDO parameter sub-index *)

TO : TIME; (* timeout for exchange *)

Output arguments:

Ready : BOOL; (* TRUE when the block is ready - FALSE during an exchange *)

RC : DINT; (* CANopen return check *)

VAL : DINT; (* read parameter value answered by the slave *)

Writing a simple parameter (SDO) - coWriteParam function block

The coWriteParam function block is used for sending a simple SDO message to write a parameter to a slave.

Input arguments:

EN : BOOL; (* the message is sent on a rising edge of this input *)

PORT : STRING; (* Name of the CAN port as specified in the CANopen master configuration *)

SLV : DINT; (* CANopen slave number *)

Param : DINT; (* SDO parameter index *)

Sub : DINT; (* SDO parameter sub-index *)

VAL : DINT; (* parameter value *)

LEN : DINT; (* number of bytes to send - from 1 to 4 *)

TO : TIME; (* timeout for exchange *)

Output arguments:

Ready : BOOL; (* TRUE when the block is ready - FALSE during an exchange *)

RC : DINT; (* CANopen return check *)

Sending the PDO mapping (SDOs) - coSendPdoMap function block

The coSendPdoMap function block sends a sequence of SDO messages for applying the PDO mapping to a slave such as defined in the CANopen configuration.

Input arguments:

EN : BOOL; (* the message is sent on a rising edge of this input *)

PORT : STRING; (* Name of the CAN port as specified in the CANopen master configuration *)

SLV : DINT; (* CANopen slave number *)

TO : TIME; (* timeout for exchange *)

Output arguments:

Ready : BOOL; (* TRUE when the block is ready - FALSE during the exchanges *)

RC : DINT; (* CANopen return check *)


CanRcvMsg

Programming languages - Reference guide -> Advanced operations -> CanRcvMsg

Previous chapter Next chapter Show all Show all Hide all Hide all

Function block - Receive a CANbus message.

Inputs

PORT : STRING CAN port identification (see remarks).

DATA : USINT[] CAN data (filled on output) - array size must be 8.

Outputs

OK : BOOL TRUE if successful.

ID : DWORD CAN message ID.

LEN : DINT CAN message data length.

Remarks

This function gets the next received message since the last cycle. Only messages with IDs not configured in the CANbus configuration are received by this block.

The number of messages possibly received within one cycle is limited by the FIFO size defined in the CANbus configuration.

The PORT input defines a CAN bus configured:

- if you specify an empty string, then the first CAN port configured is selected

- if you specify a string containing a number, it relates to the corresponding port. For instance, '2' mens the second port

- you can also specify the string entered as "port settings" in the CANbus configuration, e.g. 'CAN0'


CanSndMsg

Programming languages - Reference guide -> Advanced operations -> CanSndMsg

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Send a CANbus message.

Inputs

PORT : STRING CAN port identification (see remarks).

ID : DWORD CAN message ID.

LEN : DINT CAN message data length.

DATA : USINT[] CAN data.

RTR : BOOL Send in RTR mode.

Outputs

OK : BOOL TRUE if successful.

Remarks

This function sends an asynchronous message on the specified CAN port. The message will be sent at the end of the current cycle.

The number of messages possibly sent within one cycle is limited by the FIFO size defined in the CANbus configuration.

The PORT input defines a CAN bus configured:

- if you specify an empty string, then the first CAN port configured is selected

- if you specify a string containing a number, it relates to the corresponding port. For instance, '2' means the second port

- you can also specify the string entered as "port settings" in the CANbus configuration, e.g. 'CAN0'


CycleStop

Programming languages - Reference guide -> Advanced operations -> CycleStop

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Sets the application in cycle stepping mode.

Inputs

IN : BOOL Condition.

Outputs

Q : BOOL TRUE if performed.

Remarks

This function turns the Virtual Machine in Cycle Stepping mode. Restarting normal execution will be performed using the debugger.

The VM is set in cycle stepping mode only if the IN argument is TRUE.

The current main program and all possibly called sub-programs or UDFBs are normally performed up the end. Other programs of the cycle are not executed.


CurveLin

Function Block - Linear interpolation on a curve.

Inputs

X : REAL X coordinate of the point to be interpolated.

XAxis : REAL[] X coordinates of the known points of the X axis.

YVal : REAL[] Y coordinate of the points defined on the X axis.

Outputs

Y : REAL Interpolated Y value corresponding to the X input

OK : BOOL TRUE if successful.

ERR : DINT Error code if failed - 0 if OK.

Remarks

This function performs linear interpolation in between a list of points defined in the XAxis single dimension array. The output Y value is an interpolation of the Y values of the two rounding points defined in the X axis. Y values of defined points are passed in the YVal single dimension array.

Values in XAxis must be sorted from the smallest to the biggest. There must be at least two points defined in the X axis. YVal and XAxis input arrays must have the same dimension.

In case the X input is less than the smallest defined X point, the Y output takes the first value defined in YVal and an error is reported. In case the X input is greater than the biggest defined X point, the Y output takes the last value defined in YVal and an error is reported.

The ERR output gives the cause of the error if the function fails:

Error code | Meaning
0 | OK
1 | Invalid dimension of input arrays
2 | Invalid points for the X axis
4 | X is out of the defined X axis


DERIVATE

Programming languages - Reference guide -> Advanced operations -> DERIVATE

Previous chapter Next chapter Show all Show all Hide all Hide all

Function Block - Derivates a signal.

Inputs

RUN : BOOL Run command: TRUE=derivate / FALSE=hold.
XIN : REAL Input signal.
CYCLE : TIME Sampling period (should not be less than the target cycle timing).

Outputs

XOUT : REAL Output signal.

Remarks

In LD language, the input rung is the RUN command. The output rung keeps the state of the input rung.

ST Language

MyDerv is a declared instance of DERIVATE function block.

MyDerv (RUN, XIN, CYCLE);
XOUT := MyDerv.XOUT;

FBD Language

LD Language

ENO has the same state as RUN.

IL Language

MyDerv is a declared instance of DERIVATE function block.

Op1: CAL MyDerv (RUN, XIN, CYCLE)
LD MyDerv.XOUT
ST XOUT

seealso See also

AVERAGE INTEGRAL LIM_ALRM HYSTER STACKINT


DNP3 Master function blocks

Programming languages - Reference guide -> Advanced operations -> DNP3 Master function blocks

Previous chapter Next chapter Show all Show all Hide all Hide all

DNP3_CMDANLG

Issue an analog command

Input | Description
EN : BOOL | Activate the block
SESN : UINT | Session number
PNUM : UINT | Point number
FC : UINT | Fucntion code - must be DNP3_FC_SELECT or DNP3_FC_OPERATE or DNP3_FC_DIRECT_OP or DNP3_FC_DIRECT_OP_NOACK See values at the end of this page
VART : UINT | Object variation to use in request
QUAL : UINT | Qualifier - must be DNP3_QUAL_8BIT_INDEX or DNP3_QUAL_16BIT_INDEX See values at the end of this page
VALUE : ANY | Value to write - can be any data type

Output | Description
READY : BOOL | TRUE if the block is ready for a new command
RC : DINT | Status: see values DNP3_RESP_STATUS_... at the end of this page

DNP3_CMDBIN

Issue a binary command

Input | Description
EN : BOOL | Activate the block
SESN : UINT | Session number
PNUM : UINT | Point number
FC : UINT | Fucntion code - must be DNP3_FC_SELECT or DNP3_FC_OPERATE or DNP3_FC_DIRECT_OP or DNP3_FC_DIRECT_OP_NOACK See values at the end of this page
CONTROL : UINT | Control code - must be DNP3_CROB_CTRL_PULSE_ON or DNP3_CROB_CTRL_PULSE_OFF or DNP3_CROB_CTRL_LATCH_ON or DNP3_CROB_CTRL_LATCH_OFF or DNP3_CROB_CTRL_CLEAR or DNP3_CROB_CTRL_PAIRED_CLOSE or DNP3_CROB_CTRL_PAIRED_TRIP See values at the end of this page
QUAL : UINT | Qualifier - must be DNP3_QUAL_8BIT_INDEX or DNP3_QUAL_16BIT_INDEX See values at the end of this page
TON : TIME | ON duration
TOFF : TIME | OFF duration

Output | Description
READY : BOOL | TRUE if the block is ready for a new command
RC : DINT | Status: see values DNP3_RESP_STATUS_... at the end of this page

DNP3_EVPOLL

Issue an event data poll

Input | Description
EN : BOOL | Activate the block
SESN : UINT | Session number

Output | Description
READY : BOOL | TRUE if the block is ready for a new command
RC : DINT | Status: see values DNP3_RESP_STATUS_... at the end of this page

DNP3_FREEZCNTR

Issue a freeze counters request

Input | Description
EN : BOOL | Activate the block
SESN : UINT | Session number
QUAL : UINT | Qualifier - must be DNP3_QUAL_ALL_POINTS or DNP3_QUAL_8BIT_START_STOP or DNP3_QUAL_16BIT_START_STOP See values at the end of this page
START : UINT | Start point if qualifier is 8/16 bit start/stop
STOP : UINT | Stop point if qualifier is 8/16 bit start/top

Output | Description
READY : BOOL | TRUE if the block is ready for a new command
RC : DINT | Status: see values DNP3_RESP_STATUS_... at the end of this page

DNP3_INTPOLL

Issue an integrity data poll

Input | Description
EN : BOOL | Activate the block
SESN : UINT | Session number

Output | Description
READY : BOOL | TRUE if the block is ready for a new command
RC : DINT | Status: see values DNP3_RESP_STATUS_... at the end of this page

DNP3_READCLASS

Issue a read class request

Input | Description
EN : BOOL | Activate the block
SESN : UINT | Session number
QUAL : UINT | Qualifier - must be DNP3_QUAL_ALL_POINTS or DNP3_QUAL_8BIT_LIMITED_QTY or DNP3_QUAL_16BIT_LIMITED_QTY See values at the end of this page
QTY : UINT | Quantity to request if qualifier is 8/16 bit limited quantity
CLASS0 : BOOL | TRUE to request class 0 (static data)
CLASS1 : BOOL | TRUE to request class 1 event data
CLASS2 : BOOL | TRUE to request class 2 event data
CLASS3 : BOOL | TRUE to request class 3 event data

Output | Description
READY : BOOL | TRUE if the block is ready for a new command
RC : DINT | Status: see values DNP3_RESP_STATUS_... at the end of this page

DNP3_READGROUP

Issue a read group request to the specified session

Input | Description
EN : BOOL | Activate the block
SESN : UINT | Session number
GRP : UINT | Object group for read request
VART : UINT | object variation to read. The type specified by this is specific to the object group being read
QUAL : UINT | Qualifier - must be DNP3_QUAL_ALL_POINTS or DNP3_QUAL_8BIT_START_STOP or DNP3_QUAL_16BIT_START_STOP or DNP3_QUAL_8BIT_LIMITED_QTY or DNP3_QUAL_16BIT_LIMITED_QTY See values at the end of this page
START : UINT | Start point if qualifier is start/stop
STOP : UINT | Stop point if qualifier is start/stop or quantity if qualifier is limited points

Output | Description
READY : BOOL | TRUE if the block is ready for a new command
RC : DINT | Status: see values DNP3_RESP_STATUS_... at the end of this page

DNP3_READPTS

Issue an read one or more specific data points request to the specified session

Input | Description
EN : BOOL | Activate the block
SESN : UINT | Session number
GRP : UINT | Object group for read request
VART : UINT | object variation to read
QUAL : UINT | Qualifier - must be DNP3_QUAL_8BIT_INDEX or DNP3_QUAL_16BIT_INDEX See values at the end of this page
ARPTS[] : UINT | Array of point numbers to read

Output | Description
READY : BOOL | TRUE if the block is ready for a new command
RC : DINT | Status: see values DNP3_RESP_STATUS_... at the end of this page

DNP3_WRITEBIN

Issue a binary output write command to the specified session

Input | Description
EN : BOOL | Activate the block
SESN : UINT | Session number
QUAL : UINT | Qualifier - must be DNP3_QUAL_8BIT_START_STOP or DNP3_QUAL_16BIT_START_STOP See values at the end of this page
START : UINT | Start point index
STOP : UINT | End point index
VALUE[] : BOOL | Array of values (FALSE = off / TRUE = on)

Output | Description
READY : BOOL | TRUE if the block is ready for a new command
RC : DINT | Status: see values DNP3_RESP_STATUS_... at the end of this page

DNP3_WRITESTR

Write a string object to the specified point

Input | Description
EN : BOOL | Activate the block
SESN : UINT | Session number
PNUM : UINT | Point number for the string to write
STR : STRING | String value

Output | Description
READY : BOOL | TRUE if the block is ready for a new command
RC : DINT | Status: see values DNP3_RESP_STATUS_... at the end of this page

Command and status values

Below are command values and status values used by or returned by DNP3 Master function blocks. You can directly copy / paste these definitions in the "Global Defines" editor.

// Qualifier

#define DNP3_QUAL_8BIT_START_STOP 16#00

#define DNP3_QUAL_16BIT_START_STOP 16#01

#define DNP3_QUAL_ALL_POINTS 16#06

#define DNP3_QUAL_8BIT_LIMITED_QTY 16#07

#define DNP3_QUAL_16BIT_LIMITED_QTY 16#08

#define DNP3_QUAL_8BIT_INDEX 16#17

#define DNP3_QUAL_16BIT_INDEX 16#28

// Function code

#define DNP3_FC_SELECT 16#03

#define DNP3_FC_OPERATE 16#04

#define DNP3_FC_DIRECT_OP 16#05

#define DNP3_FC_DIRECT_OP_NOACK 16#06

// Values for control code of CROB

#define DNP3_CROB_CTRL_PULSE_ON 16#01 // The point is turned on for the specified onTime, turned off for the specified offTime, and left in the off state

#define DNP3_CROB_CTRL_PULSE_OFF 16#02 // The point is turned off for the specific offTime, then turned on for the specified onTime, and left in the on state

#define DNP3_CROB_CTRL_LATCH_ON 16#03 // The point is latched on

#define DNP3_CROB_CTRL_LATCH_OFF 16#04 // The point is latched off

#define DNP3_CROB_CTRL_CLEAR 16#20 // Cancel the currently running operation

#define DNP3_CROB_CTRL_PAIRED_CLOSE 16#40 // Activate Close relay

#define DNP3_CROB_CTRL_PAIRED_TRIP 16#80 // Activate Trip relay

// Response values

#define DNP3_RESP_STATUS_SUCCESS 16#00 // This indicates the request has completed successfully

#define DNP3_RESP_STATUS_INTERMEDIATE 16#01 // This indicates a response was received but the requested command is not yet complete

#define DNP3_RESP_STATUS_FAILURE 16#02 // This indicates that the transmission of the request failed

#define DNP3_RESP_STATUS_MISMATCH 16#03 // The response to a select or an execute did not echo the request

#define DNP3_RESP_STATUS_STATUSCODE 16#04 // The response to a select or an execute echoed the request, except the status code was different indicating a failure

#define DNP3_RESP_STATUS_IIN 16#05 // The response to the request had IIN bits set indicating the command failed

#define DNP3_RESP_STATUS_TIMEOUT 16#06 // This indicates that the request has timed out

#define DNP3_RESP_STATUS_CANCELED 16#07 // Request canceled by user

#define DNP3_RESP_STATUS_OTHERERR 16#ff // Command failed (ie. Variation not supported)


Dynamic memory allocation functions

Programming languages - Reference guide -> Advanced operations -> Dynamic memory allocation functions

Previous chapter Next chapter Show all Show all Hide all Hide all

The following functions enable the dynamic allocation of arrays for storing DINT integer values:

ARCREATE allocates an array of DINT integers.
ARREAD read a DINT integer in an array allocated by ARCREATE.
ARWRITE write a DINT integer in an array allocated by ARCREATE.

attention Attention
  • The memory used for those arrays is allocated directly by the Operating System of the target. There is no insurance that the required memory space will be available.
  • Allocating large arrays may cause the Operating System to be instable or slow down the performances of the target system.
  • Dynamic memory allocation may be unsuccessful (not enough memory available on the target). Your application should process such error cases in a safe way.
  • Dynamic memory allocation may be not available on some targets. Please refer to OEM instructions for further details about available features.

ARCREATE: array allocation

OK := ARCREATE (ID, SIZE);

ID : DINT integer ID to be assigned to the array (first possible ID is 0) .
SIZE : DINT wished number of DINT values to be stored in the array.
OK : DINT return check.

Return values

  1. OK - array is allocated and ready for read / write operations.
  2. The specified ID is invalid or already used for another array.
  3. The specified size is invalid.
  4. Not enough memory (action denied by the Operating System).

The memory allocated by ARCREATE will be released when the application stops.

ARREAD: read array element

VAL := ARREAD (ID, POS);

ID : DINT integer ID of the array.
POS : DINT index of the element in the array (first valid index is 0).
VAL : DINT value of the specified item or 0 if arguments are invalid.

ARWRITE: write array element

OK := ARWRITE (ID, POS, IN);

ID : DINT integer ID of the array.
POS : DINT index of the element in the array (first valid index is 0).
IN : DINT value to be assigned to the element.
OK : DINT return check.

Return values

  1. OK - element was forced successfully
  2. The specified ID is invalid (not an allocated array).
  3. The specified index is invalid (out of array bounds).


EnableEvents

Programming languages - Reference guide -> Advanced operations -> EnableEvents

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Enable or disable the production of events for binding (runtime to runtime variable exchange).

Inputs

EN : BOOL TRUE to enable events / FALSE to disable events.

Outputs

ENO : BOOL Echo of EN input.

Remarks

Production is enabled when the application starts. The first production will be operated after the first cycle. So to disable events since the beginning, you must call EnableEvents (FALSE) in the very first cycle.

In LD language, the input rung (EN) enables the event production, and the output rung keeps the state of the input rung. In IL language, the input must be loaded before the function call.

ST Language

ENO := EnableEvents (EN);

FBD Language

LD Language

Events are enables if EN is TRUE.
ENO has the same value as EN.

IL Language

Op1: LD EN
EnableEvents
ST ENO


FatalStop

Programming languages - Reference guide -> Advanced operations -> FatalStop

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Breaks the application in fatal error.

Inputs

IN : BOOL Condition.

Outputs

Q : BOOL TRUE if performed.

Remarks

This function breaks the current cycle and sets the Virtual Machine in ERROR mode. Restarting normal execution will be performed using the debugger.

The VM is stopped only if the IN argument is TRUE. The end of the current cycle is then not performed.


FIFO

Programming languages - Reference guide -> Advanced operations -> FIFO

Previous chapter Next chapter Show all Show all Hide all Hide all

Function block - Manages a first in / first out list.

Inputs

PUSH : BOOL Push a new value (on rising edge).
POP : BOOL Pop a new value (on rising edge).
RST : BOOL Reset the list.
NEXTIN : ANY Value to be pushed.
NEXTOUT : ANY Value of the oldest pushed value - updated after call!
BUFFER : ANY Array for storing values.

Outputs

EMPTY : BOOL TRUE if the list is empty.
OFLO : BOOL TRUE if overflow on a PUSH command.
COUNT : DINT Number of values in the list.
PREAD : DINT Index in the buffer of the oldest pushed value.
PWRITE : DINT Index in the buffer of the next push position.

Remarks

NEXTIN, NEXTOUT and BUFFER must have the same data type and cannot be STRING.

The NEXTOUT argument specifies a variable that is filled with the oldest push value after the block is called.

Values are stored in the BUFFER array. Data is arranged as a roll over buffer and is never shifted or reset. Only read and write pointers and pushed values are updated. The maximum size of the list is the dimension of the array.

The first time the block is called, it remembers on which array it should work. If you call later the same instance with another BUFFER input, the call is considered as invalid and makes nothing. Outputs reports an empty list in this case.

In LD language, input rung is the PUSH input. The output rung is the EMPTY output.

ST Language

MyFIFO is a declared instance of FIFO function block.

SMyFIFO (PUSH, POP, RST, NEXTIN, NEXTOUT, BUFFER);
EMPTY := MyFIFO.EMPTY;
OFLO := MyFIFO.OFLO;
COUNT := MyFIFO.COUNT;
PREAD := MyFIFO.PREAD;
PWRITE := MyFIFO.PWRITE;

FBD Language

LD Language

IL Language

MyFIFO is a declared instance of FIFO function block.

Op1: CAL MyFIFO (PUSH, POP, RST, NEXTIN, NEXTOUT, BUFFER)
LD MyFIFO.EMPTY
ST EMPTY
LD MyFIFO.OFLO
ST OFLO
LD MyFIFO.COUNT
ST COUNT
LD MyFIFO.PREAD
ST PREAD
LD MyFIFO.PWRITE
ST PWRITE

seealso See also

LIFO


File Management functions

Programming languages - Reference guide -> Advanced operations -> File Management functions

Previous chapter Next chapter Show all Show all Hide all Hide all

The following functions enable sequential read / write operations in disk files:

F_ROPEN open a file for reading.
F_WOPEN create or reset a file and open it for writing.
F_AOPEN create or open a file in append mode.
F_CLOSE close an open file.

F_EOF test if the end of file is reached in a file open for read.
FA_READ read a DINT integer from a binary file.
FA_WRITE write a DINT integer to a binary file.
FM_READ read a STRING value from a text file
FM_WRITE write a STRING value to a text file.
FB_READ read binary data from a file.
FB_WRITE write binary data to a file.
F_EXIST test if a file exist.
F_GETSIZE get the size of a file.
F_COPY copy a file.
F_DELETE remove a file.
F_RENAME rename a file.

F_SAVERETAIN store RETAIN variables to a file.
F_LOADERETAIN load RETAIN variables from a file

seealso See also

LogFileCSV Log values of variables to a CSV file.

Each file is identified in the application by a unique handle manipulated as a DINT value. The file handles are allocated by the target system. Handles are returned by the Open functions and used in all other calls for identifying the file.

attention Attention
  • File are opened and closed directly by the Operating System of the target. Opening some files may be dangerous for system safety and integrity. The number of open files may be limited by the target system.
  • Opening a file may be unsuccessful (invalid path or file name, too many open files...) Your application should process such error cases in a safe way.
  • File management may be not available on some targets. Please refer to OEM instructions for further details about available features.
  • Valid paths for storing files depend on the target implementation. Please refer to OEM instructions for further details about available paths.
  • If you use a flash disk, it is your responsibility not to call write functions too often, in order not to destroy the flash. This particularly applies to F_SAVERETAIN function.

F_ROPEN: open a file for reading

ID := F_ROPEN (PATH);

PATH : STRING name of the file - the file must exist.
may include a path name according to target system conventions.
ID : DINT ID of the open file or NULL if the file cant be read.

F_WOPEN: open a file for writing

ID := F_AOPEN (PATH);

PATH : STRING name of the file.
may include a path name according to target system conventions.
ID : DINT ID of the open file or NULL if the file cant be open.

If the file does not exist, it is created. If the file already exists, its contents is cleared.

F_AOPEN: open a file in append mode

ID := F_WOPEN (PATH);

PATH : STRING name of the file.
may include a pathname according to target system conventions.
ID : DINT ID of the open file or NULL if the file cant be open.

If the file does not exist, it is created. If the file already exists, it is open at the end for append.

F_CLOSE: close an open file

OK := F_CLOSE (ID);

ID : DINT ID of the open file.
OK : BOOL return check: TRUE if successful.

F_EOF: test if end of file is encountered

OK := F_EOF (ID);

ID : DINT ID of a file open for reading.
OK : BOOL TRUE if the end of file has been encountered.

F_EOF must be used only for files open in read mode by the F_ROPEN function.

FA_READ: read a DINT value from a file

Q := FA_READ (ID);

ID : DINT ID of a file open for reading.
Q : DINT read value or 0 in case or error.

Integer values read by FA_READ must have been written by the FA_WRITE function. Integers are stored in binary format in the file, using memory conventions of the target system.

FA_WRITE: write a DINT value to a file

OK := FA_WRITE (ID, IN);

ID : DINT ID of a file open for writing.
IN : DINT integer value to be written.
OK : BOOL return check: TRUE if successful.

Integers are stored in binary format in the file, using memory conventions of the target system.

FM_READ: read a STRING value from a file

Q := FM_READ (ID);

ID : DINT ID of a file open for reading.
Q : STRING read value or empty string in case or error.

This function is intended to read a text line in the file. Reading stops when end of line character is encountered. Reading stops when the maximum length declared for the return variable is reached.

FM_WRITE: write a STRING value to a file

OK := FM_WRITE (ID, IN);

ID : DINT ID of a file open for writing.
IN : STRING string value to be written.
OK : BOOL return check: TRUE if successful.

This function writes a text line in the file. End of line character is systematically written after the input string.

FB_READ: read binary data from a file

OK := FB_READ (ID, V);

ID : DINT ID of a file open for reading.
V : ANY variable to be read (cannot be string).
OK : BOOL return check: TRUE if successful.

Variables are stored in binary format in the file, using memory conventions of the target system.

FB_WRITE: write binary data to a file

OK := FB_WRITE (ID, V);

ID : DINT ID of a file open for writing.
V : ANY variable to be written.
OK : BOOL return check: TRUE if successful.

Variables are stored in binary format in the file, using memory conventions of the target system.

F_EXIST: test if file exist

OK := F_EXIST (PATH);

PATH : STRING name of the file.
may include a pathname according to target system conventions.
OK : BOOL TRUE if the file exists.

F_GETSIZE: get file size

SIZE := F_GETSIZE (PATH);

PATH : STRING name of the file.
may include a pathname according to target system conventions.
SIZE : DINT Size of the file in bytes.

F_COPY: copy a file

OK := F_COPY (SRC, DST);

SRC : STRING name of the source file (must exist)
may include a pathname according to target system conventions.
DST : STRING name of the destination file.
may include a pathname according to target system conventions.
OK : BOOL TRUE if successful.

F_DELETE: remove a file

OK := F_DELETE (PATH);

PATH : STRING name of the file (must exist).
may include a pathname according to target system conventions.
OK : BOOL TRUE if successful.

F_RENAME: rename a file

OK := F_RENAME (PATH, NEWNAME);

PATH : STRING name of the file (must exist)
may include a pathname according to target system conventions.
NEWNAME : STRING new name for the file.
OK : BOOL TRUE if successful.

F_SAVERETAIN: save RETAIN variabes to a file

OK := F_SAVERETAIN (PATH);

PATH : STRING name of the file
may include a pathname according to target system conventions.
OK : BOOL TRUE if successful.

F_LOADRETAIN: reload RETAIN variables from a file

OK := F_LOADRETAIN (PATH);

PATH : STRING name of the file (must exist)
may include a pathname according to target system conventions.
OK : BOOL TRUE if successful.


GETSYSINFO

Programming languages - Reference guide -> Advanced operations -> GETSYSINFO

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Returns system information.

Inputs

INFO : DINT Identifier of the requested information.

Outputs

Q : DINT Value of the requested information or 0 if error.

Remarks

The INFO parameter can be one of the following predefined values:

Value | Description
_SYSINFO_TRIGGER_MICROS | Programmed cycle time in micro-seconds.
_SYSINFO_TRIGGER_MS | Programmed cycle time in milliseconds.
_SYSINFO_CYCLETIME_MICROS | Duration of the previous cycle in micro-seconds.
_SYSINFO_CYCLETIME_MS | Duration of the previous cycle in milliseconds.
_SYSINFO_CYCLEMAX_MICROS | Maximum detected cycle time in micro-seconds.
_SYSINFO_CYCLEMAX_MS | Maximum detected cycle time in milliseconds.
_SYSINFO_CYCLESTAMP_MS | Time stamp of the current cycle in milliseconds (OEM dependent).
_SYSINFO_CYCLEOVERFLOWS | Number of detected cycle time overflows.
_SYSINFO_CYCLECOUNT | Counter of cycles.
_SYSINFO_APPVERSION | Version number of the application.
_SYSINFO_APPSTAMP | Compiling date stamp of the application.
_SYSINFO_CODECRC | CRC of the application code.
_SYSINFO_DATACRC | CRC of the application symbols.
_SYSINFO_FREEHEAP | Available space in memory heap (bytes)
_SYSINFO_DBSIZE | Space used in RAM (bytes)
_SYSINFO_ELAPSED | Seconds elapsed since startup
_SYSINFO_CHANGE_CYCLE | Indicates a cycle just after an On Line Change
_SYSINFO_WARMSTART | Non zero if RETAIN variables were loaded at the last start
_SYSINFO_NBLOCKED | Number of locked variables
_SYSINFO_NBBREAKPOINTS | Number of installed breakpoints

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. In IL, the input must be loaded in the current result before calling the function.

ST Language

Q := GETSYSINFO (INFO);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD INFO
GETSYSINFO
ST Q


HYSTER

Programming languages - Reference guide -> Advanced operations -> HYSTER

Previous chapter Next chapter Show all Show all Hide all Hide all

Function Block - Hysteresis detection.

Inputs

XIN1 : REAL First input signal.
XIN2 : REAL Second input signal.
EPS : REAL Hysteresis.

Outputs

Q : BOOL Detected hysteresis: TRUE if XIN1 becomes greater than XIN2+EPS and is not yet below XIN2-EPS.

Remarks

The hysteresis is detected on the difference of XIN1 and XIN2 signals. In LD language, the input rung (EN) is used for enabling the block. The output rung is the Q output.

ST Language

MyHyst is a declared instance of HYSTER function block.

MyHyst (XIN1, XIN2, EPS);
Q := MyHyst.Q;

FBD Language

LD Language

The block is not called if EN is FALSE.

IL Language

MyHyst is a declared instance of HYSTER function block.

Op1: CAL MyHyst (XIN1, XIN2, EPS)
LD MyHyst.Q
ST Q

seealso See also

AVERAGE INTEGRAL DERIVATE LIM_ALRM STACKINT


HYSTERacc

Programming languages - Reference guide -> Advanced operations -> HYSTERacc

Previous chapter Next chapter Show all Show all Hide all Hide all

Function Block - Hysteresis with accumulation

Inputs

XIN : REAL Input signal.
EPS : REAL Hysteresis.
FACTOR : REAL See notes.

Outputs

XOUT : REAL Filtered output.

Remarks

This block calculates the error in between XIN and its previous updated value (the one currently visible on output). The output is updated with XIN value:

- if the error is greater than or equal to EPS

- or if the integral of the error multiplied by FACTOR is greater than or equal to EPS

The integral is to be understood since the last update.

ST Language

MyHyst is a declared instance of HYSTER function block.

MyHyst (rIn, rEps, rFactor);
rOUT := MyHyst.XOUT;


INTEGRAL

Programming languages - Reference guide -> Advanced operations -> INTEGRAL

Previous chapter Next chapter Show all Show all Hide all Hide all

Function Block - Calculates the integral of a signal.

Inputs

RUN : BOOL Run command: TRUE=integrate / FALSE=hold.
R1 : BOOL Overriding reset.
XIN : REAL Input signal.
X0 : REAL Initial value.
CYCLE : TIME Sampling period (should not be less than the target cycle timing).

Outputs

Q : DINT Running mode report: NOT (R1).
XOUT : REAL Output signal.

Remarks

In LD language, the input rung is the RUN command. The output rung is the Q report status.

ST Language

MyIntg is a declared instance of INTEGRAL function block.

MyIntg (RUN, R1, XIN, X0, CYCLE);
Q := MyIntg.Q;
XOUT := MyIntg.XOUT;

FBD Language

LD Language

IL Language

MyIntg is a declared instance of INTEGRAL function block.

Op1: CAL MyIntg (RUN, R1, XIN, X0, CYCLE)
LD MyIntg.Q
ST Q
LD MyIntg.XOUT
ST XOUT

seealso See also

AVERAGE DERIVATE LIM_ALRM HYSTER STACKINT


LIFO

Programming languages - Reference guide -> Advanced operations -> LIFO

Previous chapter Next chapter Show all Show all Hide all Hide all

Function block - Manages a last in / first out stack.

Inputs

PUSH : BOOL Push a new value (on rising edge).
POP : BOOL Pop a new value (on rising edge).
RST : BOOL Reset the list.
NEXTIN : ANY Value to be pushed.
NEXTOUT : ANY Value at the top of the stack - updated after call!
BUFFER : ANY Array for storing values.

Outputs

EMPTY : BOOL TRUE if the stack is empty.
OFLO : BOOL TRUE if overflow on a PUSH command.
COUNT : DINT Number of values in the stack.
PREAD : DINT Index in the buffer of the top of the stack.
PWRITE : DINT Index in the buffer of the next push position.

Remarks

NEXTIN, NEXTOUT and BUFFER must have the same data type and cannot be STRING.

The NEXTOUT argument specifies a variable that is filled with the value at the top of the stack after the block is called.

Values are stored in the BUFFER array. Data is never shifted or reset. Only read and write pointers and pushed values are updated. The maximum size of the stack is the dimension of the array.

The first time the block is called, it remembers on which array it should work. If you call later the same instance with another BUFFER input, the call is considered as invalid and makes nothing. Outputs reports an empty stack in this case.

In LD language, input rung is the PUSH input. The output rung is the EMPTY output.

ST Language

MyLIFO is a declared instance of LIFO function block.

MyLIFO (PUSH, POP, RST, NEXTIN, NEXTOUT, BUFFER);
EMPTY := MyLIFO.EMPTY;
OFLO := MyLIFO.OFLO;
COUNT := MyLIFO.COUNT;
PREAD := MyLIFO.PREAD;
PWRITE := MyLIFO.PWRITE;

FBD Language

LD Language

IL Language

MyLIFO is a declared instance of LIFO function block.

Op1: CAL MyLIFO (PUSH, POP, RST, NEXTIN, NEXTOUT, BUFFER)
LD MyLIFO.EMPTY
ST EMPTY
LD MyLIFO.OFLO
ST OFLO
LD MyLIFO.COUNT
ST COUNT
LD MyLIFO.PREAD
ST PREAD
LD MyLIFO.PWRITE
ST PWRITE

seealso See also

FIFO


LIM_ALRM

Programming languages - Reference guide -> Advanced operations -> LIM_ALRM

Previous chapter Next chapter Show all Show all Hide all Hide all

Function Block - Detects High and Low limits of a signal with hysteresis.

Inputs

H : REAL Value of the High limit.
X : REAL Input signal.
L : REAL Value of the Low limit.
EPS : REAL Value of the hysteresis.

Outputs

QH : BOOL TRUE if the signal exceeds the High limit.
Q : BOOL TRUE if the signal exceeds one of the limits (equals to QH OR QL).
QL : BOOL TRUE if the signal exceeds the Low limit.

Remarks

In LD language, the input rung (EN) is used for enabling the block. The output rung is the QH output.

ST Language

MyAlarm is a declared instance of LIM_ALRM function block.

MyAlarm (H, X, L, EPS);
QH := MyAlarm.QH;
Q := MyAlarm.Q;
QL := MyAlarm.QL;

FBD Language

LD Language

The block is not called if EN is FALSE.

IL Language

MyAlarm is a declared instance of LIM_ALRM function block.

Op1: CAL MyAlarm (H, X, L, EPS)
LD MyAlarm.QH
ST QH
LD MyAlarm.Q
ST Q
LD MyAlarm.QL
ST QL

seealso See also

ALARM_A ALARM_M


LogFileCSV

Programming languages - Reference guide -> Advanced operations -> LogFileCSV

Previous chapter Next chapter Show all Show all Hide all Hide all

Function block - Generate a log file in CSV format for a list of variables.

(see description for SetCsvOpt function at the end of this page)

Inputs

LOG : BOOL Variables are saved on any rising edge of this input.
RST : BOOL Reset the contents of the CSV file.
LIST : DINT ID of the list of variables to log (use VLID function).
PATH : STRING Pathname of the CSV file.

Outputs

Q : BOOL TRUE if the requested operation has been performed without error.
ERR : DINT Error report for the last requested operation (0 is OK).

attention Attention
  • File are opened and closed directly by the Operating System of the target. Opening some files may be dangerous for system safety and integrity. The number of open files may be limited by the target system.
  • Opening a file may be unsuccessful (invalid path or file name, too many open files...) Your application should process such error cases in a safe way.
  • File management may be not available on some targets. Please refer to OEM instructions for further details about available features.
  • Valid paths for storing files depend on the target implementation. Please refer to OEM instructions for further details about available paths.

Remarks

This function enables to log values of a list of variables in a CSV file. On each rising edge of the LOG input, one more line of values is added to the file. There is one column for each variable, as they are defined in the list.

The list of variables is prepared using the workbench or a text editor. Use the VLID function to get the identifier of the list.

On a rising edge of the RST command, the file is emptied.

The "SetCsvOpt" function described at the end of this page enables you to customize the format of the CSV file.

When a LOG or RST command is requested, the Q output is set to TRUE if successful. In case of error, a report is given in the ERR output. Possible error values are:

Value | Meaning
1 | Cannot reset file on a RST command.
2 | Cannot open file for data storing on a LOG command.
3 | Embedded lists are not supported by the runtime.
4 | Invalid list ID.
5 | Error while writing to file.

Combined with real time clock management functions, this block provides a very easy way to generate a periodical log file. The following example shows a list and a program that log values everyday at 14h23:

Example Example

Example

MyLOG is a declared instance of LogFileCSV function block.

MyLOG (LOG, RST, LIST, PATH);
Q := MyLOG.Q;
ERR := MyLog.ERR;

The SetCsvOpt function

As default, the LogFileCsv block uses semicolons (";") as separators and dots (".") as decimal points. The SetCsvOpt function enables you to change these characters.

Syntax:

OK := SetCsvOpt (strSeparator, strDecimal);

Parameters:

StrSeparator (STRING) : single character string to be used as separator

strDecimal (STRING) : single character string to be used as decimal point

OK (BOOL) : TRUE if successful. FALSE if inputs are not single character strings.

seealso See also

VLID


MBMasterRTU

Programming languages - Reference guide -> Advanced operations -> MBMasterRTU

Previous chapter Next chapter Show all Show all Hide all Hide all

Function Block - MODBUS-RTU Master.

This function block manages a master on MODBUS-RTU over a serial line and enables the management of various MODBUS functions. Function blocks MBMASTERTCP and MBMASTERRTU give an alternative to the MODBUS configurator. You do not need to configure anything in the fieldbus configurator to use these blocks.

Inputs

CNX : BOOL

A rising edge on this input to open the specified COM port. If the port is successfully open, the Ready output will be set to TRUE. If the opening fails, an error is reported by the Error output.

BREFRESH : BOOL

A rising edge on this input starts a new exchange such as specified by other paramerters. A exchange can be started only if the Ready output is TRUE.

SLAVE : DINT

Slave number (or unit number) of the MODBUS TCP server.

FCODE : DINT

MODBUS function code. The following functions are supported:

1 = Read coil bits

2 = Read input bits

3 = Read holding registers

4 = Read input registers

5 = Write one coil bit

6 = Write one holding registers

7 = Read exception status

15 = Write N coil bits

16 = Write N holding registers

17 = Report slave ID

23 = Read/write holding registers

ADDR : DINT

Address of the first address to read. Used only for functions 1, 2, 3, 4 and 23.

NBR : DINT

Number of items to read. Used only for functions 1, 2, 3, 4 and 23.

ADDW : DINT

Address of the first address to write. Used only for functions 5, 6, 15, 16 and 23.

NBW : DINT

Number of items to write. Used only for functions 5, 6, 15, 16 and 23. Must be 1 for functions 5 and 6.

DATA : ARRAY OF ...

Buffer containing the values read or written. Must be set on input before calling functions 5, 6, 15, 16 and 23. Filled on for other functions and also for function 23. The dimension of the array must be greater than or equal to the specified number of items. The data type of the array depends on the function:

BOOL for functions 1, 2, 5 and 15

INT or UINT or WORD for functions 3, 4, 6, 16 and 23

SINT or USINT or BYTE for functions 7 and 17.

TIMEOUT : TIME

Communication timeout for the complete exchange.

PORT : STRING

Specification of the COM port (e.g. 'COM1:9600,N,8,1'). Refer to OEM's instruction for more information about COM port specification.

Outputs

READY : BOOL

This output is TRUE when the connection is correctly established and no pending exchange is currently running.

OK : BOOL

This output is set to TRUE at the end of a successful exchange. It is reset to FALSE when a new exchange is started.

ERROR : DINT

Error report. Can be one of the following values:

1 = invalid function code
2 = bad address
3 = bad value
4 = server failed
5 = server acknoledge
6 = server is busy
8 = data parity error
10 = gateway bad path
11 = gateway target failed
128 = timeout on exchange
129 = bad CRC
130 = frame error or bad COM port
200 = invalid slave number
201 = invalid MODBUS address
202 = invalid number of items or DATA array too small
203 = invalid type for DATA array
204 = invalid numner of items

Note: some devices may answer some other specific error reports


MBMasterTCP

Programming languages - Reference guide -> Advanced operations -> MBMasterTCP

Previous chapter Next chapter Show all Show all Hide all Hide all

Function Block - MODBUS-TCP Master (client).

This function block manages a client connection on MODBUS-TCP and enables the management of various MODBUS functions. Function blocks MBMASTERTCP and MBMASTERRTU give an alternative to the MODBUS configurator. You do not need to configure anything in the fieldbus configurator to use these blocks.

Inputs

CNX : BOOL

A rising edge on this input establishes the connection with the specified server. Later on, if the connection is successful, the Ready output will be set to TRUE. If the connection fails, an error is reported by the Error output. After the connection is lost (typically when unplugging the Ethernet cable) the application is responsible for rising again the Cnx input in order to attempt a new connection.

BREFRESH : BOOL

A rising edge on this input starts a new exchange such as specified by other paramerters. A exchange can be started only if the Ready output is TRUE.

SLAVE : DINT

Slave number (or unit number) of the MODBUS TCP server.

FCODE : DINT

MODBUS function code. The following functions are supported:

1 = Read coil bits

2 = Read input bits

3 = Read holding registers

4 = Read input registers

5 = Write one coil bit

6 = Write one holding registers

7 = Read exception status

15 = Write N coil bits

16 = Write N holding registers

17 = Report slave ID

23 = Read/write holding registers

ADDR : DINT

Address of the first address to read. Used only for functions 1, 2, 3, 4 and 23.

NBR : DINT

Number of items to read. Used only for functions 1, 2, 3, 4 and 23.

ADDW : DINT

Address of the first address to write. Used only for functions 5, 6, 15, 16 and 23.

NBW : DINT

Number of items to write. Used only for functions 5, 6, 15, 16 and 23. Must be 1 for functions 5 and 6.

DATA : ARRAY OF ...

Buffer containing the values read or written. Must be set on input before calling functions 5, 6, 15, 16 and 23. Filled on for other functions and also for function 23. The dimension of the array must be greater than or equal to the specified number of items. The data type of the array depends on the function:

BOOL for functions 1, 2, 5 and 15

INT or UINT or WORD for functions 3, 4, 6, 16 and 23

SINT or USINT or BYTE for functions 7 and 17.

TIMEOUT : TIME

Communication timeout for the complete exchange.

IP : STRING

IP address of the MODBUS server.

PORT : DINT

TCP port number of the server (usually 502).

Outputs

READY : BOOL

This output is TRUE when the connection is correctly established and no pending exchange is currently running.

OK : BOOL

This output is set to TRUE at the end of a successful exchange. It is reset to FALSE when a new exchange is started.

ERROR : DINT

Error report. Can be one of the following values:

1 = invalid function code
2 = bad address
3 = bad value
4 = server failed
5 = server acknoledge
6 = server is busy
8 = data parity error
10 = gateway bad path
11 = gateway target failed
128 = timeout on exchange
129 = bad CRC
130 = ETHERNET/TCP error
200 = invalid slave number
201 = invalid MODBUS address
202 = invalid number of items or DATA array too small
203 = invalid type for DATA array
204 = invalid numner of items

Note: some devices may answer some other specific error reports


MBSlaveRTU / MBSlaveRTUex

Programming languages - Reference guide -> Advanced operations -> MBSlaveRTU / MBSlaveRTUex

Previous chapter Next chapter Show all Show all Hide all Hide all

Function Block - MODBUS RTU Slave protocol on serial port.

Inputs

IN : BOOL Enabling command: the port is open when this input is TRUE.
PORT : STRING Settings string for the serial port (e.g. 'COM1:9600,N,8,1').
SLV : DINT MODBUS slave number.
SrvID : STRING MBSlaveRTUex only: ID of the server in the configuration.

Outputs

Q : BOOL TRUE if the port is successfully open.

Remarks

When active, this function block manages the MODBUS RTU Slave protocol on the specified serial communication port. The configuration of the MODBUS Slave map (designing MODBUS addresses) is done using the MODBUS configuration tool, from the Fieldbus Configurator.

There can be several instances of the MBSlaveRTU working simultaneously on different serial ports. Other MODBUS Slave connections (TCP server, UDP) can also be active at the same time.

The slave number entered in the MODBUS Slave configuration tool is ignored when MODBUS Slave protocol is handled by this function block. Instead, the SLV input specifies the MODBUS slave number.

With MBSlaveRTUex, you can specify the ID of a server from the MODBUS slave configuration. If you specify an empty string, the first server is used. MBSlaveRTU always works with the first server in the configuration.

ST Language

MySlave is a declared instance of MBSlaveRTU function block.

MySlave (IN, PORT, SLV);
Q := MySlave.Q;

FBD Language

LD Language

IL Language

MySlave is a declared instance of MBSlaveRTU function block.

Op1: CAL MySlave (IN, PORT, SLV)
LD MySlave.Q
ST Q
LD MyCounter.CV
ST CV

seealso See also

MBSlaveUDP MODBUS configuration


MBSlaveUDP / MBSlaveUDPex

Programming languages - Reference guide -> Advanced operations -> MBSlaveUDP / MBSlaveUDPex

Previous chapter Next chapter Show all Show all Hide all Hide all

Function Block - MODBUS UDP Slave protocol on ETHERNET.

Inputs

IN : BOOL Enabling command: the port is open when this input is TRUE.
PORT : DINT ETHERNET port number.
SLV : DINT MODBUS slave number.
RTU : BOOL Protocol: TRUE = MODBUS RTU / FALSE = Open MODBUS.
SrvID : STRING MBSlaveUDPex only: ID of the server in the configuration.

Outputs

Q : BOOL TRUE if the port is successfully open.

Remarks

When active, this function block manages the MODBUS UDP Slave protocol on the specified ETHERNETport. The configuration of the MODBUS Slave map (designing MODBUS addresses) is done using the MODBUS configuration tool, from the Fieldbus Configurator.

There can be several instances of the MBSlaveUDP working simultaneously on different serial ports. Other MODBUS Slave connections (TCP server, serial) can also be active at the same time.

The slave number entered in the MODBUS Slave configuration tool is ignored when MODBUS Slave protocol is handled by this function block. Instead, the SLV input specifies the MODBUS slave number. If SLV is 0 then the default port number from the MODBUS configuration is used.

With MBSlaveUDPex, you can specify the ID of a server from the MODBUS slave configuration. If you specify an empty string, the first server is used. MBSlaveUDP always works with the first server in the configuration.

ST Language

MySlave is a declared instance of MBSlaveUDP function block.

MySlave (IN, PORT, SLV, RTU);
Q := MySlave.Q;

FBD Language

LD Language

IL Language

MySlave is a declared instance of MBSlaveUDP function block.

Op1: CAL MySlave (IN, PORT, SLV, RTU)
LD MySlave.Q
ST Q
LD MyCounter.CV
ST CV

seealso See also

MBSlaveRTU MODBUS configuration


PID

Programming languages - Reference guide -> Advanced operations -> PID

Previous chapter Next chapter Show all Show all Hide all Hide all

Function Block - PID loop.

Input | Type | Description
AUTO | BOOL | TRUE = normal mode - FALSE = manual mode.
PV | REAL | Process value.
SP | REAL | Set point.
Xout_Manu | REAL | Output value in manual mode.
KP | REAL | Gain.
TI | REAL | Integration factor.
TD | REAL | Derivation factor.
TS | TIME | Sampling period.
XMIN | REAL | Minimum allowed output value.
XMAX | REAL | Maximum output value.
I_SEL | BOOL | If FALSE, the integrated value is ignored.
INT_HOLD | BOOL | If TRUE, the integrated value is frozen.
I_ITL_ON | BOOL | If TRUE, the integrated value is reset to I_ITLVAL.
I_ITLVAL | REAL | Reset value for integration when I_ITL_ON is TRUE.
DEADB_ERR | REAL | Hysteresis on PV. PV will be considered as unchanged if greater than (PVprev - DEADBAND_W) and less that (PRprev + DEADBAND_W).
FFD | REAL | Disturbance value on output.

Output | Type | Description
Xout | REAL | Output command value.
ER | REAL | Last calculated error.
Xout_P | REAL | Last calculated proportional value.
Xout_I | REAL | Last calculated integrated value.
Xout_D | REAL | Last calculated derivated value.
Xout_HLM | BOOL | TRUE if the output valie is saturated to XMIN.
Xout_LLM | BOOL | TRUE if the output value is saturated to XMAX.

Diagram

Remarks

It is important for the stability of the control that the TS sampling period is much bigger than the cycle time.

In LD language, the output rung has the same value as the AUTO input, corresponding to the input rung.

ST Language

MyPID is a declared instance of PID function block.

MyPID (AUTO, PV, SP, XOUT_MANU, KP, TI, TD, TS, XMIN, XMAX,
I_SEL, I_ITL_ON, I_ITLVAL, DEADB_ERR, FFD);
XOUT := MyPID.XOUT;
ER := MyPID.ER;
XOUT_P := MyPID.XOUT_P;
XOUT_I := MyPID.XOUT_I;
XOUT_D := MyPID.XOUT_D;
XOUT_HLM := MyPID.XOUT_HLM;
XOUT_LLM := MyPID.XOUT_LLM;

FBD Language

LD Language

ENO has the same state as the input rung.

IL Language

MyPID is a declared instance of PID function block.

Op1: CAL MyPID (AUTO, PV, SP, XOUT_MANU, KP, TI, TD, TS,
XMIN, XMAX, I_SEL, I_ITL_ON, I_ITLVAL,
DEADB_ERR, FFD)
LD MyPID.XOUT
ST XOUT
LD MyPID.ER
ST ER
LD MyPID.XOUT_P
ST XOUT_P
LD MyPID.XOUT_I
ST XOUT_I
LD MyPID.XOUT_D
ST XOUT_D
LD MyPID.XOUT_HLM
ST XOUT_HLM
LD MyPID.XOUT_LLM
ST XOUT_LLM


printf

Programming languages - Reference guide -> Advanced operations -> printf

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Display a trace output.

Inputs

FMT : STRING Trace message.
ARG1..ARG4 : DINT Numerical arguments to be included in the trace.

Outputs

Q : BOOL Return check.

Remarks

This function works as the famous "printf" function of the "C" language, with up to 4 integer arguments. You can use the following pragmas in the FMT trace message to represent the arguments according to their left to the right order:

%ld signed value in decimal
%lu unsigned value in decimal
%lx value in hexadecimal

The trace message is displayed in the LOG window with runtime messages. Trace is supported by the simulator.

attention Attention

Your target platform may not support trace functions. Please refer to OEM instructions for further details on available features.

Example Example

(* i1, i2, i3, i4 are declared as DINT *)
i1 := 1;
i2 := 2;
i3 := 3;
i4 := 4;
printf ('i1=%ld; i2=%ld; i3=%ld; i4=%ld', i1, i2, i3, i4);

Output message:

i1=1; i2=2; i3=3; i4=4;


RAMP

Programming languages - Reference guide -> Advanced operations -> RAMP

Previous chapter Next chapter Show all Show all Hide all Hide all

Function block - Limit the ascendance or descendance of a signal.

Inputs

IN : REAL Input signal.
ASC : REAL Maximum ascendance during time base.
DSC : REAL Maximum descendance during time base.
TM : TIME Time base.
RST : BOOL Reset.

Outputs

OUT : REAL Ramp signal.

Time diagram

Remarks

Parameters are not updated constantly. They are taken into account when only:

  • The first time the block is called.
  • When the reset input (RST) is TRUE.

In these two situations, the output is set to the value of IN input.

ASC and DSC give the maximum ascendant and descendant growth during the TB time base.
Both must be expressed as positive numbers.

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung.

ST Language

MyRamp is a declared instance of RAMP function block.

MyRamp (IN, ASC, DSC, TM, RST);
OUT := MyRamp.OUT;

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

MyRamp is a declared instance of RAMP function block.

Op1: CAL MyRamp (IN, ASC, DSC, TM, RST)
LD MyBlinker.OUT
ST OUT


Real Time Clock management functions

Programming languages - Reference guide -> Advanced operations -> Real Time Clock management functions

Previous chapter Next chapter Show all Show all Hide all Hide all

The following functions read the real time clock of the target system:

DTCurDate Get current date stamp.
DTCurTime Get current time stamp.
DTCurDateTime Get current date and time stamp.
DTDay Get day from date stamp.
DTMonth Get month from date stamp.
DTYear Get year from date stamp.
DTSec Get seconds from time stamp.
DTMin Get minutes from time stamp.
DTHour Get hours from time stamp.
DTMs Get milliseconds from time stamp.

The following functions format the current date/time to a string:

DAY_TIME With predefined format.
DTFORMAT With custom format.

The following functions are used for triggering operations:

DTAt Pulse signal at the given date/time.
DTEvery Pulse signal with long period.

attention Attention

Real Time clock may be not available on some targets. Please refer to OEM instructions for further details about available features.

DAY_TIME: get current date or time

Q := DAY_TIME (SEL);

SEL : DINT specifies the wished information (see below).
Q : STRING wished information formatted on a string.

Possible values of SEL input:

Value | Description
1 | current time - format: 'HH:MM:SS'.
2 | day of the week.
0 (default) | current date - format: 'YYYY/MM/DD'.

DTCURDATE: get current date stamp

Q := DTCurDate ();

Q : DINT numerical stamp representing the current date.

DTCURTIME: get current time stamp

Q := DTCurTime ();

Q : DINT numerical stamp representing the current time of the day.

DTCURDATETIME: get current time stamp (function block)

Inst_DTCurDateTime (bLocal);

bLocal : BOOL TRUE if local time is requested (GMT if FALSE).

.Year : DINT Output: current year

.Month : DINT Output: current month

.Day : DINT Output: current day

.Hour : DINT Output: current time: hours

.Min : DINT Output: current time: minutes

.Sec : DINT Output: current time: seconds

.MSec : DINT Output: current time: milliseconds

.TmOfDay : TIME Output: current time of day (since midnight)

.DST : BOOL Output: TRUE if Daylight Saving Time is active

DTYEAR: extract the year from a date stamp

Q := DTYear (iDate);

IDATE : DINT numerical stamp representing a date.
Q : DINT year of the date (ex: 2004).

DTMONTH: extract the month from a date stamp

Q := DTMonth (iDate);

IDATE : DINT numerical stamp representing a date.
Q : DINT month of the date (1..12).

DTDAY: extract the day of the month from a date stamp

Q := DTDay (iDate);

IDATE : DINT numerical stamp representing a date.
Q : DINT day of the month of the date (1..31).

DTHOUR: extract the hours from a time stamp

Q := DTHour (iTime);

ITIME : DINT numerical stamp representing a time.
Q : DINT Hours of the time (0..23).

DTMIN: extract the minutes from a time stamp

Q := DTMin (iTime);

ITIME : DINT numerical stamp representing a time.
Q : DINT Minutes of the time (0..59).

DTSEC: extract the seconds from a time stamp

Q := DTSec (iTime);

ITIME : DINT numerical stamp representing a time.
Q : DINT Seconds of the time (0..59).

DTMS: extract the milliseconds from a time stamp

Q := DTMs (iTime);

ITIME : DINT numerical stamp representing a time.
Q : DINT Milliseconds of the time (0..999).

In this section

DAY_TIME

DTFORMAT

DTAT

DTEVERY


DAY_TIME

Programming languages - Reference guide -> Advanced operations -> Real Time Clock management functions -> DAY_TIME

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Format the current date/time to a string.

Inputs

SEL : DINT Format selector.

Outputs

Q : STRING String containing formatted date or time.

attention Attention

Real Time clock may be not available on some targets. Please refer to OEM instructions for further details about available features.

Remarks

Possible values of the SEL input are:

Value | Meaning
1 | current time - format: 'HH:MM:SS'.
2 | day of the week.
0 (default) | current date - format: 'YYYY/MM/DD'.

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung.

ST Language

Q := DAY_TIME (SEL);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD SEL
DAY_TIME
ST Q

seealso See also

DTFORMAT


DTFORMAT

Programming languages - Reference guide -> Advanced operations -> Real Time Clock management functions -> DTFORMAT

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Format the current date/time to a string with a custom format.

Inputs

FMT : STRING Format string.

Outputs

Q : STRING String containing formatted date or time.

attention Attention

Real Time clock may be not available on some targets. Please refer to OEM instructions for further details about available features.

Remarks

The format string may contain any character. Some special markers beginning with the '%' character indicates a date/time information:

%Y Year including century (e.g. 2006)
%y Year without century (e.g. 06)
%m Month (1..12)
%d Day of the month (1..31)
%H Hours (0..23)
%M Minutes (0..59)
%S Seconds (0..59)

Example Example

(* let's say we are at July 04th 2006, 18:45:20 *)

Q := DTFORMAT ('Today is %Y/%m/%d - %H:%M:%S');

(* Q is 'Today is 2006/07/04 - 18:45:20 *)

ST Language

Q := DTFORMAT (FMT);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Op1: LD FMT
DTFORMAT
ST Q

seealso See also

DAY_TIME


DTAT

Programming languages - Reference guide -> Advanced operations -> Real Time Clock management functions -> DTAT

Previous chapter Next chapter Show all Show all Hide all Hide all

Function Block - Generate a pulse at given date and time

Inputs

YEAR : DINT Wished year (e.g. 2006).
MONTH : DINT Wished month (1 = January).
DAY : DINT Wished day (1 to 31).
TMOFDAY : TIME Wished time.
RST : BOOL Reset command.

Outputs

QAT : BOOL Pulse signal.
QPAST : BOOL TRUE if elapsed.

attention Attention

Real Time clock may be not available on some targets. Please refer to OEM instructions for further details about available features.

Remarks

Parameters are not updated constantly. They are taken into account when only:

  • the first time the block is called.
  • when the reset input (RST) is TRUE.

In these two situations, the outputs are reset to FALSE.

The first time the block is called with RST=FALSE and the specified date/stamp is passed, the output QPAST is set to TRUE, and the output QAT is set to TRUE for one cycle only (pulse signal).

Highest units are ignored if set to 0. For instance, if arguments are year=0, month=0, day = 3, tmofday=t#10h then the block will trigger on the next 3rd day of the month at 10h.

In LD language, the block is activated only if the input rung is TRUE.

ST Language

MyDTAT is a declared instance of DTAT function block.

MyDTAT (YEAR, MONTH, DAY, TMOFDAY, RST);
QAT := MyDTAT.QAT;
QPAST := MyDTATA.QPAST;

FBD Language

LD Language

Called only if EN is TRUE.

IL Language

MyDTAT is a declared instance of DTAT function block.

Op1: CAL MyDTAT (YEAR, MONTH, DAY, TMOFDAY, RST)
LD MyDTAT.QAT
ST QAT
LD MyDTATA.QPAST
ST QPAST

seealso See also

DTEVERY Real time clock functions.


DTEVERY

Programming languages - Reference guide -> Advanced operations -> Real Time Clock management functions -> DTEVERY

Previous chapter Next chapter Show all Show all Hide all Hide all

Function Block - Generate a pulse signal with long period.

Inputs

RUN : DINT Enabling command.
DAYS : DINT Period : number of days.
TM : TIME Rest of the period (if not a multiple of 24h).

Outputs

Q : BOOL Pulse signal.

Remarks

This block provides a pulse signal with a period of more than 24h. The period is expressed as:

DAYS * 24h + TM

For instance, specifying DAYS=1 and TM=6h means a period of 30 hours.

ST Language

MyDTEVERY is a declared instance of DTEVERY function block.

MyDTEVERY (RUN, DAYS, TM);
Q := MyDTEVERY.Q;

FBD Language

LD Language

IL Language

MyDTEVERY is a declared instance of DTEVERY function block.

Op1: CAL MyDTEVERY (RUN, DAYS, TM)
LD MyDTEVERY.Q
ST Q

seealso See also

DTAT Real time clock functions


SerializeIn

Programming languages - Reference guide -> Advanced operations -> SerializeIn

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Extract the value of a variable from a binary frame.

Inputs

FRAME : USINT Source buffer - must be an array.
DATA : ANY(*) Destination variable to be copied.
POS : DINT Position in the source buffer.
BIGENDIAN : BOOL TRUE if the frame is encoded with Big Endian format.

(*) DATA cannot be a STRING.

Outputs

NEXTPOS : DINT Position in the source buffer after the extracted data.
0 in case or error (invalid position / buffer size).

Remarks

This function is commonly used for extracting data from a communication frame in binary format.

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. This function is not available in IL language.

The FRAME input must fit the input position and data size. If the value cannot be safely extracted, the function returns 0.

The DATA input must be directly connected to a variable, and cannot be a constant or complex expression. This variable will be forced with the extracted value.

The function extracts the following number of bytes from the source frame:

1 byte for BOOL, SINT, USINT and BYTE variables
2 bytes for INT, UINT and WORD variables
4 bytes for DINT, UDINT, DWORD and REAL variables
8 bytes for LINT and LREAL variables

The function cannot be used to serialize STRING variables.

The function returns the position in the source frame, after the extracted data. Thus the return value can be used as a position for the next serialization.

ST Language

Q := SERIALIZEIN (FRAME, DATA, POS, BIGENDIAN);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Not available.

seealso See also

SERIALIZEOUT


SerializeOut

Programming languages - Reference guide -> Advanced operations -> SerializeOut

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Copy the value of a variable to a binary frame.

Inputs

FRAME : USINT Destination buffer - must be an array.
DATA : ANY(*) Source variable to be copied.
POS : DINT Position in the destination buffer.
BIGENDIAN : BOOL TRUE if the frame is encoded with Big Endian format.

(*) DATA cannot be a STRING.

Outputs

NEXTPOS : DINT Position in the destination buffer after the copied data.
0 in case or error (invalid position / buffer size).

Remarks

This function is commonly used for building a communication frame in binary format.

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. This function is not available in IL language.

The FRAME input must be an array large enough to receive the data. If the data cannot be safely copied to the destination buffer, the function returns 0.

The function copies the following number of bytes to the destination frame:

1 byte for BOOL, SINT, USINT and BYTE variables
2 bytes for INT, UINT and WORD variables
4 bytes for DINT, UDINT, DWORD and REAL variables
8 bytes for LINT and LREAL variables

The function cannot be used to serialize STRING variables.

The function returns the position in the destination frame, after the copied data. Thus the return value can be used as a position for the next serialization.

ST Language

Q := SERIALIZEOUT (FRAME, DATA, POS, BIGENDIAN);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Not available.

seealso See also

SERIALIZEIN


SerGetString

Programming languages - Reference guide -> Advanced operations -> SerGetString

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Extract a string from a binary frame.

Inputs

FRAME : USINT Source buffer - must be an array.
DST : STRING Destination variable to be copied.
POS : DINT Position in the source buffer.
MAXLEN : DINT Specifies a fixed length string.
EOS : BOOL Specifies a null terminated string.
HEAD : BOOL Specifies a string headed with its length.

Outputs

NEXTPOS : DINT Position in the source buffer after the extracted data.
0 in case or error (invalid position / buffer size)

Remarks

This function is commonly used for extracting data from a communication frame in binary format.

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. This function is not available in IL language.

The FRAME input must fit the input position and data size. If the value cannot be safely extracted, the function returns 0.

The DST input must be directly connected to a variable, and cannot be a constant or complex expression. This variable will be forced with the extracted value.

The function extracts the following bytes from the source frame:

MAXLEN | EOS | HEAD | Description
<> 0 | any | any | The string is stored on a fixed length specified by MAXLEN. If the string is actually smaller, the space is completed with null bytes.
= 0 | TRUE | any | The string is stored with its actual length and terminated by anull byte.
= 0 | FALSE | TRUE | The string is stored with its actual length and preceded by its length stored on one byte
=0 | FALSE | FALSE | invalid call

The function returns the position in the source frame, after the extracted data. Thus the return value can be used as a position for the next serialization.

ST Language

Q := SerGetString (FRAME, DSR, POS, MAXLEN, EOS, HEAD);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Not available.


SerPutString

Programming languages - Reference guide -> Advanced operations -> SerPutString

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Copies a string to a binary frame

Inputs

FRAME : USINT Destination buffer - must be an array.
DST : STRING Source variable to be copied.
POS : DINT Position in the source buffer.
MAXLEN : DINT Specifies a fixed length string.
EOS : BOOL Specifies a null terminated string.
HEAD : BOOL Specifies a string headed with its length.

Outputs

NEXTPOS : DINT Position in the destination buffer after the copied data.
0 in case or error (invalid position / buffer size)

Remarks

This function is commonly used for storing data to a communication frame.

In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung. This function is not available in IL language.

The FRAME input must fit the input position and data size. If the value cannot be safely copied, the function returns 0.

The function copies the following bytes to the frame:

MAXLEN | EOS | HEAD | Description
<> 0 | any | any | The string is stored on a fixed length specified by MAXLEN. If the string is actually smaller, the space is completed with null bytes. If the string is longer, it is truncated.
= 0 | TRUE | any | The string is stored with its actual length and terminated by anull byte.
= 0 | FALSE | TRUE | The string is stored with its actual length and preceded by its length stored on one byte.
=0 | FALSE | FALSE | invalid call

The function returns the position in the source frame, after the stored data. Thus the return value can be used as a position for the next serialization.

ST Language

Q := SerPutString (FRAME, DSR, POS, MAXLEN, EOS, HEAD);

FBD Language

LD Language

The function is executed only if EN is TRUE.
ENO keeps the same value as EN.

IL Language

Not available.


SERIO

Programming languages - Reference guide -> Advanced operations -> SERIO

Previous chapter Next chapter Show all Show all Hide all Hide all

Function Block - Serial communication.

Inputs

RUN : BOOL Enable communication (opens the comm port).
SND : BOOL TRUE if data has to be sent.
CONF : STRING Configuration of the communication port.
DATASND : STRING Data to send.

Outputs

OPEN : BOOL TRUE if the communication port is open.
RCV : BOOL TRUE if data has been received.
ERR : BOOL TRUE if error detected during sending data.
DATARCV : STRING Received data.

Remarks

The RUN input does not include an edge detection. The block tries to open the port on each call if RUN is TRUE and if the port is still not successfully open. The CONF input is used for settings when opening the port. Please refer to your OEM instructions for further details about possible parameters.

The SND input does not include an edge detection. Characters are sent on each call if SND is TRUE and DATASND is not empty.

The DATARCV string is erased on each cycle with received data (if any). Your application is responsible for checking or storing received character immediately after the call to SERIO block.

SERIO is available during simulation. In that case, the CONF input defines the communication port according to the syntax of the MODE command. For example:

'COM1:9600,N,8,1'

The SERIO block may not be supported on some targets. Refer to your OEM instructions for further details.

ST Language

MySer is a declared instance of SERIO function block.

MySer (RUN, SND, CONF, DATASND);
OPEN := MySer.OPEN;
RCV := MySer.RCV;
ERR := MySer.ERR;
DATARCV := MySer.DATARCV;

FBD Language

LD Language

IL Language

MySer is a declared instance of SERIO function block.

Op1: CAL MySer (RUN, SND, CONF, DATASND)
LD MySer.OPEN
ST OPEN
LD MySer.RCV
ST RCV
LD MySer.ERR
ST ERR
LD MySer.DATARCV
ST DATARCV


SERIO_B

Programming languages - Reference guide -> Advanced operations -> SERIO_B

Previous chapter Next chapter Show all Show all Hide all Hide all

Function Block - Serial communication - using arrays of bytes.

Inputs

RUN : BOOL Enable communication (opens the comm port).
CONF : STRING Configuration of the communication port.
DATASND : USINT Data to send - must be an array of bytes.
IXSND : DINT Index of the first byte to send in DATASND array.
MAXSND : DINT Number of bytes to send - see remarks.
DATARCV : USINT Array of bytes where to store received data.
IXRCV : DINT Index in DATASND array where to copy the first byte received.
MAXRCV : DINT Maximum number of bytes to receive - see remarks.

Outputs

OPEN : BOOL TRUE if the communication port is open.
NSND : DINT Number of bytes sent
NRCV : DINT Number of bytes received.

Remarks

The RUN input does not include an edge detection. The block tries to open the port on each call if RUN is TRUE and if the port is still not successfully open. The CONF input is used for settings when opening the port. Please refer to your OEM instructions for further details about possible parameters.

On every call to the SERIO_B block, the following operations are performed:

- try to send MAXSND characters from the DATASND array, starting at the IXSND index. The NSND output contains the number of bytes actually sent during the call. It can be less than the specified MAXSND value in case system buffers are full.

- pump received characters and store them, in the DATARCV array, starting at the IXRCV index and not exceeding MAXRCV. The NRCV output contains the number of bytes actually received during the call.

The SERIO_B works asynchronously. The physical sending and receiving of characters is performed as a background by system drivers. The block simply exchange data with the FIFOs of the system drivers.


SigID

Programming languages - Reference guide -> Advanced operations -> SigID

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Get the identifier of a Signal resource.

Inputs

SIGNAL : STRING Name of the signal resource - must be a constant value!
COL : STRING Name of the column within the signal resource - must be a constant value!

Outputs

ID : DINT ID of the signal - to be passed to other blocks.

Remarks

Some blocks have arguments that refer to a signal resource. For all these blocks, the signal argument is materialized by a numerical identifier. This function enables you to get the identifier of a signal defined as a resource.

ST Language

ID := SigID ('MySignal', 'FirstColumn');

FBD Language

LD Language

IL Language

Op1: LD 'MySignal'
SigID 'FirstColumn'
ST ID

seealso See also

SigPlay SigScale Signal resources


SigPlay

Programming languages - Reference guide -> Advanced operations -> SigPlay

Previous chapter Next chapter Show all Show all Hide all Hide all

Function block - Generate a signal defined in a resource.

Inputs

IN : BOOL Triggering command.
ID : DINT ID of the signal resource, provided by SigID function.
RST : BOOL Reset command.
TM : TIME Minimum duration in between two changes of the output.

Outputs

Q : BOOL TRUE when the signal is finished.
OUT : REAL Generated signal.
ET : TIME Elapsed time.

Remarks

The ID argument is the identifier of the signal resource. Use the SigID function to get this value.

The IN argument is used as a Play / Pause command to play the signal. The signal is not reset to the beginning when IN becomes FALSE. Instead, use the RST input that resets the signal and forces the OUT output to 0.

The TM input specifies the minimum amount of time in between two changes of the output signal. This parameter is ignored if less than the cycle scan time.

This function block includes its own timer. Alternatively, you can use the SigScale function if you want to trigger the signal using a specific timer.

ST Language

MySig is a declared instance of SIGPLAY function block.

MySig (II, ID, RST, TM);
Q := MySig.Q;
OUT := MySig.OUT;
ET := MySig.ET;

FBD Language

LD Language

IL Language

MySig is a declared instance of SIGPLAY function block.

Op1: CAL MySig (II, ID, RST, TM)
LD MySig.Q
ST Q
LD MySig.OUT
ST OUT
LD MySig.ET
ST ET

seealso See also

SigScale SigID Signal resources


SigScale

Programming languages - Reference guide -> Advanced operations -> SigScale

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Get a point from a Signal resource.

Inputs

ID : DINT ID of the signal resource, provided by SigID function.
IN : TIME Time (X) coordinate of the wished point within the signal resource.

Outputs

Q : REAL Value (Y) coordinate of the point in the signal.

Remarks

The ID argument is the identifier of the signal resource. Use the SigID function to get this value.

This function converts a time value to a analog value such as defined in the signal resource. This function can be used instead of SigPlay function block if you want to trigger the signal using a specific timer.

ST Language

Q := SigScale (ID, IN);

FBD Language

LD Language

IL Language

Op1: LD IN
SigScale ID
ST Q

seealso See also

SigPlay SigID Signal resources


STACKINT

Programming languages - Reference guide -> Advanced operations -> STACKINT

Previous chapter Next chapter Show all Show all Hide all Hide all

Function Block - Manages a stack of DINT integers.

Inputs

PUSH : BOOL Command: when changing from FALSE to TRUE, the value of IN is pushed on the stack.
POP : BOOL Pop command: when changing from FALSE to TRUE, deletes the top of the stack.
R1 : BOOL Reset command: if TRUE, the stack is emptied and its size is set to N.
IN : DINT Value to be pushed on a rising pulse of PUSH.
N : DINT maximum stack size - cannot exceed 128.

Outputs

EMPTY : BOOL TRUE if the stack is empty.
OFLO : BOOL TRUE if the stack is full.
OUT : DINT value at the top of the stack.

Remarks

Push and pop operations are performed on rising pulse of PUSH and POP inputs. In LD language, the input rung is the PUSH command. The output rung is the EMPTY output.

The specified size (N) is taken into account only when the R1 (reset) input is TRUE.

ST Language

MyStack is a declared instance of STACKINT function block.

MyStack (PUSH, POP, R1, IN, N);
EMPTY := MyStack.EMPTY;
OFLO := MyStack.OFLO;
OUT := MyStack.OUT;

FBD Language

LD Language

IL Language

MyStack is a declared instance of STACKINT function block.

Op1: CAL MyStack (PUSH, POP, R1, IN, N)
LD MyStack.EMPTY
ST EMPTY
LD MyStack.OFLO
ST OFLO
LD MyStack.OUT
ST OUT

seealso See also

AVERAGE INTEGRAL DERIVATE LIM_ALRM HYSTER


SurfLin

Programming languages - Reference guide -> Advanced operations -> SurfLin

Previous chapter Next chapter Show all Show all Hide all Hide all

Function Block - Linear interpolation on a surface.

Inputs

X : REAL X coordinate of the point to be interpolated.

Y : REAL Y coordinate of the point to be interpolated.

XAxis : REAL[] X coordinates of the known points of the X axis.

YAxis : REAL[] Y coordinates of the known points of the Y axis.

ZVal : REAL[,] Z coordinate of the points defined by the axis.

Outputs

Z : REAL Interpolated Z value corresponding to the X,Y input point

OK : BOOL TRUE if successful.

ERR : DINT Error code if failed - 0 if OK.

Remarks

This function performs linear surface interpolation in between a list of points defined in XAxis and YAxis single dimension arrays. The output Z value is an interpolation of the Z values of the four rounding points defined in the axis. Z values of defined points are passed in the ZVal matrix (two dimension array).

ZVal dimensions must be understood as: ZVal [ iX , iY ]

Values in X and Y axis must be sorted from the smallest to the biggest. There must be at least two points defined in each axis. ZVal must fit the dimension of XAxis and YAxis arrays. For instance:

XAxis : ARRAY [0..2] of REAL;

YAxis : ARRAY [0.3] of REAL;

ZVal : ARRAY [0..2,0..3] of REAL;

In case the input point is outside the rectangle defined by XAxis and YAxis limits, the Z output is bound to the corresponding value and an error is reported.

The ERR output gives the cause of the error if the function fails:

Error code | Meaning
0 | OK
1 | Invalid dimension of input arrays
2 | Invalid points for the X axis
3 | Invalid points for the Y axis
4 | X,Y point is out of the defined axis


TCP-IP Management functions

Programming languages - Reference guide -> Advanced operations -> TCP-IP Management functions

Previous chapter Next chapter Show all Show all Hide all Hide all

The following functions enable management of TCP-IP sockets for building client or server applications over ETHERNET network:

tcpListen create a listening server socket.
tcpAccept accept client connections.
tcpConnect create a client socket and connect it to a server.
tcpIsConnected test if a client socket is connected.
tcpClose close a socket.
tcpSend send characters.
tcpReceive receive characters.
tcpIsValid test if a socket is valid.

Each socket is identified in the application by a unique handle manipulated as a DINT value.

attention Attention
  • Although the system provides a simplified interface, you must be familiar with the socket interface such as existing in other programming languages such as "C".
  • Socket management may be not available on some targets. Please refer to OEM instructions for further details about available features.

tcpListen: create a listening server socket

SOCK := tcpListen (PORT, MAXCNX);

PORT : DINT TCP port number to be attached to the server socket.
MAXCNX : DINT maximum number of client sockets that can be accepted.
SOCK : DINT ID of the new server socket.

This functions creates a new socket performs the bind and listen operations using default TCP settings. You will have to call the tcpClose function to release the socket returned by this function.

tcpAccept: accept a new client connection

SOCK := tcpAccept (LSOCK);

LSOCK : DINT ID of a server socket returned by the tcpListen function.
SOCK : DINT ID of a new client socket accepted, or invalid ID if no new connection.

This functions performs the accept operation using default TCP settings. You will have to call the tcpClose function to release the socket returned by this function.

tcpConnect: create a client socket and connect it to a server

SOCK := tcpConnect (ADDRESS, PORT);

ADDRESS : STRING IP address of the remote server.
PORT : DINT wished port number on the server.
SOCK : DINT ID of the new client socket.

This functions creates a new socket performs the connect operation using default TCP settings and specified server address and port. You will have to call the tcpClose function to release the socket returned by this function.

attention Attention

It is possible that the functions returns a valid socket ID even if the connection to the server is not yet actually performed. After calling this function, you must call tcpIsConnected function to know if the connection is ready.

tcpIsConnected: test if a client socket is connected

OK := tcpIsConnected (SOCK);

SOCK : DINT ID of the client socket.
OK : BOOL TRUE if connection is correctly established.

attention Attention

It is possible that the socket becomes invalid after this function is called, if an error occurs in the TCP connection. You must call the tcpIsValid function after calling this function. If the socket is not valid anymore then you must close it by calling tcpClose.

tcpClose: release a socket

OK := tcpClose (SOCK);

SOCK : DINT ID of any socket.
OK : BOOL TRUE if successful.

You are responsible for closing any socket created by tcpListen, tcpAccept or tcpConnect functions, even if they have become invalid.

tcpSend: send characters

NBSENT := tcpSend (SOCK, NBCHR, DATA);

SOCK : DINT ID of a socket.
NBCHAR : DINT number of characters to be sent.
DATA : STRING string containing characters to send.
NBSENT : DINT number of characters actually sent.

It is possible that the number of characters actually sent is less than the number expected. In that case, you will have to call again the function on the next cycle to send the pending characters.

attention Attention

It is possible that the socket becomes invalid after this function is called, if an error occurs in the TCP connection. You must call the tcpIsValid function after calling this function. If the socket is not valid anymore then you must close it by calling tcpClose.

tcpReceive: receive characters

NBRCV := tcpReceive (SOCK, MAXCHR, DATA);

SOCK : DINT ID of a socket.
MAXCHR : DINT maximum number of characters wished.
DATA : STRING string where to store received characters.
NBRCV : DINT number of characters actually received.

It is possible that the number of characters actually received is less than the number expected. In that case, you will have to call again the function on te next cycle to receive the pending characters.

attention Attention

It is possible that the socket becomes invalid after this function is called, if an error occurs in the TCP connection. You must call the tcpIsValid function after calling this function. If the socket is not valid anymore then you must close it by calling tcpClose.

tcpIsValid: test if a socket is valid

OK := tcpIsValid (SOCK);

SOCK : DINT ID of the socket.
OK : BOOL TRUE if specified socket is still valid.


Text buffers manipulation

Programming languages - Reference guide -> Advanced operations -> Text buffers manipulation

Previous chapter Next chapter Show all Show all Hide all Hide all

Strings are limited to 255 characters. Here is a set of functions and function blocks for working with not limited text buffers. Text buffers are dynamically allocated or re-allocated.

attention Attention
  • Text buffers management functions use safe dynamic memory allocation that needs to be configured in the project settings. From the project settings, press the "Advanced" push button and go to "Memory" tab. Here you can setup the memory for safe dynamic allocation.
  • There must be one instance of the TxbManager declared in your application for using these functions.
  • The application should take care of releasing memory allocated for each buffer. Allocating buffers without freing them will lead to memory leaks.

The application is responsible for freeing all allocated text buffers. However, all allocated buffers are automatically released when the application stops.

Memory management / Miscellaneous

TxbManager: Main gatherer of text buffer data in memory.

TxbLastError: Get detailed error report about last call.

Allocation / exchange with files

TxbNew: Allocate a new empty buffer.

TxbNewString: Allocate a new buffer initialized with string.

TxbFree: Release a text buffer.

TxbReadFile: Allocate a new buffer from file.

TxbWriteFile: Store a text buffer to file.

Data exchange

TxbGetLength: Get length of a text buffer.

TxbGetData: Store text contents to an array of characters.

TxbGetString: Store text contents to a string.

TxbSetData: Store an array of characters to a text buffer.

TxbSetString: Store string to text buffer.

TxbClear: Empty a text buffer.

TxbCopy: Copy a text buffer.

Sequential reading

TxbRewind: Rewind sequential reading.

TxbGetLine: Sequential read line by line.

Sequential writing

TxbAppend: Append variable value.

TxbAppendLine: Append a text line.

TxbAppendEol: Append end of line characters.

TxbAppendTxb: Append contents of another buffer.

UNICODE conversions

TxbAnsiToUtf8: Convert a text buffer to UNICODE.

TxbUtf8ToAnsi: Convert a text buffer to ANSI.

In this section

Memory management / Miscellaneous

Allocation / exchange with files

Data exchange

Sequential reading

Sequential writing

UNICODE conversions


Memory management / Miscellaneous

Programming languages - Reference guide -> Advanced operations -> Text buffers manipulation -> Memory management / Miscellaneous

Previous chapter Next chapter Show all Show all Hide all Hide all

In this section

TxbManager

TxbLastError


TxbManager

Programming languages - Reference guide -> Advanced operations -> Text buffers manipulation -> Memory management / Miscellaneous -> TxbManager

Previous chapter Next chapter Show all Show all Hide all Hide all

TxbManager

Description

This function block is used for managing the memory allocated for text buffers. It takes care of releasing the corresponding memory when the application stops, and can be used for tracking memory leaks.

attention Attention

There must be one and only one instance of this block declared in the IEC application in order to use any other Txb... function.

Output | Description
bOK : BOOL | TRUE if the text buffers memory system is correctly initialized.
nBuffers : DINT | Number of text buffers currently allocated in memory.

seealso See also

Memory management / Miscellaneous

TxbManager: Main gatherer of text buffer data in memory.

TxbLastError: Get detailed error report about last call.

Allocation / exchange with files

TxbNew: Allocate a new empty buffer.

TxbNewString: Allocate a new buffer initialized with string.

TxbFree: Release a text buffer.

TxbReadFile: Allocate a new buffer from file.

TxbWriteFile: Store a text buffer to file.

Data exchange

TxbGetLength: Get length of a text buffer.

TxbGetData: Store text contents to an array of characters.

TxbGetString: Store text contents to a string.

TxbSetData: Store an array of characters to a text buffer.

TxbSetString: Store string to text buffer.

TxbClear: Empty a text buffer.

TxbCopy: Copy a text buffer.

Sequential reading

TxbRewind: Rewind sequential reading.

TxbGetLine: Sequential read line by line.

Sequential writing

TxbAppend: Append variable value.

TxbAppendLine: Append a text line.

TxbAppendEol: Append end of line characters.

TxbAppendTxb: Append contents of another buffer.

UNICODE conversions

TxbAnsiToUtf8: Convert a text buffer to UNICODE.

TxbUtf8ToAnsi: Convert a text buffer to ANSI.


TxbLastError

Programming languages - Reference guide -> Advanced operations -> Text buffers manipulation -> Memory management / Miscellaneous -> TxbLastError

Previous chapter Next chapter Show all Show all Hide all Hide all

TxbLastError

Description

All TXB functions and blocks simply return a boolean information as a return value. This function can be called after any other function giving a FALSE return. It gives a detailed error code about the last detected error.

Output | Description
iErr : DINT | Error code reported by the last call: 0 = OK other = error (see below)

Below are possible error codes:

Code | Meaning
1 2 3 4 5 6 7 8 9 | Invalid instance of TXBManager - should be only one. Manager already open - should be only one instance of TxbManager. Manager not open - no instance of TxbManager declared. Invalid handle. String has been truncated during copy. Cannot read file. Cannot write file. Unsupported data type. Too many text buffers allocated.

seealso See also

Memory management / Miscellaneous

TxbManager: Main gatherer of text buffer data in memory.

TxbLastError: Get detailed error report about last call.

Allocation / exchange with files

TxbNew: Allocate a new empty buffer.

TxbNewString: Allocate a new buffer initialized with string.

TxbFree: Release a text buffer.

TxbReadFile: Allocate a new buffer from file.

TxbWriteFile: Store a text buffer to file.

Data exchange

TxbGetLength: Get length of a text buffer.

TxbGetData: Store text contents to an array of characters.

TxbGetString: Store text contents to a string.

TxbSetData: Store an array of characters to a text buffer.

TxbSetString: Store string to text buffer.

TxbClear: Empty a text buffer.

TxbCopy: Copy a text buffer.

Sequential reading

TxbRewind: Rewind sequential reading.

TxbGetLine: Sequential read line by line.

Sequential writing

TxbAppend: Append variable value.

TxbAppendLine: Append a text line.

TxbAppendEol: Append end of line characters.

TxbAppendTxb: Append contents of another buffer.

UNICODE conversions

TxbAnsiToUtf8: Convert a text buffer to UNICODE.

TxbUtf8ToAnsi: Convert a text buffer to ANSI.


Allocation / exchange with files

Programming languages - Reference guide -> Advanced operations -> Text buffers manipulation -> Allocation / exchange with files

Previous chapter Next chapter Show all Show all Hide all Hide all

In this section

TxbNew

TxbNewString

TxbFree

TxbReadFile

TxbWriteFile


TxbNew

Programming languages - Reference guide -> Advanced operations -> Text buffers manipulation -> Allocation / exchange with files -> TxbNew

Previous chapter Next chapter Show all Show all Hide all Hide all

TxbNew

Description

This function allocates a new text buffer initially empty. The application will be responsible for releasing the buffer by calling the TxbFree() function.

Output | Description
hTxb : DINT | Handle of the new buffer

seealso See also

Memory management / Miscellaneous

TxbManager: Main gatherer of text buffer data in memory.

TxbLastError: Get detailed error report about last call.

Allocation / exchange with files

TxbNew: Allocate a new empty buffer.

TxbNewString: Allocate a new buffer initialized with string.

TxbFree: Release a text buffer.

TxbReadFile: Allocate a new buffer from file.

TxbWriteFile: Store a text buffer to file.

Data exchange

TxbGetLength: Get length of a text buffer.

TxbGetData: Store text contents to an array of characters.

TxbGetString: Store text contents to a string.

TxbSetData: Store an array of characters to a text buffer.

TxbSetString: Store string to text buffer.

TxbClear: Empty a text buffer.

TxbCopy: Copy a text buffer.

Sequential reading

TxbRewind: Rewind sequential reading.

TxbGetLine: Sequential read line by line.

Sequential writing

TxbAppend: Append variable value.

TxbAppendLine: Append a text line.

TxbAppendEol: Append end of line characters.

TxbAppendTxb: Append contents of another buffer.

UNICODE conversions

TxbAnsiToUtf8: Convert a text buffer to UNICODE.

TxbUtf8ToAnsi: Convert a text buffer to ANSI.


TxbNewString

Programming languages - Reference guide -> Advanced operations -> Text buffers manipulation -> Allocation / exchange with files -> TxbNewString

Previous chapter Next chapter Show all Show all Hide all Hide all

TxbNewString

Description

This function allocates a new text buffer initially filled with the specified string. The application will be responsible for releasing the buffer by calling the TxbFree() function.

Input | Description
szText : STRING | Initial value of the text buffer

Output | Description
hTxb : DINT | Handle of the new buffer

seealso See also

Memory management / Miscellaneous

TxbManager: Main gatherer of text buffer data in memory.

TxbLastError: Get detailed error report about last call.

Allocation / exchange with files

TxbNew: Allocate a new empty buffer.

TxbNewString: Allocate a new buffer initialized with string.

TxbFree: Release a text buffer.

TxbReadFile: Allocate a new buffer from file.

TxbWriteFile: Store a text buffer to file.

Data exchange

TxbGetLength: Get length of a text buffer.

TxbGetData: Store text contents to an array of characters.

TxbGetString: Store text contents to a string.

TxbSetData: Store an array of characters to a text buffer.

TxbSetString: Store string to text buffer.

TxbClear: Empty a text buffer.

TxbCopy: Copy a text buffer.

Sequential reading

TxbRewind: Rewind sequential reading.

TxbGetLine: Sequential read line by line.

Sequential writing

TxbAppend: Append variable value.

TxbAppendLine: Append a text line.

TxbAppendEol: Append end of line characters.

TxbAppendTxb: Append contents of another buffer.

UNICODE conversions

TxbAnsiToUtf8: Convert a text buffer to UNICODE.

TxbUtf8ToAnsi: Convert a text buffer to ANSI.


TxbFree

Programming languages - Reference guide -> Advanced operations -> Text buffers manipulation -> Allocation / exchange with files -> TxbFree

Previous chapter Next chapter Show all Show all Hide all Hide all

TxbFree

Description

This function releases a text buffer from memory.

Input | Description
hTxb : DINT | Handle of a valid text buffer.

Output | Description
bOK : BOOL | TRUE if successful.

seealso See also

Memory management / Miscellaneous

TxbManager: Main gatherer of text buffer data in memory.

TxbLastError: Get detailed error report about last call.

Allocation / exchange with files

TxbNew: Allocate a new empty buffer.

TxbNewString: Allocate a new buffer initialized with string.

TxbFree: Release a text buffer.

TxbReadFile: Allocate a new buffer from file.

TxbWriteFile: Store a text buffer to file.

Data exchange

TxbGetLength: Get length of a text buffer.

TxbGetData: Store text contents to an array of characters.

TxbGetString: Store text contents to a string.

TxbSetData: Store an array of characters to a text buffer.

TxbSetString: Store string to text buffer.

TxbClear: Empty a text buffer.

TxbCopy: Copy a text buffer.

Sequential reading

TxbRewind: Rewind sequential reading.

TxbGetLine: Sequential read line by line.

Sequential writing

TxbAppend: Append variable value.

TxbAppendLine: Append a text line.

TxbAppendEol: Append end of line characters.

TxbAppendTxb: Append contents of another buffer.

UNICODE conversions

TxbAnsiToUtf8: Convert a text buffer to UNICODE.

TxbUtf8ToAnsi: Convert a text buffer to ANSI.


TxbReadFile

Programming languages - Reference guide -> Advanced operations -> Text buffers manipulation -> Allocation / exchange with files -> TxbReadFile

Previous chapter Next chapter Show all Show all Hide all Hide all

TxbReadFile

Description

This function allocates a new text buffer and fills it with the contents of the specified file. The application will be responsible for releasing the buffer by calling the TxbFree() function.

Input | Description
szPath : STRING | Full qualified pathname of the file to be read

Output | Description
hTxb : DINT | Handle of the new buffer

seealso See also

Memory management / Miscellaneous

TxbManager: Main gatherer of text buffer data in memory.

TxbLastError: Get detailed error report about last call.

Allocation / exchange with files

TxbNew: Allocate a new empty buffer.

TxbNewString: Allocate a new buffer initialized with string.

TxbFree: Release a text buffer.

TxbReadFile: Allocate a new buffer from file.

TxbWriteFile: Store a text buffer to file.

Data exchange

TxbGetLength: Get length of a text buffer.

TxbGetData: Store text contents to an array of characters.

TxbGetString: Store text contents to a string.

TxbSetData: Store an array of characters to a text buffer.

TxbSetString: Store string to text buffer.

TxbClear: Empty a text buffer.

TxbCopy: Copy a text buffer.

Sequential reading

TxbRewind: Rewind sequential reading.

TxbGetLine: Sequential read line by line.

Sequential writing

TxbAppend: Append variable value.

TxbAppendLine: Append a text line.

TxbAppendEol: Append end of line characters.

TxbAppendTxb: Append contents of another buffer.

UNICODE conversions

TxbAnsiToUtf8: Convert a text buffer to UNICODE.

TxbUtf8ToAnsi: Convert a text buffer to ANSI.


TxbWriteFile

Programming languages - Reference guide -> Advanced operations -> Text buffers manipulation -> Allocation / exchange with files -> TxbWriteFile

Previous chapter Next chapter Show all Show all Hide all Hide all

TxbWriteFile

Description

This function stores the contents of a text buffer to a file. The text buffer remains allocated in memory.

Input | Description
hTxb : DINT | Handle of the text buffer.
szPath : STRING | Full qualified pathname of the file to be created.

Output | Description
bOK : BOOL | TRUE if successful.

seealso See also

Memory management / Miscellaneous

TxbManager: Main gatherer of text buffer data in memory.

TxbLastError: Get detailed error report about last call.

Allocation / exchange with files

TxbNew: Allocate a new empty buffer.

TxbNewString: Allocate a new buffer initialized with string.

TxbFree: Release a text buffer.

TxbReadFile: Allocate a new buffer from file.

TxbWriteFile: Store a text buffer to file.

Data exchange

TxbGetLength: Get length of a text buffer.

TxbGetData: Store text contents to an array of characters.

TxbGetString: Store text contents to a string.

TxbSetData: Store an array of characters to a text buffer.

TxbSetString: Store string to text buffer.

TxbClear: Empty a text buffer.

TxbCopy: Copy a text buffer.

Sequential reading

TxbRewind: Rewind sequential reading.

TxbGetLine: Sequential read line by line.

Sequential writing

TxbAppend: Append variable value.

TxbAppendLine: Append a text line.

TxbAppendEol: Append end of line characters.

TxbAppendTxb: Append contents of another buffer.

UNICODE conversions

TxbAnsiToUtf8: Convert a text buffer to UNICODE.

TxbUtf8ToAnsi: Convert a text buffer to ANSI.


Data exchange

Programming languages - Reference guide -> Advanced operations -> Text buffers manipulation -> Data exchange

Previous chapter Next chapter Show all Show all Hide all Hide all

In this section

TxbGetLength

TxbGetData

TxbGetString

TxbSetData

TxbSetString

TxbClear

TxbCopy


TxbGetLength

Programming languages - Reference guide -> Advanced operations -> Text buffers manipulation -> Data exchange -> TxbGetLength

Previous chapter Next chapter Show all Show all Hide all Hide all

TxbGetLength

Description

This function returns the current length of a text buffer.

Input | Description
hTxb : DINT | Handle of the text buffer.

Output | Description
len : DINT | Number of characters in the text buffer.

seealso See also

Memory management / Miscellaneous

TxbManager: Main gatherer of text buffer data in memory.

TxbLastError: Get detailed error report about last call.

Allocation / exchange with files

TxbNew: Allocate a new empty buffer.

TxbNewString: Allocate a new buffer initialized with string.

TxbFree: Release a text buffer.

TxbReadFile: Allocate a new buffer from file.

TxbWriteFile: Store a text buffer to file.

Data exchange

TxbGetLength: Get length of a text buffer.

TxbGetData: Store text contents to an array of characters.

TxbGetString: Store text contents to a string.

TxbSetData: Store an array of characters to a text buffer.

TxbSetString: Store string to text buffer.

TxbClear: Empty a text buffer.

TxbCopy: Copy a text buffer.

Sequential reading

TxbRewind: Rewind sequential reading.

TxbGetLine: Sequential read line by line.

Sequential writing

TxbAppend: Append variable value.

TxbAppendLine: Append a text line.

TxbAppendEol: Append end of line characters.

TxbAppendTxb: Append contents of another buffer.

UNICODE conversions

TxbAnsiToUtf8: Convert a text buffer to UNICODE.

TxbUtf8ToAnsi: Convert a text buffer to ANSI.


TxbGetData

Programming languages - Reference guide -> Advanced operations -> Text buffers manipulation -> Data exchange -> TxbGetData

Previous chapter Next chapter Show all Show all Hide all Hide all

TxbGetData

Description

This function copies the contents of a text buffer to an array of characters.

Input | Description
hTxb : DINT | Handle of the text buffer.
arData : SINT[] | Array of characters to be filled with text.

Output | Description
bOK : BOOL | TRUE if successful.

seealso See also

Memory management / Miscellaneous

TxbManager: Main gatherer of text buffer data in memory.

TxbLastError: Get detailed error report about last call.

Allocation / exchange with files

TxbNew: Allocate a new empty buffer.

TxbNewString: Allocate a new buffer initialized with string.

TxbFree: Release a text buffer.

TxbReadFile: Allocate a new buffer from file.

TxbWriteFile: Store a text buffer to file.

Data exchange

TxbGetLength: Get length of a text buffer.

TxbGetData: Store text contents to an array of characters.

TxbGetString: Store text contents to a string.

TxbSetData: Store an array of characters to a text buffer.

TxbSetString: Store string to text buffer.

TxbClear: Empty a text buffer.

TxbCopy: Copy a text buffer.

Sequential reading

TxbRewind: Rewind sequential reading.

TxbGetLine: Sequential read line by line.

Sequential writing

TxbAppend: Append variable value.

TxbAppendLine: Append a text line.

TxbAppendEol: Append end of line characters.

TxbAppendTxb: Append contents of another buffer.

UNICODE conversions

TxbAnsiToUtf8: Convert a text buffer to UNICODE.

TxbUtf8ToAnsi: Convert a text buffer to ANSI.


TxbGetString

Programming languages - Reference guide -> Advanced operations -> Text buffers manipulation -> Data exchange -> TxbGetString

Previous chapter Next chapter Show all Show all Hide all Hide all

TxbGetString

Description

This function copies the contents of a text buffer to a string. The text is truncated if the string is not large enough.

Input | Description
hTxb : DINT | Handle of the text buffer

Output | Description
szText : STRING | String to be filled with text

seealso See also

Memory management / Miscellaneous

TxbManager: Main gatherer of text buffer data in memory.

TxbLastError: Get detailed error report about last call.

Allocation / exchange with files

TxbNew: Allocate a new empty buffer.

TxbNewString: Allocate a new buffer initialized with string.

TxbFree: Release a text buffer.

TxbReadFile: Allocate a new buffer from file.

TxbWriteFile: Store a text buffer to file.

Data exchange

TxbGetLength: Get length of a text buffer.

TxbGetData: Store text contents to an array of characters.

TxbGetString: Store text contents to a string.

TxbSetData: Store an array of characters to a text buffer.

TxbSetString: Store string to text buffer.

TxbClear: Empty a text buffer.

TxbCopy: Copy a text buffer.

Sequential reading

TxbRewind: Rewind sequential reading.

TxbGetLine: Sequential read line by line.

Sequential writing

TxbAppend: Append variable value.

TxbAppendLine: Append a text line.

TxbAppendEol: Append end of line characters.

TxbAppendTxb: Append contents of another buffer.

UNICODE conversions

TxbAnsiToUtf8: Convert a text buffer to UNICODE.

TxbUtf8ToAnsi: Convert a text buffer to ANSI.


TxbSetData

Programming languages - Reference guide -> Advanced operations -> Text buffers manipulation -> Data exchange -> TxbSetData

Previous chapter Next chapter Show all Show all Hide all Hide all

TxbSetData

Description

This function copies an array of characters to a text buffer. All characters of the input array are copied.

Input | Description
hTxb : DINT | Handle of the text buffer
arData : SINT[] | Array of characters to copy

Output | Description
bOK : BOOL | TRUE if successful

seealso See also

Memory management / Miscellaneous

TxbManager: Main gatherer of text buffer data in memory.

TxbLastError: Get detailed error report about last call.

Allocation / exchange with files

TxbNew: Allocate a new empty buffer.

TxbNewString: Allocate a new buffer initialized with string.

TxbFree: Release a text buffer.

TxbReadFile: Allocate a new buffer from file.

TxbWriteFile: Store a text buffer to file.

Data exchange

TxbGetLength: Get length of a text buffer.

TxbGetData: Store text contents to an array of characters.

TxbGetString: Store text contents to a string.

TxbSetData: Store an array of characters to a text buffer.

TxbSetString: Store string to text buffer.

TxbClear: Empty a text buffer.

TxbCopy: Copy a text buffer.

Sequential reading

TxbRewind: Rewind sequential reading.

TxbGetLine: Sequential read line by line.

Sequential writing

TxbAppend: Append variable value.

TxbAppendLine: Append a text line.

TxbAppendEol: Append end of line characters.

TxbAppendTxb: Append contents of another buffer.

UNICODE conversions

TxbAnsiToUtf8: Convert a text buffer to UNICODE.

TxbUtf8ToAnsi: Convert a text buffer to ANSI.


TxbSetString

Programming languages - Reference guide -> Advanced operations -> Text buffers manipulation -> Data exchange -> TxbSetString

Previous chapter Next chapter Show all Show all Hide all Hide all

TxbSetString

Description

This function copies the contents of a string to a text buffer.

Input | Description
hTxb : DINT | Handle of the text buffer.
szText : STRING | String to be copied.

Output | Description
bOK : BOOL | TRUE if successful.

seealso See also

Memory management / Miscellaneous

TxbManager: Main gatherer of text buffer data in memory.

TxbLastError: Get detailed error report about last call.

Allocation / exchange with files

TxbNew: Allocate a new empty buffer.

TxbNewString: Allocate a new buffer initialized with string.

TxbFree: Release a text buffer.

TxbReadFile: Allocate a new buffer from file.

TxbWriteFile: Store a text buffer to file.

Data exchange

TxbGetLength: Get length of a text buffer.

TxbGetData: Store text contents to an array of characters.

TxbGetString: Store text contents to a string.

TxbSetData: Store an array of characters to a text buffer.

TxbSetString: Store string to text buffer.

TxbClear: Empty a text buffer.

TxbCopy: Copy a text buffer.

Sequential reading

TxbRewind: Rewind sequential reading.

TxbGetLine: Sequential read line by line.

Sequential writing

TxbAppend: Append variable value.

TxbAppendLine: Append a text line.

TxbAppendEol: Append end of line characters.

TxbAppendTxb: Append contents of another buffer.

UNICODE conversions

TxbAnsiToUtf8: Convert a text buffer to UNICODE.

TxbUtf8ToAnsi: Convert a text buffer to ANSI.


TxbClear

Programming languages - Reference guide -> Advanced operations -> Text buffers manipulation -> Data exchange -> TxbClear

Previous chapter Next chapter Show all Show all Hide all Hide all

TxbClear

Description

This function empties a text buffer.

Input | Description
hTxb : DINT | Handle of the text buffer.

Output | Description
bOK : BOOL | TRUE if successful.

seealso See also

Memory management / Miscellaneous

TxbManager: Main gatherer of text buffer data in memory.

TxbLastError: Get detailed error report about last call.

Allocation / exchange with files

TxbNew: Allocate a new empty buffer.

TxbNewString: Allocate a new buffer initialized with string.

TxbFree: Release a text buffer.

TxbReadFile: Allocate a new buffer from file.

TxbWriteFile: Store a text buffer to file.

Data exchange

TxbGetLength: Get length of a text buffer.

TxbGetData: Store text contents to an array of characters.

TxbGetString: Store text contents to a string.

TxbSetData: Store an array of characters to a text buffer.

TxbSetString: Store string to text buffer.

TxbClear: Empty a text buffer.

TxbCopy: Copy a text buffer.

Sequential reading

TxbRewind: Rewind sequential reading.

TxbGetLine: Sequential read line by line.

Sequential writing

TxbAppend: Append variable value.

TxbAppendLine: Append a text line.

TxbAppendEol: Append end of line characters.

TxbAppendTxb: Append contents of another buffer.

UNICODE conversions

TxbAnsiToUtf8: Convert a text buffer to UNICODE.

TxbUtf8ToAnsi: Convert a text buffer to ANSI.


TxbCopy

Programming languages - Reference guide -> Advanced operations -> Text buffers manipulation -> Data exchange -> TxbCopy

Previous chapter Next chapter Show all Show all Hide all Hide all

TxbCopy

Description

This function copies the contents of the hTxb buffer the to hTxbDst buffer.

Input | Description
hTxbDst : DINT | Handle of the destination text buffer.
hTxb : DINT | Handle of the source text buffer.

Output | Description
bOK : BOOL | TRUE if successful.

seealso See also

Memory management / Miscellaneous

TxbManager: Main gatherer of text buffer data in memory.

TxbLastError: Get detailed error report about last call.

Allocation / exchange with files

TxbNew: Allocate a new empty buffer.

TxbNewString: Allocate a new buffer initialized with string.

TxbFree: Release a text buffer.

TxbReadFile: Allocate a new buffer from file.

TxbWriteFile: Store a text buffer to file.

Data exchange

TxbGetLength: Get length of a text buffer.

TxbGetData: Store text contents to an array of characters.

TxbGetString: Store text contents to a string.

TxbSetData: Store an array of characters to a text buffer.

TxbSetString: Store string to text buffer.

TxbClear: Empty a text buffer.

TxbCopy: Copy a text buffer.

Sequential reading

TxbRewind: Rewind sequential reading.

TxbGetLine: Sequential read line by line.

Sequential writing

TxbAppend: Append variable value.

TxbAppendLine: Append a text line.

TxbAppendEol: Append end of line characters.

TxbAppendTxb: Append contents of another buffer.

UNICODE conversions

TxbAnsiToUtf8: Convert a text buffer to UNICODE.

TxbUtf8ToAnsi: Convert a text buffer to ANSI.


Sequential reading

Programming languages - Reference guide -> Advanced operations -> Text buffers manipulation -> Sequential reading

Previous chapter Next chapter Show all Show all Hide all Hide all

In this section

TxbRewind

TxbGetLine


TxbRewind

Programming languages - Reference guide -> Advanced operations -> Text buffers manipulation -> Sequential reading -> TxbRewind

Previous chapter Next chapter Show all Show all Hide all Hide all

TxbRewind

Description

This function resets the sequential reading of a text buffer (rewind to the beginning of the text).

Input | Description
hTxb : DINT | Handle of the text buffer.

Output | Description
bOK : BOOL | TRUE if successful.

seealso See also

Memory management / Miscellaneous

TxbManager: Main gatherer of text buffer data in memory.

TxbLastError: Get detailed error report about last call.

Allocation / exchange with files

TxbNew: Allocate a new empty buffer.

TxbNewString: Allocate a new buffer initialized with string.

TxbFree: Release a text buffer.

TxbReadFile: Allocate a new buffer from file.

TxbWriteFile: Store a text buffer to file.

Data exchange

TxbGetLength: Get length of a text buffer.

TxbGetData: Store text contents to an array of characters.

TxbGetString: Store text contents to a string.

TxbSetData: Store an array of characters to a text buffer.

TxbSetString: Store string to text buffer.

TxbClear: Empty a text buffer.

TxbCopy: Copy a text buffer.

Sequential reading

TxbRewind: Rewind sequential reading.

TxbGetLine: Sequential read line by line.

Sequential writing

TxbAppend: Append variable value.

TxbAppendLine: Append a text line.

TxbAppendEol: Append end of line characters.

TxbAppendTxb: Append contents of another buffer.

UNICODE conversions

TxbAnsiToUtf8: Convert a text buffer to UNICODE.

TxbUtf8ToAnsi: Convert a text buffer to ANSI.


TxbGetLine

Programming languages - Reference guide -> Advanced operations -> Text buffers manipulation -> Sequential reading -> TxbGetLine

Previous chapter Next chapter Show all Show all Hide all Hide all

TxbGetLine

Description

This function sequentially reads a line of text from a text buffer. End of line characters are not copied to the output string.

Input | Description
hTxb : DINT | Handle of the text buffer.
szText : STRING | String to be filled with read line.

Output | Decription
bOK : BOOL | TRUE if successful.

seealso See also

Memory management / Miscellaneous

TxbManager: Main gatherer of text buffer data in memory.

TxbLastError: Get detailed error report about last call.

Allocation / exchange with files

TxbNew: Allocate a new empty buffer.

TxbNewString: Allocate a new buffer initialized with string.

TxbFree: Release a text buffer.

TxbReadFile: Allocate a new buffer from file.

TxbWriteFile: Store a text buffer to file.

Data exchange

TxbGetLength: Get length of a text buffer.

TxbGetData: Store text contents to an array of characters.

TxbGetString: Store text contents to a string.

TxbSetData: Store an array of characters to a text buffer.

TxbSetString: Store string to text buffer.

TxbClear: Empty a text buffer.

TxbCopy: Copy a text buffer.

Sequential reading

TxbRewind: Rewind sequential reading.

TxbGetLine: Sequential read line by line.

Sequential writing

TxbAppend: Append variable value.

TxbAppendLine: Append a text line.

TxbAppendEol: Append end of line characters.

TxbAppendTxb: Append contents of another buffer.

UNICODE conversions

TxbAnsiToUtf8: Convert a text buffer to UNICODE.

TxbUtf8ToAnsi: Convert a text buffer to ANSI.


Sequential writing

Programming languages - Reference guide -> Advanced operations -> Text buffers manipulation -> Sequential writing

Previous chapter Next chapter Show all Show all Hide all Hide all

In this section

TxbAppend

TxbAppendLine

TxbAppendEol

TxbAppendTxb


TxbAppend

Programming languages - Reference guide -> Advanced operations -> Text buffers manipulation -> Sequential writing -> TxbAppend

Previous chapter Next chapter Show all Show all Hide all Hide all

TxbAppend

Description

This function adds the contents of a variable, formatted as text, to a text buffer. The specified variable can have any data type.

Input | Description
hTxb : DINT | Handle of the text buffer.
data : ANY | Any variable.

Output | Description
bOK : BOOL | TRUE if successful.

seealso See also

Memory management / Miscellaneous

TxbManager: Main gatherer of text buffer data in memory.

TxbLastError: Get detailed error report about last call.

Allocation / exchange with files

TxbNew: Allocate a new empty buffer.

TxbNewString: Allocate a new buffer initialized with string.

TxbFree: Release a text buffer.

TxbReadFile: Allocate a new buffer from file.

TxbWriteFile: Store a text buffer to file.

Data exchange

TxbGetLength: Get length of a text buffer.

TxbGetData: Store text contents to an array of characters.

TxbGetString: Store text contents to a string.

TxbSetData: Store an array of characters to a text buffer.

TxbSetString: Store string to text buffer.

TxbClear: Empty a text buffer.

TxbCopy: Copy a text buffer.

Sequential reading

TxbRewind: Rewind sequential reading.

TxbGetLine: Sequential read line by line.

Sequential writing

TxbAppend: Append variable value.

TxbAppendLine: Append a text line.

TxbAppendEol: Append end of line characters.

TxbAppendTxb: Append contents of another buffer.

UNICODE conversions

TxbAnsiToUtf8: Convert a text buffer to UNICODE.

TxbUtf8ToAnsi: Convert a text buffer to ANSI.


TxbAppendLine

Programming languages - Reference guide -> Advanced operations -> Text buffers manipulation -> Sequential writing -> TxbAppendLine

Previous chapter Next chapter Show all Show all Hide all Hide all

TxbAppendLine

Description

This function adds the contents of the specified string variable to a text buffer, plus end of line characters.

Input | Description
hTxb : DINT | Handle of the text buffer.
szText : STRING | String to be added to the text.

Output | Description
bOK : BOOL | TRUE if successful.

seealso See also

Memory management / Miscellaneous

TxbManager: Main gatherer of text buffer data in memory.

TxbLastError: Get detailed error report about last call.

Allocation / exchange with files

TxbNew: Allocate a new empty buffer.

TxbNewString: Allocate a new buffer initialized with string.

TxbFree: Release a text buffer.

TxbReadFile: Allocate a new buffer from file.

TxbWriteFile: Store a text buffer to file.

Data exchange

TxbGetLength: Get length of a text buffer.

TxbGetData: Store text contents to an array of characters.

TxbGetString: Store text contents to a string.

TxbSetData: Store an array of characters to a text buffer.

TxbSetString: Store string to text buffer.

TxbClear: Empty a text buffer.

TxbCopy: Copy a text buffer.

Sequential reading

TxbRewind: Rewind sequential reading.

TxbGetLine: Sequential read line by line.

Sequential writing

TxbAppend: Append variable value.

TxbAppendLine: Append a text line.

TxbAppendEol: Append end of line characters.

TxbAppendTxb: Append contents of another buffer.

UNICODE conversions

TxbAnsiToUtf8: Convert a text buffer to UNICODE.

TxbUtf8ToAnsi: Convert a text buffer to ANSI.


TxbAppendEol

Programming languages - Reference guide -> Advanced operations -> Text buffers manipulation -> Sequential writing -> TxbAppendEol

Previous chapter Next chapter Show all Show all Hide all Hide all

TxbAppendEol

Description

This function adds end of line characters to a text buffer.

Input | Description
hTxb : DINT | Handle of the text buffer.

Output | Description
bOK : BOOL | TRUE if successful.

seealso See also

Memory management / Miscellaneous

TxbManager: Main gatherer of text buffer data in memory.

TxbLastError: Get detailed error report about last call.

Allocation / exchange with files

TxbNew: Allocate a new empty buffer.

TxbNewString: Allocate a new buffer initialized with string.

TxbFree: Release a text buffer.

TxbReadFile: Allocate a new buffer from file.

TxbWriteFile: Store a text buffer to file.

Data exchange

TxbGetLength: Get length of a text buffer.

TxbGetData: Store text contents to an array of characters.

TxbGetString: Store text contents to a string.

TxbSetData: Store an array of characters to a text buffer.

TxbSetString: Store string to text buffer.

TxbClear: Empty a text buffer.

TxbCopy: Copy a text buffer.

Sequential reading

TxbRewind: Rewind sequential reading.

TxbGetLine: Sequential read line by line.

Sequential writing

TxbAppend: Append variable value.

TxbAppendLine: Append a text line.

TxbAppendEol: Append end of line characters.

TxbAppendTxb: Append contents of another buffer.

UNICODE conversions

TxbAnsiToUtf8: Convert a text buffer to UNICODE.

TxbUtf8ToAnsi: Convert a text buffer to ANSI.


TxbAppendTxb

Programming languages - Reference guide -> Advanced operations -> Text buffers manipulation -> Sequential writing -> TxbAppendTxb

Previous chapter Next chapter Show all Show all Hide all Hide all

TxbAppendTxb

Description

This function adds the contents of the hTxb text buffer to the hTxbDst text buffer.

Input | Description
hTxbDst : DINT | Handle of the text buffer to be completed.
hTxb : DINT | Handle of the text buffer to be added.

Output | Description
bOK : BOOL | TRUE if successful.

seealso See also

Memory management / Miscellaneous

TxbManager: Main gatherer of text buffer data in memory.

TxbLastError: Get detailed error report about last call.

Allocation / exchange with files

TxbNew: Allocate a new empty buffer.

TxbNewString: Allocate a new buffer initialized with string.

TxbFree: Release a text buffer.

TxbReadFile: Allocate a new buffer from file.

TxbWriteFile: Store a text buffer to file.

Data exchange

TxbGetLength: Get length of a text buffer.

TxbGetData: Store text contents to an array of characters.

TxbGetString: Store text contents to a string.

TxbSetData: Store an array of characters to a text buffer.

TxbSetString: Store string to text buffer.

TxbClear: Empty a text buffer.

TxbCopy: Copy a text buffer.

Sequential reading

TxbRewind: Rewind sequential reading.

TxbGetLine: Sequential read line by line.

Sequential writing

TxbAppend: Append variable value.

TxbAppendLine: Append a text line.

TxbAppendEol: Append end of line characters.

TxbAppendTxb: Append contents of another buffer.

UNICODE conversions

TxbAnsiToUtf8: Convert a text buffer to UNICODE.

TxbUtf8ToAnsi: Convert a text buffer to ANSI.


UNICODE conversions

Programming languages - Reference guide -> Advanced operations -> Text buffers manipulation -> UNICODE conversions

Previous chapter Next chapter Show all Show all Hide all Hide all

In this section

TxbAnsiToUtf8

TxbUtf8ToAnsi


TxbAnsiToUtf8

Programming languages - Reference guide -> Advanced operations -> Text buffers manipulation -> UNICODE conversions -> TxbAnsiToUtf8

Previous chapter Next chapter Show all Show all Hide all Hide all

TxbAnsiToUtf8

Description

This function converts the whole contents of a text buffer from ANSI to UNICODE UTF8 encoding. Warning:

attention Attention
  • This function may be time and memory consuming for large buffers.
  • UNICODE conversion may be not available on some operating systems

Input | Description
hTxb : DINT | Handle of the text buffer.

Output | Description
bOK : BOOL | TRUE if successful.

seealso See also

Memory management / Miscellaneous

TxbManager: Main gatherer of text buffer data in memory.

TxbLastError: Get detailed error report about last call.

Allocation / exchange with files

TxbNew: Allocate a new empty buffer.

TxbNewString: Allocate a new buffer initialized with string.

TxbFree: Release a text buffer.

TxbReadFile: Allocate a new buffer from file.

TxbWriteFile: Store a text buffer to file.

Data exchange

TxbGetLength: Get length of a text buffer.

TxbGetData: Store text contents to an array of characters.

TxbGetString: Store text contents to a string.

TxbSetData: Store an array of characters to a text buffer.

TxbSetString: Store string to text buffer.

TxbClear: Empty a text buffer.

TxbCopy: Copy a text buffer.

Sequential reading

TxbRewind: Rewind sequential reading.

TxbGetLine: Sequential read line by line.

Sequential writing

TxbAppend: Append variable value.

TxbAppendLine: Append a text line.

TxbAppendEol: Append end of line characters.

TxbAppendTxb: Append contents of another buffer.

UNICODE conversions

TxbAnsiToUtf8: Convert a text buffer to UNICODE.

TxbUtf8ToAnsi: Convert a text buffer to ANSI.


TxbUtf8ToAnsi

Programming languages - Reference guide -> Advanced operations -> Text buffers manipulation -> UNICODE conversions -> TxbUtf8ToAnsi

Previous chapter Next chapter Show all Show all Hide all Hide all

TxbUtf8ToAnsi

Description

This function converts the whole contents of a text buffer from UNICODE UTF8 to ANSI encoding.

attention Attention
  • This function may be time and memory consuming for large buffers.
  • UNICODE conversion may be not available on some operating systems

Input | Description
hTxb : DINT | Handle of the text buffer.

Output | Description
bOK : BOOL | TRUE if successful.

seealso See also

Memory management / Miscellaneous

TxbManager: Main gatherer of text buffer data in memory.

TxbLastError: Get detailed error report about last call.

Allocation / exchange with files

TxbNew: Allocate a new empty buffer.

TxbNewString: Allocate a new buffer initialized with string.

TxbFree: Release a text buffer.

TxbReadFile: Allocate a new buffer from file.

TxbWriteFile: Store a text buffer to file.

Data exchange

TxbGetLength: Get length of a text buffer.

TxbGetData: Store text contents to an array of characters.

TxbGetString: Store text contents to a string.

TxbSetData: Store an array of characters to a text buffer.

TxbSetString: Store string to text buffer.

TxbClear: Empty a text buffer.

TxbCopy: Copy a text buffer.

Sequential reading

TxbRewind: Rewind sequential reading.

TxbGetLine: Sequential read line by line.

Sequential writing

TxbAppend: Append variable value.

TxbAppendLine: Append a text line.

TxbAppendEol: Append end of line characters.

TxbAppendTxb: Append contents of another buffer.

UNICODE conversions

TxbAnsiToUtf8: Convert a text buffer to UNICODE.

TxbUtf8ToAnsi: Convert a text buffer to ANSI.


UDP Management functions

Programming languages - Reference guide -> Advanced operations -> UDP Management functions

Previous chapter Next chapter Show all Show all Hide all Hide all

The following functions enable management of UDP sockets for building client or server applications over ETHERNET network:

udpCreate create a UDP socket.
udpAddrMake build an address buffer for UDP functions.
updSendTo send a telegram.
udpRcvFrom receive a telegram.
udpClose close a socket.
udpIsValid test if a socket is valid.
updSendToArray send a telegram.
udpRcvFromArray receive a telegram.

Each socket is identified in the application by a unique handle manipulated as a DINT value.

attention Attention
  • Although the system provides a simplified interface, you must be familiar with the socket interface such as existing in other programming languages such as "C".
  • Socket management may be not available on some targets. Please refer to OEM instructions for further details about available features.

udpCreate: create a UDP socket

SOCK := udpCreate (PORT);

PORT : DINT TCP port number to be attached to the server socket or 0 for a client socket.
SOCK : DINT ID of the new server socket.

This functions creates a new UDP socket. If the PORT argument is not 0, the socket is bound to the port and thus can be used as a server socket.

udpAddrMake: build an address buffer for UDP functions

OK := udpAddrMake (IPADDR, PORT, ADD);

IPADDR : STRING IP address in form xxx.xxx.xxx.xxx
PORT : DINT IP port number.
ADD : USINT[32] Buffer where to store the UDP address (filled on output).
OK : BOOL TRUE if successful.

This functions is required for building a internal UDP address to be passed to the udpSendTo function in case of UDP client processing.

udpSendTo: send a UDP telegram

OK := udpSendTo (SOCK, NB, ADD, DATA);

SOCK : DINT ID of the client socket.
NB : DINT number of characters to send.
ADD : USINT[32] buffer containing the UDP address (on input).
DATA : STRING characters to send.
OK : BOOL TRUE if successful.

The ADD buffer must contain a valid UDP address either constructed by the udpAddrMake function or returned by the udpRcvFrom function.

udpSendToArray: send a UDP telegram

OK := udpSendTo (SOCK, NB, ADD, DATA);

SOCK : DINT ID of the client socket.
NB : DINT number of characters to send.
ADD : USINT[32] buffer containing the UDP address (on input).
DATA : USINT[] array of characters to send.
OK : BOOL TRUE if successful.

The ADD buffer must contain a valid UDP address either constructed by the udpAddrMake function or returned by the udpRcvFrom function.

udpRcvFrom: receive a UDP telegram

OK := udpRcvFrom (SOCK, NB, ADD, DATA);

SOCK : DINT ID of the client socket.
NB : DINT Maximum number of characters received.
ADD : USINT[32] Buffer containing the UDP address of the transmitter (filled on output).
DATA : STRING buffer where to store received characters.
Q : DINT number of actually received characters.

If characters are received, the function fills the ADD argument with the internal UDP of the sender. This buffer can then be passed to the udpSendTo function to send the answer.

udpRcvFromArray: receive a UDP telegram

OK := udpRcvFrom (SOCK, NB, ADD, DATA);

SOCK : DINT ID of the client socket.
NB : DINT Maximum number of characters received.
ADD : USINT[32] Buffer containing the UDP address of the transmitter (filled on output).
DATA : USINT[] Array where to store received characters.
Q : DINT number of actually received characters.

If characters are received, the function fills the ADD argument with the internal UDP of the sender. This buffer can then be passed to the udpSendTo function to send the answer.

udpClose: release a socket

OK := udpClose (SOCK);

SOCK : DINT ID of any socket.
OK : BOOL TRUE if successful.

You are responsible for closing any socket created by tcpListen, tcpAccept or tcpConnect functions, even if they have become invalid.

udpIsValid: test if a socket is valid

OK := udpIsValid (SOCK);

SOCK : DINT ID of the socket.
OK : BOOL TRUE if specified socket is still valid.


VLID

Programming languages - Reference guide -> Advanced operations -> VLID

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Get the identifier of an embedded list of variables.

Inputs

FILE : STRING Pathname of the list file (.SPL or .TXT) - must be a constant value!

Outputs

ID : DINT ID of the list - to be passed to other blocks.

Remarks

Some blocks have arguments that refer to a list of variables. For all these blocks, the list argument is materialized by a numerical identifier. This function enables you to get the identifier of a list of variables.

Embedded lists of variables can be:

  • Watch lists created with the Workbench. Such files are suffixed with .SPL.
  • Simple .TXT text files with one variable name per line.

Lists must contain single variables only. Items of arrays and structures must be specified one by one. The length of the list is not limited by the system.

attention Attention

List files are read at compiling time and are embedded into the downloaded application code. This implies that a modification performed in the list file after downloading will not be taken into account by the application.

ST Language

ID := VLID ('MyFile.spl');

FBD Language

LD Language

The function is executed only if EN is TRUE.

IL Language

Op1: LD 'MyFile.spl'
VLID COL
ST ID


XML writing and parsing

Programming languages - Reference guide -> Advanced operations -> XML writing and parsing

Previous chapter Next chapter Show all Show all Hide all Hide all

XML documents can be managed from the IEC application as a tree of XML tags. Each XML tag is represented by:

  • a tag name,
  • a list of attributes (name=value),
  • a contents (raw text),
  • a list of child tags.

A whole XML document is handled as its main tag.

XML functions are originally designed for working with text buffers. However, some additional functions have been added for dealing with XML files on disk as it may be helpful in other applications.

attention Attention

XML parsing and witing functions support only 8 bit encoding features. This can be UTF8 or ANSI (ISO-8859-1) encoding. Some text buffers handling functions provide conversion between UTF8 and ANSI formats.

There must be one instance of the XmlManager declared in your application for using these functions.

There must be one instance of the TxbManager declared in your application for using text buffers related functions.

Memory management / Miscellaneous

XmlManager: Main gatherer of XML data in memory.

XmlLastError: Get detailed error report about last call.

Reading/writing documents

XmlNewDoc: Create an empty XML document.

XmlFreeDoc: Release an XML document from memory.

XmlParseDocTxb: Parse an XML document from text buffer.

XmlParseDocFile: Parse an XML document form file.

XmlWriteDocTxb: Format XML data to text buffer.

XmlWriteDocFile: Format XML data to file.

Exploring an XML document

XmlGetTagName: Get name of an XML tag.

XmlCheckTagName: Test the name of an XML tag.

XmlGetTagCont: Get tag contents as STRING.

XmlGetTagContT: Get tag contents as text buffer.

XmlGetTagAttrib: Get tag attribute.

XmlGetParent: Get parent tag.

XmlFirstChild: Start enumerating child tags.

XmlNextChild: Enumerate child tags

Building an XML document

XmlSetTagAttrib: Set tag attribute.

XmlSetTagCont: Set tag contents with STRING.

XmlSetTagContT: Set tag contents with text buffer.

XmlAddChild: Add a child tag.

Exchanging variables using their name

XmlGetSybValue: Get variable value using its symbol.

XmlSetSybValue: Set variable value using its symbol.

In this section

Memory Management / Miscellaneous

Reading/writing documents

Exploring an XML document

Building an XML document

Exchanging variables using their name


Memory Management / Miscellaneous

Programming languages - Reference guide -> Advanced operations -> XML writing and parsing -> Memory Management / Miscellaneous

Previous chapter Next chapter Show all Show all Hide all Hide all

In this section

XmlManager

XmlLastError


XmlManager

Programming languages - Reference guide -> Advanced operations -> XML writing and parsing -> Memory Management / Miscellaneous -> XmlManager

Previous chapter Next chapter Show all Show all Hide all Hide all

XmlManager – Function block

Description

This function block is used for managing the memory allocated for XML tags and documents. It takes care of releasing the corresponding memory when the application stops, and can be used for tracking memory leaks. There must be one and only one instance of this block declared in the IEC application in order to use any other Xml function.

Output | Description
bOK : BOOL | TRUE if the XML memory system is correctly initialized.
nBuffers : DINT | Number of XML documents currently allocated in memory.
nTags : DINT | Number of XML tags currently allocated in memory.

seealso See also

Memory management / Miscellaneous

XmlManager: Main gatherer of XML data in memory.

XmlLastError: Get detailed error report about last call.

Reading/writing documents

XmlNewDoc: Create an empty XML document.

XmlFreeDoc: Release an XML document from memory.

XmlParseDocTxb: Parse an XML document from text buffer.

XmlParseDocFile: Parse an XML document form file.

XmlWriteDocTxb: Format XML data to text buffer.

XmlWriteDocFile: Format XML data to file.

Exploring an XML document

XmlGetTagName: Get name of an XML tag.

XmlCheckTagName: Test the name of an XML tag.

XmlGetTagCont: Get tag contents as STRING.

XmlGetTagContT: Get tag contents as text buffer.

XmlGetTagAttrib: Get tag attribute.

XmlFirstChild: Start enumerating child tags.

XmlNextChild: Enumerate child tags

Building an XML document

XmlSetTagAttrib: Set tag attribute.

XmlSetTagCont: Set tag contents with STRING.

XmlSetTagContT: Set tag contents with text buffer.

XmlAddChild: Add a child tag.

Exchanging variables using their name

XmlGetSybValue: Get variable value using its symbol.

XmlSetSybValue: Set variable value using its symbol.


XmlLastError

Programming languages - Reference guide -> Advanced operations -> XML writing and parsing -> Memory Management / Miscellaneous -> XmlLastError

Previous chapter Next chapter Show all Show all Hide all Hide all

XmlLastError – Function

Description

All XML functions and blocks simply return a boolean information as a return value. This function can be called after any other function giving a FALSE return. It gives a detailed error code about the last detected error.

Output | Description
iErr : DINT | Error code reported by the last call: 0 = OK. other = error.

Below are possible error codes:

Error Code | Description
1 2 3 4 5 6 7 8 9 | Invalid instance of XMLManager (should be only one). Manager already open - should be only one instance declared. Manager not open - no instance of XmlManager declared. Invalid handle. Too many tags allocated. Invalid handle of a text buffer (or no instance of TxbManager declared). Invalid XML file or XML syntax error. Cannot read file. Cannot write file.

seealso See also

Memory management / Miscellaneous

XmlManager: Main gatherer of XML data in memory.

XmlLastError: Get detailed error report about last call.

Reading/writing documents

XmlNewDoc: Create an empty XML document.

XmlFreeDoc: Release an XML document from memory.

XmlParseDocTxb: Parse an XML document from text buffer.

XmlParseDocFile: Parse an XML document form file.

XmlWriteDocTxb: Format XML data to text buffer.

XmlWriteDocFile: Format XML data to file.

Exploring an XML document

XmlGetTagName: Get name of an XML tag.

XmlCheckTagName: Test the name of an XML tag.

XmlGetTagCont: Get tag contents as STRING.

XmlGetTagContT: Get tag contents as text buffer.

XmlGetTagAttrib: Get tag attribute.

XmlFirstChild: Start enumerating child tags.

XmlNextChild: Enumerate child tags

Building an XML document

XmlSetTagAttrib: Set tag attribute.

XmlSetTagCont: Set tag contents with STRING.

XmlSetTagContT: Set tag contents with text buffer.

XmlAddChild: Add a child tag.

Exchanging variables using their name

XmlGetSybValue: Get variable value using its symbol.

XmlSetSybValue: Set variable value using its symbol.


Reading/writing documents

Programming languages - Reference guide -> Advanced operations -> XML writing and parsing -> Reading/writing documents

Previous chapter Next chapter Show all Show all Hide all Hide all

In this section

XmlNewDoc

XmlFreeDoc

XmlParseDocTxb

XmlParseDocFile

XmlWriteDocTxb

XmlWriteDocFile


XmlNewDoc

Programming languages - Reference guide -> Advanced operations -> XML writing and parsing -> Reading/writing documents -> XmlNewDoc

Previous chapter Next chapter Show all Show all Hide all Hide all

XmlNewDoc – Function

Description

This function allocates a new XML document, initially filled with one empty root tag. The application is responsible for releasing the allocated memory by calling the XmlFreeDoc function.

Input | Description
szTag : STRING | Name of the root tag.

Output | Description
hRootTag : DINT | Handle of the root tag. Can be used as a tag handle for building the document, or as a complete document handle for releasing the memory.

seealso See also

Memory management / Miscellaneous

XmlManager: Main gatherer of XML data in memory.

XmlLastError: Get detailed error report about last call.

Reading/writing documents

XmlNewDoc: Create an empty XML document.

XmlFreeDoc: Release an XML document from memory.

XmlParseDocTxb: Parse an XML document from text buffer.

XmlParseDocFile: Parse an XML document form file.

XmlWriteDocTxb: Format XML data to text buffer.

XmlWriteDocFile: Format XML data to file.

Exploring an XML document

XmlGetTagName: Get name of an XML tag.

XmlCheckTagName: Test the name of an XML tag.

XmlGetTagCont: Get tag contents as STRING.

XmlGetTagContT: Get tag contents as text buffer.

XmlGetTagAttrib: Get tag attribute.

XmlFirstChild: Start enumerating child tags.

XmlNextChild: Enumerate child tags

Building an XML document

XmlSetTagAttrib: Set tag attribute.

XmlSetTagCont: Set tag contents with STRING.

XmlSetTagContT: Set tag contents with text buffer.

XmlAddChild: Add a child tag.

Exchanging variables using their name

XmlGetSybValue: Get variable value using its symbol.

XmlSetSybValue: Set variable value using its symbol.


XmlFreeDoc

Programming languages - Reference guide -> Advanced operations -> XML writing and parsing -> Reading/writing documents -> XmlFreeDoc

Previous chapter Next chapter Show all Show all Hide all Hide all

XmlFreeDoc – Function

Description

This function releases the memory allocated for an XML document. It releases the specified tag and all its child tags. This function can also be used to delete a child tag and keep its parent tag in memory.

Input | Description
hRootTag : DINT | Handle of the XML document’s root tag.

Output | Description
bOK : BOOL | TRUE if successful.

seealso See also

Memory management / Miscellaneous

XmlManager: Main gatherer of XML data in memory.

XmlLastError: Get detailed error report about last call.

Reading/writing documents

XmlNewDoc: Create an empty XML document.

XmlFreeDoc: Release an XML document from memory.

XmlParseDocTxb: Parse an XML document from text buffer.

XmlParseDocFile: Parse an XML document form file.

XmlWriteDocTxb: Format XML data to text buffer.

XmlWriteDocFile: Format XML data to file.

Exploring an XML document

XmlGetTagName: Get name of an XML tag.

XmlCheckTagName: Test the name of an XML tag.

XmlGetTagCont: Get tag contents as STRING.

XmlGetTagContT: Get tag contents as text buffer.

XmlGetTagAttrib: Get tag attribute.

XmlFirstChild: Start enumerating child tags.

XmlNextChild: Enumerate child tags

Building an XML document

XmlSetTagAttrib: Set tag attribute.

XmlSetTagCont: Set tag contents with STRING.

XmlSetTagContT: Set tag contents with text buffer.

XmlAddChild: Add a child tag.

Exchanging variables using their name

XmlGetSybValue: Get variable value using its symbol.

XmlSetSybValue: Set variable value using its symbol.


XmlParseDocTxb

Programming languages - Reference guide -> Advanced operations -> XML writing and parsing -> Reading/writing documents -> XmlParseDocTxb

Previous chapter Next chapter Show all Show all Hide all Hide all

XmlParseDocTxb – Function

Description

This function parses the XML text contained in a text buffer and allocates a new XML document to store it. The application is responsible for releasing the allocated memory by calling the XmlFreeDoc function.

attention Attention

XML parsing and witing functions support only 8 bit encoding features. This can be UTF8 or ANSI (ISO-8859-1) encoding. Some additional functions will be provided for conversion between UTF8 and ANSI formats.

Input | Description
hTxb : DINT | Handle of a text buffer containing XML text.

Output | Description
hRootTag : DINT | Handle of the root tag. Can be used as a tag handle for exploringment, or as a complete document handle for releasing the memory.

seealso See also

Memory management / Miscellaneous

XmlManager: Main gatherer of XML data in memory.

XmlLastError: Get detailed error report about last call.

Reading/writing documents

XmlNewDoc: Create an empty XML document.

XmlFreeDoc: Release an XML document from memory.

XmlParseDocTxb: Parse an XML document from text buffer.

XmlParseDocFile: Parse an XML document form file.

XmlWriteDocTxb: Format XML data to text buffer.

XmlWriteDocFile: Format XML data to file.

Exploring an XML document

XmlGetTagName: Get name of an XML tag.

XmlCheckTagName: Test the name of an XML tag.

XmlGetTagCont: Get tag contents as STRING.

XmlGetTagContT: Get tag contents as text buffer.

XmlGetTagAttrib: Get tag attribute.

XmlFirstChild: Start enumerating child tags.

XmlNextChild: Enumerate child tags

Building an XML document

XmlSetTagAttrib: Set tag attribute.

XmlSetTagCont: Set tag contents with STRING.

XmlSetTagContT: Set tag contents with text buffer.

XmlAddChild: Add a child tag.

Exchanging variables using their name

XmlGetSybValue: Get variable value using its symbol.

XmlSetSybValue: Set variable value using its symbol.


XmlParseDocFile

Programming languages - Reference guide -> Advanced operations -> XML writing and parsing -> Reading/writing documents -> XmlParseDocFile

Previous chapter Next chapter Show all Show all Hide all Hide all

XmlParseDocFile – Function

Description

This function parses the XML text contained in a file and allocates a new XML document to store it. The application is responsible for releasing the allocated memory by calling the XmlFreeDoc function.

attention Attention

XML parsing and witing functions support only 8 bit encoding features. This can be UTF8 or ANSI (ISO-8859-1) encoding. Some additional functions will be provided for conversion between UTF8 and ANSI formats.

Input | Description
szPath : STRING | Full qualified pathname of the XML file.

Output | Description
hRootTag : DINT | Handle of the root tag. Can be used as a tag handle for exploringment, or as a complete document handle for releasing the memory.

seealso See also

Memory management / Miscellaneous

XmlManager: Main gatherer of XML data in memory.

XmlLastError: Get detailed error report about last call.

Reading/writing documents

XmlNewDoc: Create an empty XML document.

XmlFreeDoc: Release an XML document from memory.

XmlParseDocTxb: Parse an XML document from text buffer.

XmlParseDocFile: Parse an XML document form file.

XmlWriteDocTxb: Format XML data to text buffer.

XmlWriteDocFile: Format XML data to file.

Exploring an XML document

XmlGetTagName: Get name of an XML tag.

XmlCheckTagName: Test the name of an XML tag.

XmlGetTagCont: Get tag contents as STRING.

XmlGetTagContT: Get tag contents as text buffer.

XmlGetTagAttrib: Get tag attribute.

XmlFirstChild: Start enumerating child tags.

XmlNextChild: Enumerate child tags

Building an XML document

XmlSetTagAttrib: Set tag attribute.

XmlSetTagCont: Set tag contents with STRING.

XmlSetTagContT: Set tag contents with text buffer.

XmlAddChild: Add a child tag.

Exchanging variables using their name

XmlGetSybValue: Get variable value using its symbol.

XmlSetSybValue: Set variable value using its symbol.


XmlWriteDocTxb

Programming languages - Reference guide -> Advanced operations -> XML writing and parsing -> Reading/writing documents -> XmlWriteDocTxb

Previous chapter Next chapter Show all Show all Hide all Hide all

XmlWriteDocTxb – Function

Description

This function format an XML document to a text buffer. It does not releases the memory allocated for the XML document.

attention Attention

XML parsing and witing functions support only 8 bit encoding features. This can be UTF8 or ANSI (ISO-8859-1) encoding. Some additional functions will be provided for conversion between UTF8 and ANSI formats.

Input | Description
hRootTag : DINT | Handle of the XML document root tag.
hTxb : DINT | Handle of the text buffer where to store XML text. This handle has been allocated and will be released by the application.

Output | Description
bOK : BOOL | TRUE if successful.

seealso See also

Memory management / Miscellaneous

XmlManager: Main gatherer of XML data in memory.

XmlLastError: Get detailed error report about last call.

Reading/writing documents

XmlNewDoc: Create an empty XML document.

XmlFreeDoc: Release an XML document from memory.

XmlParseDocTxb: Parse an XML document from text buffer.

XmlParseDocFile: Parse an XML document form file.

XmlWriteDocTxb: Format XML data to text buffer.

XmlWriteDocFile: Format XML data to file.

Exploring an XML document

XmlGetTagName: Get name of an XML tag.

XmlCheckTagName: Test the name of an XML tag.

XmlGetTagCont: Get tag contents as STRING.

XmlGetTagContT: Get tag contents as text buffer.

XmlGetTagAttrib: Get tag attribute.

XmlFirstChild: Start enumerating child tags.

XmlNextChild: Enumerate child tags

Building an XML document

XmlSetTagAttrib: Set tag attribute.

XmlSetTagCont: Set tag contents with STRING.

XmlSetTagContT: Set tag contents with text buffer.

XmlAddChild: Add a child tag.

Exchanging variables using their name

XmlGetSybValue: Get variable value using its symbol.

XmlSetSybValue: Set variable value using its symbol.


XmlWriteDocFile

Programming languages - Reference guide -> Advanced operations -> XML writing and parsing -> Reading/writing documents -> XmlWriteDocFile

Previous chapter Next chapter Show all Show all Hide all Hide all

XmlWriteDocFile – Function

Description

This function format an XML document to a file. It does not releases the memory allocated for the XML document.

attention Attention

XML parsing and writing functions support only 8 bit encoding features. This can be UTF8 or ANSI (ISO-8859-1) encoding. Some additional functions will be provided for conversion between UTF8 and ANSI formats.

Input | Description
hRootTag : DINT | Handle of the XML document root tag.
szPath : STRING | Full qualified pathname of the XML file to be created.

Output | Description
bOK : BOOL | TRUE if successful.

seealso See also

Memory management / Miscellaneous

XmlManager: Main gatherer of XML data in memory.

XmlLastError: Get detailed error report about last call.

Reading/writing documents

XmlNewDoc: Create an empty XML document.

XmlFreeDoc: Release an XML document from memory.

XmlParseDocTxb: Parse an XML document from text buffer.

XmlParseDocFile: Parse an XML document form file.

XmlWriteDocTxb: Format XML data to text buffer.

XmlWriteDocFile: Format XML data to file.

Exploring an XML document

XmlGetTagName: Get name of an XML tag.

XmlCheckTagName: Test the name of an XML tag.

XmlGetTagCont: Get tag contents as STRING.

XmlGetTagContT: Get tag contents as text buffer.

XmlGetTagAttrib: Get tag attribute.

XmlFirstChild: Start enumerating child tags.

XmlNextChild: Enumerate child tags

Building an XML document

XmlSetTagAttrib: Set tag attribute.

XmlSetTagCont: Set tag contents with STRING.

XmlSetTagContT: Set tag contents with text buffer.

XmlAddChild: Add a child tag.

Exchanging variables using their name

XmlGetSybValue: Get variable value using its symbol.

XmlSetSybValue: Set variable value using its symbol.


Exploring an XML document

Programming languages - Reference guide -> Advanced operations -> XML writing and parsing -> Exploring an XML document

Previous chapter Next chapter Show all Show all Hide all Hide all

In this section

XmlGetTagName

XmlCheckTagName

XmlGetTagCont

XmlGetTagContT

XmlGetTagAttrib

XmlGetParent

XmlFirstChild

XmlNextChild


XmlGetTagName

Programming languages - Reference guide -> Advanced operations -> XML writing and parsing -> Exploring an XML document -> XmlGetTagName

Previous chapter Next chapter Show all Show all Hide all Hide all

XmlGetTagName – Function

Description

This function returns the name of an XML tag.

Input | Description
hTag : DINT | Handle of the XML tag.

Output | Description
szTag : STRING | Name of the tag. Ex: “ABC” for <ABC/>.

seealso See also

Memory management / Miscellaneous

XmlManager: Main gatherer of XML data in memory.

XmlLastError: Get detailed error report about last call.

Reading/writing documents

XmlNewDoc: Create an empty XML document.

XmlFreeDoc: Release an XML document from memory.

XmlParseDocTxb: Parse an XML document from text buffer.

XmlParseDocFile: Parse an XML document form file.

XmlWriteDocTxb: Format XML data to text buffer.

XmlWriteDocFile: Format XML data to file.

Exploring an XML document

XmlGetTagName: Get name of an XML tag.

XmlCheckTagName: Test the name of an XML tag.

XmlGetTagCont: Get tag contents as STRING.

XmlGetTagContT: Get tag contents as text buffer.

XmlGetTagAttrib: Get tag attribute.

XmlFirstChild: Start enumerating child tags.

XmlNextChild: Enumerate child tags

Building an XML document

XmlSetTagAttrib: Set tag attribute.

XmlSetTagCont: Set tag contents with STRING.

XmlSetTagContT: Set tag contents with text buffer.

XmlAddChild: Add a child tag.

Exchanging variables using their name

XmlGetSybValue: Get variable value using its symbol.

XmlSetSybValue: Set variable value using its symbol.


XmlCheckTagName

Programming languages - Reference guide -> Advanced operations -> XML writing and parsing -> Exploring an XML document -> XmlCheckTagName

Previous chapter Next chapter Show all Show all Hide all Hide all

XmlCheckTagName – Function

Description

This function returns TRUE if the specified tag has the specified name. This function makes case insensitive comparison of tag manes.

Input | Description
hTag : DINT | Handle of the XML tag.
szTag : STRING | Wished tag name.

Output | Description
bOK : BOOL | TRUE if the tag matches the specified name.

seealso See also

Memory management / Miscellaneous

XmlManager: Main gatherer of XML data in memory.

XmlLastError: Get detailed error report about last call.

Reading/writing documents

XmlNewDoc: Create an empty XML document.

XmlFreeDoc: Release an XML document from memory.

XmlParseDocTxb: Parse an XML document from text buffer.

XmlParseDocFile: Parse an XML document form file.

XmlWriteDocTxb: Format XML data to text buffer.

XmlWriteDocFile: Format XML data to file.

Exploring an XML document

XmlGetTagName: Get name of an XML tag.

XmlCheckTagName: Test the name of an XML tag.

XmlGetTagCont: Get tag contents as STRING.

XmlGetTagContT: Get tag contents as text buffer.

XmlGetTagAttrib: Get tag attribute.

XmlFirstChild: Start enumerating child tags.

XmlNextChild: Enumerate child tags

Building an XML document

XmlSetTagAttrib: Set tag attribute.

XmlSetTagCont: Set tag contents with STRING.

XmlSetTagContT: Set tag contents with text buffer.

XmlAddChild: Add a child tag.

Exchanging variables using their name

XmlGetSybValue: Get variable value using its symbol.

XmlSetSybValue: Set variable value using its symbol.


XmlGetTagCont

Programming languages - Reference guide -> Advanced operations -> XML writing and parsing -> Exploring an XML document -> XmlGetTagCont

Previous chapter Next chapter Show all Show all Hide all Hide all

XmlGetTagCont – Function

Description

This function copies the contents of an XML tag to a variable. The specified variable can have any data type.

Input | Description
hTag : DINT | Handle of the XML tag.
data : ANY | Variable to be assigned with the contents of the tag.

Output | Description
bOK : BOOL | TRUE if successful.

seealso See also

Memory management / Miscellaneous

XmlManager: Main gatherer of XML data in memory.

XmlLastError: Get detailed error report about last call.

Reading/writing documents

XmlNewDoc: Create an empty XML document.

XmlFreeDoc: Release an XML document from memory.

XmlParseDocTxb: Parse an XML document from text buffer.

XmlParseDocFile: Parse an XML document form file.

XmlWriteDocTxb: Format XML data to text buffer.

XmlWriteDocFile: Format XML data to file.

Exploring an XML document

XmlGetTagName: Get name of an XML tag.

XmlCheckTagName: Test the name of an XML tag.

XmlGetTagCont: Get tag contents as STRING.

XmlGetTagContT: Get tag contents as text buffer.

XmlGetTagAttrib: Get tag attribute.

XmlFirstChild: Start enumerating child tags.

XmlNextChild: Enumerate child tags

Building an XML document

XmlSetTagAttrib: Set tag attribute.

XmlSetTagCont: Set tag contents with STRING.

XmlSetTagContT: Set tag contents with text buffer.

XmlAddChild: Add a child tag.

Exchanging variables using their name

XmlGetSybValue: Get variable value using its symbol.

XmlSetSybValue: Set variable value using its symbol.


XmlGetTagContT

Programming languages - Reference guide -> Advanced operations -> XML writing and parsing -> Exploring an XML document -> XmlGetTagContT

Previous chapter Next chapter Show all Show all Hide all Hide all

XmlGetTagContT – Function

Description

This function copies the contents of an XML tag to a text buffer. The text buffer is allocated by the function, and must be released by the application after use.

Input | Description
hTag : DINT | Handle of the XML tag.

Output | Description
hTxb : DINT | Handle of the text buffer allocated and filled with tag contents.

seealso See also

Memory management / Miscellaneous

XmlManager: Main gatherer of XML data in memory.

XmlLastError: Get detailed error report about last call.

Reading/writing documents

XmlNewDoc: Create an empty XML document.

XmlFreeDoc: Release an XML document from memory.

XmlParseDocTxb: Parse an XML document from text buffer.

XmlParseDocFile: Parse an XML document form file.

XmlWriteDocTxb: Format XML data to text buffer.

XmlWriteDocFile: Format XML data to file.

Exploring an XML document

XmlGetTagName: Get name of an XML tag.

XmlCheckTagName: Test the name of an XML tag.

XmlGetTagCont: Get tag contents as STRING.

XmlGetTagContT: Get tag contents as text buffer.

XmlGetTagAttrib: Get tag attribute.

XmlFirstChild: Start enumerating child tags.

XmlNextChild: Enumerate child tags

Building an XML document

XmlSetTagAttrib: Set tag attribute.

XmlSetTagCont: Set tag contents with STRING.

XmlSetTagContT: Set tag contents with text buffer.

XmlAddChild: Add a child tag.

Exchanging variables using their name

XmlGetSybValue: Get variable value using its symbol.

XmlSetSybValue: Set variable value using its symbol.


XmlGetTagAttrib

Programming languages - Reference guide -> Advanced operations -> XML writing and parsing -> Exploring an XML document -> XmlGetTagAttrib

Previous chapter Next chapter Show all Show all Hide all Hide all

XmlGetTagAttrib – Function

Description

This function copies the contents of an XML attribute to a variable. The specified variable can have any data type.

Input | Description
hTag : DINT | Handle of the XML tag.
szAttrib : STRING | Name of the wished attribute.
data : ANY | Variable to be assigned with the value of the tag attribute.

Output | Description
bOK : BOOL | TRUE if successful.

seealso See also

Memory management / Miscellaneous

XmlManager: Main gatherer of XML data in memory.

XmlLastError: Get detailed error report about last call.

Reading/writing documents

XmlNewDoc: Create an empty XML document.

XmlFreeDoc: Release an XML document from memory.

XmlParseDocTxb: Parse an XML document from text buffer.

XmlParseDocFile: Parse an XML document form file.

XmlWriteDocTxb: Format XML data to text buffer.

XmlWriteDocFile: Format XML data to file.

Exploring an XML document

XmlGetTagName: Get name of an XML tag.

XmlCheckTagName: Test the name of an XML tag.

XmlGetTagCont: Get tag contents as STRING.

XmlGetTagContT: Get tag contents as text buffer.

XmlGetTagAttrib: Get tag attribute.

XmlFirstChild: Start enumerating child tags.

XmlNextChild: Enumerate child tags

Building an XML document

XmlSetTagAttrib: Set tag attribute.

XmlSetTagCont: Set tag contents with STRING.

XmlSetTagContT: Set tag contents with text buffer.

XmlAddChild: Add a child tag.

Exchanging variables using their name

XmlGetSybValue: Get variable value using its symbol.

XmlSetSybValue: Set variable value using its symbol.


XmlGetParent

Programming languages - Reference guide -> Advanced operations -> XML writing and parsing -> Exploring an XML document -> XmlGetParent

Previous chapter Next chapter Show all Show all Hide all Hide all

XmlGetParent – Function

Description

This function returns the handle of the parent of an XML tag.

Input | Description
IN : DINT | Handle of the XML tag.

Output | Description
OUT : DINT | Handle of the parent tag.

seealso See also

Memory management / Miscellaneous

XmlManager: Main gatherer of XML data in memory.

XmlLastError: Get detailed error report about last call.

Reading/writing documents

XmlNewDoc: Create an empty XML document.

XmlFreeDoc: Release an XML document from memory.

XmlParseDocTxb: Parse an XML document from text buffer.

XmlParseDocFile: Parse an XML document form file.

XmlWriteDocTxb: Format XML data to text buffer.

XmlWriteDocFile: Format XML data to file.

Exploring an XML document

XmlGetTagName: Get name of an XML tag.

XmlCheckTagName: Test the name of an XML tag.

XmlGetTagCont: Get tag contents as STRING.

XmlGetTagContT: Get tag contents as text buffer.

XmlGetTagAttrib: Get tag attribute.

XmlFirstChild: Start enumerating child tags.

XmlNextChild: Enumerate child tags

Building an XML document

XmlSetTagAttrib: Set tag attribute.

XmlSetTagCont: Set tag contents with STRING.

XmlSetTagContT: Set tag contents with text buffer.

XmlAddChild: Add a child tag.

Exchanging variables using their name

XmlGetSybValue: Get variable value using its symbol.

XmlSetSybValue: Set variable value using its symbol.


XmlFirstChild

Programming languages - Reference guide -> Advanced operations -> XML writing and parsing -> Exploring an XML document -> XmlFirstChild

Previous chapter Next chapter Show all Show all Hide all Hide all

XmlFirstChild – Function

Description

This function returns the handle of the first child tag having the specified name. If “szTag” is empty, then the first child tag is returned whatever its name is.

Input | Description
hTag : DINT | Handle of the XML tag.
szTag : STRING | Name of the wished child tag. Empty string for enumerating all children.

Output | Description
hChildTag | Handle of the first child tag matching the specified name, or 0 if no child found.

Typical use in ST:

hChild := XmlFirstChild (hParentTag, 'TagName');

while hChild <> 0 do

(* explore the tag *)

hChild := XmlNextChild (hParentTag, hChild, 'TagName');

end_while;

seealso See also

Memory management / Miscellaneous

XmlManager: Main gatherer of XML data in memory.

XmlLastError: Get detailed error report about last call.

Reading/writing documents

XmlNewDoc: Create an empty XML document.

XmlFreeDoc: Release an XML document from memory.

XmlParseDocTxb: Parse an XML document from text buffer.

XmlParseDocFile: Parse an XML document form file.

XmlWriteDocTxb: Format XML data to text buffer.

XmlWriteDocFile: Format XML data to file.

Exploring an XML document

XmlGetTagName: Get name of an XML tag.

XmlCheckTagName: Test the name of an XML tag.

XmlGetTagCont: Get tag contents as STRING.

XmlGetTagContT: Get tag contents as text buffer.

XmlGetTagAttrib: Get tag attribute.

XmlFirstChild: Start enumerating child tags.

XmlNextChild: Enumerate child tags

Building an XML document

XmlSetTagAttrib: Set tag attribute.

XmlSetTagCont: Set tag contents with STRING.

XmlSetTagContT: Set tag contents with text buffer.

XmlAddChild: Add a child tag.

Exchanging variables using their name

XmlGetSybValue: Get variable value using its symbol.

XmlSetSybValue: Set variable value using its symbol.


XmlNextChild

Programming languages - Reference guide -> Advanced operations -> XML writing and parsing -> Exploring an XML document -> XmlNextChild

Previous chapter Next chapter Show all Show all Hide all Hide all

XmlNextChild – Function

Description

This function returns the handle of the next child tag having the specified name. If szTag is empty, then the next child tag is returned whatever its name is.

Input | Description
hTag : DINT | Handle of the XML tag.
hChildTag : DINT | Handle of the previous child tag.
szTag : STRING | Name of the wished child tag. Empty string for enumerating all children.

Output | Description
hChildNext | Handle of the next child tag matching the specified name, or 0 if no child found.

Typical use in ST:

hChild := XmlFirstChild (hParentTag, 'TagName');

while hChild <> 0 do

(* explore the tag *)

hChild := XmlNextChild (hParentTag, hChild, 'TagName');

end_while;

seealso See also

Memory management / Miscellaneous

XmlManager: Main gatherer of XML data in memory.

XmlLastError: Get detailed error report about last call.

Reading/writing documents

XmlNewDoc: Create an empty XML document.

XmlFreeDoc: Release an XML document from memory.

XmlParseDocTxb: Parse an XML document from text buffer.

XmlParseDocFile: Parse an XML document form file.

XmlWriteDocTxb: Format XML data to text buffer.

XmlWriteDocFile: Format XML data to file.

Exploring an XML document

XmlGetTagName: Get name of an XML tag.

XmlCheckTagName: Test the name of an XML tag.

XmlGetTagCont: Get tag contents as STRING.

XmlGetTagContT: Get tag contents as text buffer.

XmlGetTagAttrib: Get tag attribute.

XmlFirstChild: Start enumerating child tags.

XmlNextChild: Enumerate child tags

Building an XML document

XmlSetTagAttrib: Set tag attribute.

XmlSetTagCont: Set tag contents with STRING.

XmlSetTagContT: Set tag contents with text buffer.

XmlAddChild: Add a child tag.

Exchanging variables using their name

XmlGetSybValue: Get variable value using its symbol.

XmlSetSybValue: Set variable value using its symbol.


Building an XML document

Programming languages - Reference guide -> Advanced operations -> XML writing and parsing -> Building an XML document

Previous chapter Next chapter Show all Show all Hide all Hide all

In this section

XmlSetTagAttrib

XmlSetTagCont

XmlSetTagContT

XmlAddChild


XmlSetTagAttrib

Programming languages - Reference guide -> Advanced operations -> XML writing and parsing -> Building an XML document -> XmlSetTagAttrib

Previous chapter Next chapter Show all Show all Hide all Hide all

XmlSetTagAttrib – Function

Description

This function copies the value of a variable to an XML attribute. The specified variable can have any data type.

Input | Description
hTag : DINT | Handle of the XML tag.
szAttrib : STRING | Name of the attribute.
data : ANY | Variable to be copied to the value of the tag attribute.

Output | Description
bOK : BOOL | TRUE if successful.

seealso See also

Memory management / Miscellaneous

XmlManager: Main gatherer of XML data in memory.

XmlLastError: Get detailed error report about last call.

Reading/writing documents

XmlNewDoc: Create an empty XML document.

XmlFreeDoc: Release an XML document from memory.

XmlParseDocTxb: Parse an XML document from text buffer.

XmlParseDocFile: Parse an XML document form file.

XmlWriteDocTxb: Format XML data to text buffer.

XmlWriteDocFile: Format XML data to file.

Exploring an XML document

XmlGetTagName: Get name of an XML tag.

XmlCheckTagName: Test the name of an XML tag.

XmlGetTagCont: Get tag contents as STRING.

XmlGetTagContT: Get tag contents as text buffer.

XmlGetTagAttrib: Get tag attribute.

XmlFirstChild: Start enumerating child tags.

XmlNextChild: Enumerate child tags

Building an XML document

XmlSetTagAttrib: Set tag attribute.

XmlSetTagCont: Set tag contents with STRING.

XmlSetTagContT: Set tag contents with text buffer.

XmlAddChild: Add a child tag.

Exchanging variables using their name

XmlGetSybValue: Get variable value using its symbol.

XmlSetSybValue: Set variable value using its symbol.


XmlSetTagCont

Programming languages - Reference guide -> Advanced operations -> XML writing and parsing -> Building an XML document -> XmlSetTagCont

Previous chapter Next chapter Show all Show all Hide all Hide all

XmlSetTagCont – Function

Description

This function copies the value of a variable to the contents of an XML tag. The specified variable can have any data type.

Input | Description
hTag : DINT | Handle of the XML tag.
data : ANY | Variable to be copied to the contents of the tag.

Output | Description
bOK : BOOL | TRUE if successful.

seealso See also

Memory management / Miscellaneous

XmlManager: Main gatherer of XML data in memory.

XmlLastError: Get detailed error report about last call.

Reading/writing documents

XmlNewDoc: Create an empty XML document.

XmlFreeDoc: Release an XML document from memory.

XmlParseDocTxb: Parse an XML document from text buffer.

XmlParseDocFile: Parse an XML document form file.

XmlWriteDocTxb: Format XML data to text buffer.

XmlWriteDocFile: Format XML data to file.

Exploring an XML document

XmlGetTagName: Get name of an XML tag.

XmlCheckTagName: Test the name of an XML tag.

XmlGetTagCont: Get tag contents as STRING.

XmlGetTagContT: Get tag contents as text buffer.

XmlGetTagAttrib: Get tag attribute.

XmlFirstChild: Start enumerating child tags.

XmlNextChild: Enumerate child tags

Building an XML document

XmlSetTagAttrib: Set tag attribute.

XmlSetTagCont: Set tag contents with STRING.

XmlSetTagContT: Set tag contents with text buffer.

XmlAddChild: Add a child tag.

Exchanging variables using their name

XmlGetSybValue: Get variable value using its symbol.

XmlSetSybValue: Set variable value using its symbol.


XmlSetTagContT

Programming languages - Reference guide -> Advanced operations -> XML writing and parsing -> Building an XML document -> XmlSetTagContT

Previous chapter Next chapter Show all Show all Hide all Hide all

XmlSetTagContT – Function

Description

This function copies a text buffer to the contents of an XML tag. The text buffer is allocated by the application, and must be released by the application after use.

Input | Description
hTag : DINT | Handle of the XML tag.
hTxb : DINT | Handle of the text buffer to be copied.

Output | Description
bOK : BOOL | TRUE if successful.

seealso See also

Memory management / Miscellaneous

XmlManager: Main gatherer of XML data in memory.

XmlLastError: Get detailed error report about last call.

Reading/writing documents

XmlNewDoc: Create an empty XML document.

XmlFreeDoc: Release an XML document from memory.

XmlParseDocTxb: Parse an XML document from text buffer.

XmlParseDocFile: Parse an XML document form file.

XmlWriteDocTxb: Format XML data to text buffer.

XmlWriteDocFile: Format XML data to file.

Exploring an XML document

XmlGetTagName: Get name of an XML tag.

XmlCheckTagName: Test the name of an XML tag.

XmlGetTagCont: Get tag contents as STRING.

XmlGetTagContT: Get tag contents as text buffer.

XmlGetTagAttrib: Get tag attribute.

XmlFirstChild: Start enumerating child tags.

XmlNextChild: Enumerate child tags

Building an XML document

XmlSetTagAttrib: Set tag attribute.

XmlSetTagCont: Set tag contents with STRING.

XmlSetTagContT: Set tag contents with text buffer.

XmlAddChild: Add a child tag.

Exchanging variables using their name

XmlGetSybValue: Get variable value using its symbol.

XmlSetSybValue: Set variable value using its symbol.


XmlAddChild

Programming languages - Reference guide -> Advanced operations -> XML writing and parsing -> Building an XML document -> XmlAddChild

Previous chapter Next chapter Show all Show all Hide all Hide all

XmlAddChild – Function

Description

This function adds a new child tag to an XML tag, with the specified tag name.

Input | Description
hTag : DINT | Handle of the XML tag.
szTag : STRING | Name of the new child tag.

Output | Description
hChildTag : DINT | Handle of the new child tag.

seealso See also

Memory management / Miscellaneous

XmlManager: Main gatherer of XML data in memory.

XmlLastError: Get detailed error report about last call.

Reading/writing documents

XmlNewDoc: Create an empty XML document.

XmlFreeDoc: Release an XML document from memory.

XmlParseDocTxb: Parse an XML document from text buffer.

XmlParseDocFile: Parse an XML document form file.

XmlWriteDocTxb: Format XML data to text buffer.

XmlWriteDocFile: Format XML data to file.

Exploring an XML document

XmlGetTagName: Get name of an XML tag.

XmlCheckTagName: Test the name of an XML tag.

XmlGetTagCont: Get tag contents as STRING.

XmlGetTagContT: Get tag contents as text buffer.

XmlGetTagAttrib: Get tag attribute.

XmlFirstChild: Start enumerating child tags.

XmlNextChild: Enumerate child tags

Building an XML document

XmlSetTagAttrib: Set tag attribute.

XmlSetTagCont: Set tag contents with STRING.

XmlSetTagContT: Set tag contents with text buffer.

XmlAddChild: Add a child tag.

Exchanging variables using their name

XmlGetSybValue: Get variable value using its symbol.

XmlSetSybValue: Set variable value using its symbol.


Exchanging variables using their name

Programming languages - Reference guide -> Advanced operations -> XML writing and parsing -> Exchanging variables using their name

Previous chapter Next chapter Show all Show all Hide all Hide all

In this section

XmlGetSybValue

XmlSetSybValue


XmlGetSybValue

Programming languages - Reference guide -> Advanced operations -> XML writing and parsing -> Exchanging variables using their name -> XmlGetSybValue

Previous chapter Next chapter Show all Show all Hide all Hide all

XmlGetSybValue – Function

Description

This function copies the value of the variable having the symbol specified in szSyb to the output string. It assumes that the symbol of the variable has been embedded in the runtime application.

This function enables the automation of data exchange between XML data and the runtime. For example, you can find the symbol of a variable in a tag attribute and update the value in another one.

Input | Description
szSyb : STRING | Symbol of the variable.
keepCase : BOOL | Default is FALSE as normally all embedded symbols are turned uppercase by the compiler. Must be TRUE if the Keep case of embedded symbols compiling option is set.

Output | Description
value : STRING | Current value of the variable formatted as STRING.

seealso See also

Memory management / Miscellaneous

XmlManager: Main gatherer of XML data in memory.

XmlLastError: Get detailed error report about last call.

Reading/writing documents

XmlNewDoc: Create an empty XML document.

XmlFreeDoc: Release an XML document from memory.

XmlParseDocTxb: Parse an XML document from text buffer.

XmlParseDocFile: Parse an XML document form file.

XmlWriteDocTxb: Format XML data to text buffer.

XmlWriteDocFile: Format XML data to file.

Exploring an XML document

XmlGetTagName: Get name of an XML tag.

XmlCheckTagName: Test the name of an XML tag.

XmlGetTagCont: Get tag contents as STRING.

XmlGetTagContT: Get tag contents as text buffer.

XmlGetTagAttrib: Get tag attribute.

XmlFirstChild: Start enumerating child tags.

XmlNextChild: Enumerate child tags

Building an XML document

XmlSetTagAttrib: Set tag attribute.

XmlSetTagCont: Set tag contents with STRING.

XmlSetTagContT: Set tag contents with text buffer.

XmlAddChild: Add a child tag.

Exchanging variables using their name

XmlGetSybValue: Get variable value using its symbol.

XmlSetSybValue: Set variable value using its symbol.


XmlSetSybValue

Programming languages - Reference guide -> Advanced operations -> XML writing and parsing -> Exchanging variables using their name -> XmlSetSybValue

Previous chapter Next chapter Show all Show all Hide all Hide all

XmlSetSybValue – Function

Description

This function copies the value of the variable having the symbol specified in szSyb to the output string. It assumes that the symbol of the variable has been embedded in the runtime application.

This function enables the automation of data exchange between XML data and the runtime. For example, you can find the symbol of a variable in a tag attribute and the value in another one.

Input | Description
szSyb : STRING | Symbol of the variable.
value : STRING | Value to be assigned to the variable, formatted as STRING.
keepCase : BOOL | Default is FALSE as normally all embedded symbols are turned uppercase by the compiler. Must be TRUE if the Keep case of embedded symbols compiling option is set.

Output | Description
bOK : BOOL | TRUE if successful.

seealso See also

Memory management / Miscellaneous

XmlManager: Main gatherer of XML data in memory.

XmlLastError: Get detailed error report about last call.

Reading/writing documents

XmlNewDoc: Create an empty XML document.

XmlFreeDoc: Release an XML document from memory.

XmlParseDocTxb: Parse an XML document from text buffer.

XmlParseDocFile: Parse an XML document form file.

XmlWriteDocTxb: Format XML data to text buffer.

XmlWriteDocFile: Format XML data to file.

Exploring an XML document

XmlGetTagName: Get name of an XML tag.

XmlCheckTagName: Test the name of an XML tag.

XmlGetTagCont: Get tag contents as STRING.

XmlGetTagContT: Get tag contents as text buffer.

XmlGetTagAttrib: Get tag attribute.

XmlFirstChild: Start enumerating child tags.

XmlNextChild: Enumerate child tags

Building an XML document

XmlSetTagAttrib: Set tag attribute.

XmlSetTagCont: Set tag contents with STRING.

XmlSetTagContT: Set tag contents with text buffer.

XmlAddChild: Add a child tag.

Exchanging variables using their name

XmlGetSybValue: Get variable value using its symbol.

XmlSetSybValue: Set variable value using its symbol.


The Win-GRAF PAC Registry management functions

Programming languages - Reference guide -> Advanced operations -> The Win-GRAF PAC Registry management functions

Previous chapter Next chapter Show all Show all Hide all Hide all

The The Win-GRAF PAC Registry enables you to design and monitor remotely a hierarchical registry of parameters. Parameters can be set apart from the Workbench, and can also be read or written from the IEC program.

The following functions are available:

RegParGet Get the current value of a parameter.
RegParPut Change the value of a parameter.

Parameter pathnames

Any parameter is specified by a full qualified pathname that gives its exact location in the registry. The / separator is used to separate folders in the pathname. For a registry defined as:

(Root)
- Folder1
- Folder2
- MyParam

The pathname of the parameter will be:

/Folder1/Folder2/MyParam

attention Attention
  • The Win-GRAF PAC Registry may be not available on some targets. Please refer to OEM instructions for further details about available features.
  • All parameter pathnames are case sensitive.

RegParGet: get the current value of a parameter

Q := RegParGet (PATH, DEF);

PATH : STRING specifies the full pathname of the parameter in the registry.
DEF : ANY default value to be returned if the parameter does not exist.
Q : ANY current value of the parameter.

attention Attention

The DEF input defines the actual type for ANY pins. If you specify a constant expression, it must be fully type-qualified according to the wished returned value. Example for getting a parameter as an INT:

intVariable := RegParGet ('\MyParam', INT#0);

All pathnames are case sensitive.

RegParPut: change the value of a parameter

OK := RegParPut (PATH, IN);

PATH : STRING specifies the full pathname of the parameter in the registry.
IN : ANY new value for the parameter.
OK : BOOL TRUE if successful.

The function will returned FALSE in the following cases:

  • The specified pathname is not found in the registry.
  • The registry is currently being saved and cannot be changed.


Embedded HMI

Embedded HMI

The Workbench enables you to design and integrate in your project an Embbed HMI application to be run on your runtime platform, assuming that it has a graphic display available. The Embedded HMI manages the animated display of screen masks designed in the Workbench with appropriate tools. Interactions between the IEC application and the embedded HMI is performed through variables (controlled by the IEC program and linked to some properties of graphic objects) plus a set of functions and function blocks.

For enabling the Embedded HMI in your IEC application you need to:

1- from the Workspace when the project is selected, run "Insert Shortcut / Embedded HMI" command from the context menu

2- declare one instance of the hmiManager function block.

During step #1, you must select the kind of device (hardware display) available on your system. Refer to OEM's instructions for more information about available hardware.

In this section

Embedded HMI strings

Embedded HMI bitmaps

Embedded HMI character fonts

Embedded HMI screens

Embedded HMI functions and blocks

Managing menus


Embedded HMI strings

Embedded HMI -> Embedded HMI strings

The string editor for Embedded HMI enables you to enter a collection of strings to be used as static properties among graphic objects put in screen masks. Each string is identified by a name. Using strings instead of entering texts directly in objects properties is a nice way to get the consistent set of texts used in your HMI application in one look, and eases the translation to other languages.


Embedded HMI bitmaps

Embedded HMI -> Embedded HMI bitmaps

In order to insert pictures (bitmaps) in screen masks, you first need to declare them in the Bitmap Editor for Embedded HMI. Each bitmap declared here is defined as:

- a name (ID) to be used in graphic objects properties and IEC programs

- a pathname to a valid .BMP file (other image formats are not supported)

If you don't specify any path for the .BMP file, it is searched in the \BITMAP folder where the Workbench is installed.

Bitmap IDs can be directly used in IEC programs as integer values, in order for example to set a dynamically changed bitmap to an object through a variable. You don't need to declare or define bitmap IDs in the IEC application. Their name are automatically known by the compiler.

Bitmaps are automatically converted into the set of colors available on the selected display device.


Embedded HMI character fonts

Embedded HMI -> Embedded HMI character fonts

In order to use character fonts in screen masks, you first need to declare them in the Font Editor for Embedded HMI. Each font declared can be defined as:

- either a system font if available on your display device

- or a specific user-defined charcter font (see below)

User defined character fonts are stored in files suffixed with ".K5FNT" and created with a tool installed with the Workbench.

To create or change a specific character font run the "Font Editor" command from the popu menu.

If you don't specify any path for a font file, it is searched in the \FONT folder where the Workbench is installed.

Font IDs can be directly used in IEC programs as integer values, in order for example to set a dynamically changed font to an object through a variable. You don't need to declare or define font IDs in the IEC application. Their name are automatically known by the compiler.


Embedded HMI screens

Embedded HMI -> Embedded HMI screens

The Embedded HMI application is designed as a set of screen masks. To create a new screen, run the "Insert Item / New Screen" command from the context menu in the Workspace. Each screen is identified by a name (ID) such as shown in the workspace tree. You can change this ID using the "Rename" command.

The hmiSetScreen function enables you to dynamically change the active screen mask from IEC programs.

Screen IDs can be directly used in IEC programs as integer values. You don't need to declare or define again IDs in the IEC application. Their name are automatically known by the compiler.

Double click on a screen in the Workspace to edit its contents. A screen mask is designed as:

- some properties visible when no object is selected,

- a set of graphic objects having static or dynamic properties.

In this section

Embedded HMI graphic objects


Embedded HMI graphic objects

Embedded HMI -> Embedded HMI screens -> Embedded HMI graphic objects

Previous chapter Next chapter Show all Show all Hide all Hide all

A graphic object is a predefined piece of graphic to be inserted into a screen mask. Eache object has a set of properties that can be either statically defined or dynamically set by the IEC program through the value of a variable. The following kinds of objects are available:

- Rectangle (shape or text area)

- Bargrapgh

- Picture (bitmap)

Available objects are displayed in the bottom-right area of the screen editor. Just drag them to the screen and then fill up their properties.

Rectangle (or text area)

This object is used for the display of a rectangle area that may contain a single line of text. Its properties are:

Property | Meaning
Align | Horizontal alignment for the text (left, center or right). If dynamically passed through a variable, use these values: 0 = center -1 = left 1 = right
Border color | Color index of the border (can be dynamically passed through a variable)
Border size | Width of the border in pixels (0 = no border)
Back. color | Background color index (can be dynamically passed through a variable)
Text color | Color of the text (can be dynamically changed through a variable)
Text | Text to be displayed: can be a speicif text, or an ID of a declared HMI string, or the name of a STRING variable
Font | Character font: can be an ID of a declared font or the name of an integer variable that will contain this ID.

Round rectangle

This object is used for the display of a rounded rectangle area that may contain a single line of text. Its properties are:

Property | Meaning
Align | Horizontal alignment for the text (left, center or right). If dynamically passed through a variable, use these values: 0 = center -1 = left 1 = right
Border color | Color index of the border (can be dynamically passed through a variable)
Border size | Width of the border in pixels (0 = no border)
Back. color | Background color index (can be dynamically passed through a variable)
Text color | Color of the text (can be dynamically changed through a variable)
Text | Text to be displayed: can be a speicif text, or an ID of a declared HMI string, or the name of a STRING variable
Font | Character font: can be an ID of a declared font or the name of an integer variable that will contain this ID.
Round corner | Size of the round corner, in pixels

Ellipse

This object is used for the display of an ellipse or circle. Its properties are:

Property | Meaning
Border color | Color index of the border (can be dynamically passed through a variable)
Border size | Width of the border in pixels (0 = no border)
Fill color | Background color index (can be dynamically passed through a variable)
Font | Character font: can be an ID of a declared font or the name of an integer variable that will contain this ID.
Text color | Color of the text (can be dynamically changed through a variable)
Text | List of choices (lines) to be displayed, separated by '|' characters. E.g.: Choice1|Choice2|Choice3

Line

This object is used for the display of a line. Its properties are:

Property | Meaning
Direction | Direction of the line within its rectangle area
Line width | Width of the line, in pixels
Status | Boolean status for color selection
Color FALSE | Line color when status is FALSE
Color TRUE | Line color when status is TRUE

Bargraph

This object is used for the display of a bargraph reactangle area. Its properties are:

Property | Meaning
Direction | Growing direction of the bargraph. If dynamically passed through a variable, use these values: 0 = left to right 1 = bottom to top 2 = right to left 3 = top to bottom
Border color | Color index of the border (can be dynamically passed through a variable)
Border size | Width of the border in pixels (0 = no border)
Back. color | Background color index (can be dynamically passed through a variable)
Fill color | Color of the filled part (can be dynamically changed through a variable)
Fill value | Percentage of the rectangle filled (from 0 to 100), generally exchanged through an integer variable.

Picture (bitmap)

This object is used for the display of a bitmap picture. Its properties are:

Property | Meaning
Back. color | Background color index used if the object is larger than the bitmap.
Bitmap | ID of the bitmap declared in the bitmap editor. Can be the name of an integer variiable that will contain this ID.

Trend

This object is used for the display of a trend diagram. Its properties are:

Property | Meaning
Style | Kind of drawing. Possible values are: 1: histogram (filled area under the curve) 2: points (curve line)
Border color | Color index of the border (can be dynamically passed through a variable)
Border size | Width of the border in pixels (0 = no border)
Back. color | Background color index (can be dynamically passed through a variable)
Fill color | Color of the filled part (can be dynamically changed through a variable)
Item width | Number of pixels on the X axis for each sample of the trend
First array item | 0-based index of the item of the array to be displayed as the first value
Last array item | 0-based index of the item of the array to be displayed as the last value
Array | Array of values to be displayed (in range 0-100)

Menu

This object is used for the display of menu like scrollable choice list. Its properties are:

Property | Meaning
Align | Horizontal alignment for the text (left, center or right). If dynamically passed through a variable, use these values: 0 = center -1 = left 1 = right
Border color | Color index of the border (can be dynamically passed through a variable)
Border size | Width of the border in pixels (0 = no border)
Font | Character font: can be an ID of a declared font or the name of an integer variable that will contain this ID.
Back. color | Background color index (can be dynamically passed through a variable)
Text color | Color of the text (can be dynamically changed through a variable)
Select font | Character font for the selected line
Select back. color | Background color index of the selected line
Select text color | Color of the text on the selected line
Text | List of choices (lines) to be displayed, separated by '|' characters. E.g.: Choice1|Choice2|Choice3
Line height | Height of a line, in pixels
Selection | Index of the selected line (first line is 1) Any selection is removed if this value is 0


Embedded HMI functions and blocks

Embedded HMI -> Embedded HMI functions and blocks

A set of functions and function blocks is available for the dynamic control of the Embedded HMI application from the IEC programs.

In this section

hmiManager

hmiSetScreen


hmiManager

Embedded HMI -> Embedded HMI functions and blocks -> hmiManager

Previous chapter Next chapter Show all Show all Hide all Hide all

Function Block - Enable the use of Embedded HMI.

Outputs

OK : BOOL TRUE if Embedded HMI is active.

Remarks

You need to declare one and only one instance of this function block in order to activate the Embedded HMI.

It is not mandatory to call the instance from your program. Declaring the instance is enough for activation.


hmiSetScreen

Embedded HMI -> Embedded HMI functions and blocks -> hmiSetScreen

Previous chapter Next chapter Show all Show all Hide all Hide all

Function - Set the active screen for the Embedded HMI.

Inputs

ID : DINT Identifier of the screen.
DISPLAY : DINT This parameter is reserved for extensions and must be 0.

Outputs

OK : BOOL TRUE if successful.

Remarks

Call this function in order to set the active screen of the Embedded HMI.

The screen ID is the name given to the screen such as displayed in the project tree.

Example

hmiSetScreen (IDP1, 0);


Managing menus

Embedded HMI -> Managing menus

The system includes a set of functions function blocks for easily managing hierarchical menus within an embedded HMI application. These functions are intended to be used together with the "Menu" graphic object for embedded HMI screens.

attention Attention
  • Menu management functions use safe dynamic memory allocation that needs to be configured in the project settings. From the project settings, press the "Advanced" push button and go to "Memory" tab. Here you can setup the memory for safe dynamic allocation.

Creating a hierarchy of menus

The following functions are used to create menus. They should be called once when the application starts so that the hierarchy of menus remain available in memory for use with the "Menu" graphic object. The following functions are available:

hMenu := HmiNewMenu (hParentMenu, strTitle); (* creates a main or sub menu *)

hItem := HmiNewMenuItem (hParentMenu, strChoice, idCommand); (* adds a choice to a menu *)

ok := HmiRenameMenu (hItem, strChoice); (* changes the text of a choice or the title of a menu *)

ok := HmiDelMenu (hItem); (* deletes a nemu item of a menu *)

Arguments:

hMenu : BOOL; (* handle of a main or sub menu *)

hParentMenu : DINT; (* handle of the parent menu - specify 0 to create a root menu *)

hItem : DINT; (* handle of a menu or an item to be used in other function calls *)

strTitle : STRING; (* optional title for a menu *)

strChoice : STRING; (* choice text for a menu item *)

idCommand : DINT; (* numerical identifier of a menu item to be used in the application *)

ok : BOOL; (* TRUE if successful *)

Running a hierarchy of menus

Then you can use the HmiMenu function block to activate the hierarchy of menus. First you must declare an instance of it, for example:

MENU : HmiMenu;

You should call the FB instance with the following input arguments:

UP : BOOL; (* the selection is moved up on a rising edge of this signal *)

DN : BOOL; (* the selection is moved down on a rising edge of this signal *)

OK : BOOL; (* the selected sub-menu is selected on a rising edge of this signal *)

ESC : BOOL; (* the parent menu is selected on a rising edge of this signal *)

Menu : DINT (* handle of the root menu *)

Below are the outputs of the HmiMenu function block:

SelID : DINT; (* ID of the selected menu item on a rising edge of the OK input *)

SelPos : DINT; (* position of the selected choice to be passed to the "Menu" graphic object *)

Title : STRING; (* title of the current menu *)

Texts : STRING; (* list of choices to be passed to the "Menu" graphic object *)

Example

Below is an example that creates a main menu with 2 sub-menus:

if not bInitDone then

// create the main menu (root)

hRootMenu := hmiNewMenu (0, 'Main menu');

// create the first sub menu with 2 items

hSubMenu := hmiNewMenu (hRootMenu, 'Menu 1');

hmiNewMenuItem (hSubMenu, 'Choice 1', 101);

hmiNewMenuItem (hSubMenu, 'Choice 2', 102);

// create the second sub menu with 2 items

hSubMenu := hmiNewMenu (hRootMenu, 'Menu 2');

hmiNewMenuItem (hSubMenu, 'Choice 3', 201);

hmiNewMenuItem (hSubMenu, 'Choice 4', 202);

bInitDone := true;

end_if;

Below is a tyipcal call to the HmiMenu function block ("MENU" is a declared instance of the FB):

MENU (bUP, bDOWN, bOK, bBACK, hRootMenu);

case MENU.SelID of

101 : // manage command 1

102 : // manage command 2

201 : // manage command 3

202 : // manage command 4

end_case;

Below is how to configure a text graphic object to diaplay the current menu title using the outputs of the FB instance:

Below is how to configure a "Menu" graphic object to diaplay the current menu title using the outputs of the FB instance:


The Win-GRAF PAC Registry for runtime parameters

The Win-GRAF PAC Registry for runtime parameters

The The Win-GRAF PAC Registry enables you to design and monitor remotely a hierarchical registry of parameters. Parameters can be set apart from the Workbench, and can also be read or written from the IEC program.

Designing the registry of parameters

The Registry Design tool enables you to design the set of runtime parameters and how they will be edited during monitoring. The definition of parameters is stored in an XML file. The design tool works mainly on this file. Additionally, the design tool is used to send the new registry to the runtime in binary form. Optionally the XML file can also be stored in the runtime.

To run the design tool from the Workbench, use the menu command Tools / Runtime Parameters / Design.

Parameters are freely organized with folders. The left part of the editor shows you the complete hierarchy of folders and parameters. The right hand area is used for entering the detailed description of the folder or parameter currently selected in the tree. Use the commands of the Edit menu to add new folders and parameters.

For each folder you must specify the following pieces of information:

Information | Description
Name | Name of the folder - cannot contain "/" characters.
Access | Access mode (read-write or read only).
Protection | Protection mode for write (using password): No = no protection. Yes = password protected. Inherit = use the same protection as the parent folder.
Password | Password for write.
Description | Free description text.

For each parameter you must specify the following pieces of information:

Information | Description
Name | Name of the folder - cannot contain / characters.
Type | Data type.
Max. length | Maximum length for STRING. Maximum lengthy cannot exceed 200 characters.
Access | Access mode (read-write or read only).
Protection | Protection mode for write (using password): No = no protection. Yes = password protected. Inherit = use the same protection as the parent folder.
Password | Password for write.
Default | Default value when registry is loaded for the first time.
Description | Free description text.
Editing mode | Editing method when monitoring.
Extra data | Description of choices for a list or combo box editing mode.
Minimum | Minimum allowed value for numbers.
Maximum | Maximum allowed value for numbers.

The commands of the Project menu are used for updating the runtime:

  • Check Registry

This command checks the whole contents of the designed registry and reports possible consistency errors.

  • Send Registry

This command sends the registry in binary format to the runtime system. You normally need to select the communication parameters of a remote runtime, but you can also save the binary registry in a local file if you want to use another transfer method. For remote sending, you can optionally send the XML definition file together with the binary registry.

Depending on the runtime system, it may happen that the new registry is not taken into account immediately, if it is currently in use by the system. Some runtimes will need a Stop/Restart of the IEC application. Some other runtimes may require a full reboot. Refer to the OEM instructions.

Monitoring parameters

The Register Host tool is used for monitoring runtime parameters On Line. Parameters can be displayed, and possibly modified according to their protection as defined in the Design tool. To run the host tool from the Workbench, use the menu command Tools / Runtime Parameters / Monitor. Then use the File / Open command to connect to the runtime and monitor its parameters.

The left side tree shows the folders of the Registry. The right-side area shows the parameters of the selected folder. Double click on a parameter to change its value.

Use the View / Refresh command to refresh the value of the parameters.

The File / Save menu command asks the runtime system to save the contents of the registry to backup support (flash or disk).


Project Automation Library

Project Automation Library

The workbench enables you to automate the creation or change of your IEC61131-3 projects. Many powerful applications are possible by writing automation scripts:

  • Create new wizards to build the skeleton of a new project.
  • Create wizards that automate or import the I/O configuration.
  • Automatically generate documentation about project items.
  • Any import / export procedure.

For that, no need of extra tool, and no need for you to get knowledge of other programming or scripting languages such as VB or C++. Simply use the Workbench to develop, test and run your scripts. Scripts are written using IEC langauges (typically Structured Text).

Please follow these links for further information:

  • Guidelines
  • Automation Library Reference

In this section

Guidelines

Reference


Guidelines

Project Automation Library -> Guidelines

The workbench enables you to automate the creation or change of your IEC61131-3 projects. Many powerful applications are possible by writing automation scripts using ST language. This page explains the principle of project automation tools. Refer to the following pages for further information about related features:

Creating a new script
Developing and testing the script
Registering the script in the workbench as a New project wizard
Registering the script in the workbench as a Tools menu command
Running the script from external applications
Reference of the automation library

Principle

A project automation script is a program written in IEC languages. Structured Text is typically used as the programming language for scripts as it is the most adapted to automation feature. The script is developed as a project, linked to a dedicated library called AUTOMATION:

When the Workbench is used for the development of a project automation script, the Simulation and On Line commands are replaced by a Execute Script command used for executing the script.

info Info

Unlike other IEC projects, the program of a script is executed only once, and is not repeated from cycle to cycle.

Scripts can be used either for generating the skeleton of a new project, or for changing / completing an existing project. Thus the AUTOMATION library does not only contain functions for building the project, but also for enumerating and changing the existing items of a project.

In this section

Creating a new Project Automation script

Developing and testing the script

Registering the script in the workbench as a "New project" wizard

Registering the script in the workbench as a tool

Running a script from other applications


Creating a new Project Automation script

Project Automation Library -> Guidelines -> Creating a new Project Automation script

Previous chapter Next chapter Show all Show all Hide all Hide all

To create a new Project Automation script, Run the File / New Project command from the menu, and then select the Automation Script choice in the project creation dialog box:

Then follow the instructions. You must specify how your script will be used:

  • Generating a new project from scratch.
  • Modifying an existing project.
  • Modifying a project or creating it if not yet existing.

While creating the script, you already can define some parameters to be entered by the user when the script is run. The system will automatically create:

  • Some global variables in your script project that will be the parameters.
  • A list of variables grouping parameters.
  • The few lines of ST code for prompting the user to enter parameters.

The script is generated with the following workspace:

The Main program is the automation script. You can freely create sub-programs and UDFBs to be called by this program.

The Templates folder will contain all your template programs to be instanciated (copied) to the target project when the script is run.

It is recommended to keep only one top level program for the script (the Main program). This program must have the following Task specification entered in its properties:

Thus, if you need to create other top level programs to be executed in your script, you need to set this property for all of them.


Developing and testing the script

Project Automation Library -> Guidelines -> Developing and testing the script

Previous chapter Next chapter Show all Show all Hide all Hide all

An Automation Script is developed as any project with the Workbench, but with some particular constraints. The biggest difference is that a script is a program (generally written in ST language) that is executed only once, and not repeated from cycle to cycle. The top program must have the special task property set to SCRIPT. However, you don't need to care about that as the New Script wizard has generated the skeleton of the script project for you:

The Main program is the automation script. You can freely create sub-programs and UDFBs to be called by this program, but it is recommended to keep only one top level program for the script (the Main program).

The script project refers to a special library called AUTOMATION that contains all necessary functions for developing scripts:

When developing a script project, the commands Simulate and On Line of the Project menu are replaced by the Execute Script command:

This command enables to run your script for test purpose. It opens the following box:

Enter the name of the target project (to be created or changed) in the upper box and press Go!. Any trace message or error report is displayed in the list below.


Registering the script in the workbench as a "New project" wizard

Project Automation Library -> Guidelines -> Registering the script in the workbench as a "New project" wizard

Previous chapter Next chapter Show all Show all Hide all Hide all

If your script is intended to create the skeleton for a new project, you can register it so that the workbench proposes it in its standard New Project procedure.

For that you simply need to copy the script folder under the AUTOMATION\SCRIPTS\ folder where the Workbench is installed:

Then your script will be available for creating a new project from the workbench. For that the user will have to select the Automation script choice in the New Project dialog box:

Your script must be compiled in order to be available as a wizard.

It is highly recommended that you copy the whole contents of your script project so that all possibly required template programs are available. By the way, if your script does not use templates, only the file APPLI.XTI is required in the script folder.


Registering the script in the workbench as a tool

Project Automation Library -> Guidelines -> Registering the script in the workbench as a tool

Previous chapter Next chapter Show all Show all Hide all Hide all

If your script is intended to modify an open project, you can register it so that the workbench proposes it from the Tools / Automation Script menu command.

For that you simply need to copy the script folder under the AUTOMATION\MACROS\ folder where the Workbench is installed:

Then your script will be available for modifying a project open with the workbench.

It is highly recommended that you copy the whole contents of your script project so that all possibly required template programs are available. By the way, if your script does not use templates, only the file APPLI.XTI is required in the script folder.


Running a script from other applications

Project Automation Library -> Guidelines -> Running a script from other applications

Previous chapter Next chapter Show all Show all Hide all Hide all

Scripts developed with the workbench can be run from external applications. Below are possible calling mode:

From the command line

Scripts can be executed directly from the Windows console or from .BAT files, using the K5Script.exe utility program installed with the Workbench.

Syntax:

K5Script.exe <script> <target_project>

Arguments:

<script> : Name of the folder containing the script. If no pathname is specified, the script folder is searched under the AUTOMATION\SCRIPTS\ folder where the Workbench is installed.

<target_project> : full qualified pathname of the target project to be created or modified by the script.

From application using COM interface

Not available yet.

From "C / C++" applications

Your "C/C++" applications can link to the K5NETAS.DLL located with the installed Workbench and use the following export function to run a script:

From "C" language:

LPCSTR __declspec(dllimport) K5NETAS_RunScript (LPCSTR szScript, LPCSTR szDest);

From "C++" language:

extern "C" LPCSTR __declspec(dllimport) K5NETAS_RunScript (LPCSTR szScript, LPCSTR szDest);

Arguments:

szScript : Name of the folder containing the script. If no pathname is specified, the script folder is searched under the "AUTOMATION\SCRIPTS\" folder where the Workbench is installed.

szDest : full qualified pathname of the target project to be created or modified by the script

Return value:

The function returns a pointer to a string containing the report.


Reference

Project Automation Library -> Reference

Below are the functions available in the AUTOMATION library for developing automation scripts:

Main services

  • Target project management

Declaring and managing IEC objects

  • Declaring programs
  • Declaring data types (structures)
  • Declaring variables
  • Declaring I/O boards

Generating project documents (files)

  • Common file handling services
  • Text files
  • IEC 61131-3 source files
  • Network and fiedlbus configuration
  • Watch window dowuments
  • Resources

Gerenating documents from templates

  • Defining variable keywords for a template
  • Templates of programs

Tools

  • Working with script parameters
  • Miscellaneous

In this section

Project level services

Declaring objects

Generating documents

Templates

Script parameters

miscellaneous


Project level services

Project Automation Library -> Reference -> Project level services

Previous chapter Next chapter Show all Show all Hide all Hide all

Below are the main services to manage the target project.

Opening the target project

paCreateProject - Create the target project.
paCreateProjectFromTemplate - Create the target project using a template.
paOpenProject - Open the target project for modification.

Setting project level information

paSetProjectComment - Set the description for title bar.
paSetOption - Set a project option.
paAddLibrary - Add a link to a library.

In this section

paCreateProject

paCreateProjectFromTemplate

paOpenProject

paSetProjectComment

paSetOption

paAddLibrary


paCreateProject

Project Automation Library -> Reference -> Project level services -> paCreateProject

Previous chapter Next chapter Show all Show all Hide all Hide all

paCreateProject - Create the target project

OK := paCreateProject ()

Parameters | Description
OK : BOOL; | TRUE if successful.

Description

This function creates the target project as an empty project. The destination folder should not exist yet. This function is typically called in a script that creates the skeleton of a new project.

You should call this function at the beginning of your script before any other declaration or creation function. Your script should terminate if this function returns FALSE.

Example Example

// at the beginning of the script:
if not paCreateProject () then
return;
end_if;
// ...

seealso See also

paCreateProjectFromTemplate - Create the target project using a template.

paOpenProject - Open the target project for modification.

paSetProjectComment - Set the description for title bar.

paSetOption - Set a project option.

paAddLibrary - Add a link to a library.


paCreateProjectFromTemplate

Project Automation Library -> Reference -> Project level services -> paCreateProjectFromTemplate

Previous chapter Next chapter Show all Show all Hide all Hide all

paCreateProjectFromTemplate - Create the target project from a template

OK := paCreateProjectFromTemplate (TEMPLATE)

Parameters | Description
TEMPLATE : STRING; | Name of a template projects.
OK : BOOL; | TRUE if successful.

Description

This function creates the target project as a copy of a template project. The destination folder should not exist yet. This function is typically called in a script that creates the skeleton of a new project.

Template projects are located under the TEMPLATE\ folder of the installed Workbench. the TEMPLATE parameter specifies only the name of the template project, and does not include its path.

You should call this function at the beginning of your script before any other declaration or creation function. Your script should terminate if this function returns FALSE.

Example Example

// at the beginning of the script:
if not paCreateProjectFromTemplate ('MyTemplate') then
return;
end_if;
// ...

seealso See also

paCreateProject - Create the target project.

paOpenProject - Open the target project for modification.

paSetProjectComment - Set the description for title bar.

paSetOption - Set a project option.

paAddLibrary - Add a link to a library.


paOpenProject

Project Automation Library -> Reference -> Project level services -> paOpenProject

Previous chapter Next chapter Show all Show all Hide all Hide all

paOpenProject - Open the target project for modification

OK := paOpenProject (CREATE)

Parameters | Description
CREATE : BOOL; | If TRUE, creates the project if not existing yet.
OK : BOOL; | TRUE if successful.

Description

This function opens the target project as an empty project. If the CREATE parameter is FALSE, the project must exist. If CREATE is TRUE and the project does not exist yet, then it is created.

You should call this function at the beginning of your script before any other declaration or creation function. Your script should terminate if this function returns FALSE.

Example Example

// ensure that the target project already exists
if not paOpenProject (FALSE) then
return;
end_if;
// ...

seealso See also

paCreateProject - Create the target project.

paCreateProjectFromTemplate - Create the target project using a template.

paSetProjectComment - Set the description for title bar.

paSetOption - Set a project option.

paAddLibrary - Add a link to a library.


paSetProjectComment

Project Automation Library -> Reference -> Project level services -> paSetProjectComment

Previous chapter Next chapter Show all Show all Hide all Hide all

paSetProjectComment - Change the description of the target project

OK := paSetProjectComment (COMM)

Parameter | Description
COMM : STRING; | Project description.
OK : BOOL; | TRUE if successful.

Description

This function sets the comment text used for describing the project. This text is displayed in the title bar of the Workbench when the project is open.

Note that in case of a new project wizard, a comment text has already been entered by the user.

Example Example

// after opening or creating the target project
paSetProjectComment ('Project generated by script')

seealso See also

paCreateProject - Create the target project.

paCreateProjectFromTemplate - Create the target project using a template.

paOpenProject - Open the target project for modification.

paSetOption - Set a project option.

paAddLibrary - Add a link to a library.


paSetOption

Project Automation Library -> Reference -> Project level services -> paSetOption

Previous chapter Next chapter Show all Show all Hide all Hide all

paSetOption - Set a project option

OK := paSetOption (OPTION, VALUE)

Parameter | Description
OPTION : STRING; | Option name.
VALUE : STRING; | Value of the option.
OK : BOOL; | TRUE if successful.

Description

This function sets an option in the project settings. The following options are available:

Name | Value | Description
TARGET | T5RTM / T5RTI | Type of target runtime.
DEBUG | ON / OFF | Compile in Debug mode.
CTSEG | ON / OFF | Complex variables in a separate segments.
FBDFLOW | ON / OFF | Color FBD lines during debug.
EMBEDSYMBOLS | ON / OFF | Embed all variable symbols.
EMBEDSYBCASE | ON / OFF | Keep case of embedded symbols.
WARNING | ON / OFF | Display warning messages.
SFCSAFE | ON / OFF | Check SFC charts safety.
SPCLEAN | ON / OFF | Remove code of uncalled sub-programs.
IECCHECK | ON / OFF | Check conformity to IEC standard.
SAFEARRAY | ON / OFF | Check array bounds at runtime.
LARGEJUMP | ON / OFF | Allow large jump instructions.
LOCK | IO / ALL / NONE | Range of lockable variables.
PASSWORD | number | Password for connection.

seealso See also

paCreateProject - Create the target project.

paCreateProjectFromTemplate - Create the target project using a template.

paOpenProject - Open the target project for modification.

paSetProjectComment - Set the description for title bar.

paAddLibrary - Add a link to a library.


paAddLibrary

Project Automation Library -> Reference -> Project level services -> paAddLibrary

Previous chapter Next chapter Show all Show all Hide all Hide all

paAddLibrary - Add a link to a library

OK := paAddLibrary (PATH)

Parameters | Description
PATH : STRING; | Full qualified pathname of the library folder.
OK : BOOL; | TRUE if successful.

Description

This function adds a link to a library for the target project.

seealso See also

paCreateProject - Create the target project.

paCreateProjectFromTemplate - Create the target project using a template.

paOpenProject - Open the target project for modification.

paSetProjectComment - Set the description for title bar.

paSetOption - Set a project option.


Declaring objects

Project Automation Library -> Reference -> Declaring objects

In this section

Declaring Programs

Declaring data structures

Declaring Variables

Declaring I/O Boards


Declaring Programs

Project Automation Library -> Reference -> Declaring objects -> Declaring Programs

Previous chapter Next chapter Show all Show all Hide all Hide all

Below are the main services to declaring programs.

Declaration

paCreateProgram - Create a main program.
paCreateSubProgram - Create a sub-program.
paCreateUDFB - Create User Defined Function Block.
paCreateSfcChildProgram - Create a child SFC program.
paCopyProgram - Duplicate a program.
paSetProgramComment - Set the desrciption text of a program.

Working with existing programs

paEnumProgram - Enumerate programs.
paGetProgramDesc - Get information about a program.
paDeleteProgram - Remove a program.

In this section

paCreateProgram

paCreateSubProgram

paCreateUDFB

paCreateSfcChildProgram

paCopyProgram

paSetProgramComment

paEnumProgram

paGetProgramDesc

paDeleteProgram

paCreateProgramFolder

paSendProgramToFolder

paEnumProgramFolder

paDeleteProgramFolder


paCreateProgram

Project Automation Library -> Reference -> Declaring objects -> Declaring Programs -> paCreateProgram

Previous chapter Next chapter Show all Show all Hide all Hide all

paCreateProgram - Create a main program

OK := paCreateProgram (NAME, LANGUAGE)

Parameter | Description
NAME : STRING; | Name of the new program.
LANGUAGE : STRING; | Programming language (see notes).
OK : BOOL; | TRUE if successful.

Description

This function creates a main program in the target project. Main programs are arranged in the cycle in the same order you create them from your script.

The following values are predefined for the LANGUAGE parameter:

Value | Description
_LG_SFC | Sequential Function Chart.
_LG_FBD | Function Block Diagram.
_LG_LD | Ladder Diagram.
_LG_ST | Structured Text.
_LG_IL | Instruction List.

Example Example

// create a new program folder
paCreateProgramFolder ('Folder1') then
// create a new program in LD language
if paCreateProgram ('Prog1', _LG_LD) then
// and put it in the folder
paSendProgramToFolder ('Prog1', 'Folder1');
end_if;

seealso See also

paCreateSubProgram - Create a sub-program.
paCreateUDFB - Create User Defined Function Block.
paCreateSfcChildProgram - Create a child SFC program.
paCopyProgram - Duplicate a program.
paSetProgramComment - Set the desrciption text of a program.

paEnumProgram - Enumerate programs.
paGetProgramDesc - Get information about a program.
paDeleteProgram - Remove a program.

paCreateProgramFolder - Create a new folder.
paSendProgramToFolder - Put a program in a folder.
paEnumProgramFolder - Enumerate program folders.
paDeleteProgramFolder - Remove a folder.


paCreateSubProgram

Project Automation Library -> Reference -> Declaring objects -> Declaring Programs -> paCreateSubProgram

Previous chapter Next chapter Show all Show all Hide all Hide all

paCreateSubProgram - Create a sub-program

OK := paCreateSubProgram (NAME, LANGUAGE)

Parameter | Description
NAME : STRING; | Name of the new program.
LANGUAGE : STRING; | Programming language (see notes).
OK : BOOL; | TRUE if successful.

Description

This function creates a sub-program in the target project.

The following values are predefined for the LANGUAGE parameter:

Value | Description
_LG_FBD | Function Block Diagram.
_LG_LD | Ladder Diagram.
_LG_ST | Structured Text.
_LG_IL | Instruction List.

Example Example

// create a new program folder
paCreateProgramFolder ('SubPrograms') then
// create a new sub-program in LD language
if paCreateSubProgram ('SP1', _LG_LD) then
// and put it in the folder
paSendProgramToFolder ('SP1', 'SubPrograms');
end_if;

seealso See also

paCreateProgram - Create a main program.
paCreateUDFB - Create User Defined Function Block.
paCreateSfcChildProgram - Create a child SFC program.
paCopyProgram - Duplicate a program.
paSetProgramComment - Set the desrciption text of a program.

paEnumProgram - Enumerate programs.
paGetProgramDesc - Get information about a program.
paDeleteProgram - Remove a program.

paCreateProgramFolder - Create a new folder.
paSendProgramToFolder - Put a program in a folder.
paEnumProgramFolder - Enumerate program folders.
paDeleteProgramFolder - Remove a folder.


paCreateUDFB

Project Automation Library -> Reference -> Declaring objects -> Declaring Programs -> paCreateUDFB

Previous chapter Next chapter Show all Show all Hide all Hide all

paCreateUDFB - Create a User Defined Function Block

OK := paCreateUDFB (NAME, LANGUAGE)

Parameter | Description
NAME : STRING; | Name of the new function block.
LANGUAGE : STRING; | Programming language (see notes).
OK : BOOL; | TRUE if successful.

Description

This function creates a User Defined Function Block in the target project.

The following values are predefined for the LANGUAGE parameter:

Value | Description
_LG_FBD | Function Block Diagram.
_LG_LD | Ladder Diagram.
_LG_ST | Structured Text.
_LG_IL | Instruction List.

Example Example

// create a new program folder
paCreateProgramFolder ('UDFBs') then
// create a new sub-UDFB in LD language
if paCreateUDFB ('FB1', _LG_LD) then
// and put it in the folder
paSendProgramToFolder ('F1', 'UDFBs');
end_if;

seealso See also

paCreateProgram - Create a main program.
paCreateSubProgram - Create a sub-program.
paCreateSfcChildProgram - Create a child SFC program.
paCopyProgram - Duplicate a program.
paSetProgramComment - Set the desrciption text of a program.

paEnumProgram - Enumerate programs.
paGetProgramDesc - Get information about a program.
paDeleteProgram - Remove a program.

paCreateProgramFolder - Create a new folder.
paSendProgramToFolder - Put a program in a folder.
paEnumProgramFolder - Enumerate program folders.
paDeleteProgramFolder - Remove a folder.


paCreateSfcChildProgram

Project Automation Library -> Reference -> Declaring objects -> Declaring Programs -> paCreateSfcChildProgram

Previous chapter Next chapter Show all Show all Hide all Hide all

paCreateSfcChildProgram - Create a child SFC program

OK := paCreateUDFB (NAME, PARENT)

Parameter | Description
NAME : STRING; | Name of the new child program.
PARENT : STRING; | Name of the parent program.
OK : BOOL; | TRUE if successful.

Description

This function creates a new SFC program to be a child of the specified parent SFC program. The parent SFC program must exist before calling this function.

Example Example

// create the parent program
paCreateProgram ('MAIN', _LG_SFC);
// create the child program
paCreateSfcChildProgram ('Child1', 'MAIN');

seealso See also

paCreateProgram - Create a main program.
paCreateSubProgram - Create a sub-program.
paCreateUDFB - Create User Defined Function Block.
paCopyProgram - Duplicate a program.
paSetProgramComment - Set the desrciption text of a program.

paEnumProgram - Enumerate programs.
paGetProgramDesc - Get information about a program.
paDeleteProgram - Remove a program.

paCreateProgramFolder - Create a new folder.
paSendProgramToFolder - Put a program in a folder.
paEnumProgramFolder - Enumerate program folders.
paDeleteProgramFolder - Remove a folder.


paCopyProgram

Project Automation Library -> Reference -> Declaring objects -> Declaring Programs -> paCopyProgram

Previous chapter Next chapter Show all Show all Hide all Hide all

paCopyProgram - Duplicate a program

OK := paCopyProgram (SRC, DST)

Parameter | Description
SRC : STRING; | Name of the source program.
DST : STRING; | Destination program.
OK : BOOL; | TRUE if successful.

Description

This function duplicates the SRC program in the DST program. This function creates the DST program and is normally not used for overwriting an existing program.

seealso See also

paCreateProgram - Create a main program.
paCreateSubProgram - Create a sub-program.
paCreateUDFB - Create User Defined Function Block.
paCreateSfcChildProgram - Create a child SFC program.
paSetProgramComment - Set the desrciption text of a program.

paEnumProgram - Enumerate programs.
paGetProgramDesc - Get information about a program.
paDeleteProgram - Remove a program.

paCreateProgramFolder - Create a new folder.
paSendProgramToFolder - Put a program in a folder.
paEnumProgramFolder - Enumerate program folders.
paDeleteProgramFolder - Remove a folder.


paSetProgramComment

Project Automation Library -> Reference -> Declaring objects -> Declaring Programs -> paSetProgramComment

Previous chapter Next chapter Show all Show all Hide all Hide all

paSetProgramComment - Set the description a program

OK := paSetProgramComment (NAME, COMM)

Parameter | Description
NAME : STRING; | Name of the program.
COMM : STRING; | Description text.
OK : BOOL; | TRUE if successful.

Description

This function sets the comment text of a program. It may be used for either programs or sub-programs or User Defined Function Blocks (UDFBs).

Example Example

// create the program
paCreateProgram ('PROG1', _LG_ST);
// and sets its description text
paSetProgramComment ('PROG1', 'This is PROG1 description');

seealso See also

paCreateProgram - Create a main program.
paCreateSubProgram - Create a sub-program.
paCreateUDFB - Create User Defined Function Block.
paCreateSfcChildProgram - Create a child SFC program.
paCopyProgram - Duplicate a program.

paEnumProgram - Enumerate programs.
paGetProgramDesc - Get information about a program.
paDeleteProgram - Remove a program.

paCreateProgramFolder - Create a new folder.
paSendProgramToFolder - Put a program in a folder.
paEnumProgramFolder - Enumerate program folders.
paDeleteProgramFolder - Remove a folder.


paEnumProgram

Project Automation Library -> Reference -> Declaring objects -> Declaring Programs -> paEnumProgram

Previous chapter Next chapter Show all Show all Hide all Hide all

paEnumProgram - Enumerate programs of the target project

function block: Inst_paEnumProgram (LOAD, CHECK, ITEM, FILTER)

Input | Description
LOAD : TRUE; | If TRUE, load the list of programs.
CHECK : BOOL; | If TRUE, open a checklist box to select some of the loaded programs.
ITEM : DINT; | Index of the item wanted on input (1 based).
FILTER : STRING; | Filtering mask for loading programs.

Output | Description
NB : DINT; | Number of programs.
Q : STRING; | Name of the item selected with ITEM.

Description

This function block is used for enumerating the programs, sucb-programs and UDFBs of the target project. You must first call it with LOAD input at TRUE in order to load the list of programs. You get the number of programs in the NB output. Then call it again with LOAD at FALSE and specifying the index of the wished program in the ITEM input to get the name of the selected item in the Q output. The numbering of items starts at 1.

When loading programs (LOAD inputs is TRUE), you can specify a filtering string that may include some '*' or '?' wildchars.

After loading, if can call again the block with the CHECK input at TRUE for opening a dialog box where the user can check wished programs. After the box is closed, only checked items remain in the loaded list.

Example Example

// "ENU" is a declared instance of paEnumProgram function block
// load all programs
ENU (TRUE, FALSE, 0, '*');
// open a dialog box for the user to check wished items
ENU (FALSE, TRUE, 0, '');
// enumerate checked items
for i := 1 to ENU.NB do
// select the item "i"
ENU (FALSE, FALSE, i, '');
// get the name of the item specified by "i"
sProgName := ENU.Q;
end_for;

seealso See also

paCreateProgram - Create a main program.
paCreateSubProgram - Create a sub-program.
paCreateUDFB - Create User Defined Function Block.
paCreateSfcChildProgram - Create a child SFC program.
paCopyProgram - Duplicate a program.
paSetProgramComment - Set the desrciption text of a program.

paGetProgramDesc - Get information about a program.
paDeleteProgram - Remove a program.

paCreateProgramFolder - Create a new folder.
paSendProgramToFolder - Put a program in a folder.
paEnumProgramFolder - Enumerate program folders.
paDeleteProgramFolder - Remove a folder.


paGetProgramDesc

Project Automation Library -> Reference -> Declaring objects -> Declaring Programs -> paGetProgramDesc

Previous chapter Next chapter Show all Show all Hide all Hide all

paGetProgramDesc - Get information about a program

function block: Inst_paGetProgramDesc (NAME)

Input | Description
NAME : STRING; | Name of the program.

Output | Description
OK : BOOL; | TRUE if successful.
KIND : STRING; | Kind of POU.
LANGUAGE : STRING; | Programming language.
PARENT : STRING; | Parent SFC program or empty string.
COMMENT : STRING; | Description text.

Description

This function block is for getting information about a program of the target project. It can be used for programs, sub-programs or UDFBs.

The following values are predefined for the LANGUAGE output:

Value | Description
_LG_SFC | Sequential Function Chart.
_LG_FBD | Function Block Diagram.
_LG_LD | Ladder Diagram.
_LG_ST | Structured Text.
_LG_IL | Instruction List.

The following values are predefined for the KIND output:

Value | Description
_POU_MAIN | Main program.
_POU_SP | Sub-program.
_POU_UDFB | User Defined Function Block.
_POU_CHILDOF | Child SFC program (the name of its parent program is in the PARENT output).

seealso See also

paCreateProgram - Create a main program.
paCreateSubProgram - Create a sub-program.
paCreateUDFB - Create User Defined Function Block.
paCreateSfcChildProgram - Create a child SFC program.
paCopyProgram - Duplicate a program.
paSetProgramComment - Set the desrciption text of a program.

paEnumProgram - Enumerate programs.
paDeleteProgram - Remove a program.

paCreateProgramFolder - Create a new folder.
paSendProgramToFolder - Put a program in a folder.
paEnumProgramFolder - Enumerate program folders.
paDeleteProgramFolder - Remove a folder.


paDeleteProgram

Project Automation Library -> Reference -> Declaring objects -> Declaring Programs -> paDeleteProgram

Previous chapter Next chapter Show all Show all Hide all Hide all

paDeleteProgram - Delete a program

OK := paDeleteProgram (NAME)

Parameter | Description
NAME : STRING; | Name of the program (see notes).
OK : BOOL; | TRUE if successful.

Description

This function deletes the specified program. It can be used for programs, sub-programs of UDFBS. The NAME parameter can contain '?' and '*' wildchars. For instance, paDeleteProgram ('*') deletes all the POUs of the target project. If the specified program is a SFC program having child programs, its children are deleted as well.

seealso See also

paCreateProgram - Create a main program.
paCreateSubProgram - Create a sub-program.
paCreateUDFB - Create User Defined Function Block.
paCreateSfcChildProgram - Create a child SFC program.
paCopyProgram - Duplicate a program.
paSetProgramComment - Set the desrciption text of a program.

paEnumProgram - Enumerate programs.
paGetProgramDesc - Get information about a program.

paCreateProgramFolder - Create a new folder.
paSendProgramToFolder - Put a program in a folder.
paEnumProgramFolder - Enumerate program folders.
paDeleteProgramFolder - Remove a folder.


paCreateProgramFolder

Project Automation Library -> Reference -> Declaring objects -> Declaring Programs -> paCreateProgramFolder

Previous chapter Next chapter Show all Show all Hide all Hide all

obsolete


paSendProgramToFolder

Project Automation Library -> Reference -> Declaring objects -> Declaring Programs -> paSendProgramToFolder

Previous chapter Next chapter Show all Show all Hide all Hide all

obsolete


paEnumProgramFolder

Project Automation Library -> Reference -> Declaring objects -> Declaring Programs -> paEnumProgramFolder

Previous chapter Next chapter Show all Show all Hide all Hide all

obsolete


paDeleteProgramFolder

Project Automation Library -> Reference -> Declaring objects -> Declaring Programs -> paDeleteProgramFolder

Previous chapter Next chapter Show all Show all Hide all Hide all

obsolete


Declaring data structures

Project Automation Library -> Reference -> Declaring objects -> Declaring data structures

Previous chapter Next chapter Show all Show all Hide all Hide all

Below are the main services to declaring data structures.

Declaration

paCreateStruct - Create a data structure.
paSetStructComment - Set the desrciption text of a structure.

Working with existing data structures

paEnumStruct - Enumerate data structures.
paGetStructDesc - Get information about a data structure.
paDeleteStruct - Remove a data structure.

In this section

paCreateStruct

paSetStructComment

paEnumStruct

paGetStructDesc

paDeleteStruct


paCreateStruct

Project Automation Library -> Reference -> Declaring objects -> Declaring data structures -> paCreateStruct

Previous chapter Next chapter Show all Show all Hide all Hide all

paCreateStruct - Create a data structure

OK := paCreateStruct (NAME)

Parameter | Description
NAME : STRING; | Name of the structure.
OK : BOOL; | TRUE if successful.

Description

This function creates a data structure in the target project.

seealso See also

paSetStructComment - Set the desrciption text of a structure.

paEnumStruct - Enumerate data structures.
paGetStructDesc - Get information about a data structure.
paDeleteStruct - Remove a data structure.


paSetStructComment

Project Automation Library -> Reference -> Declaring objects -> Declaring data structures -> paSetStructComment

Previous chapter Next chapter Show all Show all Hide all Hide all

paSetStructComment - Set the description a structure

OK := paSetStructComment (NAME, COMM)

Parameter | Description
NAME : STRING; | Name of the structure.
COMM : STRING; | Description text.
OK : BOOL; | TRUE if successful.

Description

This function sets the comment text of a data structure.

seealso See also

paCreateStruct - Create a data structure.
paEnumStruct - Enumerate data structures.
paGetStructDesc - Get information about a data structure.
paDeleteStruct - Remove a data structure.


paEnumStruct

Project Automation Library -> Reference -> Declaring objects -> Declaring data structures -> paEnumStruct

Previous chapter Next chapter Show all Show all Hide all Hide all

paEnumStruct - Enumerate data structures of the target project

function block: Inst_paEnumStruct (LOAD, CHECK, ITEM, FILTER)

Input | Description
LOAD : TRUE; | If TRUE, load the list of structures.
CHECK : BOOL; | If TRUE, open a checklist box to select some of the loaded structures.
ITEM : DINT; | Index of the item wanted on input (1 based).
FILTER : STRING; | Filtering mask for loading structures.

Output | Description
NB : DINT; | Number of structures.
Q : STRING; | Name of the item selected with ITEM.

Description

This function block is used for enumerating the data structures of the target project. You must first call it with LOAD input at TRUE in order to load the list of structures. You get the number of structures in the NB output. Then call it again with LOAD at FALSE and specifying the index of the wished structure in the ITEM input to get the name of the selected item in the Q output. The numbering of items starts at 1.

When loading structures (LOAD inputs is TRUE), you can specify a filtering string that may include some '*' or '?' wildchars.

After loading, if can call again the block with the CHECK input at TRUE for opening a dialog box where the user can check wished structures. After the box is closed, only checked items remain in the loaded list.

Example Example

// "ENU" is a declared instance of paEnumStruct function block
// load all structures
ENU (TRUE, FALSE, 0, '*');
// open a dialog box for the user to check wished items
ENU (FALSE, TRUE, FALSE, 0, '');
// enumerate checked items
for i := 1 to ENU.NB do
// select the item "i"
ENU (FALSE, FALSE, i, '');
// get the name of the item specified by "i"
sProgName := ENU.Q;
end_for;

seealso See also

paCreateStruct - Create a data structure.
paSetStructComment - Set the desrciption text of a structure.

paGetStructDesc - Get information about a data structure.
paDeleteStruct - Remove a data structure.


paGetStructDesc

Project Automation Library -> Reference -> Declaring objects -> Declaring data structures -> paGetStructDesc

Previous chapter Next chapter Show all Show all Hide all Hide all

paGetStructDesc - Get information about a data structure

function block: Inst_paGetStructDesc (NAME)

Input | Description
NAME : STRING; | Name of the structure.

Output | Description
OK : BOOL; | TRUE if successful.
COMMENT : STRING; | Description text.

Description

This function block is for getting information about a structure of the target project.

seealso See also

paCreateStruct - Create a data structure.
paSetStructComment - Set the desrciption text of a structure.

paEnumStruct - Enumerate data structures.
paDeleteStruct - Remove a data structure.


paDeleteStruct

Project Automation Library -> Reference -> Declaring objects -> Declaring data structures -> paDeleteStruct

Previous chapter Next chapter Show all Show all Hide all Hide all

paDeleteStruct - Delete a data structure

OK := paDeleteStruct (NAME)

Parameter | Description
NAME : STRING; | Name of the structure (see notes).
OK : BOOL; | TRUE if successful.

Description

This function deletes the specified structure. The NAME parameter can contain '?' and '*' wildchars. For instance, paDeleteStruct ('*') deletes all the structures of the target project.

seealso See also

paCreateStruct - Create a data structure.
paSetStructComment - Set the desrciption text of a structure.

paEnumStruct - Enumerate data structures.
paGetStructDesc - Get information about a data structure.


Declaring Variables

Project Automation Library -> Reference -> Declaring objects -> Declaring Variables

Previous chapter Next chapter Show all Show all Hide all Hide all

Below are the main services to declaring variables.

Declaration

paCreateVar - Create a variable.
paCreateInputParam - Create an input parameter of a sub-program or UDFB.
paCreateOutputParam - Create an output parameter of a sub-program or UDFB.
paSetVarXDim(s) - Set dimension(s) of a variable.
paSetVarInitValue - Set initial value of a variable.
paSetVarComment - Set description text of a variable.
paEmbedVarSymbol - Embed the symbol of a variable.
paProfileVar - Set variable profile and properties.

Working with existing variables

paEnumVar - Enumerate variables.
paGetVarDesc - Get information about a variable.
paDeleteVar - Delete a variable.

Naming conventions

In any function where you need to specify a variable by its name, you must specify the group containing the variable. A variable can be Global or I/O, Retain, Local to a POU or can be an item of a data structure.

The convention for these functions is to prefix the variable name by its group name and the '.' separator. If no group is specified, then the variable is considered as Global.

Example Example

Declaration | Meaning
VarName | A global variable.
RETAIN.VarName | A RETAIN variable.
%IX1.0 | A global I/O channel.
ProgName.LocVarName | A variable local to a program.
UDFBName.ParamName | A parameter of a UDFB.
StructName.Item | An item of a data structure.

In this section

paCreateVar

paCreateInputParam

paCreateOutputParam

paSetVarDim

paSetVarInitValue

paSetVarComment

paEmbedVarSymbol

paProfileVar

paEnumVar

paGetVarDesc

paDeleteVar


paCreateVar

Project Automation Library -> Reference -> Declaring objects -> Declaring Variables -> paCreateVar

Previous chapter Next chapter Show all Show all Hide all Hide all

paCreateVar - Create a variable

OK := paCreateVar (SNAME, STYPE)

Parameter | Description
SNAME : STRING; | Name of the new variable and speficication of ots group (see naming conventions).
STYPE : STRING; | Data type.
OK : BOOL; | TRUE if successful.

Description

This function creates a program with the specified name in the specified group. The STYPE indicates its data type. It can be a type of function block for declaring an instance. In case of a STRING type, the type must be followed by the string length. e.g. 'STRING(255)'

The same function can be used to create an item in a data structure.

Example Example

// create global variable and FB instance
paCreateVar ('Global1', 'BOOL');
paCreateVar ('Timer1', 'TON');
// create a retain variable
paCreateVar ('RETAIN.RetVar1', 'STRING(20)');
// create a variable local to a program
paCreateVar ('Prog1.Local1', 'DINT');
// create an item of a structure
paCreateVar ('Struct1.Item1', 'REAL');

seealso See also

paCreateInputParam - Create an input parameter of a sub-program or UDFB.
paCreateOutputParam - Create an output parameter of a sub-program or UDFB.
paSetVarXDim(s) - Set dimension(s) of a variable.
paSetVarInitValue - Set initial value of a variable.
paSetVarComment - Set description text of a variable.
paEmbedVarSymbol - Embed the symbol of a variable.
paProfileVar - Set variable profile and properties.

paEnumVar - Enumerate variables.
paGetVarDesc - Get information about a variable.
paDeleteVar - Delete a variable.


paCreateInputParam

Project Automation Library -> Reference -> Declaring objects -> Declaring Variables -> paCreateInputParam

Previous chapter Next chapter Show all Show all Hide all Hide all

paCreateInputParam - Create an input parameter of a POU

OK := paCreateInputParam (SNAME, STYPE)

Parameter | Description
SNAME : STRING; | Name of the new variable in form 'POUName.VarName' (see naming conventions).
STYPE : STRING; | Data type.
OK : BOOL; | TRUE if successful.

Description

This function creates an input parameter for the POU (sub-program or UDFB) specified as a prefix in the variable name. The STYPE indicates its data type. In case of a STRING type, the type must be followed by the string length. e.g. 'STRING(255)'

Example Example

// create a sub program
paCreateSubProgram ('SP', _LG_LD);
// declare parameters
paCreateInputParam ('SP.IN1', 'BOOL');
paCreateInputParam ('SP.IN2', 'DINT');
paCreateOutputParam ('SP.Q', 'BOOL');

seealso See also

paCreateVar - Create a variable.
paCreateOutputParam - Create an output parameter of a sub-program or UDFB.
paSetVarXDim(s) - Set dimension(s) of a variable.
paSetVarInitValue - Set initial value of a variable.
paSetVarComment - Set description text of a variable.
paEmbedVarSymbol - Embed the symbol of a variable.
paProfileVar - Set variable profile and properties.

paEnumVar - Enumerate variables.
paGetVarDesc - Get information about a variable.
paDeleteVar - Delete a variable.


paCreateOutputParam

Project Automation Library -> Reference -> Declaring objects -> Declaring Variables -> paCreateOutputParam

Previous chapter Next chapter Show all Show all Hide all Hide all

paCreateOutputParam - Create an output parameter of a POU

OK := paCreateOutputParam (SNAME, STYPE)

Parameter | Description
SNAME : STRING; | Name of the new variable in form 'POUName.VarName' (see naming conventions).
STYPE : STRING; | Data type.
OK : BOOL; | TRUE if successful.

Description

This function creates an output parameter for the POU (sub-program or UDFB) specified as a prefix in the variable nameThe STYPE indicates its data type. In case of a STRING type, the type must be followed by the string length. e.g. 'STRING(255)'

Example Example

// create a sub program
paCreateSubProgram ('SP', _LG_LD);
// declare parameters
paCreateInputParam ('SP.IN1', 'BOOL');
paCreateInputParam ('SP.IN2', 'DINT');
paCreateOutputParam ('SP.Q', 'BOOL');

seealso See also

paCreateVar - Create a variable.
paCreateInputParam - Create an input parameter of a sub-program or UDFB.
paSetVarXDim(s) - Set dimension(s) of a variable.
paSetVarInitValue - Set initial value of a variable.
paSetVarComment - Set description text of a variable.
paEmbedVarSymbol - Embed the symbol of a variable.
paProfileVar - Set variable profile and properties.

paEnumVar - Enumerate variables.
paGetVarDesc - Get information about a variable.
paDeleteVar - Delete a variable.


paSetVarDim

Project Automation Library -> Reference -> Declaring objects -> Declaring Variables -> paSetVarDim

Previous chapter Next chapter Show all Show all Hide all Hide all

paSetVar1Dim / paSetVar2Dims / paSetVar3Dims - Set the demiension(s) of a variable (array)

OK := paSetVarDim (NAME, DIM) // 1 dimension array
OK := paSetVar2Dims (NAME, DIMHIGH, DIMLOW) // 2 dimension array
OK := paSetVar3Dims (NAME, DIMHIGH, DIMMEDIUM, DIMLOW) // 3 dimension array

Parameter | Description
NAME : STRING; | Name of the variable and speficication of ots group (see naming conventions).
DIMxxx : DINT; | Dimension(s) of the array.
OK : BOOL; | TRUE if successful.

Description

This function sets the dimension of a declared variable, in order to declare an array. The same function can be used for an item in a data structure.

Example Example

// declare Array1 : array [0..9] of BOOL
paCreateVar ('Array1', 'BOOL');
paSetVarDim ('Array1', 10);
// declare Array2 : array [0..9,0..4] of BOOL
paCreateVar ('Array2', 'BOOL');
paSetVar2Dims ('Array2', 10, 5);
// declare Array2 : array [0..9,0..4,0..19] of BOOL
paCreateVar ('Array3', 'BOOL');
paSetVar3Dims ('Array3', 10, 5, 20);

seealso See also

paCreateVar - Create a variable.
paCreateInputParam - Create an input parameter of a sub-program or UDFB.
paCreateOutputParam - Create an output parameter of a sub-program or UDFB.
paSetVarInitValue - Set initial value of a variable.
paSetVarComment - Set description text of a variable.
paEmbedVarSymbol - Embed the symbol of a variable.
paProfileVar - Set variable profile and properties.

paEnumVar - Enumerate variables.
paGetVarDesc - Get information about a variable.
paDeleteVar - Delete a variable.


paSetVarInitValue

Project Automation Library -> Reference -> Declaring objects -> Declaring Variables -> paSetVarInitValue

Previous chapter Next chapter Show all Show all Hide all Hide all

paSetVarInitValue - Set the initial value of a variable

OK := paSetVarInitValue (NAME, VALUE)

Parameter | Description
NAME : STRING; | Name of the variable and speficication of ots group (see naming conventions).
VALUE : STRING; | Initial value in IEC 61131-3 syntax.
OK : BOOL; | TRUE if successful.

Description

This function sets the initial value of a declared variable. The same function can be used for an item in a data structure.

Example Example

// declare Integer1 : DINT := 1234;
paCreateVar ('Integer1', 'BOOL');
paSetVarInitValue ('Integer1', '1234');
// declare Array1 : array [0..3] of BOOL := 1, 2, 3, 4;
paCreateVar ('Array1', 'BOOL');
paSetVarDim ('Array1', 4);
paSetVarInitValue ('Integer1', '1,2,3,4');

seealso See also

paCreateVar - Create a variable.
paCreateInputParam - Create an input parameter of a sub-program or UDFB.
paCreateOutputParam - Create an output parameter of a sub-program or UDFB.
paSetVarXDim(s) - Set dimension(s) of a variable.
paSetVarComment - Set description text of a variable.
paEmbedVarSymbol - Embed the symbol of a variable.
paProfileVar - Set variable profile and properties.

paEnumVar - Enumerate variables.
paGetVarDesc - Get information about a variable.
paDeleteVar - Delete a variable.


paSetVarComment

Project Automation Library -> Reference -> Declaring objects -> Declaring Variables -> paSetVarComment

Previous chapter Next chapter Show all Show all Hide all Hide all

paSetVarComment - Set the description a variable

OK := paSetVarComment (NAME, COMM, TAG)

Parameter | Description
NAME : STRING; | Name of the variable and speficication of ots group (see naming conventions).
COMM : STRING; | Description text.
TAG : STRING; | Short description text.
OK : BOOL; | TRUE if successful.

Description

This function sets the comment text of a declared variable. The same function can be for an item in a data structure.

seealso See also

paCreateVar - Create a variable.
paCreateInputParam - Create an input parameter of a sub-program or UDFB.
paCreateOutputParam - Create an output parameter of a sub-program or UDFB.
paSetVarXDim(s) - Set dimension(s) of a variable.
paSetVarInitValue - Set initial value of a variable.
paEmbedVarSymbol - Embed the symbol of a variable.
paProfileVar - Set variable profile and properties.

paEnumVar - Enumerate variables.
paGetVarDesc - Get information about a variable.
paDeleteVar - Delete a variable.


paEmbedVarSymbol

Project Automation Library -> Reference -> Declaring objects -> Declaring Variables -> paEmbedVarSymbol

Previous chapter Next chapter Show all Show all Hide all Hide all

paEmbedVarSymbol - Embed the symbol of a variable

OK := paEmbedVarSymbol (NAME, SYB)

Parameter | Description
NAME : STRING; | Name of the variable and speficication of ots group (see naming conventions).
SYB : BOOL; | TRUE if the variable symbol must be embedded.
OK : BOOL; | TRUE if successful.

Description

This function specifies if the symbol of a declared variable must be embedded. The same function can be for an item in a data structure.

seealso See also

paCreateVar - Create a variable.
paCreateInputParam - Create an input parameter of a sub-program or UDFB.
paCreateOutputParam - Create an output parameter of a sub-program or UDFB.
paSetVarXDim(s) - Set dimension(s) of a variable.
paSetVarInitValue - Set initial value of a variable.
paSetVarComment - Set description text of a variable.
paProfileVar - Set variable profile and properties.

paEnumVar - Enumerate variables.
paGetVarDesc - Get information about a variable.
paDeleteVar - Delete a variable.


paProfileVar

Project Automation Library -> Reference -> Declaring objects -> Declaring Variables -> paProfileVar

Previous chapter Next chapter Show all Show all Hide all Hide all

paProfileVar - Defines the profile and embedded properties of a variable

OK := paProfileVar (PROFILE, PROPERTIES)

Parameter | Description
NAME : STRING; | Name of the variable and speficication of ots group (see naming conventions).
PROFILE : STRING; | Name of the profile.
PROPERTIES : STRING; | Embedded properties attached to the profile (if any).
OK : BOOL; | TRUE if successful.

Description

This function specifies the profile and the corresponding embedded properties for a declared variable. Properties are written in form:

prop=value,prop=value,...

Example Example

// declare the variable
paCreateVar ('F1', 'BOOL');
paProfileVar ('K1', '1234');
// declare Array1 : array [0..3] of BOOL := 1, 2, 3, 4;
paCreateVar ('Array1', 'FKey', 'Key=1');

seealso See also

paCreateVar - Create a variable.
paCreateInputParam - Create an input parameter of a sub-program or UDFB.
paCreateOutputParam - Create an output parameter of a sub-program or UDFB.
paSetVarXDim(s) - Set dimension(s) of a variable.
paSetVarInitValue - Set initial value of a variable.
paSetVarComment - Set description text of a variable.
paEmbedVarSymbol - Embed the symbol of a variable.

paEnumVar - Enumerate variables.
paGetVarDesc - Get information about a variable.
paDeleteVar - Delete a variable.


paEnumVar

Project Automation Library -> Reference -> Declaring objects -> Declaring Variables -> paEnumVar

Previous chapter Next chapter Show all Show all Hide all Hide all

paEnumVar - Enumerate variables of a group in the target project

function block: Inst_paEnumVar (LOAD, CHECK, ITEM, FILTER)

Input | Description
LOAD : TRUE; | If TRUE, load the list of variables.
CHECK : BOOL; | If TRUE, open a checklist box to select some of the loaded variables.
ITEM : DINT; | Index of the item wanted on input (1 based).
FILTER : STRING; | Group specification and filtering mask for loading variables.

Output | Description
NB : DINT; | Number of variables.
Q : STRING; | Name of the item selected with "ITEM".

Description

This function block is used for enumerating the variables of a group in the target project. You must first call it with LOAD input at TRUE in order to load the list of variables. You get the number of programs in the NB output. Then call it again with LOAD at FALSE and specifying the index of the wished variable in the ITEM input to get the name of the selected item in the Q output. The numbering of items starts at 1.

When loading programs (LOAD inputs is TRUE), you must specify the group in the FILTER parameter, possibly followed by the '.' separator and a filtering string including some '*' or '?' wildchars. No group name is required for global variables.

After loading, if can call again the block with the CHECK input at TRUE for opening a dialog box where the user can check wished variables. After the box is closed, only checked items remain in the loaded list.

Example Example

// "ENU" is a declared instance of paEnumVar function block
// load all RETAIN variables
ENU (TRUE, FALSE, 0, 'RETAIN.*');
// open a dialog box for the user to check wished items
ENU (FALSE, TRUE, FALSE, 0, '');
// enumerate checked items
for i := 1 to ENU.NB do
// select the item "i"
ENU (FALSE, FALSE, i, '');
// get the name of the item specified by "i"
sVarName := ENU.Q;
end_for;

seealso See also

paCreateVar - Create a variable.
paCreateInputParam - Create an input parameter of a sub-program or UDFB.
paCreateOutputParam - Create an output parameter of a sub-program or UDFB.
paSetVarXDim(s) - Set dimension(s) of a variable.
paSetVarInitValue - Set initial value of a variable.
paSetVarComment - Set description text of a variable.
paEmbedVarSymbol - Embed the symbol of a variable.
paProfileVar - Set variable profile and properties.

paGetVarDesc - Get information about a variable.
paDeleteVar - Delete a variable.


paGetVarDesc

Project Automation Library -> Reference -> Declaring objects -> Declaring Variables -> paGetVarDesc

Previous chapter Next chapter Show all Show all Hide all Hide all

paGetVarDesc - Get information about a variable

function block: Inst_paGetVarDesc (NAME)

Input | Description
NAME : STRING; | Name of the variable and speficication of ots group (see naming conventions).

Output | Description
OK : BOOL; | TRUE if successful.
INPARAM : BOOL; | TRUE if it is an input parameter.
OUTPARAM : BOOL; | TRUE if it is an output parameter.
DATATYPE : STRING; | Data type.
DIMTOTAL : DINT; | Total number of items for an array.
DIMHIGH : DINT; | Highest dimension (0 for 1 or 2 dimension arrays).
DIMMEDIUM : DINT; | Medium dimension (0 for 1 dimension arrays).
DIMLOW : DINT; | Lowest dimension.
INIT : STRING; | Initial value in IEC syntax.
SYB : BOOL; | TRUE if the symbol of the variable is embedded.
PROFILE : STRING; | Name of the attached profile.
PROPS : STRING; | Embedded properties attached to the profile.
COMMENT : STRING; | Description text.
TAG : STRING; | Short description text.

Description

This function block is for getting information about a declared variable. The same block can be used for an item in a data structure.

seealso See also

paCreateVar - Create a variable.
paCreateInputParam - Create an input parameter of a sub-program or UDFB.
paCreateOutputParam - Create an output parameter of a sub-program or UDFB.
paSetVarXDim(s) - Set dimension(s) of a variable.
paSetVarInitValue - Set initial value of a variable.
paSetVarComment - Set description text of a variable.
paEmbedVarSymbol - Embed the symbol of a variable.
paProfileVar - Set variable profile and properties.

paEnumVar - Enumerate variables.
paDeleteVar - Delete a variable.


paDeleteVar

Project Automation Library -> Reference -> Declaring objects -> Declaring Variables -> paDeleteVar

Previous chapter Next chapter Show all Show all Hide all Hide all

paDeleteVar - Delete a variable

OK := paDeleteVar (NAME)

Parameter | Description
NAME : STRING; | Name of the variable and speficication of ots group (see naming conventions).
OK : BOOL; | TRUE if successful.

Description

This function deletes the specified variable. The same function can be used for an item in a data structure.

The name of the variable may contain '?' and '*' wildchars, but the group name cannot. For instance, paDeleteVar ('RETAIN.*') deletes all the retain variables.

seealso See also

paCreateVar - Create a variable.
paCreateInputParam - Create an input parameter of a sub-program or UDFB.
paCreateOutputParam - Create an output parameter of a sub-program or UDFB.
paSetVarXDim(s) - Set dimension(s) of a variable.
paSetVarInitValue - Set initial value of a variable.
paSetVarComment - Set description text of a variable.
paEmbedVarSymbol - Embed the symbol of a variable.
paProfileVar - Set variable profile and properties.

paEnumVar - Enumerate variables.
paGetVarDesc - Get information about a variable.


Declaring I/O Boards

Project Automation Library -> Reference -> Declaring objects -> Declaring I/O Boards

Previous chapter Next chapter Show all Show all Hide all Hide all

Below are the main services to declaring I/O Boards.

Declaration

paCreateIOBoard - Create an instance of an IO device.
paSetIOBoardComment - Set description text for an IO device.
paSetIOBoardParam - Set a parameter of an IO board.
paSetIOAlias - Define an alias for a channel of an IO board.

Working with existing I/O boards

paEnumIOBoards - Enumerate IO boards.
paGetIOBoardDesc - GetDescription of an IO board.
paDeleteIOBoard - Delete an instance of an IO device.
paDeleteAllIOBoards - Delete all IO devices.

In this section

paCreateIOBoard

paSetIOBoardComment

paSetIOBoardParam

paSetIOAlias

paEnumIOBoards

paGetIOBoardDesc

paDeleteIOBoard

paDeleteAllIOBoards


paCreateIOBoard

Project Automation Library -> Reference -> Declaring objects -> Declaring I/O Boards -> paCreateIOBoard

Previous chapter Next chapter Show all Show all Hide all Hide all

paCreateIOBoard - Create an instance of an IO device

OK := paCreateIOBoard (SLOT, DEVTYPE)

Parameter | Description
SLOT : DINT; | Slot number (0..255).
DEVTYPE : STRING; | Name of the type of IO device.
OK : BOOL; | TRUE if successful.

Description

This function creates an instance of the specified IO device at the specified slot number.

seealso See also

paSetIOBoardComment - Set description text for an IO device.
paSetIOBoardParam - Set a parameter of an IO board.
paSetIOAlias - Define an alias for a channel of an IO board.

paEnumIOBoards - Enumerate IO boards.
paGetIOBoardDesc - GetDescription of an IO board.
paDeleteIOBoard - Delete an instance of an IO device.
paDeleteAllIOBoards - Delete all IO devices.


paSetIOBoardComment

Project Automation Library -> Reference -> Declaring objects -> Declaring I/O Boards -> paSetIOBoardComment

Previous chapter Next chapter Show all Show all Hide all Hide all

paSetIOBoardComment - Set the description an IO device

OK := paSetIOBoardComment (SLOT, COMM)

Parameter | Description
SLOT : DINT; | Slot number (0..255).
COMM : STRING; | Description text.
OK : BOOL; | True if successful.

Description

This function sets the comment text of the specified instance of an IO device.

seealso See also

paCreateIOBoard - Create an instance of an IO device.
paSetIOBoardParam - Set a parameter of an IO board.
paSetIOAlias - Define an alias for a channel of an IO board.

paEnumIOBoards - Enumerate IO boards.
paGetIOBoardDesc - GetDescription of an IO board.
paDeleteIOBoard - Delete an instance of an IO device.
paDeleteAllIOBoards - Delete all IO devices.


paSetIOBoardParam

Project Automation Library -> Reference -> Declaring objects -> Declaring I/O Boards -> paSetIOBoardParam

Previous chapter Next chapter Show all Show all Hide all Hide all

paSetIOBoardParam - Set the value of a parameter of an IO device

OK := paSetIOBoardComment (SLOT, COMM)

Parameter | Description
BOARD : STRING; | Board name (e.g. '%QX0').
PARAM : STRING; | Name of the parameter.
VALUE : STRING; | Value of the parameter.
OK : BOOL; | TRUE if successful.

Description

This function sets the value of an IO board parameter. Refer to OEM instruction for details about available parameters.

seealso See also

paCreateIOBoard - Create an instance of an IO device.
paSetIOBoardComment - Set description text for an IO device.
paSetIOAlias - Define an alias for a channel of an IO board.

paEnumIOBoards - Enumerate IO boards.
paGetIOBoardDesc - GetDescription of an IO board.
paDeleteIOBoard - Delete an instance of an IO device.
paDeleteAllIOBoards - Delete all IO devices.


paSetIOAlias

Project Automation Library -> Reference -> Declaring objects -> Declaring I/O Boards -> paSetIOAlias

Previous chapter Next chapter Show all Show all Hide all Hide all

paSetIOAlias - Define an alias for an IO channel

OK := paSetIOBoardComment (SLOT, COMM)

Parameter | Description
CHANNEL : STRING; | Channel name (e.g. '%QX0.1').
ALIAS : STRING; | Readable name to be used as an alias for the channel.
OK : BOOL; | TRUE if successful.

Description

This function defines a readable name for the specified IO channel. The alias can then be used in place of the "%" name in programs.

seealso See also

paCreateIOBoard - Create an instance of an IO device.
paSetIOBoardComment - Set description text for an IO device.
paSetIOBoardParam - Set a parameter of an IO board.
paEnumIOBoards - Enumerate IO boards.
paGetIOBoardDesc - GetDescription of an IO board.
paDeleteIOBoard - Delete an instance of an IO device.
paDeleteAllIOBoards - Delete all IO devices.


paEnumIOBoards

Project Automation Library -> Reference -> Declaring objects -> Declaring I/O Boards -> paEnumIOBoards

Previous chapter Next chapter Show all Show all Hide all Hide all

paEnumIOBoards - Enumerate IO boards of the target project

function block: Inst_paEnumIOBoard (LOAD, CHECK, ITEM, FILTER)

Input | Description
LOAD : TRUE; | If TRUE, load the list of boards.
CHECK : BOOL; | If TRUE, open a checklist box to select some of the loaded boards.
ITEM : DINT; | Index of the item wanted on input (1 based).

Output | Description
NB : DINT; | Number of boards.
Q : STRING; | Name of the item selected with "ITEM".

Description

This function block is used for enumerating the IO boards of the target project. You must first call it with LOAD input at TRUE in order to load the list of IO boards. You get the number of boards in the NB output. Then call it again with LOAD at FALSE and specifying the index of the wished structure in the ITEM input to get the name of the selected item in the Q output. The numbering of items starts at 1.

For complex IO devices, only the child boards of the device are listed. The complex device itself does not occur in the list.

After loading, if can call again the block with the CHECK input at TRUE for opening a dialog box where the user can check wished boards. After the box is closed, only checked items remain in the loaded list.

Example Example

// "ENU" is a declared instance of paEnumIOBoard function block
// load all boards
ENU (TRUE, FALSE, 0);
// open a dialog box for the user to check wished items
ENU (FALSE, TRUE, FALSE, 0);
// enumerate checked items
for i := 1 to ENU.NB do
// select the item "i"
ENU (FALSE, FALSE, i);
// get the name of the item specified by "i"
sBoardName := ENU.Q;
end_for;

seealso See also

paCreateIOBoard - Create an instance of an IO device.
paSetIOBoardComment - Set description text for an IO device.
paSetIOBoardParam - Set a parameter of an IO board.
paSetIOAlias - Define an alias for a channel of an IO board.

paGetIOBoardDesc - GetDescription of an IO board.
paDeleteIOBoard - Delete an instance of an IO device.
paDeleteAllIOBoards - Delete all IO devices.


paGetIOBoardDesc

Project Automation Library -> Reference -> Declaring objects -> Declaring I/O Boards -> paGetIOBoardDesc

Previous chapter Next chapter Show all Show all Hide all Hide all

paGetIOBoardDesc - Get information about an IO board

function block: Inst_paGetIOBoardDesc (NAME)

Input | Description
NAME : STRING; | Name of the board (e.g. '%QX0').

Output | Description
OK : BOOL; | TRUE if successful.
NBCHANNEL : DINT; | Number of channels.
DEVNAME : STRING; | IO Device name.
DEVGROUP : STRING; | In case of a complex IO device, name of the group within the device.
COMMENT : STRING; | Description text.

Description

This function block is for getting information about an IO board of the target project.

seealso See also

paCreateIOBoard - Create an instance of an IO device.
paSetIOBoardComment - Set description text for an IO device.
paSetIOBoardParam - Set a parameter of an IO board.
paSetIOAlias - Define an alias for a channel of an IO board.

paEnumIOBoards - Enumerate IO boards.
paDeleteIOBoard - Delete an instance of an IO device.
paDeleteAllIOBoards - Delete all IO devices.


paDeleteIOBoard

Project Automation Library -> Reference -> Declaring objects -> Declaring I/O Boards -> paDeleteIOBoard

Previous chapter Next chapter Show all Show all Hide all Hide all

paDeleteIOBoard - Delete an instance of an IO device

OK := paDeleteIOBoard (SLOT)

Parameter | Description
SLOT : DINT; | Slot number (0..255).
OK : BOOL; | TRUE if successful.

Description

This function deletes the specified instance of an IO device. In case of a complex device, the whole device (with all its groups) is removed.

seealso See also

paCreateIOBoard - Create an instance of an IO device.
paSetIOBoardComment - Set description text for an IO device.
paSetIOBoardParam - Set a parameter of an IO board.
paSetIOAlias - Define an alias for a channel of an IO board.

paEnumIOBoards - Enumerate IO boards.
paGetIOBoardDesc - GetDescription of an IO board.
paDeleteAllIOBoards - Delete all IO devices.


paDeleteAllIOBoards

Project Automation Library -> Reference -> Declaring objects -> Declaring I/O Boards -> paDeleteAllIOBoards

Previous chapter Next chapter Show all Show all Hide all Hide all

paDeleteAllIOBoards - Delete all instances of IO devices

OK := paDeleteAllIOBoards ()

Parameter | Description
OK : BOOL; | TRUE if successful.

Description

This function deletes all the existing instances of any IO device.

seealso See also

paCreateIOBoard - Create an instance of an IO device.
paSetIOBoardComment - Set description text for an IO device.
paSetIOBoardParam - Set a parameter of an IO board.
paSetIOAlias - Define an alias for a channel of an IO board.

paEnumIOBoards - Enumerate IO boards.
paGetIOBoardDesc - GetDescription of an IO board.
paDeleteIOBoard - Delete an instance of an IO device.


Generating documents

Project Automation Library -> Reference -> Generating documents

Previous chapter Next chapter Show all Show all Hide all Hide all

In this section

Common file services

Text file writing services

IEC Source code file writing services

Networking and fieldbuses - file writing services

Watch window documents - file writing services

Resource documents - file writing services


Common file services

Project Automation Library -> Reference -> Generating documents -> Common file services

Previous chapter Next chapter Show all Show all Hide all Hide all

Below are the main services for managing files when generating documents in the target project.

Declaration

paFileOpenWrite - Open any file in the target project for writing.
paFileOpenWriteProgramSrc - Open the source file of a POU for writing.
paFileOpenWriteProgramDef - Open the definitions file of a POU for writing.
paFileClose - Close an open file.

In this section

paFileOpenWrite

paFileOpenWriteProgramSrc

paFileOpenWriteProgramDef

paFileClose


paFileOpenWrite

Project Automation Library -> Reference -> Generating documents -> Common file services -> paFileOpenWrite

Previous chapter Next chapter Show all Show all Hide all Hide all

paFileOpenWrite - Open any file in the target project for writing

FID := paFileOpenWrite (PREFIX, SUFFIX)

Parameter | Description
PREFIX : STRING; | File prefix.
SUFFIX : STRING; | File suffix.
FID : DINT; | File identifier or 0 if fail.

Description

This function opens a target project file for writing. It should normally not be used as dedicated file open functions are available for most of possible project documents.

This functions removes the contents of the file if it already exist.

When written, the file must be closed by calling the paFileClose function.

seealso See also

paFileOpenWriteProgramSrc - Open the source file of a POU for writing.
paFileOpenWriteProgramDef - Open the definitions file of a POU for writing.
paFileClose - Close an open file.


paFileOpenWriteProgramSrc

Project Automation Library -> Reference -> Generating documents -> Common file services -> paFileOpenWriteProgramSrc

Previous chapter Next chapter Show all Show all Hide all Hide all

paFileOpenWriteProgramSrc - Open a POU source file for writing

FID := paFileOpenWriteProgramSrc (NAME)

Parameter | Description
NAME : STRING; | Program name.
FID : DINT; | File identifier or 0 if fail.

Description

This function opens for writing the file that contains the source code of a program, sub-program or UDFB. Then you should use the appropriate file writing functions according to the language of the specified POU.

This functions removes the contents of the file if it already exist.

When written, the file must be closed by calling the paFileClose function.

seealso See also

paFileOpenWrite - Open any file in the target project for writing.
paFileOpenWriteProgramDef - Open the definitions file of a POU for writing.
paFileClose - Close an open file.


paFileOpenWriteProgramDef

Project Automation Library -> Reference -> Generating documents -> Common file services -> paFileOpenWriteProgramDef

Previous chapter Next chapter Show all Show all Hide all Hide all

paFileOpenWriteProgramDef - Open a POU definitions file for writing

FID := paFileOpenWriteProgramDef (NAME)

Parameter | Description
NAME : STRING; | Program name.
FID : DINT; | File identifier or 0 if fail.

Description

This function opens for writing the file that contains the local definitions of a program, sub-program or UDFB. Then you should use the text file writing functions to fill the file.

This functions removes the contents of the file if it already exist.

When written, the file must be closed by calling the paFileClose function.

seealso See also

paFileOpenWrite - Open any file in the target project for writing.
paFileOpenWriteProgramSrc - Open the source file of a POU for writing.
paFileClose - Close an open file.


paFileClose

Project Automation Library -> Reference -> Generating documents -> Common file services -> paFileClose

Previous chapter Next chapter Show all Show all Hide all Hide all

paFileClose - Close an open file

OK := paFileClose (FID)

Parameter | Description
FID : DINT; | File identifier returned by any file open function.

Description

This function closes a file open by any of available file open functions.

seealso See also

paFileOpenWrite - Open any file in the target project for writing.
paFileOpenWriteProgramSrc - Open the source file of a POU for writing.
paFileOpenWriteProgramDef - Open the definitions file of a POU for writing.


Text file writing services

Project Automation Library -> Reference -> Generating documents -> Text file writing services

Previous chapter Next chapter Show all Show all Hide all Hide all

Below are the main services for writing in text files.

paFTextEol - Write end of line characters to a text file.
paFTextLine - Write a line in a text file.
paFTextString - Write a string in a text file.

In this section

paFTextEol

paFTextLine

paFTextString


paFTextEol

Project Automation Library -> Reference -> Generating documents -> Text file writing services -> paFTextEol

Previous chapter Next chapter Show all Show all Hide all Hide all

paFTextEol - Write end of line characters in a text file

OK := paFTextEol (FID)

Parameter | Description
FID : DINT; | File identifier returned by the file open function.

Description

This function writes end of line characters in a text file open for writing.

seealso See also

paFTextLine - Write a line in a text file.
paFTextString - Write a string in a text file.


paFTextLine

Project Automation Library -> Reference -> Generating documents -> Text file writing services -> paFTextLine

Previous chapter Next chapter Show all Show all Hide all Hide all

paFTextLine - Write a line in a text file

OK := paFTextLine (FID, TEXT)

Parameter | Description
FID : DINT; | File identifier returned by the file open function.
TEXT : STRING; | Text to be written.

Description

This function writes the string specified by the TEXT parameter plus end of line characters in a text file open for writing.

seealso See also

paFTextEol - Write end of line characters to a text file.
paFTextString - Write a string in a text file.


paFTextString

Project Automation Library -> Reference -> Generating documents -> Text file writing services -> paFTextString

Previous chapter Next chapter Show all Show all Hide all Hide all

paFTextString - Write a string in a text file

OK := paFTextEol (FID, TEXT)

Parameter | Description
FID : DINT; | File identifier returned by the file open function.
TEXT : STRING; | Text to be written.

Description

This function writes the string specified by the TEXT parameter in a text file open for writing.

seealso See also

paFTextEol - Write end of line characters to a text file.
paFTextLine - Write a line in a text file.


IEC Source code file writing services

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services

Previous chapter Next chapter Show all Show all Hide all Hide all

Below are the main services for writing source code in IEC language in POU source files. Files are open using the paFileOpenWriteSrc function. When complete, they must be closed by calling the paFileClose function.

There are various set of available functions depending on the programming language:

  • Structured Text or Instruction List:

    Text file writing functions

  • Function Block Diagram:

    Functions for FBD sequential writing

  • Ladder Diagram:

    Functions for LD sequential writing

  • Sequential Function Chart:

    Functions for SFC sequential writing

In this section

ST / IL text

FBD - sequential file writing services

LD - file writing services

SFC - file writing services


ST / IL text

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> ST / IL text

Previous chapter Next chapter Show all Show all Hide all Hide all

Below are the main services for writing in text files.

paFTextEol - Write end of line characters to a text file.
paFTextLine - Write a line in a text file.
paFTextString - Write a string in a text file.

In this section

paFTextEol

paFTextLine

paFTextString


paFTextEol

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> ST / IL text -> paFTextEol

Previous chapter Next chapter Show all Show all Hide all Hide all

paFTextEol - Write end of line characters in a text file

OK := paFTextEol (FID)

Parameter | Description
FID : DINT; | File identifier returned by the file open function.

Description

This function writes end of line characters in a text file open for writing.

seealso See also

paFTextLine - Write a line in a text file.
paFTextString - Write a string in a text file.


paFTextLine

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> ST / IL text -> paFTextLine

Previous chapter Next chapter Show all Show all Hide all Hide all

paFTextLine - Write a line in a text file

OK := paFTextLine (FID, TEXT)

Parameter | Description
FID : DINT; | File identifier returned by the file open function.
TEXT : STRING; | Text to be written.

Description

This function writes the string specified by the TEXT parameter plus end of line characters in a text file open for writing.

seealso See also

paFTextEol - Write end of line characters to a text file.
paFTextString - Write a string in a text file.


paFTextString

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> ST / IL text -> paFTextString

Previous chapter Next chapter Show all Show all Hide all Hide all

paFTextString - Write a string in a text file

OK := paFTextEol (FID, TEXT)

Parameter | Description
FID : DINT; | File identifier returned by the file open function.
TEXT : STRING; | Text to be written.

Description

This function writes the string specified by the TEXT parameter in a text file open for writing.

seealso See also

paFTextEol - Write end of line characters to a text file.
paFTextLine - Write a line in a text file.


FBD - sequential file writing services

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> FBD - sequential file writing services

Previous chapter Next chapter Show all Show all Hide all Hide all

The functions below enable you to write sequentially (from the top to the bottom) the source code of a program written in FBD language. Is has limited features (it is not possible to link 2 blocks together) but provides a very easy way to generate FBD as you do not need to care with the position of the elements in the diagram. Files are open using the paFileOpenWriteSrc function. When complete, they must be closed by calling the paFileClose function.

Use the following functions for inserting objects sequentially:

paFbdsBreak - Insert a network break.
paFbdsComment - Insert a multiline comment block.
paFbdsLabel - Insert a label.
paFbdsJump - Insert a unconditional jump.
paFbdsReturn - Insert a unconditional <RETURN> statement.
paFbdsBlock - Insert a block.

Just after inserting a block, you then can define its inputs and outputs:

paFbdsInputVar - Connect a variable on input of the last block.
paFbdsOutputVar - Connect a variable on output of the last block.
paFbdsOutputJump - Connect a jump statement on output of the last block.
paFbdsOutputReturn - Connect a <RETURN> statement on output of the last block.

See an example.

In this section

paFbdsBreak

paFbdsComment

paFbdsLabel

paFbdsJump

paFbdsReturn

paFbdsBlock

paFbdsInputVar

paFbdsOutputVar

paFbdsOutputJump

paFbdsOutputReturn

Example


paFbdsBreak

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> FBD - sequential file writing services -> paFbdsBreak

Previous chapter Next chapter Show all Show all Hide all Hide all

paFbdsBreak - add a network break

OK := paFbdsBreak (FID, TEXT)

Parameter | Description
FID : DINT; | File identifier answered by paFileOpenWriteSrc.
TEXT : STRING; | Text written on the network break.
OK : BOOL; | TRUE if successful.

Description

This function adds a network break under the last added item in a FBD source file open for writing.

seealso See also

paFbdsComment - Insert a multiline comment block.
paFbdsLabel - Insert a label.
paFbdsJump - Insert a unconditional jump.
paFbdsReturn - Insert a unconditional <RETURN> statement.
paFbdsBlock - Insert a block.

paFbdsInputVar - Connect a variable on input of the last block.
paFbdsOutputVar - Connect a variable on output of the last block.
paFbdsOutputJump - Connect a jump statement on output of the last block.
paFbdsOutputReturn - Connect a <RETURN> statement on output of the last block.

See an example.


paFbdsComment

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> FBD - sequential file writing services -> paFbdsComment

Previous chapter Next chapter Show all Show all Hide all Hide all

paFbdsComment - add a comment block

OK := paFbdsComment (FID, TEXT, HEIGHT)

Parameter | Description
FID : DINT; | File identifier answered by paFileOpenWriteSrc.
TEXT : STRING; | Comment text.
HEIGHT ; DINT; | Height of the comment block (in diagram grid unit).
OK : BOOL; | TRUE if successful.

Description

This function adds a multiline comment block under the last added item in a FBD source file open for writing. You can use the '$N' sequence in the comment text to specify an end of line.

seealso See also

paFbdsBreak - Insert a network break.
paFbdsLabel - Insert a label.
paFbdsJump - Insert a unconditional jump.
paFbdsReturn - Insert a unconditional <RETURN> statement.
paFbdsBlock - Insert a block.

paFbdsInputVar - Connect a variable on input of the last block.
paFbdsOutputVar - Connect a variable on output of the last block.
paFbdsOutputJump - Connect a jump statement on output of the last block.
paFbdsOutputReturn - Connect a <RETURN> statement on output of the last block.

See an example.


paFbdsLabel

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> FBD - sequential file writing services -> paFbdsLabel

Previous chapter Next chapter Show all Show all Hide all Hide all

paFbdsLabel - add a label

OK := paFbdsLabel (FID, LABEL)

Parameter | Description
FID : DINT; | File identifier answered by paFileOpenWriteSrc.
LABEL : STRING; | Label name.
OK : BOOL; | TRUE if successful.

Description

This function adds a label under the last added item in a FBD source file open for writing. The label is placed on the left side of the diagram.

seealso See also

paFbdsBreak - Insert a network break.
paFbdsComment - Insert a multiline comment block.
paFbdsJump - Insert a unconditional jump.
paFbdsReturn - Insert a unconditional <RETURN> statement.
paFbdsBlock - Insert a block.

paFbdsInputVar - Connect a variable on input of the last block.
paFbdsOutputVar - Connect a variable on output of the last block.
paFbdsOutputJump - Connect a jump statement on output of the last block.
paFbdsOutputReturn - Connect a <RETURN> statement on output of the last block.

See an example.


paFbdsJump

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> FBD - sequential file writing services -> paFbdsJump

Previous chapter Next chapter Show all Show all Hide all Hide all

paFbdsJump - add a unconditional jump

OK := paFbdsLabel (FID, LABEL)

Parameter | Description
FID : DINT; | File identifier answered by paFileOpenWriteSrc.
LABEL : STRING; | Target label name.
OK : BOOL; | TRUE if successful.

Description

This function adds a jump instruction under the last added item in a FBD source file open for writing. It is an unconditional jump instruction. The jump symbol is placed on the left side of the diagram, connected to a LD left power rail (always true):

seealso See also

paFbdsBreak - Insert a network break.
paFbdsComment - Insert a multiline comment block.
paFbdsLabel - Insert a label.
paFbdsReturn - Insert a unconditional <RETURN> statement.
paFbdsBlock - Insert a block.

paFbdsInputVar - Connect a variable on input of the last block.
paFbdsOutputVar - Connect a variable on output of the last block.
paFbdsOutputJump - Connect a jump statement on output of the last block.
paFbdsOutputReturn - Connect a <RETURN> statement on output of the last block.

See an example.


paFbdsReturn

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> FBD - sequential file writing services -> paFbdsReturn

Previous chapter Next chapter Show all Show all Hide all Hide all

paFbdsReturn - add a unconditional <return> symbol

OK := paFbdsReturn (FID)

Parameter | Description
FID : DINT; | File identifier answered by paFileOpenWriteSrc.
OK : BOOL; | TRUE if successful.

Description

This function adds a <RETURN> jump instruction under the last added item in a FBD source file open for writing. It is an unconditional instruction. The jump symbol is placed on the left side of the diagram, connected to a LD left power rail (always true):

seealso See also

paFbdsBreak - Insert a network break.
paFbdsComment - Insert a multiline comment block.
paFbdsLabel - Insert a label.
paFbdsJump - Insert a unconditional jump.
paFbdsBlock - Insert a block.

paFbdsInputVar - Connect a variable on input of the last block.
paFbdsOutputVar - Connect a variable on output of the last block.
paFbdsOutputJump - Connect a jump statement on output of the last block.
paFbdsOutputReturn - Connect a <RETURN> statement on output of the last block.

See an example.


paFbdsBlock

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> FBD - sequential file writing services -> paFbdsBlock

Previous chapter Next chapter Show all Show all Hide all Hide all

paFbdsBlock - add a block

OK := paFbdsBlock (FID, NAME, INSTANCE)

Parameter | Description
FID : DINT; | File identifier answered by paFileOpenWriteSrc.
NAME : STRING; | Block name.
INSTANCE : STRING; | Instance name in case of a function block.
OK : BOOL; | TRUE if successful.

Description

This function adds a block symbol under the last added item in a FBD source file open for writing. It can be a basic operator, a function or a function block. The name of the instance must be specified in case of a function block.

Immediately after calling this function, use the FbdsInput... and FbdsOutput... functions in order to connect the input and output pins of the block.

seealso See also

paFbdsBreak - Insert a network break.
paFbdsComment - Insert a multiline comment block.
paFbdsLabel - Insert a label.
paFbdsJump - Insert a unconditional jump.
paFbdsReturn - Insert a unconditional <RETURN> statement.

paFbdsInputVar - Connect a variable on input of the last block.
paFbdsOutputVar - Connect a variable on output of the last block.
paFbdsOutputJump - Connect a jump statement on output of the last block.
paFbdsOutputReturn - Connect a <RETURN> statement on output of the last block.

See an example.


paFbdsInputVar

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> FBD - sequential file writing services -> paFbdsInputVar

Previous chapter Next chapter Show all Show all Hide all Hide all

paFbdsInputVar - connect an input of the last added block

OK := paFbdsInputVar (FID, NAME, PIN, NEGATE)

Parameter | Description
FID : DINT; | File identifier answered by paFileOpenWriteSrc.
NAME : STRING; | Variable name or constant expression.
PIN : DINT; | Index of the input pin of the block (the first input pin is 1).
NEGATE : BOOL; | If TRUE, the connection between the variable and the block has a boolean negation.
OK : BOOL; | TRUE if successful.

Description

This function connects a variable box on input of the last block added by the paFbdsBlock function, and must be called immediately after.

seealso See also

paFbdsBreak - Insert a network break.
paFbdsComment - Insert a multiline comment block.
paFbdsLabel - Insert a label.
paFbdsJump - Insert a unconditional jump.
paFbdsReturn - Insert a unconditional <RETURN> statement.
paFbdsBlock - Insert a block.

paFbdsOutputVar - Connect a variable on output of the last block.
paFbdsOutputJump - Connect a jump statement on output of the last block.
paFbdsOutputReturn - Connect a <RETURN> statement on output of the last block.

See an example.


paFbdsOutputVar

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> FBD - sequential file writing services -> paFbdsOutputVar

Previous chapter Next chapter Show all Show all Hide all Hide all

paFbdsOutputVar - connect an output of the last added block

OK := paFbdsOutputVar (FID, NAME, PIN, NEGATE)

Parameter | Description
FID : DINT; | File identifier answered by paFileOpenWriteSrc.
NAME : STRING; | Variable name.
PIN : DINT; | Index of the output pin of the block (the first output pin is 1).
NEGATE : BOOL; | If TRUE, the connection between the block and the variable has a boolean negation.
OK : BOOL; | TRUE if successful.

Description

This function connects a variable box on output of the last block added by the paFbdsBlock function, and must be called immediately after.

seealso See also

paFbdsBreak - Insert a network break.
paFbdsComment - Insert a multiline comment block.
paFbdsLabel - Insert a label.
paFbdsJump - Insert a unconditional jump.
paFbdsReturn - Insert a unconditional <RETURN> statement.
paFbdsBlock - Insert a block.

paFbdsInputVar - Connect a variable on input of the last block.
paFbdsOutputJump - Connect a jump statement on output of the last block.
paFbdsOutputReturn - Connect a <RETURN> statement on output of the last block.

See an example.


paFbdsOutputJump

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> FBD - sequential file writing services -> paFbdsOutputJump

Previous chapter Next chapter Show all Show all Hide all Hide all

paFbdsOutputJump - connect a jump symbol on output of the last added block

OK := paFbdsOutputJump (FID, LABEL, PIN, NEGATE)

Parameter | Description
FID : DINT; | File identifier answered by paFileOpenWriteSrc.
LABEL : STRING; | Target label name.
PIN : DINT; | Index of the output pin of the block (the first output pin is 1).
NEGATE : BOOL; | If TRUE, the connection between the block and the variable has a boolean negation.
OK : BOOL; | TRUE if successful.

Description

This function connects a jump instruction on output of the last block added by the paFbdsBlock function, and must be called immediately after.

seealso See also

paFbdsBreak - Insert a network break.
paFbdsComment - Insert a multiline comment block.
paFbdsLabel - Insert a label.
paFbdsJump - Insert a unconditional jump.
paFbdsReturn - Insert a unconditional <RETURN> statement.
paFbdsBlock - Insert a block.

paFbdsInputVar - Connect a variable on input of the last block.
paFbdsOutputVar - Connect a variable on output of the last block.
paFbdsOutputReturn - Connect a <RETURN> statement on output of the last block.

See an example.


paFbdsOutputReturn

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> FBD - sequential file writing services -> paFbdsOutputReturn

Previous chapter Next chapter Show all Show all Hide all Hide all

paFbdsOutputReturn - connect a <return> jump symbol on output of the last added block

OK := paFbdsOutputReturn (FID, PIN, NEGATE)

Parameter | Description
FID : DINT; | File identifier answered by paFileOpenWriteSrc.
PIN : DINT; | Index of the output pin of the block (the first output pin is 1).
NEGATE : BOOL; | If TRUE, the connection between the block and the variable has a boolean negation.
OK : BOOL; | TRUE if successful.

Description

This function connects a <RETURN> instruction on output of the last block added by the paFbdsBlock function, and must be called immediately after.

seealso See also

paFbdsBreak - Insert a network break.
paFbdsComment - Insert a multiline comment block.
paFbdsLabel - Insert a label.
paFbdsJump - Insert a unconditional jump.
paFbdsReturn - Insert a unconditional <RETURN> statement.
paFbdsBlock - Insert a block.

paFbdsInputVar - Connect a variable on input of the last block.
paFbdsOutputVar - Connect a variable on output of the last block.
paFbdsOutputJump - Connect a jump statement on output of the last block.

See an example.


Example

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> FBD - sequential file writing services -> Example

Previous chapter Next chapter Show all Show all Hide all Hide all

Below is an example of script that generates a FBD file in the target project:

// make FBD code - sequential writing
f := paFileOpenWriteProgramSrc ('ProgFBD');
if f <> 0 then
// add a comment block (2 lines of text)
paFbdsComment (f, 'FBD program$Ngenerated by script', 2);
// add a function block and its inputs and outputs
paFbdsBreak (f, 'function block');
paFbdsBlock (f, 'Blink', 'Blinker');
paFbdsInputVar (f, 'TRUE', 1, FALSE);
paFbdsInputVar (f, 't#1s', 2, FALSE);
paFbdsOutputJump (f, 'TheEnd', 1, FALSE);
// add a function and its inputs and outputs
paFbdsBreak (f, 'simple addition');
paFbdsBlock (f, '+', '');
paFbdsInputVar (f, 'i1', 1, FALSE);
paFbdsInputVar (f, 'i2', 2, FALSE);
paFbdsOutputVar (f, 'q', 1, FALSE);
// add a label and an unconditional return instruction
paFbdsBreak (f, 'the end');
paFbdsLabel (f, 'TheEnd');
paFbdsReturn (f);
// add a break at the end of the diagram
paFbdsBreak (f, 'eof');
// close the file
paFileClose (f);
end_if;

Here is the FBD program generated by the script:


LD - file writing services

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> LD - file writing services

Previous chapter Next chapter Show all Show all Hide all Hide all

The functions below enable you to write sequentially (from the top to the bottom) the source code of a program written in LD language. The program is written ung after rung. Items are placed sequentially on the rung from the left to the right. Files are open using the paFileOpenWriteSrc function. When complete, they must be closed by calling the paFileClose function.

Use the following functions for inserting rungs in the diagram:

paFLdCommentLine - Add a comment line (network break).
paFLdStartRung - Start a new rung.
paFLdEndRung - Terminate the rung.
paFLdDivergence - Start an OR divergence on the current rung.
paFLdConvergence - Terminate an OR divergence on the current rung.
paFLdNextBranch - Add a parallel branch to the current divergence.

Use the following functions for adding items on the current rung:

paFLdContact - Add a contact.
paFLdCoil - Add a coil.
paFLdJump - Add a jump instruction.
paFLdReturn - Add a <return> jump instruction.
paFLdBlock - Add a block.
paFLdHorzSegment - Add a horizontal segment line.

See an example.

In this section

paFLdCommentLine

paFLdStartRung

paFLdEndRung

paFLdDivergence

paFLdConvergence

paFLdNextBranch

paFLdContact

paFLdCoil

paFLdJump

paFLdReturn

paFLdBlock

paFLdHorzSegment

Example


paFLdCommentLine

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> LD - file writing services -> paFLdCommentLine

Previous chapter Next chapter Show all Show all Hide all Hide all

paFLdCommentLine - add a network break

OK := paFLdCommentLine (FID, TEXT)

Parameter | Description
FID : DINT; | File identifier answered by paFileOpenWriteSrc.
TEXT : STRING; | Text written on the network break.
OK : BOOL; | TRUE if successful.

Description

This function adds a comment line (network break) in between rungs.

seealso See also

paFLdStartRung - Start a new rung.
paFLdEndRung - Terminate the rung.
paFLdDivergence - Start an OR divergence on the current rung.
paFLdConvergence - Terminate an OR divergence on the current rung.
paFLdNextBranch - Add a parallel branch to the current divergence.

paFLdContact - Add a contact.
paFLdCoil - Add a coil.
paFLdJump - Add a jump instruction.
paFLdReturn - Add a <return> jump instruction.
paFLdBlock - Add a block.
paFLdHorzSegment - Add a horizontal segment line.

See an example.


paFLdStartRung

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> LD - file writing services -> paFLdStartRung

Previous chapter Next chapter Show all Show all Hide all Hide all

paFLdStartRung - start a new rung

OK := paFLdStartRung (FID, LABEL)

Parameter | Description
FID : DINT; | File identifier answered by paFileOpenWriteSrc.
LABEL : STRING; | Rung label name (empty string if no label defined).
OK : BOOL; | TRUE if successful.

Description

This function starts a new rung. After calling this function, you can call other functions to add items on the rung from the left to the right. When complete, you need to call the paFLdEndRung function to terminate the rung.

seealso See also

paFLdCommentLine - Add a comment line (network break).
paFLdEndRung - Terminate the rung.
paFLdDivergence - Start an OR divergence on the current rung.
paFLdConvergence - Terminate an OR divergence on the current rung.
paFLdNextBranch - Add a parallel branch to the current divergence.

paFLdContact - Add a contact.
paFLdCoil - Add a coil.
paFLdJump - Add a jump instruction.
paFLdReturn - Add a <return> jump instruction.
paFLdBlock - Add a block.
paFLdHorzSegment - Add a horizontal segment line.

See an example.


paFLdEndRung

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> LD - file writing services -> paFLdEndRung

Previous chapter Next chapter Show all Show all Hide all Hide all

paFLdEndRung - terminates the rung

OK := paFLdEndRung (FID)

Parameter | Description
FID : DINT; | File identifier answered by paFileOpenWriteSrc.
OK : BOOL; | TRUE if successful.

Description

This function terminates the current rung. You need to call it before starting another rung or adding a comment line.

seealso See also

paFLdCommentLine - Add a comment line (network break).
paFLdStartRung - Start a new rung.
paFLdDivergence - Start an OR divergence on the current rung.
paFLdConvergence - Terminate an OR divergence on the current rung.
paFLdNextBranch - Add a parallel branch to the current divergence.

paFLdContact - Add a contact.
paFLdCoil - Add a coil.
paFLdJump - Add a jump instruction.
paFLdReturn - Add a <return> jump instruction.
paFLdBlock - Add a block.
paFLdHorzSegment - Add a horizontal segment line.

See an example.


paFLdDivergence

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> LD - file writing services -> paFLdDivergence

Previous chapter Next chapter Show all Show all Hide all Hide all

paFLdDivergence - starts a divergence

OK := paFLdDivergence (FID)

Parameter | Description
FID : DINT; | File identifier answered by paFileOpenWriteSrc.
OK : BOOL; | TRUE if successful.

Description

This function starts a OR divergence on the current rung. After calling this function, items can be added on the first (top) branch of the divergence. Parallel branches can be added by calling the paFLdNextBranch function. When complete, you need to call the paFLdConvergence function to terminate the divergence.

seealso See also

paFLdCommentLine - Add a comment line (network break).
paFLdStartRung - Start a new rung.
paFLdEndRung - Terminate the rung.
paFLdConvergence - Terminate an OR divergence on the current rung.
paFLdNextBranch - Add a parallel branch to the current divergence.

paFLdContact - Add a contact.
paFLdCoil - Add a coil.
paFLdJump - Add a jump instruction.
paFLdReturn - Add a <return> jump instruction.
paFLdBlock - Add a block.
paFLdHorzSegment - Add a horizontal segment line.

See an example.


paFLdConvergence

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> LD - file writing services -> paFLdConvergence

Previous chapter Next chapter Show all Show all Hide all Hide all

paFLdConvergence - terminates a divergence

OK := paFLdConvergence (FID)

Parameter | Description
FID : DINT; | File identifier answered by paFileOpenWriteSrc.
OK : BOOL; | TRUE rue if successful.

Description

This function terminates the current OR divergence. After calling this function, items can be added after the divergence on the parent rung.

seealso See also

paFLdCommentLine - Add a comment line (network break).
paFLdStartRung - Start a new rung.
paFLdEndRung - Terminate the rung.
paFLdDivergence - Start an OR divergence on the current rung.
paFLdNextBranch - Add a parallel branch to the current divergence.

paFLdContact - Add a contact.
paFLdCoil - Add a coil.
paFLdJump - Add a jump instruction.
paFLdReturn - Add a <return> jump instruction.
paFLdBlock - Add a block.
paFLdHorzSegment - Add a horizontal segment line.

See an example.


paFLdNextBranch

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> LD - file writing services -> paFLdNextBranch

Previous chapter Next chapter Show all Show all Hide all Hide all

paFLdNextBranch - add a branch to a divergence

OK := paFLdNextBranch (FID)

Parameter | Description
FID : DINT; | File identifier answered by paFileOpenWriteSrc.
OK : BOOL; | TRUE if successful.

Description

This function starts a new parallel branch in the current OR divergence. After calling this function, items can be added on the new branch.

seealso See also

paFLdCommentLine - Add a comment line (network break).
paFLdStartRung - Start a new rung.
paFLdEndRung - Terminate the rung.
paFLdDivergence - Start an OR divergence on the current rung.
paFLdConvergence - Terminate an OR divergence on the current rung.
paFLdContact - Add a contact.
paFLdCoil - Add a coil.
paFLdJump - Add a jump instruction.
paFLdReturn - Add a <return> jump instruction.
paFLdBlock - Add a block.
paFLdHorzSegment - Add a horizontal segment line.

See an example.


paFLdContact

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> LD - file writing services -> paFLdContact

Previous chapter Next chapter Show all Show all Hide all Hide all

paFLdContact - add a contact

OK := paFLdContact (FID, TYP, NAME)

Parameter | Description
FID : DINT; | File identifier answered by paFileOpenWriteSrc.
TYP : STRING; | Type of contact (see notes).
NAME : STRING; | Name of the variable attached to the contact.
OK : BOOL; | TRUE if successful.

Description

This function adds a contact on the current rung. The following values are available for the TYP parameter:

Value | Description
_LD_DIR | Normal contact.
_LD_INV | Negated contact.
_LD_P | Positive pulse contact.
_LD_N | Negative pulse contact.

seealso See also

paFLdCommentLine - Add a comment line (network break).
paFLdStartRung - Start a new rung.
paFLdEndRung - Terminate the rung.
paFLdDivergence - Start an OR divergence on the current rung.
paFLdConvergence - Terminate an OR divergence on the current rung.
paFLdNextBranch - Add a parallel branch to the current divergence.

paFLdCoil - Add a coil.
paFLdJump - Add a jump instruction.
paFLdReturn - Add a <return> jump instruction.
paFLdBlock - Add a block.
paFLdHorzSegment - Add a horizontal segment line.

See an example.


paFLdCoil

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> LD - file writing services -> paFLdCoil

Previous chapter Next chapter Show all Show all Hide all Hide all

paFLdCoil - add a coil

OK := paFLdCoil (FID, TYP, NAME)

Parameter | Description
FID : DINT; | File identifier answered by paFileOpenWriteSrc.
TYP : STRING; | Type of coil (see notes).
NAME : STRING; | Name of the variable attached to the coil.
OK : BOOL; | TRUE if successful.

Description

This function adds a coil on the current rung. The following values are available for the TYP parameter:

Value | Description
_LD_DIR | Normal coil.
_LD_INV | Negated coil.
_LD_P | Positive pulse coil.
_LD_N | Negative pulse coil.
_LD_SET | Set coil.
_LD_RESET | Reset coil.

seealso See also

paFLdCommentLine - Add a comment line (network break).
paFLdStartRung - Start a new rung.
paFLdEndRung - Terminate the rung.
paFLdDivergence - Start an OR divergence on the current rung.
paFLdConvergence - Terminate an OR divergence on the current rung.
paFLdNextBranch - Add a parallel branch to the current divergence.

paFLdContact - Add a contact.
paFLdJump - Add a jump instruction.
paFLdReturn - Add a <return> jump instruction.
paFLdBlock - Add a block.
paFLdHorzSegment - Add a horizontal segment line.

See an example.


paFLdJump

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> LD - file writing services -> paFLdJump

Previous chapter Next chapter Show all Show all Hide all Hide all

paFLdJump - add a jump symbol

OK := paFLdJump (FID, LABEL)

Parameter | Description
FID : DINT; | File identifier answered by paFileOpenWriteSrc.
LABEL : STRING; | Target label name.
OK : BOOL; | TRUE if successful.

Description

This function adds a jump instruction on the current rung.

seealso See also

paFLdCommentLine - Add a comment line (network break).
paFLdStartRung - Start a new rung.
paFLdEndRung - Terminate the rung.
paFLdDivergence - Start an OR divergence on the current rung.
paFLdConvergence - Terminate an OR divergence on the current rung.
paFLdNextBranch - Add a parallel branch to the current divergence.

paFLdContact - Add a contact.
paFLdCoil - Add a coil.
paFLdReturn - Add a <return> jump instruction.
paFLdBlock - Add a block.
paFLdHorzSegment - Add a horizontal segment line.

See an example.


paFLdReturn

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> LD - file writing services -> paFLdReturn

Previous chapter Next chapter Show all Show all Hide all Hide all

paFLdReturn - add a <return> jump symbol

OK := paFLdReturn (FID)

Parameter | Description
FID : DINT; | File identifier answered by paFileOpenWriteSrc.
OK : BOOL; | TRUE if successful.

Description

This function adds a <RETURN> jump instruction on the current rung.

seealso See also

paFLdCommentLine - Add a comment line (network break).
paFLdStartRung - Start a new rung.
paFLdEndRung - Terminate the rung.
paFLdDivergence - Start an OR divergence on the current rung.
paFLdConvergence - Terminate an OR divergence on the current rung.
paFLdNextBranch - Add a parallel branch to the current divergence.

paFLdContact - Add a contact.
paFLdCoil - Add a coil.
paFLdJump - Add a jump instruction.
paFLdBlock - Add a block.
paFLdHorzSegment - Add a horizontal segment line.

See an example.


paFLdBlock

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> LD - file writing services -> paFLdBlock

Previous chapter Next chapter Show all Show all Hide all Hide all

paFLdBlock - add a block

OK := paFLdBlock (FID, NAME, INSTANCE, INPUTS, OUTPUTS)

Parameter | Description
FID : DINT; | File identifier answered by paFileOpenWriteSrc.
NAME : STRING; | Type of block.
INSTANCE : STRING; | Name of the instance in case of a function block.
INPUTS : STRING; | List of input values (see notes).
OUTPUTS : STRING; | List of output values (see notes).
OK : BOOL; | TRUE if successful.

Description

This function adds a block on the current rung. In case of a function block, you must specify the name of the instance. Blocks are connected to the rung by their first input and output. Name of additional inputs and outputs are passed in strings separated by comas. Below is the example of an "addition" block with 2 additional inputs calle 'i1' and 'i2'and 1 additional output calle 'q':

Example Example

paFLdStartRung (f, '');
paFldBlock (f, '+', '', 'i1,i2', 'q');
paFldCoil (f, _LD_DIR, '');

paFLdEndRung (f);

seealso See also

paFLdCommentLine - Add a comment line (network break).
paFLdStartRung - Start a new rung.
paFLdEndRung - Terminate the rung.
paFLdDivergence - Start an OR divergence on the current rung.
paFLdConvergence - Terminate an OR divergence on the current rung.
paFLdNextBranch - Add a parallel branch to the current divergence.

paFLdContact - Add a contact.
paFLdCoil - Add a coil.
paFLdJump - Add a jump instruction.
paFLdReturn - Add a <return> jump instruction.
paFLdHorzSegment - Add a horizontal segment line.

See an example.


paFLdHorzSegment

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> LD - file writing services -> paFLdHorzSegment

Previous chapter Next chapter Show all Show all Hide all Hide all

paFLdHorzSegment - add a horizontal segment

OK := paFLdHorzSegment (FID)

Parameter | Description
FID : DINT; | File identifier answered by paFileOpenWriteSrc.
OK : BOOL; | TRUE if successful.

Description

This function adds a horizontal line segment on the current rung. This can be used for aligning items vertically in the diagram.

seealso See also

paFLdCommentLine - Add a comment line (network break).
paFLdStartRung - Start a new rung.
paFLdEndRung - Terminate the rung.
paFLdDivergence - Start an OR divergence on the current rung.
paFLdConvergence - Terminate an OR divergence on the current rung.
paFLdNextBranch - Add a parallel branch to the current divergence.

paFLdContact - Add a contact.
paFLdCoil - Add a coil.
paFLdJump - Add a jump instruction.
paFLdReturn - Add a <return> jump instruction.
paFLdBlock - Add a block.
See an example.


Example

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> LD - file writing services -> Example

Previous chapter Next chapter Show all Show all Hide all Hide all

Below is an example of script that generates a LD file in the target project:

// make LD code
f := paFileOpenWriteProgramSrc ('ProgLD');
if f <> 0 then
// comment line
paFLdCommentLine (f, 'Generated by script');
// a simple rung finishing with a jump
paFLdStartRung (f, '');
paFldContact (f, _LD_DIR, 'Cond');
paFldJump (f, 'TheEnd');
paFLdEndRung (f);
// a rung with contacts and coils
paFLdStartRung (f, '');
paFldContact (f, _LD_DIR, 'V1');
paFLdDivergence (f);
paFldContact (f, _LD_DIR, 'V2');
paFLdNextBranch (f);
paFldContact (f, _LD_DIR, 'V3');
paFLdConvergence (f);
paFldCoil (f, _LD_INV, 'V');
paFLdEndRung (f);
// a rung with blocks
paFLdStartRung (f, '');
paFldBlock (f, '+', '', 'i1,i2', 'q');
paFldBlock (f, 'Blink', 'Blinker', 't#1s', '');
paFldCoil (f, _LD_DIR, '');
paFLdEndRung (f);
// a rung with a label and a RETURN instruction
paFLdStartRung (f, 'TheEnd');
paFldReturn (f);
paFLdEndRung (f);
// close the file
paFileClose (f);
end_if;

Here is the LD program generated by the script:


SFC - file writing services

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> SFC - file writing services

Previous chapter Next chapter Show all Show all Hide all Hide all

The functions below enable you to write sequentially (from the top to the bottom) the source code of a program written in SFC language. The program is written sequentially, from the top to the bottom and branch per branch. Files are open using the paFileOpenWriteSrc function. When complete, they must be closed by calling the paFileClose function.

Use the following functions for inserting SFC items in the chart:

paSfcIStep - Add an initial step.
paSfcStep - Add a step.
paSfcTrans - Add a transition.
paSfcJump - Add a jump to a step.
paSfcDiv - Start a divergence on the current branch.
paSfcBranch - Start a new branch under the current divergence.
paSfcConv - Finish the current divergence.
paSfcAddLv2String - Add a text string to the level 2 program.
paSfcAddLv2Line - Add a text line to the level 2 program.
paSfcAddLv2Eol - Add end of line characters to the level 2 program.

See an example.

info Info

Macro-steps are not supported.

In this section

paSfcIStep

paSfcStep

paSfcTrans

paSfcJump

paSfcDiv

paSfcBranch

paSfcConv

paSfcAddLv2String

paSfcAddLv2Line

paSfcAddLv2Eol

Example


paSfcIStep

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> SFC - file writing services -> paSfcIStep

Previous chapter Next chapter Show all Show all Hide all Hide all

paSfcIStep - add an initial step

OK := paSfcIStep (FID, REF)

Parameter | Description
FID : DINT; | File identifier answered by paFileOpenWriteSrc.
REF : DINT; | Reference number of the step.
OK : BOOL; | TRUE if successful.

Description

This function adds an initial step at the end of the current branch.

seealso See also

paSfcStep - Add a step.
paSfcTrans - Add a transition.
paSfcJump - Add a jump to a step.
paSfcDiv - Start a divergence on the current branch.
paSfcBranch - Start a new branch under the current divergence.
paSfcConv - Finish the current divergence.
paSfcAddLv2String - Add a text string to the level 2 program.
paSfcAddLv2Line - Add a text line to the level 2 program.
paSfcAddLv2Eol - Add end of line characters to the level 2 program.

See an example.


paSfcStep

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> SFC - file writing services -> paSfcStep

Previous chapter Next chapter Show all Show all Hide all Hide all

paSfcStep - add a step

OK := paSfcStep (FID, REF)

Parameter | Description
FID : DINT; | File identifier answered by paFileOpenWriteSrc.
REF : DINT; | Reference number of the step.
OK : BOOL; | TRUE if successful.

Description

This function adds a step at the end of the current branch.

seealso See also

paSfcIStep - Add an initial step.
paSfcTrans - Add a transition.
paSfcJump - Add a jump to a step.
paSfcDiv - Start a divergence on the current branch.
paSfcBranch - Start a new branch under the current divergence.
paSfcConv - Finish the current divergence.
paSfcAddLv2String - Add a text string to the level 2 program.
paSfcAddLv2Line - Add a text line to the level 2 program.
paSfcAddLv2Eol - Add end of line characters to the level 2 program.

See an example.


paSfcTrans

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> SFC - file writing services -> paSfcTrans

Previous chapter Next chapter Show all Show all Hide all Hide all

paSfcTrans - add a transition

OK := paSfcTrans (FID, REF)

Parameter | Description
FID : DINT; | File identifier answered by paFileOpenWriteSrc.
REF : DINT; | Reference number of the transition.
OK : BOOL; | TRUE if successful.

Description

This function adds a transition at the end of the current branch.

seealso See also

paSfcIStep - Add an initial step.
paSfcStep - Add a step.
paSfcJump - Add a jump to a step.
paSfcDiv - Start a divergence on the current branch.
paSfcBranch - Start a new branch under the current divergence.
paSfcConv - Finish the current divergence.
paSfcAddLv2String - Add a text string to the level 2 program.
paSfcAddLv2Line - Add a text line to the level 2 program.
paSfcAddLv2Eol - Add end of line characters to the level 2 program.

See an example.


paSfcJump

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> SFC - file writing services -> paSfcJump

Previous chapter Next chapter Show all Show all Hide all Hide all

paSfcJump - add a jump to a step

OK := paSfcJump (FID, REF)

Parameter | Description
FID : DINT; | File identifier answered by paFileOpenWriteSrc.
REF : DINT; | Reference number of the target step.
OK : BOOL; | TRUE if successful.

Description

This function adds a jump to a step at the end of the current branch.

seealso See also

paSfcIStep - Add an initial step.
paSfcStep - Add a step.
paSfcTrans - Add a transition.
paSfcDiv - Start a divergence on the current branch.
paSfcBranch - Start a new branch under the current divergence.
paSfcConv - Finish the current divergence.
paSfcAddLv2String - Add a text string to the level 2 program.
paSfcAddLv2Line - Add a text line to the level 2 program.
paSfcAddLv2Eol - Add end of line characters to the level 2 program.

See an example.


paSfcDiv

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> SFC - file writing services -> paSfcDiv

Previous chapter Next chapter Show all Show all Hide all Hide all

paSfcDiv - start a divergence

OK := paSfcDiv (FID)

Parameter | Description
FID : DINT; | File identifier answered by paFileOpenWriteSrc.
OK : BOOL; | TRUE if successful.

Description

This function starts a divergence the end of the current branch. It automatically initiates the first branch (left side) so you can start instering items on it. The divergence will have to be ended by a convergence, even if its branches finish by a jump symbol (and thus do not actually converge). Divergences can be nested.

seealso See also

paSfcIStep - Add an initial step.
paSfcStep - Add a step.
paSfcTrans - Add a transition.
paSfcJump - Add a jump to a step.
paSfcBranch - Start a new branch under the current divergence.
paSfcConv - Finish the current divergence.
paSfcAddLv2String - Add a text string to the level 2 program.
paSfcAddLv2Line - Add a text line to the level 2 program.
paSfcAddLv2Eol - Add end of line characters to the level 2 program.

See an example.


paSfcBranch

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> SFC - file writing services -> paSfcBranch

Previous chapter Next chapter Show all Show all Hide all Hide all

paSfcBranch - add a branch to the last open divergence

OK := paSfcBranch (FID)

Parameter | Description
FID : DINT; | File identifier answered by paFileOpenWriteSrc.
OK : BOOL; | TRUE if successful.

Description

This function adds a new branch on the right of the divergence created by the last call to paSfcDiv() It is not needed to call this function for the first branch (on the left) as it is automatically initiated when the divergence is created.

seealso See also

paSfcIStep - Add an initial step.
paSfcStep - Add a step.
paSfcTrans - Add a transition.
paSfcJump - Add a jump to a step.
paSfcDiv - Start a divergence on the current branch.
paSfcConv - Finish the current divergence.
paSfcAddLv2String - Add a text string to the level 2 program.
paSfcAddLv2Line - Add a text line to the level 2 program.
paSfcAddLv2Eol - Add end of line characters to the level 2 program.

See an example.


paSfcConv

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> SFC - file writing services -> paSfcConv

Previous chapter Next chapter Show all Show all Hide all Hide all

paSfcConv - finish a divergence

OK := paSfcConv (FID)

Parameter | Description
FID : DINT; | File identifier answered by paFileOpenWriteSrc.
OK : BOOL; | TRUE if successful.

Description

This function closes the divergence created by the last call to paSfcDiv() The divergence will have to be ended by a convergence, even if its branches finish by a jump symbol (and thus do not actually converge). Divergences can be nested.

seealso See also

paSfcIStep - Add an initial step.
paSfcStep - Add a step.
paSfcTrans - Add a transition.
paSfcJump - Add a jump to a step.
paSfcDiv - Start a divergence on the current branch.
paSfcBranch - Start a new branch under the current divergence.
paSfcAddLv2String - Add a text string to the level 2 program.
paSfcAddLv2Line - Add a text line to the level 2 program.
paSfcAddLv2Eol - Add end of line characters to the level 2 program.

See an example.


paSfcAddLv2String

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> SFC - file writing services -> paSfcAddLv2String

Previous chapter Next chapter Show all Show all Hide all Hide all

paSfcAddLv2String - add text string to level2 programming

OK := paSfcAddLv2String (FID, KIND, TEXT)

Parameter | Description
FID : DINT; | File identifier answered by paFileOpenWriteSrc.
KIND : STRING; | Kind of level 2 information - see notes.
TEXT : STRING; | Text to be appened.
OK : BOOL; | TRUE if successful.

Description

This function appends a string to the level 2 programming of the last created step or transition. It must be called immediately after the step or transition is created. The KIND argument specify which piece of level 2 information must be written. The following values are predefined:

Value | Description
_LV2_NOTE | Description text.
_LV2_COND | Condition (for a transition).
_LV2_ACTION | Default actions of a step.
_LV2_P1 | P1 actions of a step.
_LV2_N | N actions of a step.
_LV2_P0 | P0 actions of a step.

Generating level 2 programs in LD or FBD is not supported.

seealso See also

paSfcIStep - Add an initial step.
paSfcStep - Add a step.
paSfcTrans - Add a transition.
paSfcJump - Add a jump to a step.
paSfcDiv - Start a divergence on the current branch.
paSfcBranch - Start a new branch under the current divergence.
paSfcConv - Finish the current divergence.
paSfcAddLv2Line - Add a text line to the level 2 program.
paSfcAddLv2Eol - Add end of line characters to the level 2 program.

See an example.


paSfcAddLv2Line

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> SFC - file writing services -> paSfcAddLv2Line

Previous chapter Next chapter Show all Show all Hide all Hide all

paSfcAddLv2Line - add text line to level2 programming

OK := paSfcAddLv2Line (FID, KIND, TEXT)

Parameter | Description
FID : DINT; | File identifier answered by paFileOpenWriteSrc.
KIND : STRING; | Kind of level 2 information - see notes.
TEXT : STRING; | Text to be appened.
OK : BOOL; | TRUE if successful.

Description

This function appends a string plus end of lines characters ('$R$N') to the level 2 programming of the last created step or transition. It must be called immediately after the step or transition is created. The KIND argument specify which piece of level 2 information must be written. The following values are predefined:

Value | Description
_LV2_NOTE | Description text.
_LV2_COND | Condition (for a transition).
_LV2_ACTION | Default actions of a step.
_LV2_P1 | P1 actions of a step.
_LV2_N | N actions of a step.
_LV2_P0 | P0 actions of a step.

Generating level 2 programs in LD or FBD is not supported.

seealso See also

paSfcIStep - Add an initial step.
paSfcStep - Add a step.
paSfcTrans - Add a transition.
paSfcJump - Add a jump to a step.
paSfcDiv - Start a divergence on the current branch.
paSfcBranch - Start a new branch under the current divergence.
paSfcConv - Finish the current divergence.
paSfcAddLv2String - Add a text string to the level 2 program.
paSfcAddLv2Eol - Add end of line characters to the level 2 program.

See an example.


paSfcAddLv2Eol

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> SFC - file writing services -> paSfcAddLv2Eol

Previous chapter Next chapter Show all Show all Hide all Hide all

paSfcAddLv2Eol - add end of line characters to level2 programming

OK := paSfcAddLv2Eol (FID, KIND)

Parameter | Description
FID : DINT; | File identifier answered by paFileOpenWriteSrc.
KIND : STRING; | Kind of level 2 information - see notes.
OK : BOOL; | TRUE if successful.

Description

This function appends end of lines characters ('$R$N') to the level 2 programming of the last created step or transition. It must be called immediately after the step or transition is created. The KIND argument specify which piece of level 2 information must be written. The following values are predefined:

Parameter | Description
_LV2_NOTE | Description text.
_LV2_COND | Condition (for a transition).
_LV2_ACTION | Default actions of a step.
_LV2_P1 | P1 actions of a step.
_LV2_N | N actions of a step.
_LV2_P0 | P0 actions of a step.

Generating level 2 programs in LD or FBD is not supported.

seealso See also

paSfcIStep - Add an initial step.
paSfcStep - Add a step.
paSfcTrans - Add a transition.
paSfcJump - Add a jump to a step.
paSfcDiv - Start a divergence on the current branch.
paSfcBranch - Start a new branch under the current divergence.
paSfcConv - Finish the current divergence.
paSfcAddLv2String - Add a text string to the level 2 program.
paSfcAddLv2Line - Add a text line to the level 2 program.

See an example.


Example

Project Automation Library -> Reference -> Generating documents -> IEC Source code file writing services -> SFC - file writing services -> Example

Previous chapter Next chapter Show all Show all Hide all Hide all

Below is an example of script that generates a SFC file in the target project:

// make LD code
f := paFileOpenWriteProgramSrc ('ProgSFC');
if f <> 0 then

// initial step
paSfcIStep (f, 1);
paSfcAddLv2String (f, _LV2_NOTE, 'Thats S1');
paSfcAddLv2Line (f, _LV2_ACTION, 'VarXX (N);');

// an 'OR' divergence
paSfcDiv (f);

paSfcTrans (f, 1);
paSfcAddLv2String (f, _LV2_NOTE, 'Thats T1');
paSfcAddLv2Line (f, _LV2_COND, 'condition');

// second branch
paSfcBranch (f);

paSfcTrans (f, 101);
paSfcStep (f, 101);
paSfcTrans (f, 102);

// converge
paSfcCnv (f);

// jump to the initial step
paSfcJump (f, 1);

// close the file
paFileClose (f);
end_if;

Here is the SFC program generated by the script:


Networking and fieldbuses - file writing services

Project Automation Library -> Reference -> Generating documents -> Networking and fieldbuses - file writing services

Previous chapter Next chapter Show all Show all Hide all Hide all

Below are the main services for writing configuration files for networking or fieldbus I/O drivers. Files are open using specific functions. When complete, they must be closed by calling the paFileClose function.

  • Functions for MODBUS configuration:

paFileOpenWriteModbus - Open the MODBUS configuration for writing.
paFModbusSlave - Configurate the MODBUS slave connection.
paFModbusMaster - Create a MODBUS master connection.
paFModbusRequestSlave - Add a MODBUS request on the slave connection.
paFModbusRequestMaster - Add a MODBUS request on a master connection.
paFModbusVariable - Add a MODBUS variable to the last declared request.

  • Functions for AS-i configuration:

paFileOpenWriteASi - Open the AS-i configuration for writing.
paFAsiApplyConfig - Set main flag.
paFAsiMaster - Add a master device.
paFAsiMasterDiag - Add a diagnostic variable on the last declared master.
paFAsiSlave - Add a slave device.
paFAsiSlaveDiag - Add a diagnostic variable on the last declared slave.
paFAsiInput - Add an input variable on the last declared slave.
paFAsiOutput - Add an output variable on the last declared slave.

  • Functions for other fieldbus drivers:

paFileOpenWriteFieldbus - Open a feldbus configuration for writing.
paFfbCreateMaster - Add a master node.
paFfbCreateSlave - Add a slave node.
paFfbCreateVar - Add a variable node.
paFfbSetProperty - Set the the value of a property.
paFfbSelectRoot - Select the root node.
paFfbSelectMaster - Select a master node.
paFfbSelectSlave - Select a slave node.
paFfbSelectVar - Select a variable node.

  • Functions for the binding configuration:

paFileOpenWriteBinding - Open the binding configuration for writing.
paFbindPublicVar - Add a public variable.
paFbindExternPort - Add an extern port.
paFbindCnxStatus - Add a connection status variable.
paFbindExternVar - Add an extern variable.
paFbindVarStatus - Add a status variable.
paFbindVarDateStamp - Add a date stamp variable.
paFbindVarTimeStamp - Add a time stamp variable.

In this section

paFileOpenWriteModbus

paFModbusSlave

paFModbusMaster

paFModbusRequestSlave

paFModbusRequestMaster

paFModbusVariable

paFileOpenWriteASi

paFAsiApplyConfig

paFAsiMaster

paFAsiMasterDiag

paFAsiSlave

paFAsiSlaveDiag

paFAsiInput

paFAsiOutput

paFileOpenWriteFieldbus

paFfbCreateMaster

paFfbCreateSlave

paFfbCreateVar

paFfbSetProperty

paFfbSelectRoot

paFfbSelectMaster

paFfbSelectSlave

paFfbSelectVar

paFileOpenWriteBinding

paFbindPublicVar

paFbindExternPort

paFbindCnxStatus

paFbindExternVar

paFbindVarStatus

paFbindVarDateStamp

paFbindVarTimeStamp


paFileOpenWriteModbus

Project Automation Library -> Reference -> Generating documents -> Networking and fieldbuses - file writing services -> paFileOpenWriteModbus

Previous chapter Next chapter Show all Show all Hide all Hide all

paFileOpenWriteModbus - Open the MODBUS configuration for writing

FID := paFileOpenWriteModbus ()

Parameter | Description
FID : DINT; | File identifier or 0 if fail.

Description

This function opens the MODBUS configuration file for writing. This functions removes the contents of the configuration if it already exist. When written, the file must be closed by calling the paFileClose function.

seealso See also
  • Functions for MODBUS configuration:

paFModbusSlave - Configurate the MODBUS slave connection.
paFModbusMaster - Create a MODBUS master connection.
paFModbusRequestSlave - Add a MODBUS request on the slave connection.
paFModbusRequestMaster - Add a MODBUS request on a master connection.
paFModbusVariable - Add a MODBUS variable to the last declared request.

  • Functions for AS-i configuration:

paFileOpenWriteASi - Open the AS-i configuration for writing.
paFAsiApplyConfig - Set main flag.
paFAsiMaster - Add a master device.
paFAsiMasterDiag - Add a diagnostic variable on the last declared master.
paFAsiSlave - Add a slave device.
paFAsiSlaveDiag - Add a diagnostic variable on the last declared slave.
paFAsiInput - Add an input variable on the last declared slave.
paFAsiOutput - Add an output variable on the last declared slave.

  • Functions for other fieldbus drivers:

paFileOpenWriteFieldbus - Open a feldbus configuration for writing.
paFfbCreateMaster - Add a master node.
paFfbCreateSlave - Add a slave node.
paFfbCreateVar - Add a variable node.
paFfbSetProperty - Set the the value of a property.
paFfbSelectRoot - Select the root node.
paFfbSelectMaster - Select a master node.
paFfbSelectSlave - Select a slave node.
paFfbSelectVar - Select a variable node.

  • Functions for the binding configuration:

paFileOpenWriteBinding - Open the binding configuration for writing.
paFbindPublicVar - Add a public variable.
paFbindExternPort - Add an extern port.
paFbindCnxStatus - Add a connection status variable.
paFbindExternVar - Add an extern variable.
paFbindVarStatus - Add a status variable.
paFbindVarDateStamp - Add a date stamp variable.
paFbindVarTimeStamp - Add a time stamp variable.


paFModbusSlave

Project Automation Library -> Reference -> Generating documents -> Networking and fieldbuses - file writing services -> paFModbusSlave

Previous chapter Next chapter Show all Show all Hide all Hide all

paFModbusSlave - Set the MODBUS slave configuration

OK := paFModbusSlave (FID, SLAVENO)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenWriteModbus function.
SLAVENO : DINT; | Default slave number for the MODBUS Slave server.
OK : BOOL; | TRUE if successful.

Description

This function defines the slave number used for the MODBUS slave server.

seealso See also
  • Functions for MODBUS configuration:

paFileOpenWriteModbus - Open the MODBUS configuration for writing.
paFModbusMaster - Create a MODBUS master connection.
paFModbusRequestSlave - Add a MODBUS request on the slave connection.
paFModbusRequestMaster - Add a MODBUS request on a master connection.
paFModbusVariable - Add a MODBUS variable to the last declared request.

  • Functions for AS-i configuration:

paFileOpenWriteASi - Open the AS-i configuration for writing.
paFAsiApplyConfig - Set main flag.
paFAsiMaster - Add a master device.
paFAsiMasterDiag - Add a diagnostic variable on the last declared master.
paFAsiSlave - Add a slave device.
paFAsiSlaveDiag - Add a diagnostic variable on the last declared slave.
paFAsiInput - Add an input variable on the last declared slave.
paFAsiOutput - Add an output variable on the last declared slave.

  • Functions for other fieldbus drivers:

paFileOpenWriteFieldbus - Open a feldbus configuration for writing.
paFfbCreateMaster - Add a master node.
paFfbCreateSlave - Add a slave node.
paFfbCreateVar - Add a variable node.
paFfbSetProperty - Set the the value of a property.
paFfbSelectRoot - Select the root node.
paFfbSelectMaster - Select a master node.
paFfbSelectSlave - Select a slave node.
paFfbSelectVar - Select a variable node.

  • Functions for the binding configuration:

paFileOpenWriteBinding - Open the binding configuration for writing.
paFbindPublicVar - Add a public variable.
paFbindExternPort - Add an extern port.
paFbindCnxStatus - Add a connection status variable.
paFbindExternVar - Add an extern variable.
paFbindVarStatus - Add a status variable.
paFbindVarDateStamp - Add a date stamp variable.
paFbindVarTimeStamp - Add a time stamp variable.


paFModbusMaster

Project Automation Library -> Reference -> Generating documents -> Networking and fieldbuses - file writing services -> paFModbusMaster

Previous chapter Next chapter Show all Show all Hide all Hide all

paFModbusMaster - Add a MODBUS master port

OK := paFModbusMaster (FID, OPENMODBUS, ADDRESS, PORT, RECONNECT)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenWriteModbus function.
OPENMODBUS : BOOL; | TRUE = Open Modbus protocol / FALSE = RTU protocol.
ADDRESS : STRING; | Configuration of the port or IP address.
PORT : DINT; | IP port number in case of MODBUS on ETHERNET.
RECONNECT : BOOL; | Option: tries to reconnect after error.
OK : BOOL; | TRUE if successful.

Description

This function adds a new MODBUS master connection to the configuration.

seealso See also
  • Functions for MODBUS configuration:

paFileOpenWriteModbus - Open the MODBUS configuration for writing.
paFModbusSlave - Configurate the MODBUS slave connection.
paFModbusRequestSlave - Add a MODBUS request on the slave connection.
paFModbusRequestMaster - Add a MODBUS request on a master connection.
paFModbusVariable - Add a MODBUS variable to the last declared request.

  • Functions for AS-i configuration:

paFileOpenWriteASi - Open the AS-i configuration for writing.
paFAsiApplyConfig - Set main flag.
paFAsiMaster - Add a master device.
paFAsiMasterDiag - Add a diagnostic variable on the last declared master.
paFAsiSlave - Add a slave device.
paFAsiSlaveDiag - Add a diagnostic variable on the last declared slave.
paFAsiInput - Add an input variable on the last declared slave.
paFAsiOutput - Add an output variable on the last declared slave.

  • Functions for other fieldbus drivers:

paFileOpenWriteFieldbus - Open a feldbus configuration for writing.
paFfbCreateMaster - Add a master node.
paFfbCreateSlave - Add a slave node.
paFfbCreateVar - Add a variable node.
paFfbSetProperty - Set the the value of a property.
paFfbSelectRoot - Select the root node.
paFfbSelectMaster - Select a master node.
paFfbSelectSlave - Select a slave node.
paFfbSelectVar - Select a variable node.

  • Functions for the binding configuration:

paFileOpenWriteBinding - Open the binding configuration for writing.
paFbindPublicVar - Add a public variable.
paFbindExternPort - Add an extern port.
paFbindCnxStatus - Add a connection status variable.
paFbindExternVar - Add an extern variable.
paFbindVarStatus - Add a status variable.
paFbindVarDateStamp - Add a date stamp variable.
paFbindVarTimeStamp - Add a time stamp variable.


paFModbusRequestSlave

Project Automation Library -> Reference -> Generating documents -> Networking and fieldbuses - file writing services -> paFModbusRequestSlave

Previous chapter Next chapter Show all Show all Hide all Hide all

paFModbusRequestSlave - Add a MODBUS slave request

OK := paFModbusRequestSlave (FID, REQUEST, ADDRESS, NBITEM, NAME)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenWriteModbus function.
REQUEST : STRING; | Type of request (see notes).
ADDRESS : DINT; | Base MODBUS address.
NBITEM : DINT; | Number of items (bits or words).
NAME : STRING; | Optionnal description text.
OK : BOOL; | TRUE if successful.

Description

This function adds a new MODBUS slave request. You can define variables of the request just after calling this function.

attention Attention

This function does not take care of address offsets defined by MODBUS. The first available address is always 0.

The following values are possible for the REQUEST parameter:

Value | Description
_MB_I_REG | Input registers.
_MB_H_REG | Holding registers.
_MB_I_BIT | Input bits.
_MB_C_BIT | Coil bits.

seealso See also
  • Functions for MODBUS configuration:

paFileOpenWriteModbus - Open the MODBUS configuration for writing.
paFModbusSlave - Configurate the MODBUS slave connection.
paFModbusMaster - Create a MODBUS master connection.
paFModbusRequestMaster - Add a MODBUS request on a master connection.
paFModbusVariable - Add a MODBUS variable to the last declared request.

  • Functions for AS-i configuration:

paFileOpenWriteASi - Open the AS-i configuration for writing.
paFAsiApplyConfig - Set main flag.
paFAsiMaster - Add a master device.
paFAsiMasterDiag - Add a diagnostic variable on the last declared master.
paFAsiSlave - Add a slave device.
paFAsiSlaveDiag - Add a diagnostic variable on the last declared slave.
paFAsiInput - Add an input variable on the last declared slave.
paFAsiOutput - Add an output variable on the last declared slave.

  • Functions for other fieldbus drivers:

paFileOpenWriteFieldbus - Open a feldbus configuration for writing.
paFfbCreateMaster - Add a master node.
paFfbCreateSlave - Add a slave node.
paFfbCreateVar - Add a variable node.
paFfbSetProperty - Set the the value of a property.
paFfbSelectRoot - Select the root node.
paFfbSelectMaster - Select a master node.
paFfbSelectSlave - Select a slave node.
paFfbSelectVar - Select a variable node.

  • Functions for the binding configuration:

paFileOpenWriteBinding - Open the binding configuration for writing.
paFbindPublicVar - Add a public variable.
paFbindExternPort - Add an extern port.
paFbindCnxStatus - Add a connection status variable.
paFbindExternVar - Add an extern variable.
paFbindVarStatus - Add a status variable.
paFbindVarDateStamp - Add a date stamp variable.
paFbindVarTimeStamp - Add a time stamp variable.


paFModbusRequestMaster

Project Automation Library -> Reference -> Generating documents -> Networking and fieldbuses - file writing services -> paFModbusRequestMaster

Previous chapter Next chapter Show all Show all Hide all Hide all

paFModbusRequestMaster - Add a MODBUS master request

OK := paFModbusRequestMaster (FID, MODE, REQUEST, SLAVENO, ADDRESS, NBITEM, PERIOD, TIMEOUT, TRIALS, NAME)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenWriteModbus function.
MODE : STRING; | Activation mode (see notes).
REQUEST : STRING; | Type of request (see notes).
SLAVENO : DINT; | Slave number of the device.
ADDRESS : DINT; | Base MODBUS address.
NBITEM : DINT; | Number of items (bits or words).
PERIOD : TIME; | Activation period (for periodic requests).
TIMEOUT : TIME; | Exchange timeout.
TRIALS : DINT; | Number of successive trials.
NAME : STRING; | Optionnal description text.
OK : BOOL; | TRUE if successful.

Description

This function adds a new MODBUS master request. You can define variables of the request just after calling this function.

attention Attention

This function does not take care of address offsets defined by MODBUS. The first available address is always 0.

The following values are possible for the MODE parameter:

Value | Description
_MB_PERIODIC | Request activated periodically.
_MB_ONCALL | Request activated by a variable.
_MB_ONCHANGE | Request activated on a change of data (for "write" requests).

The following values are possible for the REQUEST parameter:

Value | Description
_MB_READ_I_REG | Read Input registers.
_MB_READ_H_REG | Read Holding registers.
_MB_WRITE_H_REG | Write Holding registers.
_MB_READ_I_BIT | Read Input bits.
_MB_READ_C_BIT | Read Coil bits.
_MB_WRITE_C_BIT | Write Coil bits.

seealso See also
  • Functions for MODBUS configuration:

paFileOpenWriteModbus - Open the MODBUS configuration for writing.
paFModbusSlave - Configurate the MODBUS slave connection.
paFModbusMaster - Create a MODBUS master connection.
paFModbusRequestSlave - Add a MODBUS request on the slave connection.
paFModbusVariable - Add a MODBUS variable to the last declared request.

  • Functions for AS-i configuration:

paFileOpenWriteASi - Open the AS-i configuration for writing.
paFAsiApplyConfig - Set main flag.
paFAsiMaster - Add a master device.
paFAsiMasterDiag - Add a diagnostic variable on the last declared master.
paFAsiSlave - Add a slave device.
paFAsiSlaveDiag - Add a diagnostic variable on the last declared slave.
paFAsiInput - Add an input variable on the last declared slave.
paFAsiOutput - Add an output variable on the last declared slave.

  • Functions for other fieldbus drivers:

paFileOpenWriteFieldbus - Open a feldbus configuration for writing.
paFfbCreateMaster - Add a master node.
paFfbCreateSlave - Add a slave node.
paFfbCreateVar - Add a variable node.
paFfbSetProperty - Set the the value of a property.
paFfbSelectRoot - Select the root node.
paFfbSelectMaster - Select a master node.
paFfbSelectSlave - Select a slave node.
paFfbSelectVar - Select a variable node.

  • Functions for the binding configuration:

paFileOpenWriteBinding - Open the binding configuration for writing.
paFbindPublicVar - Add a public variable.
paFbindExternPort - Add an extern port.
paFbindCnxStatus - Add a connection status variable.
paFbindExternVar - Add an extern variable.
paFbindVarStatus - Add a status variable.
paFbindVarDateStamp - Add a date stamp variable.
paFbindVarTimeStamp - Add a time stamp variable.


paFModbusVariable

Project Automation Library -> Reference -> Generating documents -> Networking and fieldbuses - file writing services -> paFModbusVariable

Previous chapter Next chapter Show all Show all Hide all Hide all

paFModbusVariable - Add a MODBUS variable

OK := paFModbusVariable (FID, MODE, OFFSET, MASK, TWOWORDS, SYMBOL)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenWriteModbus function.
MODE : STRING; | Exchange mode (see notes).
OFFSET : DINT; | Offset in the request.
MASK : DINT; | Mask for data exchange.
TWOWORDS : BOOL; | TRUE if data stored on 2 consecutive words.
SYMBOL : STRING; | Symbol of the variable.
OK : BOOL; | TRUE if successful.

Description

This function connects a variable to the request defined by the last call to paFileModbusRequestSlave or paFileModbusRequestMaster functions.

The following values are possible for the MODE parameter:

Value | Description
_MB_DATA | Data exchange.
_MB_STATUS | The variable receives the connection status.
_MB_COMMAND | The variable is used for activating the request.
_MB_TRIAL | The variable receives the current trial number.

seealso See also
  • Functions for MODBUS configuration:

paFileOpenWriteModbus - Open the MODBUS configuration for writing.
paFModbusSlave - Configurate the MODBUS slave connection.
paFModbusMaster - Create a MODBUS master connection.
paFModbusRequestSlave - Add a MODBUS request on the slave connection.
paFModbusRequestMaster - Add a MODBUS request on a master connection.

  • Functions for AS-i configuration:

paFileOpenWriteASi - Open the AS-i configuration for writing.
paFAsiApplyConfig - Set main flag.
paFAsiMaster - Add a master device.
paFAsiMasterDiag - Add a diagnostic variable on the last declared master.
paFAsiSlave - Add a slave device.
paFAsiSlaveDiag - Add a diagnostic variable on the last declared slave.
paFAsiInput - Add an input variable on the last declared slave.
paFAsiOutput - Add an output variable on the last declared slave.

  • Functions for other fieldbus drivers:

paFileOpenWriteFieldbus - Open a feldbus configuration for writing.
paFfbCreateMaster - Add a master node.
paFfbCreateSlave - Add a slave node.
paFfbCreateVar - Add a variable node.
paFfbSetProperty - Set the the value of a property.
paFfbSelectRoot - Select the root node.
paFfbSelectMaster - Select a master node.
paFfbSelectSlave - Select a slave node.
paFfbSelectVar - Select a variable node.

  • Functions for the binding configuration:

paFileOpenWriteBinding - Open the binding configuration for writing.
paFbindPublicVar - Add a public variable.
paFbindExternPort - Add an extern port.
paFbindCnxStatus - Add a connection status variable.
paFbindExternVar - Add an extern variable.
paFbindVarStatus - Add a status variable.
paFbindVarDateStamp - Add a date stamp variable.
paFbindVarTimeStamp - Add a time stamp variable.


paFileOpenWriteASi

Project Automation Library -> Reference -> Generating documents -> Networking and fieldbuses - file writing services -> paFileOpenWriteASi

Previous chapter Next chapter Show all Show all Hide all Hide all

paFileOpenWriteASi - Open the AS-i configuration for writing

FID := paFileOpenWriteASi ()

Parameter | Description
FID : DINT; | File identifier or 0 if fail.

Description

This function opens the AS-i configuration file for writing. This functions removes the contents of the configuration if it already exist. When written, the file must be closed by calling the paFileClose function.

seealso See also
  • Functions for MODBUS configuration:

paFileOpenWriteModbus - Open the MODBUS configuration for writing.
paFModbusSlave - Configurate the MODBUS slave connection.
paFModbusMaster - Create a MODBUS master connection.
paFModbusRequestSlave - Add a MODBUS request on the slave connection.
paFModbusRequestMaster - Add a MODBUS request on a master connection.
paFModbusVariable - Add a MODBUS variable to the last declared request.

  • Functions for AS-i configuration:

paFAsiApplyConfig - Set main flag.
paFAsiMaster - Add a master device.
paFAsiMasterDiag - Add a diagnostic variable on the last declared master.
paFAsiSlave - Add a slave device.
paFAsiSlaveDiag - Add a diagnostic variable on the last declared slave.
paFAsiInput - Add an input variable on the last declared slave.
paFAsiOutput - Add an output variable on the last declared slave.

  • Functions for other fieldbus drivers:

paFileOpenWriteFieldbus - Open a feldbus configuration for writing.
paFfbCreateMaster - Add a master node.
paFfbCreateSlave - Add a slave node.
paFfbCreateVar - Add a variable node.
paFfbSetProperty - Set the the value of a property.
paFfbSelectRoot - Select the root node.
paFfbSelectMaster - Select a master node.
paFfbSelectSlave - Select a slave node.
paFfbSelectVar - Select a variable node.

  • Functions for the binding configuration:

paFileOpenWriteBinding - Open the binding configuration for writing.
paFbindPublicVar - Add a public variable.
paFbindExternPort - Add an extern port.
paFbindCnxStatus - Add a connection status variable.
paFbindExternVar - Add an extern variable.
paFbindVarStatus - Add a status variable.
paFbindVarDateStamp - Add a date stamp variable.
paFbindVarTimeStamp - Add a time stamp variable.


paFAsiApplyConfig

Project Automation Library -> Reference -> Generating documents -> Networking and fieldbuses - file writing services -> paFAsiApplyConfig

Previous chapter Next chapter Show all Show all Hide all Hide all

paFAsiApplyConfig - Set AS-i configuration main flags

OK := paFAsiApplyConfig (FID, APPLY)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenWriteASi function.
APPLY : BOOL; | If TRUE, the AS-i configuration is applied when the runtime stats.
OK : BOOL; | TRUE if successful.

Description

This function sets the main AS-i configuration flags for applying the AS-i configuration at runtime.

seealso See also
  • Functions for MODBUS configuration:

paFileOpenWriteModbus - Open the MODBUS configuration for writing.
paFModbusSlave - Configurate the MODBUS slave connection.
paFModbusMaster - Create a MODBUS master connection.
paFModbusRequestSlave - Add a MODBUS request on the slave connection.
paFModbusRequestMaster - Add a MODBUS request on a master connection.
paFModbusVariable - Add a MODBUS variable to the last declared request.

  • Functions for AS-i configuration:

paFileOpenWriteASi - Open the AS-i configuration for writing.
paFAsiMaster - Add a master device.
paFAsiMasterDiag - Add a diagnostic variable on the last declared master.
paFAsiSlave - Add a slave device.
paFAsiSlaveDiag - Add a diagnostic variable on the last declared slave.
paFAsiInput - Add an input variable on the last declared slave.
paFAsiOutput - Add an output variable on the last declared slave.

  • Functions for other fieldbus drivers:

paFileOpenWriteFieldbus - Open a feldbus configuration for writing.
paFfbCreateMaster - Add a master node.
paFfbCreateSlave - Add a slave node.
paFfbCreateVar - Add a variable node.
paFfbSetProperty - Set the the value of a property.
paFfbSelectRoot - Select the root node.
paFfbSelectMaster - Select a master node.
paFfbSelectSlave - Select a slave node.
paFfbSelectVar - Select a variable node.

  • Functions for the binding configuration:

paFileOpenWriteBinding - Open the binding configuration for writing.
paFbindPublicVar - Add a public variable.
paFbindExternPort - Add an extern port.
paFbindCnxStatus - Add a connection status variable.
paFbindExternVar - Add an extern variable.
paFbindVarStatus - Add a status variable.
paFbindVarDateStamp - Add a date stamp variable.
paFbindVarTimeStamp - Add a time stamp variable.


paFAsiMaster

Project Automation Library -> Reference -> Generating documents -> Networking and fieldbuses - file writing services -> paFAsiMaster

Previous chapter Next chapter Show all Show all Hide all Hide all

paFAsiMaster - Add an AS-i master

OK := paFAsiMaster (FID, NAME, SETTINGS)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenWriteASi function.
NAME : STRING; | Description text.
SETTINGS : STRING; | AS-i controiller configuration string.
OK : BOOL; | TRUE if successful.

Description

This function adds a master device to the AS-i configuration. AS-i slaves and diagnostic variables for this master must be added just after calling this function.

seealso See also
  • Functions for MODBUS configuration:

paFileOpenWriteModbus - Open the MODBUS configuration for writing.
paFModbusSlave - Configurate the MODBUS slave connection.
paFModbusMaster - Create a MODBUS master connection.
paFModbusRequestSlave - Add a MODBUS request on the slave connection.
paFModbusRequestMaster - Add a MODBUS request on a master connection.
paFModbusVariable - Add a MODBUS variable to the last declared request.

  • Functions for AS-i configuration:

paFileOpenWriteASi - Open the AS-i configuration for writing.
paFAsiApplyConfig - Set main flag.
paFAsiMasterDiag - Add a diagnostic variable on the last declared master.
paFAsiSlave - Add a slave device.
paFAsiSlaveDiag - Add a diagnostic variable on the last declared slave.
paFAsiInput - Add an input variable on the last declared slave.
paFAsiOutput - Add an output variable on the last declared slave.

  • Functions for other fieldbus drivers:

paFileOpenWriteFieldbus - Open a feldbus configuration for writing.
paFfbCreateMaster - Add a master node.
paFfbCreateSlave - Add a slave node.
paFfbCreateVar - Add a variable node.
paFfbSetProperty - Set the the value of a property.
paFfbSelectRoot - Select the root node.
paFfbSelectMaster - Select a master node.
paFfbSelectSlave - Select a slave node.
paFfbSelectVar - Select a variable node.

  • Functions for the binding configuration:

paFileOpenWriteBinding - Open the binding configuration for writing.
paFbindPublicVar - Add a public variable.
paFbindExternPort - Add an extern port.
paFbindCnxStatus - Add a connection status variable.
paFbindExternVar - Add an extern variable.
paFbindVarStatus - Add a status variable.
paFbindVarDateStamp - Add a date stamp variable.
paFbindVarTimeStamp - Add a time stamp variable.


paFAsiMasterDiag

Project Automation Library -> Reference -> Generating documents -> Networking and fieldbuses - file writing services -> paFAsiMasterDiag

Previous chapter Next chapter Show all Show all Hide all Hide all

paFAsiMasterDiag - Add an AS-i master diagnostic variable

OK := paFAsiMasterDiag (FID, NAME, DIAG)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenWriteASi function.
NAME : STRING; | Symbol of the variable.
DIAG : DINT; | Wished diagnostic information.
OK : BOOL; | TRUE if successful.

Description

This function adds a diagnostic variable to the last declared AS-i master.

The possible values are available for the DIAG parameter:

Value | Description
_ASI_M_CONFOK | Configuration OK.
_ASI_M_SLV0 | Slave detected at address 0.
_ASI_M_AUTOACT | Auto-addressing is active.
_ASI_M_AUTOAV | Auto-addressing is available.
_ASI_M_CNFACT | Configuration is active.
_ASI_M_NORMAL | Normal mode.
_ASI_M_PWFAIL | Power fail detected.
_ASI_M_OFFLINE | Off Line mode.
_ASI_M_PERIPHOK | Periphery OK.

seealso See also
  • Functions for MODBUS configuration:

paFileOpenWriteModbus - Open the MODBUS configuration for writing.
paFModbusSlave - Configurate the MODBUS slave connection.
paFModbusMaster - Create a MODBUS master connection.
paFModbusRequestSlave - Add a MODBUS request on the slave connection.
paFModbusRequestMaster - Add a MODBUS request on a master connection.
paFModbusVariable - Add a MODBUS variable to the last declared request.

  • Functions for AS-i configuration:

paFileOpenWriteASi - Open the AS-i configuration for writing.
paFAsiApplyConfig - Set main flag.
paFAsiMaster - Add a master device.
paFAsiSlave - Add a slave device.
paFAsiSlaveDiag - Add a diagnostic variable on the last declared slave.
paFAsiInput - Add an input variable on the last declared slave.
paFAsiOutput - Add an output variable on the last declared slave.

  • Functions for other fieldbus drivers:

paFileOpenWriteFieldbus - Open a feldbus configuration for writing.
paFfbCreateMaster - Add a master node.
paFfbCreateSlave - Add a slave node.
paFfbCreateVar - Add a variable node.
paFfbSetProperty - Set the the value of a property.
paFfbSelectRoot - Select the root node.
paFfbSelectMaster - Select a master node.
paFfbSelectSlave - Select a slave node.
paFfbSelectVar - Select a variable node.

  • Functions for the binding configuration:

paFileOpenWriteBinding - Open the binding configuration for writing.
paFbindPublicVar - Add a public variable.
paFbindExternPort - Add an extern port.
paFbindCnxStatus - Add a connection status variable.
paFbindExternVar - Add an extern variable.
paFbindVarStatus - Add a status variable.
paFbindVarDateStamp - Add a date stamp variable.
paFbindVarTimeStamp - Add a time stamp variable.


paFAsiSlave

Project Automation Library -> Reference -> Generating documents -> Networking and fieldbuses - file writing services -> paFAsiSlave

Previous chapter Next chapter Show all Show all Hide all Hide all

paFAsiSlave - Add an AS-i slave

OK := paFAsiSlave (FID, NAME, ADDRESS, PROFILE)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenWriteASi function.
NAME : STRING; | Description text.
ADDRESS : DINT; | AS-i slave address.
PROFILE : STRING; | Slave profile written in AS-i convention: 'H.H.H.H' (hexadecimal digits).
OK : BOOL; | TRUE if successful.

Description

This function adds a slave device under the last declared AS-i master. AS-i variables for this master must be added for this slave just after calling this function.

seealso See also
  • Functions for MODBUS configuration:

paFileOpenWriteModbus - Open the MODBUS configuration for writing.
paFModbusSlave - Configurate the MODBUS slave connection.
paFModbusMaster - Create a MODBUS master connection.
paFModbusRequestSlave - Add a MODBUS request on the slave connection.
paFModbusRequestMaster - Add a MODBUS request on a master connection.
paFModbusVariable - Add a MODBUS variable to the last declared request.

  • Functions for AS-i configuration:

paFileOpenWriteASi - Open the AS-i configuration for writing.
paFAsiApplyConfig - Set main flag.
paFAsiMaster - Add a master device.
paFAsiMasterDiag - Add a diagnostic variable on the last declared master.
paFAsiSlaveDiag - Add a diagnostic variable on the last declared slave.
paFAsiInput - Add an input variable on the last declared slave.
paFAsiOutput - Add an output variable on the last declared slave.

  • Functions for other fieldbus drivers:

paFileOpenWriteFieldbus - Open a feldbus configuration for writing.
paFfbCreateMaster - Add a master node.
paFfbCreateSlave - Add a slave node.
paFfbCreateVar - Add a variable node.
paFfbSetProperty - Set the the value of a property.
paFfbSelectRoot - Select the root node.
paFfbSelectMaster - Select a master node.
paFfbSelectSlave - Select a slave node.
paFfbSelectVar - Select a variable node.

  • Functions for the binding configuration:

paFileOpenWriteBinding - Open the binding configuration for writing.
paFbindPublicVar - Add a public variable.
paFbindExternPort - Add an extern port.
paFbindCnxStatus - Add a connection status variable.
paFbindExternVar - Add an extern variable.
paFbindVarStatus - Add a status variable.
paFbindVarDateStamp - Add a date stamp variable.
paFbindVarTimeStamp - Add a time stamp variable.


paFAsiSlaveDiag

Project Automation Library -> Reference -> Generating documents -> Networking and fieldbuses - file writing services -> paFAsiSlaveDiag

Previous chapter Next chapter Show all Show all Hide all Hide all

paFAsiSlaveDiag - Add an AS-i slave diagnostic variable

OK := paFAsiSlaveDiag (FID, NAME, DIAG)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenWriteASi function.
NAME : STRING; | Symbol of the variable.
DIAG : DINT; | Wished diagnostic information.
OK : BOOL; | TRUE if successful.

Description

This function adds a diagnostic variable to the last declared AS-i slave.

The possible values are available for the DIAG parameter:

Value | Description
_ASI_S_ACT | Slave active.
_ASI_S_DET | Slave detected.
_ASI_S_PRJ | Slave projected.
_ASI_S_COR | Slave corrupted.
_ASI_S_FLT | Periphery fault.

seealso See also
  • Functions for MODBUS configuration:

paFileOpenWriteModbus - Open the MODBUS configuration for writing.
paFModbusSlave - Configurate the MODBUS slave connection.
paFModbusMaster - Create a MODBUS master connection.
paFModbusRequestSlave - Add a MODBUS request on the slave connection.
paFModbusRequestMaster - Add a MODBUS request on a master connection.
paFModbusVariable - Add a MODBUS variable to the last declared request.

  • Functions for AS-i configuration:

paFileOpenWriteASi - Open the AS-i configuration for writing.
paFAsiApplyConfig - Set main flag.
paFAsiMaster - Add a master device.
paFAsiMasterDiag - Add a diagnostic variable on the last declared master.
paFAsiSlave - Add a slave device.
paFAsiInput - Add an input variable on the last declared slave.
paFAsiOutput - Add an output variable on the last declared slave.

  • Functions for other fieldbus drivers:

paFileOpenWriteFieldbus - Open a feldbus configuration for writing.
paFfbCreateMaster - Add a master node.
paFfbCreateSlave - Add a slave node.
paFfbCreateVar - Add a variable node.
paFfbSetProperty - Set the the value of a property.
paFfbSelectRoot - Select the root node.
paFfbSelectMaster - Select a master node.
paFfbSelectSlave - Select a slave node.
paFfbSelectVar - Select a variable node.

  • Functions for the binding configuration:

paFileOpenWriteBinding - Open the binding configuration for writing.
paFbindPublicVar - Add a public variable.
paFbindExternPort - Add an extern port.
paFbindCnxStatus - Add a connection status variable.
paFbindExternVar - Add an extern variable.
paFbindVarStatus - Add a status variable.
paFbindVarDateStamp - Add a date stamp variable.
paFbindVarTimeStamp - Add a time stamp variable.


paFAsiInput

Project Automation Library -> Reference -> Generating documents -> Networking and fieldbuses - file writing services -> paFAsiInput

Previous chapter Next chapter Show all Show all Hide all Hide all

paFAsiInput - Add an AS-i input variable

OK := paFAsiInput (FID, NAME, OFFSET)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenWriteASi function.
NAME : STRING; | Symbol of the variable.
OFFSET : DINT; | Input number (1 to 4) or 0 for all inputs in a byte.
OK : BOOL; | TRUE if successful.

Description

This function adds an input variable to the last declared AS-i slave.

seealso See also
  • Functions for MODBUS configuration:

paFileOpenWriteModbus - Open the MODBUS configuration for writing.
paFModbusSlave - Configurate the MODBUS slave connection.
paFModbusMaster - Create a MODBUS master connection.
paFModbusRequestSlave - Add a MODBUS request on the slave connection.
paFModbusRequestMaster - Add a MODBUS request on a master connection.
paFModbusVariable - Add a MODBUS variable to the last declared request.

  • Functions for AS-i configuration:

paFileOpenWriteASi - Open the AS-i configuration for writing.
paFAsiApplyConfig - Set main flag.
paFAsiMaster - Add a master device.
paFAsiMasterDiag - Add a diagnostic variable on the last declared master.
paFAsiSlave - Add a slave device.
paFAsiSlaveDiag - Add a diagnostic variable on the last declared slave.
paFAsiOutput - Add an output variable on the last declared slave.

  • Functions for other fieldbus drivers:

paFileOpenWriteFieldbus - Open a feldbus configuration for writing.
paFfbCreateMaster - Add a master node.
paFfbCreateSlave - Add a slave node.
paFfbCreateVar - Add a variable node.
paFfbSetProperty - Set the the value of a property.
paFfbSelectRoot - Select the root node.
paFfbSelectMaster - Select a master node.
paFfbSelectSlave - Select a slave node.
paFfbSelectVar - Select a variable node.

  • Functions for the binding configuration:

paFileOpenWriteBinding - Open the binding configuration for writing.
paFbindPublicVar - Add a public variable.
paFbindExternPort - Add an extern port.
paFbindCnxStatus - Add a connection status variable.
paFbindExternVar - Add an extern variable.
paFbindVarStatus - Add a status variable.
paFbindVarDateStamp - Add a date stamp variable.
paFbindVarTimeStamp - Add a time stamp variable.


paFAsiOutput

Project Automation Library -> Reference -> Generating documents -> Networking and fieldbuses - file writing services -> paFAsiOutput

Previous chapter Next chapter Show all Show all Hide all Hide all

paFAsiOutput - Add an AS-i output variable

OK := paFAsiOutput (FID, NAME, OFFSET)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenWriteASi function.
NAME : STRING; | Symbol of the variable.
OFFSET : DINT; | Output number (1 to 4) or 0 for all inputs in a byte.
OK : BOOL; | TRUE if successful.

Description

This function adds an output variable to the last declared AS-i slave.

seealso See also
  • Functions for MODBUS configuration:

paFileOpenWriteModbus - Open the MODBUS configuration for writing.
paFModbusSlave - Configurate the MODBUS slave connection.
paFModbusMaster - Create a MODBUS master connection.
paFModbusRequestSlave - Add a MODBUS request on the slave connection.
paFModbusRequestMaster - Add a MODBUS request on a master connection.
paFModbusVariable - Add a MODBUS variable to the last declared request.

  • Functions for AS-i configuration:

paFileOpenWriteASi - Open the AS-i configuration for writing.
paFAsiApplyConfig - Set main flag.
paFAsiMaster - Add a master device.
paFAsiMasterDiag - Add a diagnostic variable on the last declared master.
paFAsiSlave - Add a slave device.
paFAsiSlaveDiag - Add a diagnostic variable on the last declared slave.
paFAsiInput - Add an input variable on the last declared slave.

  • Functions for other fieldbus drivers:

paFileOpenWriteFieldbus - Open a feldbus configuration for writing.
paFfbCreateMaster - Add a master node.
paFfbCreateSlave - Add a slave node.
paFfbCreateVar - Add a variable node.
paFfbSetProperty - Set the the value of a property.
paFfbSelectRoot - Select the root node.
paFfbSelectMaster - Select a master node.
paFfbSelectSlave - Select a slave node.
paFfbSelectVar - Select a variable node.

  • Functions for the binding configuration:

paFileOpenWriteBinding - Open the binding configuration for writing.
paFbindPublicVar - Add a public variable.
paFbindExternPort - Add an extern port.
paFbindCnxStatus - Add a connection status variable.
paFbindExternVar - Add an extern variable.
paFbindVarStatus - Add a status variable.
paFbindVarDateStamp - Add a date stamp variable.
paFbindVarTimeStamp - Add a time stamp variable.


paFileOpenWriteFieldbus

Project Automation Library -> Reference -> Generating documents -> Networking and fieldbuses - file writing services -> paFileOpenWriteFieldbus

Previous chapter Next chapter Show all Show all Hide all Hide all

paFileOpenWriteFieldbus - Open the AS-i configuration for writing

FID := paFileOpenWriteFieldbus (CONFIG)

Parameter | Description
CONFIG : STRING | Type of fieldbus - see notes.
FID : DINT; | File identifier or 0 if fail.

Description

This function opens the selected fieldbus configuration file for writing. This functions removes the contents of the configuration if it already exist. When written, the file must be closed by calling the paFileClose function.

The CONFIG string is the prefix of the wizard DLL used for configuration. Available DLLs are stored in the \IOD folder where the Workbench is installed. You can also get the list of available configurations from the Prompt tab in the output window. For that, enter the following ?FB command.

Example Example

>?FB
Fieldbus configuration wizards:
K5BusAppIO: ApplicomIO configuration
K5BusCAN: CAN bus
K5BusHMS: Anybus configuration
K5BusINTERBUS: Interbus-S
K5BusIOTools: Brodersen IOTOOLS
K5BusProfDP: Hilscher CIF Profibus
K5BusProfNetIO: PROFINET IO
K5BusShm: Win32 Shared memory
K5BusSoftNet: SoftNet ProfibusDP
K5BusSycon: Hilscher SYCON configuration
K5BusXFLOW: XFlow
K5ThinkIO: ThinkIO/IOSystem 758
K5ZenOnRT: Run

seealso See also
  • Functions for MODBUS configuration:

paFileOpenWriteModbus - Open the MODBUS configuration for writing.
paFModbusSlave - Configurate the MODBUS slave connection.
paFModbusMaster - Create a MODBUS master connection.
paFModbusRequestSlave - Add a MODBUS request on the slave connection.
paFModbusRequestMaster - Add a MODBUS request on a master connection.
paFModbusVariable - Add a MODBUS variable to the last declared request.

  • Functions for AS-i configuration:

paFileOpenWriteASi - Open the AS-i configuration for writing.
paFAsiApplyConfig - Set main flag.
paFAsiMaster - Add a master device.
paFAsiMasterDiag - Add a diagnostic variable on the last declared master.
paFAsiSlave - Add a slave device.
paFAsiSlaveDiag - Add a diagnostic variable on the last declared slave.
paFAsiInput - Add an input variable on the last declared slave.
paFAsiOutput - Add an output variable on the last declared slave.

  • Functions for other fieldbus drivers:

paFfbCreateMaster - Add a master node.
paFfbCreateSlave - Add a slave node.
paFfbCreateVar - Add a variable node.
paFfbSetProperty - Set the the value of a property.
paFfbSelectRoot - Select the root node.
paFfbSelectMaster - Select a master node.
paFfbSelectSlave - Select a slave node.
paFfbSelectVar - Select a variable node.

  • Functions for the binding configuration:

paFileOpenWriteBinding - Open the binding configuration for writing.
paFbindPublicVar - Add a public variable.
paFbindExternPort - Add an extern port.
paFbindCnxStatus - Add a connection status variable.
paFbindExternVar - Add an extern variable.
paFbindVarStatus - Add a status variable.
paFbindVarDateStamp - Add a date stamp variable.
paFbindVarTimeStamp - Add a time stamp variable.


paFfbCreateMaster

Project Automation Library -> Reference -> Generating documents -> Networking and fieldbuses - file writing services -> paFfbCreateMaster

Previous chapter Next chapter Show all Show all Hide all Hide all

paFfbCreateMaster - Add a master node

OK := paFfbCreateMaster (FID)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenWriteFieldbus function.
OK : BOOL; | TRUE if successful.

Description

This function adds a master node to the configuration.

seealso See also
  • Functions for MODBUS configuration:

paFileOpenWriteModbus - Open the MODBUS configuration for writing.
paFModbusSlave - Configurate the MODBUS slave connection.
paFModbusMaster - Create a MODBUS master connection.
paFModbusRequestSlave - Add a MODBUS request on the slave connection.
paFModbusRequestMaster - Add a MODBUS request on a master connection.
paFModbusVariable - Add a MODBUS variable to the last declared request.

  • Functions for AS-i configuration:

paFileOpenWriteASi - Open the AS-i configuration for writing.
paFAsiApplyConfig - Set main flag.
paFAsiMaster - Add a master device.
paFAsiMasterDiag - Add a diagnostic variable on the last declared master.
paFAsiSlave - Add a slave device.
paFAsiSlaveDiag - Add a diagnostic variable on the last declared slave.
paFAsiInput - Add an input variable on the last declared slave.
paFAsiOutput - Add an output variable on the last declared slave.

  • Functions for other fieldbus drivers:

paFileOpenWriteFieldbus - Open a feldbus configuration for writing.
paFfbCreateSlave - Add a slave node.
paFfbCreateVar - Add a variable node.
paFfbSetProperty - Set the the value of a property.
paFfbSelectRoot - Select the root node.
paFfbSelectMaster - Select a master node.
paFfbSelectSlave - Select a slave node.
paFfbSelectVar - Select a variable node.

  • Functions for the binding configuration:

paFileOpenWriteBinding - Open the binding configuration for writing.
paFbindPublicVar - Add a public variable.
paFbindExternPort - Add an extern port.
paFbindCnxStatus - Add a connection status variable.
paFbindExternVar - Add an extern variable.
paFbindVarStatus - Add a status variable.
paFbindVarDateStamp - Add a date stamp variable.
paFbindVarTimeStamp - Add a time stamp variable.


paFfbCreateSlave

Project Automation Library -> Reference -> Generating documents -> Networking and fieldbuses - file writing services -> paFfbCreateSlave

Previous chapter Next chapter Show all Show all Hide all Hide all

paFfbCreateSlave - Add a slave node

OK := paFfbCreateSlave (FID)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenWriteFieldbus function.
OK : BOOL; | TRUE if successful.

Description

This function adds a slave node to the configuration. The node is added under the last created or selected "master" node.

seealso See also
  • Functions for MODBUS configuration:

paFileOpenWriteModbus - Open the MODBUS configuration for writing.
paFModbusSlave - Configurate the MODBUS slave connection.
paFModbusMaster - Create a MODBUS master connection.
paFModbusRequestSlave - Add a MODBUS request on the slave connection.
paFModbusRequestMaster - Add a MODBUS request on a master connection.
paFModbusVariable - Add a MODBUS variable to the last declared request.

  • Functions for AS-i configuration:

paFileOpenWriteASi - Open the AS-i configuration for writing.
paFAsiApplyConfig - Set main flag.
paFAsiMaster - Add a master device.
paFAsiMasterDiag - Add a diagnostic variable on the last declared master.
paFAsiSlave - Add a slave device.
paFAsiSlaveDiag - Add a diagnostic variable on the last declared slave.
paFAsiInput - Add an input variable on the last declared slave.
paFAsiOutput - Add an output variable on the last declared slave.

  • Functions for other fieldbus drivers:

paFileOpenWriteFieldbus - Open a feldbus configuration for writing.
paFfbCreateMaster - Add a master node.
paFfbCreateVar - Add a variable node.
paFfbSetProperty - Set the the value of a property.
paFfbSelectRoot - Select the root node.
paFfbSelectMaster - Select a master node.
paFfbSelectSlave - Select a slave node.
paFfbSelectVar - Select a variable node.

  • Functions for the binding configuration:

paFileOpenWriteBinding - Open the binding configuration for writing.
paFbindPublicVar - Add a public variable.
paFbindExternPort - Add an extern port.
paFbindCnxStatus - Add a connection status variable.
paFbindExternVar - Add an extern variable.
paFbindVarStatus - Add a status variable.
paFbindVarDateStamp - Add a date stamp variable.
paFbindVarTimeStamp - Add a time stamp variable.


paFfbCreateVar

Project Automation Library -> Reference -> Generating documents -> Networking and fieldbuses - file writing services -> paFfbCreateVar

Previous chapter Next chapter Show all Show all Hide all Hide all

paFfbCreateVar - Add a variable node

OK := paFfbCreateVar (FID)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenWriteFieldbus function.
OK : BOOL; | TRUE if successful.

Description

This function adds a variable node to the configuration. The node is added under the last created or selected slave node.

seealso See also
  • Functions for MODBUS configuration:

paFileOpenWriteModbus - Open the MODBUS configuration for writing.
paFModbusSlave - Configurate the MODBUS slave connection.
paFModbusMaster - Create a MODBUS master connection.
paFModbusRequestSlave - Add a MODBUS request on the slave connection.
paFModbusRequestMaster - Add a MODBUS request on a master connection.
paFModbusVariable - Add a MODBUS variable to the last declared request.

  • Functions for AS-i configuration:

paFileOpenWriteASi - Open the AS-i configuration for writing.
paFAsiApplyConfig - Set main flag.
paFAsiMaster - Add a master device.
paFAsiMasterDiag - Add a diagnostic variable on the last declared master.
paFAsiSlave - Add a slave device.
paFAsiSlaveDiag - Add a diagnostic variable on the last declared slave.
paFAsiInput - Add an input variable on the last declared slave.
paFAsiOutput - Add an output variable on the last declared slave.

  • Functions for other fieldbus drivers:

paFileOpenWriteFieldbus - Open a feldbus configuration for writing.
paFfbCreateMaster - Add a master node.
paFfbCreateSlave - Add a slave node.
paFfbSetProperty - Set the the value of a property.
paFfbSelectRoot - Select the root node.
paFfbSelectMaster - Select a master node.
paFfbSelectSlave - Select a slave node.
paFfbSelectVar - Select a variable node.

  • Functions for the binding configuration:

paFileOpenWriteBinding - Open the binding configuration for writing.
paFbindPublicVar - Add a public variable.
paFbindExternPort - Add an extern port.
paFbindCnxStatus - Add a connection status variable.
paFbindExternVar - Add an extern variable.
paFbindVarStatus - Add a status variable.
paFbindVarDateStamp - Add a date stamp variable.
paFbindVarTimeStamp - Add a time stamp variable.


paFfbSetProperty

Project Automation Library -> Reference -> Generating documents -> Networking and fieldbuses - file writing services -> paFfbSetProperty

Previous chapter Next chapter Show all Show all Hide all Hide all

paFfbSetProperty - Set the value of a property

OK := paFfbSetProperty (FID, PROP, VALUE)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenWriteFieldbus function.
PROP : STRING | Internal name of the property - see notes.
VALUE : STRING | Value of the propery in neutral format - see notes.
OK : BOOL; | TRUE if successful.

Description

This function adds a variable node to the configuration. The node is added under the last created or selected slave node.

The name of the property must be entered in "neutral" form, independently from the language selected for the Workbench. Also, for a check box or a drop-list property, you need to enter the value in neutral form, and not as displayed in the fieldbus configuration tool. To know the relationship in between neutral and displayed names and values, go to the Prompt tab in the output window and hit the ?FB Command followed by the name of the configuration. This command lists all properties for each level of the selected configuration tree, giving neutral names and readable names, and lists all possible neutral values for boolean and enumerated properties. Example of syntax:

Example Example

>?FB K5BusCan

seealso See also
  • Functions for MODBUS configuration:

paFileOpenWriteModbus - Open the MODBUS configuration for writing.
paFModbusSlave - Configurate the MODBUS slave connection.
paFModbusMaster - Create a MODBUS master connection.
paFModbusRequestSlave - Add a MODBUS request on the slave connection.
paFModbusRequestMaster - Add a MODBUS request on a master connection.
paFModbusVariable - Add a MODBUS variable to the last declared request.

  • Functions for AS-i configuration:

paFileOpenWriteASi - Open the AS-i configuration for writing.
paFAsiApplyConfig - Set main flag.
paFAsiMaster - Add a master device.
paFAsiMasterDiag - Add a diagnostic variable on the last declared master.
paFAsiSlave - Add a slave device.
paFAsiSlaveDiag - Add a diagnostic variable on the last declared slave.
paFAsiInput - Add an input variable on the last declared slave.
paFAsiOutput - Add an output variable on the last declared slave.

  • Functions for other fieldbus drivers:

paFileOpenWriteFieldbus - Open a feldbus configuration for writing.
paFfbCreateMaster - Add a master node.
paFfbCreateSlave - Add a slave node.
paFfbCreateVar - Add a variable node.
paFfbSelectRoot - Select the root node.
paFfbSelectMaster - Select a master node.
paFfbSelectSlave - Select a slave node.
paFfbSelectVar - Select a variable node.

  • Functions for the binding configuration:

paFileOpenWriteBinding - Open the binding configuration for writing.
paFbindPublicVar - Add a public variable.
paFbindExternPort - Add an extern port.
paFbindCnxStatus - Add a connection status variable.
paFbindExternVar - Add an extern variable.
paFbindVarStatus - Add a status variable.
paFbindVarDateStamp - Add a date stamp variable.
paFbindVarTimeStamp - Add a time stamp variable.


paFfbSelectRoot

Project Automation Library -> Reference -> Generating documents -> Networking and fieldbuses - file writing services -> paFfbSelectRoot

Previous chapter Next chapter Show all Show all Hide all Hide all

paFfbSelectRoot - Selects the root node

OK := paFfbSelectRoot (FID)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenWriteFieldbus function.
OK : BOOL; | TRUE if successful.

Description

This function selects the root node of the configuration tree. The root node is automatically selected when the file is open. Selecting a node is required for setting its properties or adding child nodes. It is not work to select a node immediately after its creation.

seealso See also
  • Functions for MODBUS configuration:

paFileOpenWriteModbus - Open the MODBUS configuration for writing.
paFModbusSlave - Configurate the MODBUS slave connection.
paFModbusMaster - Create a MODBUS master connection.
paFModbusRequestSlave - Add a MODBUS request on the slave connection.
paFModbusRequestMaster - Add a MODBUS request on a master connection.
paFModbusVariable - Add a MODBUS variable to the last declared request.

  • Functions for AS-i configuration:

paFileOpenWriteASi - Open the AS-i configuration for writing.
paFAsiApplyConfig - Set main flag.
paFAsiMaster - Add a master device.
paFAsiMasterDiag - Add a diagnostic variable on the last declared master.
paFAsiSlave - Add a slave device.
paFAsiSlaveDiag - Add a diagnostic variable on the last declared slave.
paFAsiInput - Add an input variable on the last declared slave.
paFAsiOutput - Add an output variable on the last declared slave.

  • Functions for other fieldbus drivers:

paFileOpenWriteFieldbus - Open a feldbus configuration for writing.
paFfbCreateMaster - Add a master node.
paFfbCreateSlave - Add a slave node.
paFfbCreateVar - Add a variable node.
paFfbSetProperty - Set the the value of a property.
paFfbSelectMaster - Select a master node.
paFfbSelectSlave - Select a slave node.
paFfbSelectVar - Select a variable node.

  • Functions for the binding configuration:

paFileOpenWriteBinding - Open the binding configuration for writing.
paFbindPublicVar - Add a public variable.
paFbindExternPort - Add an extern port.
paFbindCnxStatus - Add a connection status variable.
paFbindExternVar - Add an extern variable.
paFbindVarStatus - Add a status variable.
paFbindVarDateStamp - Add a date stamp variable.
paFbindVarTimeStamp - Add a time stamp variable.


paFfbSelectMaster

Project Automation Library -> Reference -> Generating documents -> Networking and fieldbuses - file writing services -> paFfbSelectMaster

Previous chapter Next chapter Show all Show all Hide all Hide all

paFfbSelectMaster - Selects a master node

OK := paFfbSelectMaster (FID, MASTER)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenWriteFieldbus function.
MASTER : DINT | 1-based index in the list of master nodes.
OK : BOOL; | TRUE if successful.

Description

This function selects a master in the configuration tree. Selecting a node is required for setting its properties or adding child nodes. It is not work to select a node immediately after its creation.

seealso See also
  • Functions for MODBUS configuration:

paFileOpenWriteModbus - Open the MODBUS configuration for writing.
paFModbusSlave - Configurate the MODBUS slave connection.
paFModbusMaster - Create a MODBUS master connection.
paFModbusRequestSlave - Add a MODBUS request on the slave connection.
paFModbusRequestMaster - Add a MODBUS request on a master connection.
paFModbusVariable - Add a MODBUS variable to the last declared request.

  • Functions for AS-i configuration:

paFileOpenWriteASi - Open the AS-i configuration for writing.
paFAsiApplyConfig - Set main flag.
paFAsiMaster - Add a master device.
paFAsiMasterDiag - Add a diagnostic variable on the last declared master.
paFAsiSlave - Add a slave device.
paFAsiSlaveDiag - Add a diagnostic variable on the last declared slave.
paFAsiInput - Add an input variable on the last declared slave.
paFAsiOutput - Add an output variable on the last declared slave.

  • Functions for other fieldbus drivers:

paFileOpenWriteFieldbus - Open a feldbus configuration for writing.
paFfbCreateMaster - Add a master node.
paFfbCreateSlave - Add a slave node.
paFfbCreateVar - Add a variable node.
paFfbSetProperty - Set the the value of a property.
paFfbSelectRoot - Select the root node.
paFfbSelectSlave - Select a slave node.
paFfbSelectVar - Select a variable node.

  • Functions for the binding configuration:

paFileOpenWriteBinding - Open the binding configuration for writing.
paFbindPublicVar - Add a public variable.
paFbindExternPort - Add an extern port.
paFbindCnxStatus - Add a connection status variable.
paFbindExternVar - Add an extern variable.
paFbindVarStatus - Add a status variable.
paFbindVarDateStamp - Add a date stamp variable.
paFbindVarTimeStamp - Add a time stamp variable.


paFfbSelectSlave

Project Automation Library -> Reference -> Generating documents -> Networking and fieldbuses - file writing services -> paFfbSelectSlave

Previous chapter Next chapter Show all Show all Hide all Hide all

paFfbSelectSlave - Selects a slave node

OK := paFfbSelectSlave (FID, MASTER, SLAVE)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenWriteFieldbus function.
MASTER : DINT | 1-based index of the parent master node.
SLAVE : DINT | 1-based index in the list of slave nodes for the selected parent master.
OK : BOOL; | TRUE if successful.

Description

This function selects a slave in the configuration tree. Selecting a node is required for setting its properties or adding child nodes. It is not work to select a node immediately after its creation.

seealso See also
  • Functions for MODBUS configuration:

paFileOpenWriteModbus - Open the MODBUS configuration for writing.
paFModbusSlave - Configurate the MODBUS slave connection.
paFModbusMaster - Create a MODBUS master connection.
paFModbusRequestSlave - Add a MODBUS request on the slave connection.
paFModbusRequestMaster - Add a MODBUS request on a master connection.
paFModbusVariable - Add a MODBUS variable to the last declared request.

  • Functions for AS-i configuration:

paFileOpenWriteASi - Open the AS-i configuration for writing.
paFAsiApplyConfig - Set main flag.
paFAsiMaster - Add a master device.
paFAsiMasterDiag - Add a diagnostic variable on the last declared master.
paFAsiSlave - Add a slave device.
paFAsiSlaveDiag - Add a diagnostic variable on the last declared slave.
paFAsiInput - Add an input variable on the last declared slave.
paFAsiOutput - Add an output variable on the last declared slave.

  • Functions for other fieldbus drivers:

paFileOpenWriteFieldbus - Open a feldbus configuration for writing.
paFfbCreateMaster - Add a master node.
paFfbCreateSlave - Add a slave node.
paFfbCreateVar - Add a variable node.
paFfbSetProperty - Set the the value of a property.
paFfbSelectRoot - Select the root node.
paFfbSelectMaster - Select a master node.
paFfbSelectVar - Select a variable node.

  • Functions for the binding configuration:

paFileOpenWriteBinding - Open the binding configuration for writing.
paFbindPublicVar - Add a public variable.
paFbindExternPort - Add an extern port.
paFbindCnxStatus - Add a connection status variable.
paFbindExternVar - Add an extern variable.
paFbindVarStatus - Add a status variable.
paFbindVarDateStamp - Add a date stamp variable.
paFbindVarTimeStamp - Add a time stamp variable.


paFfbSelectVar

Project Automation Library -> Reference -> Generating documents -> Networking and fieldbuses - file writing services -> paFfbSelectVar

Previous chapter Next chapter Show all Show all Hide all Hide all

paFfbSelectVar - Selects a Variable node

OK := paFfbSelectVar (FID, MASTER, SLAVE, VARIABLE)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenWriteFieldbus function.
MASTER : DINT | 1-based index of the parent master node.
SLAVE : DINT | 1-based index of the parent slave node.
VARIABLE : DINT | 1-based index in the list of variable nodes for the selected parent slave.
OK : BOOL; | TRUE if successful.

Description

This function selects a variable in the configuration tree. Selecting a node is required for setting its properties or adding child nodes. It is not work to select a node immediately after its creation.

seealso See also
  • Functions for MODBUS configuration:

paFileOpenWriteModbus - Open the MODBUS configuration for writing.
paFModbusSlave - Configurate the MODBUS slave connection.
paFModbusMaster - Create a MODBUS master connection.
paFModbusRequestSlave - Add a MODBUS request on the slave connection.
paFModbusRequestMaster - Add a MODBUS request on a master connection.
paFModbusVariable - Add a MODBUS variable to the last declared request.

  • Functions for AS-i configuration:

paFileOpenWriteASi - Open the AS-i configuration for writing.
paFAsiApplyConfig - Set main flag.
paFAsiMaster - Add a master device.
paFAsiMasterDiag - Add a diagnostic variable on the last declared master.
paFAsiSlave - Add a slave device.
paFAsiSlaveDiag - Add a diagnostic variable on the last declared slave.
paFAsiInput - Add an input variable on the last declared slave.
paFAsiOutput - Add an output variable on the last declared slave.

  • Functions for other fieldbus drivers:

paFileOpenWriteFieldbus - Open a feldbus configuration for writing.
paFfbCreateMaster - Add a master node.
paFfbCreateSlave - Add a slave node.
paFfbCreateVar - Add a variable node.
paFfbSetProperty - Set the the value of a property.
paFfbSelectRoot - Select the root node.
paFfbSelectMaster - Select a master node.
paFfbSelectSlave - Select a slave node.

  • Functions for the binding configuration:

paFileOpenWriteBinding - Open the binding configuration for writing.
paFbindPublicVar - Add a public variable.
paFbindExternPort - Add an extern port.
paFbindCnxStatus - Add a connection status variable.
paFbindExternVar - Add an extern variable.
paFbindVarStatus - Add a status variable.
paFbindVarDateStamp - Add a date stamp variable.
paFbindVarTimeStamp - Add a time stamp variable.


paFileOpenWriteBinding

Project Automation Library -> Reference -> Generating documents -> Networking and fieldbuses - file writing services -> paFileOpenWriteBinding

Previous chapter Next chapter Show all Show all Hide all Hide all

paFileOpenWriteBinding - Open the binding configuration for writing

FID := paFileOpenWriteBinding ()

Parameter | Description
FID : DINT; | File identifier or 0 if fail.

Description

This function opens the binding configuration file for writing. This functions removes the contents of the configuration if it already exist. When written, the file must be closed by calling the paFileClose function.

seealso See also
  • Functions for MODBUS configuration:

paFileOpenWriteModbus - Open the MODBUS configuration for writing.
paFModbusSlave - Configurate the MODBUS slave connection.
paFModbusMaster - Create a MODBUS master connection.
paFModbusRequestSlave - Add a MODBUS request on the slave connection.
paFModbusRequestMaster - Add a MODBUS request on a master connection.
paFModbusVariable - Add a MODBUS variable to the last declared request.

  • Functions for AS-i configuration:

paFileOpenWriteASi - Open the AS-i configuration for writing.
paFAsiApplyConfig - Set main flag.
paFAsiMaster - Add a master device.
paFAsiMasterDiag - Add a diagnostic variable on the last declared master.
paFAsiSlave - Add a slave device.
paFAsiSlaveDiag - Add a diagnostic variable on the last declared slave.
paFAsiInput - Add an input variable on the last declared slave.
paFAsiOutput - Add an output variable on the last declared slave.

  • Functions for other fieldbus drivers:

paFileOpenWriteFieldbus - Open a feldbus configuration for writing.
paFfbCreateMaster - Add a master node.
paFfbCreateSlave - Add a slave node.
paFfbCreateVar - Add a variable node.
paFfbSetProperty - Set the the value of a property.
paFfbSelectRoot - Select the root node.
paFfbSelectMaster - Select a master node.
paFfbSelectSlave - Select a slave node.
paFfbSelectVar - Select a variable node.

  • Functions for the binding configuration:

paFbindPublicVar - Add a public variable.
paFbindExternPort - Add an extern port.
paFbindCnxStatus - Add a connection status variable.
paFbindExternVar - Add an extern variable.
paFbindVarStatus - Add a status variable.
paFbindVarDateStamp - Add a date stamp variable.
paFbindVarTimeStamp - Add a time stamp variable.


paFbindPublicVar

Project Automation Library -> Reference -> Generating documents -> Networking and fieldbuses - file writing services -> paFbindPublicVar

Previous chapter Next chapter Show all Show all Hide all Hide all

paFbindPublicVar - add a published variable to the binding configuration

FID := paFbindPubilcVar (FID, ID, NAME, HYSTP, HYSTN)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenWriteBinding function.
ID : DINT; | ID of the binding link.
NAME : STRING; | Symbol of the variable.
HYSTP : STRING; | Positive hysteresis in IEC syntax (or empty string).
HYSTN : STRING; | Negative hysteresis in IEC syntax (or empty string).
OK : BOOL; | TRUE if successful.

Description

This function adds a public variable in the binding configuration.

seealso See also
  • Functions for MODBUS configuration:

paFileOpenWriteModbus - Open the MODBUS configuration for writing.
paFModbusSlave - Configurate the MODBUS slave connection.
paFModbusMaster - Create a MODBUS master connection.
paFModbusRequestSlave - Add a MODBUS request on the slave connection.
paFModbusRequestMaster - Add a MODBUS request on a master connection.
paFModbusVariable - Add a MODBUS variable to the last declared request.

  • Functions for AS-i configuration:

paFileOpenWriteASi - Open the AS-i configuration for writing.
paFAsiApplyConfig - Set main flag.
paFAsiMaster - Add a master device.
paFAsiMasterDiag - Add a diagnostic variable on the last declared master.
paFAsiSlave - Add a slave device.
paFAsiSlaveDiag - Add a diagnostic variable on the last declared slave.
paFAsiInput - Add an input variable on the last declared slave.
paFAsiOutput - Add an output variable on the last declared slave.

  • Functions for other fieldbus drivers:

paFileOpenWriteFieldbus - Open a feldbus configuration for writing.
paFfbCreateMaster - Add a master node.
paFfbCreateSlave - Add a slave node.
paFfbCreateVar - Add a variable node.
paFfbSetProperty - Set the the value of a property.
paFfbSelectRoot - Select the root node.
paFfbSelectMaster - Select a master node.
paFfbSelectSlave - Select a slave node.
paFfbSelectVar - Select a variable node.

  • Functions for the binding configuration:

paFileOpenWriteBinding - Open the binding configuration for writing.
paFbindExternPort - Add an extern port.
paFbindCnxStatus - Add a connection status variable.
paFbindExternVar - Add an extern variable.
paFbindVarStatus - Add a status variable.
paFbindVarDateStamp - Add a date stamp variable.
paFbindVarTimeStamp - Add a time stamp variable.


paFbindExternPort

Project Automation Library -> Reference -> Generating documents -> Networking and fieldbuses - file writing services -> paFbindExternPort

Previous chapter Next chapter Show all Show all Hide all Hide all

paFbindExternPort - add an external port to the binding configuration

FID := paFbindExternPort (FID, ADDR, PORT, NAME)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenWriteBinding function.
ADDR : STRING; | IP address.
PORT : DINT; | IP port number.
NAME : STRING | Optional description text.
OK : BOOL; | TRUE if successful.

Description

This function adds a public variable in the binding configuration. Immediately after calling this function, you can use other functions to declare external bound variables.

seealso See also
  • Functions for MODBUS configuration:

paFileOpenWriteModbus - Open the MODBUS configuration for writing.
paFModbusSlave - Configurate the MODBUS slave connection.
paFModbusMaster - Create a MODBUS master connection.
paFModbusRequestSlave - Add a MODBUS request on the slave connection.
paFModbusRequestMaster - Add a MODBUS request on a master connection.
paFModbusVariable - Add a MODBUS variable to the last declared request.

  • Functions for AS-i configuration:

paFileOpenWriteASi - Open the AS-i configuration for writing.
paFAsiApplyConfig - Set main flag.
paFAsiMaster - Add a master device.
paFAsiMasterDiag - Add a diagnostic variable on the last declared master.
paFAsiSlave - Add a slave device.
paFAsiSlaveDiag - Add a diagnostic variable on the last declared slave.
paFAsiInput - Add an input variable on the last declared slave.
paFAsiOutput - Add an output variable on the last declared slave.

  • Functions for other fieldbus drivers:

paFileOpenWriteFieldbus - Open a feldbus configuration for writing.
paFfbCreateMaster - Add a master node.
paFfbCreateSlave - Add a slave node.
paFfbCreateVar - Add a variable node.
paFfbSetProperty - Set the the value of a property.
paFfbSelectRoot - Select the root node.
paFfbSelectMaster - Select a master node.
paFfbSelectSlave - Select a slave node.
paFfbSelectVar - Select a variable node.

  • Functions for the binding configuration:

paFileOpenWriteBinding - Open the binding configuration for writing.
paFbindPublicVar - Add a public variable.
paFbindCnxStatus - Add a connection status variable.
paFbindExternVar - Add an extern variable.
paFbindVarStatus - Add a status variable.
paFbindVarDateStamp - Add a date stamp variable.
paFbindVarTimeStamp - Add a time stamp variable.


paFbindCnxStatus

Project Automation Library -> Reference -> Generating documents -> Networking and fieldbuses - file writing services -> paFbindCnxStatus

Previous chapter Next chapter Show all Show all Hide all Hide all

paFbindCnxStatus - binds a variable to the connection status of the last declared port

FID := paFbindCnxStatus (FID, NAME)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenWriteBinding function.
NAME : STRING; | Symbol of the bound variable.
OK : BOOL; | TRUE if successful.

Description

This function binds a variable for getting the connection status. The variable is bound to external port declared by the last call to the paFbindExternPort function.

seealso See also
  • Functions for MODBUS configuration:

paFileOpenWriteModbus - Open the MODBUS configuration for writing.
paFModbusSlave - Configurate the MODBUS slave connection.
paFModbusMaster - Create a MODBUS master connection.
paFModbusRequestSlave - Add a MODBUS request on the slave connection.
paFModbusRequestMaster - Add a MODBUS request on a master connection.
paFModbusVariable - Add a MODBUS variable to the last declared request.

  • Functions for AS-i configuration:

paFileOpenWriteASi - Open the AS-i configuration for writing.
paFAsiApplyConfig - Set main flag.
paFAsiMaster - Add a master device.
paFAsiMasterDiag - Add a diagnostic variable on the last declared master.
paFAsiSlave - Add a slave device.
paFAsiSlaveDiag - Add a diagnostic variable on the last declared slave.
paFAsiInput - Add an input variable on the last declared slave.
paFAsiOutput - Add an output variable on the last declared slave.

  • Functions for other fieldbus drivers:

paFileOpenWriteFieldbus - Open a feldbus configuration for writing.
paFfbCreateMaster - Add a master node.
paFfbCreateSlave - Add a slave node.
paFfbCreateVar - Add a variable node.
paFfbSetProperty - Set the the value of a property.
paFfbSelectRoot - Select the root node.
paFfbSelectMaster - Select a master node.
paFfbSelectSlave - Select a slave node.
paFfbSelectVar - Select a variable node.

  • Functions for the binding configuration:

paFileOpenWriteBinding - Open the binding configuration for writing.
paFbindPublicVar - Add a public variable.
paFbindExternPort - Add an extern port.
paFbindExternVar - Add an extern variable.
paFbindVarStatus - Add a status variable.
paFbindVarDateStamp - Add a date stamp variable.
paFbindVarTimeStamp - Add a time stamp variable.


paFbindExternVar

Project Automation Library -> Reference -> Generating documents -> Networking and fieldbuses - file writing services -> paFbindExternVar

Previous chapter Next chapter Show all Show all Hide all Hide all

paFbindExternVar - binds a variable to the last declared port

FID := paFbindExternVar (FID, ID, NAME)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenWriteBinding function.
ID : DINT; | ID of the binding link.
NAME : STRING; | Symbol of the bound variable.
OK : BOOL; | TRUE if successful.

Description

This function binds a variable for data exchange. The variable is bound to external port declared by the last call to the paFbindExternPort function.

seealso See also
  • Functions for MODBUS configuration:

paFileOpenWriteModbus - Open the MODBUS configuration for writing.
paFModbusSlave - Configurate the MODBUS slave connection.
paFModbusMaster - Create a MODBUS master connection.
paFModbusRequestSlave - Add a MODBUS request on the slave connection.
paFModbusRequestMaster - Add a MODBUS request on a master connection.
paFModbusVariable - Add a MODBUS variable to the last declared request.

  • Functions for AS-i configuration:

paFileOpenWriteASi - Open the AS-i configuration for writing.
paFAsiApplyConfig - Set main flag.
paFAsiMaster - Add a master device.
paFAsiMasterDiag - Add a diagnostic variable on the last declared master.
paFAsiSlave - Add a slave device.
paFAsiSlaveDiag - Add a diagnostic variable on the last declared slave.
paFAsiInput - Add an input variable on the last declared slave.
paFAsiOutput - Add an output variable on the last declared slave.

  • Functions for other fieldbus drivers:

paFileOpenWriteFieldbus - Open a feldbus configuration for writing.
paFfbCreateMaster - Add a master node.
paFfbCreateSlave - Add a slave node.
paFfbCreateVar - Add a variable node.
paFfbSetProperty - Set the the value of a property.
paFfbSelectRoot - Select the root node.
paFfbSelectMaster - Select a master node.
paFfbSelectSlave - Select a slave node.
paFfbSelectVar - Select a variable node.

  • Functions for the binding configuration:

paFileOpenWriteBinding - Open the binding configuration for writing.
paFbindPublicVar - Add a public variable.
paFbindExternPort - Add an extern port.
paFbindCnxStatus - Add a connection status variable.
paFbindVarStatus - Add a status variable.
paFbindVarDateStamp - Add a date stamp variable.
paFbindVarTimeStamp - Add a time stamp variable.


paFbindVarStatus

Project Automation Library -> Reference -> Generating documents -> Networking and fieldbuses - file writing services -> paFbindVarStatus

Previous chapter Next chapter Show all Show all Hide all Hide all

paFbindVarStatus - binds a status variable to the last declared port

FID := paFbindVarStatus (FID, ID, NAME)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenWriteBinding function.
ID : DINT; | ID of the binding link.
NAME : STRING; | Symbol of the bound variable.
OK : BOOL; | TRUE if successful.

Description

This function binds a variable for getting the status of a binding link. The variable is bound to external port declared by the last call to the paFbindExternPort function.

seealso See also
  • Functions for MODBUS configuration:

paFileOpenWriteModbus - Open the MODBUS configuration for writing.
paFModbusSlave - Configurate the MODBUS slave connection.
paFModbusMaster - Create a MODBUS master connection.
paFModbusRequestSlave - Add a MODBUS request on the slave connection.
paFModbusRequestMaster - Add a MODBUS request on a master connection.
paFModbusVariable - Add a MODBUS variable to the last declared request.

  • Functions for AS-i configuration:

paFileOpenWriteASi - Open the AS-i configuration for writing.
paFAsiApplyConfig - Set main flag.
paFAsiMaster - Add a master device.
paFAsiMasterDiag - Add a diagnostic variable on the last declared master.
paFAsiSlave - Add a slave device.
paFAsiSlaveDiag - Add a diagnostic variable on the last declared slave.
paFAsiInput - Add an input variable on the last declared slave.
paFAsiOutput - Add an output variable on the last declared slave.

  • Functions for other fieldbus drivers:

paFileOpenWriteFieldbus - Open a feldbus configuration for writing.
paFfbCreateMaster - Add a master node.
paFfbCreateSlave - Add a slave node.
paFfbCreateVar - Add a variable node.
paFfbSetProperty - Set the the value of a property.
paFfbSelectRoot - Select the root node.
paFfbSelectMaster - Select a master node.
paFfbSelectSlave - Select a slave node.
paFfbSelectVar - Select a variable node.

  • Functions for the binding configuration:

paFileOpenWriteBinding - Open the binding configuration for writing.
paFbindPublicVar - Add a public variable.
paFbindExternPort - Add an extern port.
paFbindCnxStatus - Add a connection status variable.
paFbindExternVar - Add an extern variable.
paFbindVarDateStamp - Add a date stamp variable.
paFbindVarTimeStamp - Add a time stamp variable.


paFbindVarDateStamp

Project Automation Library -> Reference -> Generating documents -> Networking and fieldbuses - file writing services -> paFbindVarDateStamp

Previous chapter Next chapter Show all Show all Hide all Hide all

paFbindVarDateStamp - binds a date stamp variable to the last declared port

FID := paFbindVarDateStamp (FID, ID, NAME)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenWriteBinding function.
ID : DINT; | ID of the binding link.
NAME : STRING; | Symbol of the bound variable.
OK : BOOL; | TRUE if successful.

Description

This function binds a variable for getting the date stamp of a binding link. The variable is bound to external port declared by the last call to the paFbindExternPort function.

seealso See also
  • Functions for MODBUS configuration:

paFileOpenWriteModbus - Open the MODBUS configuration for writing.
paFModbusSlave - Configurate the MODBUS slave connection.
paFModbusMaster - Create a MODBUS master connection.
paFModbusRequestSlave - Add a MODBUS request on the slave connection.
paFModbusRequestMaster - Add a MODBUS request on a master connection.
paFModbusVariable - Add a MODBUS variable to the last declared request.

  • Functions for AS-i configuration:

paFileOpenWriteASi - Open the AS-i configuration for writing.
paFAsiApplyConfig - Set main flag.
paFAsiMaster - Add a master device.
paFAsiMasterDiag - Add a diagnostic variable on the last declared master.
paFAsiSlave - Add a slave device.
paFAsiSlaveDiag - Add a diagnostic variable on the last declared slave.
paFAsiInput - Add an input variable on the last declared slave.
paFAsiOutput - Add an output variable on the last declared slave.

  • Functions for other fieldbus drivers:

paFileOpenWriteFieldbus - Open a feldbus configuration for writing.
paFfbCreateMaster - Add a master node.
paFfbCreateSlave - Add a slave node.
paFfbCreateVar - Add a variable node.
paFfbSetProperty - Set the the value of a property.
paFfbSelectRoot - Select the root node.
paFfbSelectMaster - Select a master node.
paFfbSelectSlave - Select a slave node.
paFfbSelectVar - Select a variable node.

  • Functions for the binding configuration:

paFileOpenWriteBinding - Open the binding configuration for writing.
paFbindPublicVar - Add a public variable.
paFbindExternPort - Add an extern port.
paFbindCnxStatus - Add a connection status variable.
paFbindExternVar - Add an extern variable.
paFbindVarStatus - Add a status variable.
paFbindVarTimeStamp - Add a time stamp variable.


paFbindVarTimeStamp

Project Automation Library -> Reference -> Generating documents -> Networking and fieldbuses - file writing services -> paFbindVarTimeStamp

Previous chapter Next chapter Show all Show all Hide all Hide all

paFbindVarTimeStamp - binds a time stamp variable to the last declared port

FID := paFbindVarTimeStamp (FID, ID, NAME)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenWriteBinding function.
ID : DINT; | ID of the binding link.
NAME : STRING; | Symbol of the bound variable.
OK : BOOL; | TRUE if successful.

Description

This function binds a variable for getting the time stamp of a binding link. The variable is bound to external port declared by the last call to the paFbindExternPort function.

seealso See also
  • Functions for MODBUS configuration:

paFileOpenWriteModbus - Open the MODBUS configuration for writing.
paFModbusSlave - Configurate the MODBUS slave connection.
paFModbusMaster - Create a MODBUS master connection.
paFModbusRequestSlave - Add a MODBUS request on the slave connection.
paFModbusRequestMaster - Add a MODBUS request on a master connection.
paFModbusVariable - Add a MODBUS variable to the last declared request.

  • Functions for AS-i configuration:

paFileOpenWriteASi - Open the AS-i configuration for writing.
paFAsiApplyConfig - Set main flag.
paFAsiMaster - Add a master device.
paFAsiMasterDiag - Add a diagnostic variable on the last declared master.
paFAsiSlave - Add a slave device.
paFAsiSlaveDiag - Add a diagnostic variable on the last declared slave.
paFAsiInput - Add an input variable on the last declared slave.
paFAsiOutput - Add an output variable on the last declared slave.

  • Functions for other fieldbus drivers:

paFileOpenWriteFieldbus - Open a feldbus configuration for writing.
paFfbCreateMaster - Add a master node.
paFfbCreateSlave - Add a slave node.
paFfbCreateVar - Add a variable node.
paFfbSetProperty - Set the the value of a property.
paFfbSelectRoot - Select the root node.
paFfbSelectMaster - Select a master node.
paFfbSelectSlave - Select a slave node.
paFfbSelectVar - Select a variable node.

  • Functions for the binding configuration:

paFileOpenWriteBinding - Open the binding configuration for writing.
paFbindPublicVar - Add a public variable.
paFbindExternPort - Add an extern port.
paFbindCnxStatus - Add a connection status variable.
paFbindExternVar - Add an extern variable.
paFbindVarStatus - Add a status variable.
paFbindVarDateStamp - Add a date stamp variable.


Watch window documents - file writing services

Project Automation Library -> Reference -> Generating documents -> Watch window documents - file writing services

Previous chapter Next chapter Show all Show all Hide all Hide all

Below are the main services for writing watch window document files. Files are open using specific functions. When complete, they must be closed by calling the paFileClose function.

  • Generating spy lists:

    paFileOpenWriteSpyList - Open a spy list document for writing.
    paFSpyAddVariable - Add a variable to a spy list.

  • Generating recipes:

    paFileOpenWriteRecipe - Open a recipe document for writing.
    paFrcpAddColumn - Define a column in the recipe.
    paFrcpAddVariable - Add a variable to a recipe.
    paFrcpAddValue - Add a value to a recipe.

  • Generating graphic documents:

    Not available.

In this section

paFileOpenWriteSpyList

paFSpyAddVariable

paFileOpenWriteRecipe

paFrcpAddColumn

paFrcpAddVariable

paFrcpAddValue


paFileOpenWriteSpyList

Project Automation Library -> Reference -> Generating documents -> Watch window documents - file writing services -> paFileOpenWriteSpyList

Previous chapter Next chapter Show all Show all Hide all Hide all

paFileOpenWriteSpyList - Open a spy list document for writing

FID := paFileOpenWriteSpyList (NAME)

Parameter | Description
NAME : STRING; | Name of the spy list (no suffix!).
FID : DINT; | File identifier or 0 if fail.

Description

This function opens a spy list document file for writing. This functions removes the contents of the spy list if it already exist. When written, the file must be closed by calling the paFileClose function.

seealso See also
  • Generating spy lists:

    paFSpyAddVariable - Add a variable to a spy list.

  • Generating recipes:

    paFileOpenWriteRecipe - Open a recipe document for writing.
    paFrcpAddColumn - Define a column in the recipe.
    paFrcpAddVariable - Add a variable to a recipe.
    paFrcpAddValue - Add a value to a recipe.

  • Generating graphic documents:

Not available.


paFSpyAddVariable

Project Automation Library -> Reference -> Generating documents -> Watch window documents - file writing services -> paFSpyAddVariable

Previous chapter Next chapter Show all Show all Hide all Hide all

paFSpyAddVariable - Add a variable to a spy list

OK := paFSpyAddVariable (FID, NAME)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenSpyList function.
NAME : STRING; | Symbol of the variable.
OK : BOOL; | TRUE if successful.

Description

This function adds a variable to an open spy list document.

seealso See also
  • Generating spy lists:

    paFileOpenWriteSpyList - Open a spy list document for writing.

  • Generating recipes:

    paFileOpenWriteRecipe - Open a recipe document for writing.
    paFrcpAddColumn - Define a column in the recipe.
    paFrcpAddVariable - Add a variable to a recipe.
    paFrcpAddValue - Add a value to a recipe.

  • Generating graphic documents:

Not available.


paFileOpenWriteRecipe

Project Automation Library -> Reference -> Generating documents -> Watch window documents - file writing services -> paFileOpenWriteRecipe

Previous chapter Next chapter Show all Show all Hide all Hide all

paFileOpenWriteRecipe - Open a recipe document for writing

FID := paFileOpenRecipe (NAME)

Parameter | Description
NAME : STRING; | Name of the recipe (no suffix!).
FID : DINT; | File identifier or 0 if fail.

Description

This function opens a recipe document file for writing. This functions removes the contents of the recipe if it already exist. When written, the file must be closed by calling the paFileClose function.

seealso See also
  • Generating spy lists:

    paFileOpenWriteSpyList - Open a spy list document for writing.
    paFSpyAddVariable - Add a variable to a spy list.

  • Generating recipes:

    paFrcpAddColumn - Define a column in the recipe.
    paFrcpAddVariable - Add a variable to a recipe.
    paFrcpAddValue - Add a value to a recipe.

  • Generating graphic documents:

Not available.


paFrcpAddColumn

Project Automation Library -> Reference -> Generating documents -> Watch window documents - file writing services -> paFrcpAddColumn

Previous chapter Next chapter Show all Show all Hide all Hide all

paFrcpAddColumn - Add a column to a recipe

OK := paFrcpAddColumn (FID, COL, NAME)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenRecipe function.
COL : DINT; | Index of the column (0 based).
NAME : STRING; | Name of the column.
OK : BOOL; | TRUE if successful.

Description

This function adds a column to a recipe. The index of the first column is 0. Column must be declared from the left to the right. Columns must be definied before adding values to the recipe.

seealso See also
  • Generating spy lists:

    paFileOpenWriteSpyList - Open a spy list document for writing.
    paFSpyAddVariable - Add a variable to a spy list.

  • Generating recipes:

    paFileOpenWriteRecipe - Open a recipe document for writing.
    paFrcpAddVariable - Add a variable to a recipe.
    paFrcpAddValue - Add a value to a recipe.

  • Generating graphic documents:

Not available.


paFrcpAddVariable

Project Automation Library -> Reference -> Generating documents -> Watch window documents - file writing services -> paFrcpAddVariable

Previous chapter Next chapter Show all Show all Hide all Hide all

paFrcpAddVariable - Add a variable to a recipe

OK := paFrcpAddVariable (FID, NAME)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenRecipe function.
NAME : STRING; | Symbol of the variable.
OK : BOOL; | TRUE if successful.

Description

This function adds a variable (a line) to an open recipe document. Variables must be definied before adding values to the recipe.

seealso See also
  • Generating spy lists:

    paFileOpenWriteSpyList - Open a spy list document for writing.
    paFSpyAddVariable - Add a variable to a spy list.

  • Generating recipes:

    paFileOpenWriteRecipe - Open a recipe document for writing.
    paFrcpAddColumn - Define a column in the recipe.
    paFrcpAddVariable - Add a variable to a recipe.
    paFrcpAddValue - Add a value to a recipe.

  • Generating graphic documents:

Not available.


paFrcpAddValue

Project Automation Library -> Reference -> Generating documents -> Watch window documents - file writing services -> paFrcpAddValue

Previous chapter Next chapter Show all Show all Hide all Hide all

paFrcpAddValue - Add a value to a recipe

OK := paFrcpAddValue (FID, NAME, COL, VALUE)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenRecipe function.
NAME : STRING; | Symbol of the variable.
COL : DINT; | Index of the column (0 based).
NAME : STRING; | Value in IEC syntax.
OK : BOOL; | TRUE if successful.

Description

This function adds a value (one cell) to a recipe. The corresponding variable (line) and column must be defined before calling this function.

seealso See also
  • Generating spy lists:

    paFileOpenWriteSpyList - Open a spy list document for writing.
    paFSpyAddVariable - Add a variable to a spy list.

  • Generating recipes:

    paFileOpenWriteRecipe - Open a recipe document for writing.
    paFrcpAddColumn - Define a column in the recipe.
    paFrcpAddVariable - Add a variable to a recipe.

  • Generating graphic documents:

Not available.


Resource documents - file writing services

Project Automation Library -> Reference -> Generating documents -> Resource documents - file writing services

Previous chapter Next chapter Show all Show all Hide all Hide all

Below are the main services for writing resources document files. Files are open using specific functions. When complete, they must be closed by calling the paFileClose function.

  • Generating string tables:

    paFileOpenWriteStringTable - Open a string table document for writing.
    paFstbAddColumn - Define a column in the string table.
    paFstbAddString - Add a string to a table.

  • Generating analog signal:

    paFileOpenWriteSignal - Open a signal document for writing.
    paFSignalAddColumn - Define a column in the signal resource.
    paFSignalAddPoint - Add a point to a signal resource.

In this section

paFileOpenWriteStringTable

paFstbAddColumn

paFstbAddString

paFileOpenWriteSignal

paFSignalAddColumn

paFSignalAddPoint


paFileOpenWriteStringTable

Project Automation Library -> Reference -> Generating documents -> Resource documents - file writing services -> paFileOpenWriteStringTable

Previous chapter Next chapter Show all Show all Hide all Hide all

paFileOpenWriteStringTable - Open a "string table" resource document for writing

FID := paFileOpenStringTable (NAME)

Parameter | Description
NAME : STRING; | Name of the string table (no suffix!).
FID : DINT; | File identifier or 0 if fail.

Description

This function opens a "string table" resource document file for writing. This functions removes the contents of the stringtable if it already exist. When written, the file must be closed by calling the paFileClose function.

seealso See also
  • Generating string tables:

    paFileOpenWriteStringTable - Open a string table document for writing.
    paFstbAddColumn - Define a column in the string table.
    paFstbAddString - Add a string to a table.

  • Generating analog signal:

    paFileOpenWriteSignal - Open a signal document for writing.
    paFSignalAddColumn - Define a column in the signal resource.
    paFSignalAddPoint - Add a point to a signal resource.


paFstbAddColumn

Project Automation Library -> Reference -> Generating documents -> Resource documents - file writing services -> paFstbAddColumn

Previous chapter Next chapter Show all Show all Hide all Hide all

paFstbAddColumn - Add a column to a string table resource

OK := paFstbAddColumn (FID, NAME)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenStringTable function.
COL : DINT; | Index of the column (0 based).
NAME : STRING; | Name of the column.
OK : BOOL; | TRUE if successful.

Description

This function adds a column to a "string table" resource. The index of the first column is 0. Column must be declared from the left to the right. Columns must be definied before adding strings to the table.

seealso See also
  • Generating string tables:

    paFileOpenWriteStringTable - Open a string table document for writing.
    paFstbAddColumn - Define a column in the string table.
    paFstbAddString - Add a string to a table.

  • Generating analog signal:

    paFileOpenWriteSignal - Open a signal document for writing.
    paFSignalAddColumn - Define a column in the signal resource.
    paFSignalAddPoint - Add a point to a signal resource.


paFstbAddString

Project Automation Library -> Reference -> Generating documents -> Resource documents - file writing services -> paFstbAddString

Previous chapter Next chapter Show all Show all Hide all Hide all

paFstbAddString - Add a column to a string table resource

OK := paFstbAddString (FID, NAME, COL, VALUE)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenStringTable function.
NAME : STRING; | Identifier of the string in the table.
COL : DINT; | Index of the column (0 based).
VALUE : STRING; | Contents of the string.
OK : BOOL; | TRUE if successful.

Description

This function adds a string to a "string table" resource. The corresponding column must be defined before calling this function.

seealso See also
  • Generating string tables:

    paFileOpenWriteStringTable - Open a string table document for writing.
    paFstbAddColumn - Define a column in the string table.
    paFstbAddString - Add a string to a table.

  • Generating analog signal:

    paFileOpenWriteSignal - Open a signal document for writing.
    paFSignalAddColumn - Define a column in the signal resource.
    paFSignalAddPoint - Add a point to a signal resource.


paFileOpenWriteSignal

Project Automation Library -> Reference -> Generating documents -> Resource documents - file writing services -> paFileOpenWriteSignal

Previous chapter Next chapter Show all Show all Hide all Hide all

paFileOpenWriteSignal - Open a "signal" resource document for writing

FID := paFileOpenSignal (NAME)

Parameter | Description
NAME : STRING; | Name of the signal (no suffix!).
FID : DINT; | File identifier or 0 if fail.

Description

This function opens an "analog signal" resource document file for writing. This functions removes the contents of the resource if it already exist. When written, the file must be closed by calling the paFileClose function.

seealso See also
  • Generating string tables:

    paFileOpenWriteStringTable - Open a string table document for writing.
    paFstbAddColumn - Define a column in the string table.
    paFstbAddString - Add a string to a table.

  • Generating analog signal:

    paFileOpenWriteSignal - Open a signal document for writing.
    paFSignalAddColumn - Define a column in the signal resource.
    paFSignalAddPoint - Add a point to a signal resource.


paFSignalAddColumn

Project Automation Library -> Reference -> Generating documents -> Resource documents - file writing services -> paFSignalAddColumn

Previous chapter Next chapter Show all Show all Hide all Hide all

paFSignalAddColumn

OK := paFSignalAddColumn (FID, NAME)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenSignal function.
COL : DINT; | Index of the column (0 based).
NAME : STRING; | Name of the column.
OK : BOOL; | TRUE if successful.

Description

This function adds a column to an "analog signal" resource. The index of the first column is 0. Column must be declared from the left to the right. Columns must be definied before adding points are added to the signal.

seealso See also
  • Generating string tables:

    paFileOpenWriteStringTable - Open a string table document for writing.
    paFstbAddColumn - Define a column in the string table.
    paFstbAddString - Add a string to a table.

  • Generating analog signal:

    paFileOpenWriteSignal - Open a signal document for writing.
    paFSignalAddColumn - Define a column in the signal resource.
    paFSignalAddPoint - Add a point to a signal resource.


paFSignalAddPoint

Project Automation Library -> Reference -> Generating documents -> Resource documents - file writing services -> paFSignalAddPoint

Previous chapter Next chapter Show all Show all Hide all Hide all

paFSignalAddPoint - Add a point to a signal resource

OK := paFSignalAddPoint (FID, TM, COL, VALUE)

Parameter | Description
FID : DINT; | File identifier returned by the paFileOpenSignal function.
TM : TIME; | X coordinate (time) of the point.
COL : DINT; | Index of the column (0 based).
VALUE : REAL; | Y coordinate of the point.
OK : BOOL; | TRUE if successful.

Description

This function adds a point to an "analog signal" resource. The corresponding column must be defined before calling this function.

seealso See also
  • Generating string tables:

    paFileOpenWriteStringTable - Open a string table document for writing.
    paFstbAddColumn - Define a column in the string table.
    paFstbAddString - Add a string to a table.

  • Generating analog signal:

    paFileOpenWriteSignal - Open a signal document for writing.
    paFSignalAddColumn - Define a column in the signal resource.
    paFSignalAddPoint - Add a point to a signal resource.


Templates

Project Automation Library -> Reference -> Templates

In this section

Variable keywords for copying templates

Templates of programs


Variable keywords for copying templates

Project Automation Library -> Reference -> Templates -> Variable keywords for copying templates

Previous chapter Next chapter Show all Show all Hide all Hide all

Your scripts can contain template documents to be copied in the target project. When copying documents, some special keywords may be variables defined from the script and replaced by the value given by the script.

Use the following syntax in your templates for specifying variable keywords:

$(keyname)

and use the following functions in your script to set values for keywords:

paSetKey Define the value of a variable keyword.
paRemoveKeys Reset values of all defined variable keywords.

In this section

paSetKey

paRemoveKeys


paSetKey

Project Automation Library -> Reference -> Templates -> Variable keywords for copying templates -> paSetKey

Previous chapter Next chapter Show all Show all Hide all Hide all

paSetKey - Define a variable keyword for copying templates

OK := paSetKey (NAME, VALUE)

Parameter | Description
NAME : STRING; | Name of the variable keyword.
VALUE : STRING; | Value of the variable keyword.
OK | TRUE if successful.

Description

This function defines the value of a defined keyword to be replaced when copying a template.

Example Example

Template ST program:

if ALARM_$(ALM) then
bMainAlarm := TRUE;
end_if;

Script instructions:

paSetKey ('ALM', 'Engine2')
paTplCopySource ('TargetProgram', 'TemplateName');

Generated ST program:

if ALARM_Engine2 then
bMainAlarm := TRUE;
end_if;

seealso See also

paRemoveKeys Reset values of all defined variable keywords.


paRemoveKeys

Project Automation Library -> Reference -> Templates -> Variable keywords for copying templates -> paRemoveKeys

Previous chapter Next chapter Show all Show all Hide all Hide all

paRemoveKeys - Remove all values defined for template variable keywords

OK := paRemoveKeys ()

Parameter | Description
OK | TRUE if successful.

Description

This function removes all values defined for variable keywords used for copying templates.

seealso See also

paSetKey Define the value of a variable keyword.


Templates of programs

Project Automation Library -> Reference -> Templates -> Templates of programs

Previous chapter Next chapter Show all Show all Hide all Hide all

Your scripts can contain template documents to be copied in the target project. You can include in your script project templates of POUs (programs, sub-programs or UDFBs) to be copied in the target project.

Use the following functions in your script to copy a template of POU:

paTplCopySource - Copy the source code.
paTplCopyVars - Copy local variables.
paTplCopyDefinitions - Copy local definitions.
paTplCopyAll - Copy all components of a POU template.

You also can define some variable keywords to be replaced when copying templates of POUs.

In this section

paTplCopySource

paTplCopyVars

paTplCopyDefinitions

paTplCopyAll


paTplCopySource

Project Automation Library -> Reference -> Templates -> Templates of programs -> paTplCopySource

Previous chapter Next chapter Show all Show all Hide all Hide all

paTplCopySource - Copy the source code of a POU template

OK := paTplCopySource (DSTPROG, TEMPLATE)

Parameter | Description
DSTPROG : STRING; | Name of the destination program in the target project (must exist).
TEMPLATE : STRING; | Name of the template program in the automation script project.
OK | TRUE if successful.

Description

This function copies the source code of the specified template from the automation script project to the destination project. The destination program must be declared in the target project.

seealso See also

paTplCopyVars - Copy local variables.
paTplCopyDefinitions - Copy local definitions.
paTplCopyAll - Copy all components of a POU template.

You also can define some variable keywords to be replaced when copying templates of POUs.


paTplCopyVars

Project Automation Library -> Reference -> Templates -> Templates of programs -> paTplCopyVars

Previous chapter Next chapter Show all Show all Hide all Hide all

paTplCopyVars - Copy local variables of a POU template

OK := paTplCopyVars (DSTPROG, TEMPLATE)

Parameter | Description
DSTPROG : STRING; | Name of the destination program in the target project (must exist).
TEMPLATE : STRING; | Name of the template program in the automation script project.
OK | TRUE if successful.

Description

This function copies all local variables of the specified template from the automation script project to the destination project. The destination program must be declared in the target project.

seealso See also

paTplCopySource - Copy the source code.
paTplCopyDefinitions - Copy local definitions.
paTplCopyAll - Copy all components of a POU template.

You also can define some variable keywords to be replaced when copying templates of POUs.


paTplCopyDefinitions

Project Automation Library -> Reference -> Templates -> Templates of programs -> paTplCopyDefinitions

Previous chapter Next chapter Show all Show all Hide all Hide all

paTplCopyDefinitions - Copy local defiitions of a POU template

OK := paTplCopyDefinitions (DSTPROG, TEMPLATE)

Parameter | Description
DSTPROG : STRING; | Name of the destination program in the target project (must exist).
TEMPLATE : STRING; | Name of the template program in the automation script project.
OK | TRUE if successful.

Description

This function copies all local definitions of the specified template from the automation script project to the destination project. The destination program must be declared in the target project.

seealso See also

paTplCopySource - Copy the source code.
paTplCopyVars - Copy local variables.
paTplCopyAll - Copy all components of a POU template.

You also can define some variable keywords to be replaced when copying templates of POUs.


paTplCopyAll

Project Automation Library -> Reference -> Templates -> Templates of programs -> paTplCopyAll

Previous chapter Next chapter Show all Show all Hide all Hide all

paTplCopyAll - Copy a POU template

OK := paTplCopyAll (DSTPROG, TEMPLATE)

Parameter | Description
DSTPROG : STRING; | Name of the destination program in the target project (must exist).
TEMPLATE : STRING; | Name of the template program in the automation script project.
OK | TRUE if successful.

Description

This function copies the specified template from the automation script project to the destination project. The copy includes source code, local variables and local definitions. The destination program must be declared in the target project.

seealso See also

paTplCopySource - Copy the source code.
paTplCopyVars - Copy local variables.
paTplCopyDefinitions - Copy local definitions.

You also can define some variable keywords to be replaced when copying templates of POUs.


Script parameters

Project Automation Library -> Reference -> Script parameters

The project automation system enables your script to prompt the user for entering some parameters. Such parameters are then used (as variables) by your script.

Principle

Parameters must be variables of your script project declared as global variables. Then you need to create a list of variables in your script project that groups all "parameter" variables. Finally in your script, you must call the paEditParameterList function, that opens a dialog box where the user must give values for each parameter. Then "parameter" variables can be used in your script.

A parameter must be a variable declared with a single data type (no array, no structure). All basic data types are supported. When the parameter input dialog box is open, current values of variables are shown as default value.

For a string parameter, it is possible to define a drop-list choice. For that you must set possible choices in the string value before editing parameter, separated by '|' characters. e.g.: 'Choice1|Choice2'.

Related functions

paSetParameterDesc Set the description text to be shown with a parameter.
paEditParameterList Prompt the user for entering parameters.

See an example.

In this section

paSetParameterDesc

paEditParameterList

Example


paSetParameterDesc

Project Automation Library -> Reference -> Script parameters -> paSetParameterDesc

Previous chapter Next chapter Show all Show all Hide all Hide all

paSetParameterDesc - Ses the description text to be shown with a parameter

OK := paSetParameterDesc (NAME, DESC)

Parameter | Description
NAME : STRING; | Name of the parameter, such as declared in your script project.
DESC : STRING; | Description text to be show to the user when entering parameters.
OK : BOOL | TRUE if successful.

Description

This function defines the description text to be shown together with the specified parameter when entered.

seealso See also

paEditParameterList Prompt the user for entering parameters.

See an example.


paEditParameterList

Project Automation Library -> Reference -> Script parameters -> paEditParameterList

Previous chapter Next chapter Show all Show all Hide all Hide all

paEditParameterList - Prompt the user to enter parameter values

OK := paEditParameterList (LISTID, TITLE)

Parameter | Description
LISTID : DINT; | ID of the list of parameters (use VLID function).
TITLE : STRING; | Title of the window where the user enters the parameter.
OK : BOOL; | TRUE if the use pressed the OK button.

Description

This function opens a dialog box where the user enters values for script parameters.

seealso See also

paSetParameterDesc Set the description text to be shown with a parameter.
See an example.


Example

Project Automation Library -> Reference -> Script parameters -> Example

Previous chapter Next chapter Show all Show all Hide all Hide all

This examples shows the different steps for adding parameters to a script:

  • Declare parameters as global variables of your script project:

  • Create a list of variables with parameters:

  • ST Script:

// set decription text for parameters
paSetParameterDesc ('Param1', 'This is parameter 1');
paSetParameterDesc ('Param2', 'This is parameter 2');
paSetParameterDesc ('Param3', 'This is parameter 3');
// prompt the user for parameters
paEditParameterList (VLID ('Parameters'), 'Enter parameters now');

When the script is run, the following dialog box is open:

The Param1 parameter is a check box, because it is declared as BOOL. The Param3 is shown as a drop list because the value of Param3 (its initial value in that case) is a list of words separated by '|' characters.


miscellaneous

Project Automation Library -> Reference -> miscellaneous

Below are some other functions you can use in automation scripts:

paGetLanguage Return the selected language for the Workbench.
paTRACE... Output a report message.

In this section

paGetLanguage

paTRACEx


paGetLanguage

Project Automation Library -> Reference -> miscellaneous -> paGetLanguage

Previous chapter Next chapter Show all Show all Hide all Hide all

paGetLanguage - Get current selected language

LGE := paGetLanguage ()

Parameter | Description
LGE : DINT; | Language identifier (see notes).

Description

This function returns the language currently selected for the Workbench. Possible returned values are:

Value | Description
_WB_USA | English
_WB_GER | German
_WB_FRA | French
_WB_ITA | Italian
_WB_SPA | Spanish
_MW_KOR | Korean

seealso See also

paTRACE... Output a report message.


paTRACEx

Project Automation Library -> Reference -> miscellaneous -> paTRACEx

Previous chapter Next chapter Show all Show all Hide all Hide all

paTRACE... - Output a report message

paTRACE0 (TEXT)
paTRACE1 (TEXT, ARG1)
paTRACE2 (TEXT, ARG1, ARG2)
paTRACE3 (TEXT, ARG1, ARG2, ARG3)
paTRACE4 (TEXT, ARG1, ARG2, ARG3, ARG3)

Parameter | Description
TEXT : STRING; | Text to be output.
ARG1..4 : DINT; | Arguments.

Description

The message specified in the TEXT argument is output to the report window when the automation script is run. The message text may include up to 4 integer arguments, specified in the TEXT string with special character sequences:

%ld signed value in decimal.
%lu unsigned value in decimal.
%lx value in hexadecimal.

seealso See also

paGetLanguage Return the selected language for the Workbench.


Workbench COM Interface

Workbench COM Interface

The Workbench offers a COM interface (K5COM.dll) which sets up on the program automation interface. As the referring object model is developed continuously this description could not be up to date.

The COM interfac can be use for e.g.:

  • declaring variables via a VBA wizard.
  • browsing programs or the variable lists.
  • automatic programming.
  • ...

This page describes the object model only. All the rest of the information can be looked up in the object library of the used programming environments (e.g. VBA).

Here you find the object model represented as a tree:

- StratonCom
- Project
- GlobalVariables
- Variables
- Variable
- VarProps
- VarProperty
- RetainVariables
- Variables
- Variable
- VarProps
- VarProperty
- Programs
- Variables
- Variable
- VarProps
- VarProperty
- ProgramContent
- ProgramObjects
- GraphicalObject
- ProgramLines
- LineObject

You can use all program automation commands through the shell of the used programming language (e.g. VBA).


Copyright

Copyright

Information in these pages is subject to change without notice and does not represent a commitment on the part of ICP DAS. No part of these pages may be reproduced in any form or by any means, electronic or mechanical, for any purpose without the express written permission of ICP DAS.

© 2015 ICP DAS CO., LTD. All rights reserved.

Product or company names included in these pages are trademarks or registered trademarks of their respective holders.

ICP DAS
www.icpdas.com


SAMA Blocks

This section details the basic function blocks available for SAMA programming.

In this section

SAMA - AND

SAMA - Averaging

SAMA - Bias

SAMA - Derivative

SAMA - Difference

SAMA - Dividing

SAMA - Exponetial

SAMA - High Limiting

SAMA - High/Low Limiting

SAMA - High Selecting

SAMA - Integral

SAMA - Logical Variable Signal Generator

SAMA - Low Limiting

SAMA - Low Selecting

SAMA - Manual Transfer

SAMA - Memory (R dominant)

SAMA - Memory (S dominant)

SAMA - Multiplying

SAMA - Non Linear Function

SAMA - NOT

SAMA - OR

SAMA - PI Controller with Feed Forward

SAMA - Proportional

SAMA - Pulse Duration

SAMA - Qualified Logical OR (>n)

SAMA - Qualified Logical OR (<n)

SAMA - Qualified Logical OR (=n)

SAMA - Reverse Proportional

SAMA - Root Extraction

SAMA - Summing

SAMA - Three State Signal Monitor

SAMA - Two State Signal Monitor (lower limit)

SAMA - Two State Signal Monitor (upper limit)

SAMA - Time Delay of Initiation

SAMA - Time Delay of Termination

SAMA - Transfer

SAMA - Variable Signal Generator

SAMA - Velocity Limiter


Boolean_Operations

Undocumented function or function block

This block is reserved for special runtime diagnostic and should not be used in applications.


PID Functions by JS Automation

JS_DeadTime - analog delay

Call

INPUT : signal input.
N : number of samples (200 max).
DeadTime : delay (seconds).

Return

OUT : output signal.

info Info

Allows to put a delay on an analog signal.

attention Attention

The dead time divided by the number of samples must be very greater than cycle time.
If N = 0 the function understands 1
If N > 200 the function understands 200

JS_LeadLag - signal lead / lag

Call

Input : input signal.
Lead : lead value.
Lag : lag value.
Ts : sampling period.

Return

Out : output signal.

Function

Qn = Qn-1 + Ts/Ti.(Mn-1 - Qn-1) + Td/Ti.(Mn - Mn-1)

Qn : Output at t
Qn-1 : Output at t-1
Mn : Input at t
Mn-1 : Input at t-1
Ts : Sampling period
Ti : Lag
Td : Lead

info Info

If Lag = 0 the function is not executed.
Sampling period must be very greater than cycle time.

JS_PID - PID loop setpoint balance

Call

LSL : Loop Scale Lo
LSH : Loop Scale Hi
Auto : automatic or manual mode
Pv : Process output value
Sp : Set point value
Ramp : Setpoint Ramp ( Unit per Minute )
Balance : Auto/Manu Setpoint balancing
Action : Output action Direct or Reverse
Mixt : Interactive or Non-Interactive PID
Deriv : Derivative action
Feedback : external PID feedback for output manipulations
X0 : Adjustment value: In manual mode, output pid regulator equal to X0
You must connect obligatory a variable (not a constant and no computation on this variable
Kp : Proportionality constant
Ti : Integral time constant in minute
Td : derivative time constant in minute
Ts : Sampling period
Xmin : Minimum limit on output command value
Xmax : Maximum limit on output command value

Return

SPcur : Current Setpoint
Xout : Command

info Info

Automatic mode must be set to false at init.
Balance = 0 Non-balancing Setpoint ; =1 Balancing
Xout is limited inside specified Xmin ,Xmax range.
Xmax should be greater than Xmin.
The integral term is held when Xout reaches the limits
The Ts parameter should be greater (>>>) than the kernel cycle time.

Action :

  • Direct (0) Output increase if PV-SP positive and decrease if PV-SP negative.
  • Reverse (1) Output decrease if PV-SP positive and increase if PV-SP negative.

Mixt :

  • Interactive PID (0) : The I and D parameters are multipied by KP.
  • Non-Interactive (1) : The P,I,D parameters are independant.

Feedback :

  • The range must be 0-100 .
  • Feeback=0 : internal feedback.

JS_Ramp - Limit variation speed

Call

  • INPUT : input signal
  • Rampe : maximum variation speed ( Unit/mn)
  • Cycle : application cycle time

Return

OUT : output signal

info Info
  • The variation of speed is expressed as units per minute
  • The Cycle input must be the application cycle time

    Use GetSysInfo (_SYSINFO_CYCLETIME_MS)


RedSwitch

Function - Triggers a redundancy switch.

 | Data type | Description
Inputs |  |
SWITCH | BOOL | Input to trigger the redundancy switch
Outputs |  |
ERROR | BOOL | TRUE in case of error. E.g. no passive Runtime connected.

Remarks

This function causes a redundancy switch of the Runtime when the input SWITCH becomes TRUE.

ST Language

ERROR := RedSwitch (SWITCH);

FBD Language

This function is available in FBD language.

LD Language

This function is available in LD language.

IL Language

Op1: LD SWITCH
RedSwitch
ST ERROR


ROLb / ROL_SINT / ROL_USINT / ROL_BYTE

Function - Rotate bits of a register to the left.

Inputs

IN : SINT 8 bit register.
NBR : SINT Number of rotations (each rotation is 1 bit).

Outputs

Q : SINT Rotated register.

Diagram

Remarks

In LD language, the input rung (EN) enables the operation, and the output rung keeps the state of the input rung. In IL language, the first input must be loaded before the function call. The second input is the operand of the function.

ST Language

Q := ROLb (IN, NBR);

FBD Language

LD Language

The rotation is executed only if EN is TRUE.
ENO has the same value as EN.

IL Language

Op1: LD IN
ROLb NBR
ST Q

seealso See also

SHL SHR ROL ROR SHLb SHRb RORb SHLw SHRw ROLw RORw


ROLw / ROL_INT / ROL_UINT / ROL_WORD

Function - Rotate bits of a register to the left.

Inputs

IN : INT 16 bit register.
NBR : INT Number of rotations (each rotation is 1 bit).

Outputs

Q : INT Rotated register.

Diagram

Remarks

In LD language, the input rung (EN) enables the operation, and the output rung keeps the state of the input rung. In IL language, the first input must be loaded before the function call. The second input is the operand of the function.

ST Language

Q := ROLw (IN, NBR);

FBD Language

LD Language

The rotation is executed only if EN is TRUE.
ENO has the same value as EN.

IL Language

Op1: LD IN
ROLw NBR
ST Q

seealso See also

SHL SHR ROL ROR SHLb SHRb ROLb RORb SHLw SHRw RORw


ApplyRecipeColumn RTK_IsBugCheck

Function - Reads the Blue screen of Death value on MS Windows XP.

by COPA-DATA GmbH

Inputs

---

Outputs

Q : BOOL TRUE if a Blue screen of Death occurred.

Remarks

Designed for COPA-DATA's RTK Real-time Runtime for Windows XP only.

info Info

After a Blue screen of Death of MS Windows XP Windows specific functions in the PLC code can not be executed any more. These are: File operations, TCP functions, Serial interface functions, non real time fieldbus drivers, System clock functions, RETAIN variables, writing log messages,...

In LD language, the input rung (EN) enables the selection. The output rung is Q the output signal.

ST Language

Q := RTK_IsBugCheck ();

FBD Language

LD Language

The Function is performed when the EN input is TRUE .

IL Language

Not available.


Run time options

Run time options can be entered from the Build menu of the main window. Run-time options must be defined BEFORE the application is built.

Cycle time

You must specify in this box how the cycles must be triggered at run-time:

  • not triggered: the target does not wait between two cycles. The target simply runs as fast as possible.
  • triggered: you must specify the duration of a cycle, expressed as a number of micro-seconds. Refer to OEM instructions for explanations of the supported accuracy for the cycle timing of your target system.

Program scheduling

You can define various sampling periods for programs of the application. Default period is 1: the program is executed on each cycle. Giving slower period to some programs is an easy way to give higher priority to some other programs.

To change the scheduling of programs, select them in the left side list and press > or drag them to the grid where you can change for each selected program:

  • Its period (how many cycles between two executions of the program).
  • Its phase (an offset that enables to dispatch slow programs among few cycles).

The diagram on the top shows the loading of target cycles. On each sample, the diagram shows how many programs are run. You can highlight the scheduling of a program in the diagram by checking it in the grid.

The following example illustrates the scheduling of an application with three programs. In order to give higher priority to program P3, a period of 2 is given to programs P1 and P2. P2 as an offset 1 so that it is not executed on the same cycle as P1:

Example Example

 | Period | Phase
P1 | 2 | 0
P2 | 2 | 1
P3 | 1 | 0

The diagram below shows which program is executed on each cycle according to this configuration:

P1 | P2 | P1 | P2 | P1 | P2 | P1 | P2 | P1
P3 | P3 | P3 | P3 | P3 | P3 | P3 | P3 | P3
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ...


SAMA - AND

Boolean AND. The block accepts from 2 to 16 inputs. Resize the block vertically to get more or less inputs.

Inputs

IN1 .. IN16 : BOOL

Boolean inputs

Outputs

Q : BOOL

TRUE if all inputs are TRUE


SAMA - Averaging

Calculate the average of inputs. The block accepts from 2 to 16 inputs. Resize the block horizontally to get more or less inputs.

Inputs

IN1 .. IN16 : REAL

Analog inputs

Outputs

OUT : REAL

Average of all inputs


SAMA - Bias

Holds the Bias point of the output.

Inputs

IN : REAL

Analog input

Parameters

BIAS : REAL

Bias point

Outputs

OUT : REAL

IN + BIAS


SAMA - Derivative

Derivates the input signal. The output is limited by PMIN and PMAX parameters.

Inputs

IN : REAL

Analog signal

Parameters

TD : TIME | Differential time
PMIN : REAL | Minimum output value
PMAX : REAL | Maximum output value

Outputs

OUT : REAL

Derivated signal limited to [PMIN .. PMAX]


SAMA - Difference

Calculate the difference between inputs.

Inputs

IN1 : REAL | Analog input
IN2 : REAL | Analog input

Outputs

OUT : REAL

IN1 - IN2


SAMA - Dividing

Calculate the division between inputs.

Inputs

IN1 : REAL | Analog input
IN2 : REAL | Analog input

Outputs

OUT : REAL

IN1 / IN2


SAMA - Exponetial

Calculate the exponential of the input.

Inputs

IN : REAL

Analog input

Parameters

N : DINT

Exponent

Outputs

OUT : REAL

IN exp N


SAMA - High Limiting

Limits the maximum value of the input.

Inputs

IN : REAL

Analog input

Parameters

PMAX : REAL

Maximum value for the output

Outputs

OUT : REAL

= IN if IN <= PMAX

= PMAX if IN > PMAX


SAMA - High Selecting

Select the maximum of two inputs. The block accepts from 2 to 16 inputs. Resize the block horizontally to get more or less inputs.

Inputs

IN1 .. IN16 : REAL

Analog inputs

Outputs

OUT : REAL

Maximum value of all inputs


SAMA - High/Low Limiting

Limits the mimimum and maximum value of the input.

Inputs

IN : REAL

Analog input

Parameters

PMIN : REAL | Minimum value for the output
PMAX : REAL | Maximum value for the output

Outputs

OUT : REAL

= IN if PMIN <= IN <= PMAX

= PMIN if IN < PMIN

= PMAX if IN > PMAX


SAMA - Integral

Integrates the input signal. The output is limited by PMIN and PMAX parameters.

Inputs

IN : REAL

Analog signal

Parameters

TI : TIME | Integration time
PMIN : REAL | Minimum output value
PMAX : REAL | Maximum output value

Outputs

OUT : REAL

Integral signal limited to [PMIN .. PMAX]


SAMA - Logical Variable Signal Generator

Toggles the output on every change from 0 to 1 of the TOG parameter.

Parameters

TOG : UDINT

Toggle command

Outputs

Q : BOOL | Toggled when TOG changes from 0 to 1
STATUS : BOOL | equals to Q


SAMA - Two State Signal Monitor (lower limit)

Return TRUE if the input is greater than the specified minimum value.

Inputs

IN : REAL

Analog input

Parameters

PMIN : REAL

Minimum value

Outputs

OUT : BOOL

FALSE if IN > PMIN

TRUE otherwise


SAMA - Low Limiting

Limits the mimimum value of the input.

Inputs

IN : REAL

Analog input

Parameters

PMIN : REAL

Minimum value for the output

Outputs

OUT : REAL

= IN if IN >= PMIN

= PMIN if IN < PMIN


SAMA - Low Selecting

Select the minimum of two inputs. The block accepts from 2 to 16 inputs. Resize the block horizontally to get more or less inputs.

Inputs

IN1 .. IN16 : REAL

Analog inputs

Outputs

OUT : REAL

Minimum value of all inputs


SAMA - Manual Transfer

Select one of two inputs. Change is performed when the command "S" changes from FALSE to TRUE. The change rate is limited by the "RATE" parameter.

Inputs

IN1 .. IN2 : REAL

Analog inputs

Parameters

RATE : REAL | Maximum number of transitions per second
S : BOOL | Transition command

Outputs

OUT : REAL | IN1 or IN2. Change on every rising edge of S
STATUS : BOOL | TRUE when IN2 is selected


SAMA - Multiplying

Calculate the multiplication of inputs. The block accepts from 2 to 16 inputs. Resize the block horizontally to get more or less inputs.

Inputs

IN1 .. IN16 : REAL

Analog inputs

Outputs

OUT : REAL

Multiplication of all inputs


SAMA - Non Linear Function

Calculate linear interpolation within a list of points. Points must be sorted in the increasing order of their X coordinate. You can define from 2 to 8 points for interpolation.

Inputs

IN : REAL

Input - according to X axis

Parameters

X1 .. X8 : REAL | X coordinate of interpolation points
Y1 .. Y8 : REAL | Y coordinate of interpolation points

Outputs

OUT : REAL

Y interpolation of IN

Diagram


SAMA - NOT

Boolean negation.

Inputs

IN1 : BOOL

Boolean input

Outputs

Q : BOOL

TRUE if IN is FALSE / FALSE if IN is TRUE


SAMA - Time Delay of Termination

Off-Delay Timer. The timer starts on a falling pulse of IN input. It stops when the elapsed time is equal to the programmed time. A rising pulse of IN input resets the timer to 0. The output signal is set to TRUE on when the IN input rises to TRUE, reset to FALSE when programmed time is elapsed.

Inputs

IN : BOOL

Input trigger

Parameters

T : TIME | Duration
RST : BOOL | Reset command

Outputs

Q : BOOL

Output signal

Time diagram


SAMA - Time Delay of Initiation

On-Delay Timer. The timer starts on a rising pulse of IN input. It stops when the elapsed time is equal to the programmed time. A falling pulse of IN input resets the timer to 0. The output signal is set to TRUE when programmed time is elapsed, and reset to FALSE when the input command falls.

Inputs

IN : BOOL

Input trigger

Parameters

T : TIME | Duration
RST : BOOL | Reset command

Outputs

Q : BOOL

Output signal

Time diagram


SAMA - OR

Boolean OR. The block accepts from 2 to 16 inputs. Resize the block vertically to get more or less inputs.

Inputs

IN1 .. IN16 : BOOL

Boolean inputs

Outputs

Q : BOOL

TRUE if at least one of the inputs is TRUE


SAMA - PI Controller with Feed Forward

Perform a Proportional / Integral transfer function or the difference between the SP set point and PV process value. The Feed Forward value is added to the output signal. The final output is limited by PMIN and PMAX parameters.

Inputs

SP : REAL | Set point
PV : REAL | Process value
FF : REAL | Feed Forward

Parameters

KP : REAL | Proportional gain
TN : TIME | Reset time
PMIN : REAL | Minimum output value
PMAX : REAL | Maximum output value

Outputs

OUT : REAL

Controller output


SAMA - Proportional

Multiply the input and the P gain.

Inputs

IN1 : REAL

Analog input

Parameters

P : REAL

Gain

Outputs

OUT : REAL

IN1 * P


SAMA - Pulse Duration

Pulse Timer. The timer starts on a rising pulse of IN input. It stops when the elapsed time is equal to the programmed time. A falling pulse of IN input resets the timer to 0, only if the programmed time is elapsed. All pulses of IN while the timer is running are ignored. The output signal is set to TRUE while the timer is running.

Inputs

IN : BOOL

Input trigger

Parameters

T : TIME | Duration
RST : BOOL | Reset command

Outputs

Q : BOOL

Output signal

Time diagram


SAMA - Qualified Logical OR (=n)

Returns TRUE if exactly N inputs are TRUE. The block accepts from 3 to 16 inputs. Resize the block vertically to get more or less inputs.

Inputs

IN1 .. IN16 : BOOL

Boolean inputs

Parameters

N : DINT

Expected number of inputs

Outputs

Q : BOOL

TRUE if at exactly N inputs are TRUE


SAMA - Qualified Logical OR (>n)

Returns TRUE if at least N+1 inputs are TRUE. The block accepts from 3 to 16 inputs. Resize the block vertically to get more or less inputs.

Inputs

IN1 .. IN16 : BOOL

Boolean inputs

Parameters

N : DINT

Expected number of inputs

Outputs

Q : BOOL

TRUE if at least N+1 inputs are TRUE


SAMA - Qualified Logical OR (<n)

Returns TRUE if at most N-1 inputs are TRUE. The block accepts from 3 to 16 inputs. Resize the block vertically to get more or less inputs.

Inputs

IN1 .. IN16 : BOOL

Boolean inputs

Parameters

N : DINT

Expected number of inputs

Outputs

Q : BOOL

TRUE if at most N-1 inputs are TRUE


SAMA - Reverse Proportional

Multiply the input and the opposite of the P gain.

Inputs

IN : REAL

Analog input

Parameters

P : REAL

Gain

Outputs

OUT : REAL

IN * ( - P )


SAMA - Root Extraction

Calculate the Nth root of of the input.

Inputs

IN : REAL

Analog input

Parameters

N : DINT

Exponent

Outputs

OUT : REAL

Nth root of IN


SAMA - Memory (R dominant)

Reset dominant bistable.

Inputs

S : BOOL | SET command
R : BOOL | RESET command (dominant)

Outputs

Q : BOOL | Memory state
QN : BOOL | equals to NOT Q

Truth table

S | R | Q | Q
0 | 0 | unchanged | unchanged
0 | 1 | 0 | 1
1 | 0 | 1 | 0
1 | 1 | 0 | 1


SAMA - Memory (S dominant)

Set dominant bistable.

Inputs

S : BOOL | SET command (dominant)
R : BOOL | RESET command

Outputs

Q : BOOL | Memory state
QN : BOOL | equals to NOT Q

Truth table

S | R | Q | Q
0 | 0 | unchanged | unchanged
0 | 1 | 0 | 1
1 | 0 | 1 | 0
1 | 1 | 1 | 0


SAMA - Summing

Calculate the sum of inputs. The block accepts from 2 to 16 inputs. Resize the block horizontally to get more or less inputs.

Inputs

IN1 .. IN16 : REAL

Analog inputs

Outputs

OUT : REAL

Sum of all inputs


SAMA - Transfer

Select one of two inputs. The change rate is limited by the "RATE" parameter.

Inputs

IN1 .. IN2 : REAL | Analog inputs
S : BOOL | Selection bit

Parameters

RATE : REAL

Maximum number of transitions per second

Outputs

OUT : REAL

IN1 if S is FALSE

IN2 if S is TRUE


SAMA - Three State Signal Monitor

Return TRUE if the input is in outisde the specified minimum and maximum values.

Inputs

IN : REAL

Analog input

Parameters

PMIN : REAL | Minimum value
PMAX : REAL | Maximum value

Outputs

OUT : BOOL

FALSE if PMIN < IN < PMAX

TRUE otherwise


SAMA - Two State Signal Monitor (upper limit)

Return TRUE if the input is less than the specified maximum value.

Inputs

IN : REAL

Analog input

Parameters

PMAX : REAL

Maximum value

Outputs

OUT : BOOL

FALSE if IN < PMAX

TRUE otherwise


SAMA - Variable Signal Generator

Generate an analog signal according to UP/DN commands. The output value is limited by specified minimum and maximum values. Its change rate is also limited.

Parameters

PMIN : REAL | Minimum value
PMAX : REAL | Maximum value
RATE : REAL | Maximum number of changes per second
UP : BOOL | Increasing command
DN : BOOL | Decreasing command

Outputs

OUT : REAL | IN1 if S is FALSE IN2 if S is TRUE
STATUS : UDINT | Bitfield (see notes below)

The following bits of STATUS are available on output:

Bit 0 (LSB) - Value is increasing

Bit 1 - Value is decreasing

Bit 2 - Value is over-ranging the PMIN / PMAX range


SAMA - Velocity Limiter

Limit the rate of changes for an analog input.

Inputs

IN : REAL

Analog input

Parameters

RATE : REAL

Maximum number of changes per second

Outputs

OUT : REAL

Follows IN with the specified rate for changes


SET_DAY_TIME

Function - Sets the system time of Windows operating systems.

 | Data type | Description
Inputs |  |
TM | STRING | Input string for date and time. Format: 'DD.MM.YYYY HH:MM:SS'
SEL | BOOL | Sends the value of TM to the operating system with rising edge of this input.
Outputs |  |
Q | BOOL | TRUE if successful

Remarks

Setting the system time with this function can influence the cycle time heavily.

Set back the SEL input variable to FALSE right after the function call in order to avoid problems with the operating system.

The time on Input TM must be GMT/UTC time. The target system will calculate the local time via its time zone settings.

ST Language

Q := SET_DAY_TIME (TM, SEL);

FBD Language

LD Language

The function is executed only if EN is TRUE.
The output rung is the result of the function.
The output rung is FALSE if the EN is FALSE.

IL Language

Op1: LD TM
SET_DAY_TIME SEL
ST Q


SHLb / SHL_SINT / SHL_USINT / SHL_BYTE

Function - Shift bits of a register to the left.

Inputs

IN : SINT 8 bit register.
NBS : SINT Number of shifts (each shift is 1 bit).

Outputs

Q : SINT Shifted register.

Diagram

Remarks

In LD language, the input rung (EN) enables the operation, and the output rung keeps the state of the input rung. In IL language, the first input must be loaded before the function call. The second input is the operand of the function.

ST Language

Q := SHLb (IN, NBS);

FBD Language

LD Language

The shift is executed only if EN is TRUE.
ENO has the same value as EN.

IL Language

Op1: LD IN
SHLb NBS
ST Q

seealso See also

SHL SHR ROL ROR SHRb ROLb RORb SHLw SHRw ROLw RORw


SHLw / SHL_INT / SHL_UINT / SHL_WORD

Function - Shift bits of a register to the left.

Inputs

IN : INT 16 bit register.
NBS : INT Number of shifts (each shift is 1 bit).

Outputs

Q : INT Shifted register.

Diagram

Remarks

In LD language, the input rung (EN) enables the operation, and the output rung keeps the state of the input rung. In IL language, the first input must be loaded before the function call. The second input is the operand of the function.

ST Language

Q := SHLw (IN, NBS);

FBD Language

LD Language

The shift is executed only if EN is TRUE.
ENO has the same value as EN.

IL Language

Op1: LD IN
SHLw NBS
ST Q

seealso See also

SHL SHR ROL ROR SHLb SHRb ROLb RORb SHRw ROLw RORw


SHRb / SHR_SINT / SHR_USINT / SHR_BYTE

Function - Shift bits of a register to the right.

Inputs

IN : SINT 8 bit register.
NBS : SINT Number of shifts (each shift is 1 bit).

Outputs

Q : SINT Shifted register.

Diagram

Remarks

In LD language, the input rung (EN) enables the operation, and the output rung keeps the state of the input rung. In IL language, the first input must be loaded before the function call. The second input is the operand of the function.

ST Language

Q := SHRb (IN, NBS);

FBD Language

LD Language

The shift is executed only if EN is TRUE.
ENO has the same value as EN.

IL Language

Op1: LD IN
SHRb NBS
ST Q

seealso See also

SHL SHR ROL ROR SHLb ROLb RORb SHLw SHRw ROLw RORw


SHRw / SHR_INT / SHR_UINT / SHR_WORD

Function - Shift bits of a register to the right.

Inputs

IN : INT 16 bit register.
NBS : INT Number of shifts (each shift is 1 bit).

Outputs

Q : INT Shifted register.

Diagram

Remarks

In LD language, the input rung (EN) enables the operation, and the output rung keeps the state of the input rung. In IL language, the first input must be loaded before the function call. The second input is the operand of the function.

ST Language

Q := SHRw (IN, NBS);

FBD Language

LD Language

The shift is executed only if EN is TRUE.
ENO has the same value as EN.

IL Language

Op1: LD IN
SHRw NBS
ST Q

seealso See also

SHL SHR ROL ROR SHLb SHRb ROLb RORb SHLw ROLw RORw


Stop

Function - Stops the Runtime

 | Data type | Description
Inputs |  |
I | BOOL | Input to stop the Runtime
Outputs |  |
Q | BOOL | TRUE if successful.

Remarks

This function causes a stop of the Runtime.

ST Language

Q := Stop(I);

FBD Language

This function is available in FBD language.

LD Language

This function is available in LD language.

IL Language

Op1: LD I
Stop
ST Q


Terminate

Function - Terminates the Runtime

 | Data type | Description
Inputs |  |
I | BOOL | Input to terminate (close) the Runtime
Outputs |  |
Q | BOOL | TRUE if successful.

Remarks

This function causes a termination of the Runtime.

ST Language

Q := Terminate(I);

FBD Language

This function is available in FBD language.

LD Language

This function is available in LD language.

IL Language

Op1: LD I
Terminate
ST Q


updates

Stay informed about latest news and get the latest updates for the Integrated Development Environment. Follow this link for checking latest available updates for the workbench:

http://www.icpdas.com/root/product/solutions/softplc_based_on_pac/win-graf/win-graf.html