Declaring VAR_CONFIG section within a VarCfg-object
You require a VAR_CONFIG section to assign instance specific locations to symbolically represented variables. This section is possible within a →configuration as well as within a →resource.
This article describes the declaration of the VAR_CONFIG section within a VarCfg-object.
The declaration of the VAR_CONFIG section within a VarCfg-object allows you to collect the declaration in one or more central objects for the project. Subsequently, you just insert a reference where you will need the declaration – this will be a resource or a configuration.
This possibility is an enhancement to the →IEC-standard.
This possibility is an enhancement to the →IEC-standard.
Creating VarCfg-object
Create a VarCfg-object by using the command VarCfg-Object (e.g. in the context menu for a project, under New). In the wizard, you have to select whether the VAR_CONFIG section is intended to be referenced in a configuration or resource.
See "Creating new objects and folders" for generic information on creating the objects.
VAR_CONFIG section in VarCfg-object for central declaration
Insert the lines with the instance specific location assignment for symbolically represented variables within the automatically created VAR_CONFIG section of the opened VarCfg-object. These lines correspond to the lines as they are possible within a VAR_CONFIG section of an PLC-object. One VAR_CONFIG section is possible per VarCfg-object.
RES_VARCFG name_A | CFG_VARCFG name_B
VAR_CONFIG
name_1 AT %address (* optional_begin *) {SIZE := value} (* optional_end *);
name_2 AT %address (* optional_begin *) {SIZE := value} (* optional_end *);
name_3 AT %address (* optional_begin *) {SIZE := value} (* optional_end *);
END_VAR
END_RES_VARCFG | END_CFG_VARCFG
Meaning |
declaration of the VAR_CONFIG section, name_A and name_B must be an →IEC-identifier. As already indicated, the syntax for VAR_CONFIG ... END_VAR and their possibilities are analogous to a VAR_CONFIG section of an PLC-object. |
RES_VARCFG MyVarCfg1
VAR_CONFIG
iCounter.globVar1.Elem1 AT %IW1.2.3;
iCounter.globVar2a AT %IB1.4.6 {SIZE:=2};
valvePos1 AT %QW28;
END_VAR
END_RES_VARCFG
CFG_VARCFG MyVarCfg2
VAR_CONFIG
local.iCounter.globVar1.Elem2 AT %IW1.2.3;
local.iCounter.globVar2b AT %IB1.4.6 {SIZE:=2};
local.valvePos2 AT %QW28;
END_VAR
END_CFG_VARCFG
For these examples to be free of errors, provide the declarations of the corresponding variables and/or data types (see "Addendum for examples 1 to 3" under " Declaring VAR_CONFIG sections within PLC-object ").
Reference in a resource and/or configuration
In the PLC-object, insert the INCLUDE_VARCFG directives to reference the appropriate section in the VarCfg-object.
...
{ INCLUDE_VARCFG name_A}
END_RESOURCE
{ INCLUDE_VARCFG name_B}
END_CONFIGURATION
Insert the INCLUDE_VARCFG directive before the end of a resource (END_RESOURCE) or the end of a configuration (END_CONFIGURATION). But always insert the INCLUDE_GLOBALS directives in front of a possibly existing section VAR_CONFIG ... END_VAR.
CONFIGURATION LocalConfiguration
RESOURCE local ON BuiltInPlc { ON_CHANNEL := LocalChannel }
VAR_GLOBAL
valvePos1 : INT;
valvePos2 : INT;
END_VAR
TASK DefaultTask ( INTERVAL := TIME#500ms , PRIORITY :=
38229
);
PROGRAM iCounter WITH DefaultTask : Counter;
{ INCLUDE_VARCFG MyVarCfg1} (* reference to instance specific location assignment
for
the variables declared in
'MyVarCfg1'
*)
END_RESOURCE
{ INCLUDE_VARCFG MyVarCfg2} (* reference to instance specific location assignment
for
the variables declared in
'MyVarCfg2'
*)
END_CONFIGURATION