Declaration of global variables in ST
VAR_GLOBAL (* optional_begin *) {DMA :=
'string'
} CONSTANT RETAIN NON_RETAIN (* optional_end *)
name_1, name_2, ..., name_n (* optional_begin *) {
'key'
} AT %address (* optional_end *) : data-type := initial-value;
name_3, name_4, ..., name_n (* optional_begin *) {
'key'
} AT %address (* optional_end *) : STRING[length] :=
'initial-value'
;
name_5, name_6, ..., name_n (* optional_begin *) {
'key'
} AT %address (* optional_end *) : ARRAY [x..y] OF type := [initial-value_1, initial-value_2, .., initial-value_n];
name_7, name_8, ..., name_n (* optional_begin *) {
'key'
} AT %address (* optional_end *) : ARRAY [x1..y1, x2..y2, x3..y3] OF data-type; (* Here, initial values are possible as well. *)
END_VAR
Meaning |
|||||||||||||||||||||||||||||||||||||||||||||||||
declaration of one or more →global variables, name_1, name_2 etc. must be →IEC-identifiers. Enhancement to IEC-standard This is an enhancement to the →IEC-standard which allows only one such section for resource-global or configuration-global variables. Moreover, it is possible to declare global variables within a global-object and to insert here just a reference (observe that the syntax elements might differ). The declaration of program-global variables is possible within an ST-object, in particular within the declaration of program. Access to such global variables is done in the context of other →POUs (FUNCTION, FUNCTION_BLOCK) – by using →external variables. The declaration of resource-global variables or configuration-global variables is possible within a PLC-object, in particular within the declaration of a →resource or of a →configuration. Access to such global variables is done in the context of POUs (PROGRAM, FUNCTION, FUNCTION_BLOCK) – also by using external variables. See "Declaring global variables for resource or configuration and using them". The optional attributes DMA (= Direct Memory Access) and key are intended for system integrators. Providing the optional keyword CONSTANT prevents all global variables of this section from being overwritten during program execution (makes them →constants). See "Supported data types" to learn which data types are supported for the declaration of variables. Use the optional →initial value [:= initial-value] to assign a value to the variable (see "Initialization of variables in ST" for details).
Use the optional keyword AT to assign a physical address in the →PLC to the symbolic variable. Examples for physical addresses:
If you are using EtherCAT fieldbuses that can be addressed via →EC-Master and →EC-Engineer, see "Accessing hardware IOs via EC-Master and EC-Engineer of Acontis" for information on access of their hardware IOs. Enter a physical address according to this structure:
|
Moreover, logi.CAD 3 allows you to specify additional data for the declaration . See " Defining description, comment or JSON string for variables and data types " for details.
VAR_GLOBAL
portSetting : INT;
upTime : TIME;
gVar1: ARRAY [
1
..
2
] of BOOL;
gVar2 : STRING[
10
];
END_VAR
VAR_GLOBAL
VALVE_POS AT %QW28 : INT;
END_VAR