Editing variables as text using IEC61131-3 syntax
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.
|
MyVar : BOOL; |
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.
|
Array1 : ARRAY [0 .. 99] OF DINT; |
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.
|
MyBool : BOOL := TRUE; |
Additional information and description texts
As a variable may have additional properties and comment texts in the Workbench Studio, 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 text using IEC61131-3 syntax |
IEC 61131-3 Automation platform > IEC 61131-3 Programming Environment > Variable Editor > Editing variables as text > Editing variables as text using IEC61131-3 syntax |
Created with the Personal Edition of HelpNDoc: Benefits of a Help Authoring Tool