Creating new variables
There are different options to create a new variable:
- Via a click on the Add variable context menu entry of the selected variable group. The variable is added at the end of the group.
- Via a click on the INSERT key, if a variable group is selected in the variable window. The variable is added at the end of the group.
Hint: In both cases the variables are created with a default name. You can rename the new variable or change its attribute using the variable editing grid. - Via the variable creation dialog. The dialog will be opened if you enter a new variable name for a variable, which does not exist.
Example: Enter a name for a new variable in a function block input and click on OK. The variable creation dialog will be opened.
Variable creation dialog
The dialog allows to create a new variable and to define all relevant settings. The property Declare a new variable is preselected and cannot be changed.
The dialog view can be extended or collapsed.
Parameter |
Description |
Name |
Name of the variable. The name is greyed out and cannot be changed in the dialog. Hint: If the Rename variable property is set, the Name textfield is not greyed out and can be edited. This property is available during the usage of fieldbus configuration actions and if you are trying to rename an existing symbol. |
Type |
Datatype of the variable. Hint: If the datatype STRING is selected, it is possible to enter the number of characters in a seperate field. |
Where |
Location, where the variable is stored. Default: Local to current program |
Description |
Textfield for additional information. |
Init value |
Initial value of the variable. Hint: Cannot be set, if the variable is an array. |
User Group |
Part of the description (comment). Can be used as tag in the variable editor to filter or sort variables. |
Tag |
Short comment or description. Can be displayed with the variable name in graphic languages. |
Advanced
Parameter |
Description |
Read Only |
Defines, if the variable can be edited or not. |
INOUT |
Relevant for UDFBs and Subprogram inputs only. The input can be changed, when the block is called (like in the reference in C-language). Hint: Only available, when an UDFB/subprogram input is edited. |
Syb. |
Activates the Checkbox of the property Syb. in the variable editor. |
Dim. |
Number of the arrays. |
Navigation
Parameter |
Description |
Show more |
Expands the dialog view. |
Show less |
Collapses the dialog view. |
Yes |
Confirmes the settings and closes both dialogs. |
No |
Closes both dialogs. |
Cancel |
Closes the dialog without changes. |
Help |
Opens the corresponding Help topic. |
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.
Limitations
|
The amount of variables which can be served in total by an application, ultimately depends on the used target system. It can be further limited by the available application memory (RAM), which is available for all project resources altogether. Also, the supported quantity of RETAIN variables can be limited specifically. Please consider the specification of your OEM target system in use. |
Specific variable types are stored in dedicated memory segments. Each segment is limited to 65534 variables. The error message at the end of compiling indicates an overflow (> 64534) in the segment:
XXX: Too many variables declared
where XXX indicates the segment. The following list shows the allocation of data types to the corresponding segments:
- FB: instances of C or standard function blocks
- BOOL/SINT: variables of type BOOL and 8 bits type: SINT, USINT and BYTE
- INT: 16 bits variables - type INT, UINT and WORD
- DINT/REAL: 32 bits variables - type DINT, UDINT, DWORD and REAL
- LINT/LREAL: 64 bits variables - type LINT, ULINT, LWORD and LREAL
- TIME: variables of type TIME
- STRING: variables of type STRING , regardless of the size of the STRING.
Each simple type variable counts for an item in the above mentioned segments. The segment-wise limits represent the total limit per project – regardless if the variable is declared for a POU (local), GLOBAL or RETAIN.
Hint: you can check the current quantities of variables and FB instances in all segments - in the configuration dialog of Online Change, when you (temporarily) enable it. This dialog is in menu Project - Settings... - General- Online Change: Enable; and after check you can disable it.
Limitations - Structures and Arrays
The effective limit for structures and arrays depends on the storage and handling of the related datapoints. These can either be managed in the basic segments (see limits above), or in a separate segment.
The related option is: Complex variables in separate segment
- Value = No:
Structure- and array members are managed in basic memory segments. Limits are according to the above mentioned total number of variables per segment. - Value = Yes:
Structures and arrays are managed in a separate memory segment. The maximum number of variables in this segment is mainly limited by the available memory for this segment, as provided by the target Runtime Service. In any case, there is a total limit of approx. 4GB, based on 32-bit addressing in this segment.
In addition, there is a maximum array size of 10000000 elements.
Examples:
- 2 dimensions e.g. 256x255 = 65280 => OK
- 2 dimensions e.g. 256x100x1000 = 25600000 => ERROR
Creating new variables |
IEC 61131-3 Automation platform > IEC 61131-3 Programming Environment > Editing programs > Selecting function blocks > Creating new variables |
Created with the Personal Edition of HelpNDoc: Make Documentation a Breeze with HelpNDoc's Clean and Efficient User Interface