Variables Configuration - VAR_CONFIG
You can use the variable configuration to map function block variables on the process image that is on the device I/Os. This avoids the need of specifying the definite address already in the declaration of the function block variable. The assignment of the definite address in this case is done centrally for all function block instances in a global VAR_CONFIG list.
For this purpose, you can assign incomplete addresses to the function block variables declared between the keywords VAR and END_VAR. Use an asterisk to identify these addresses.
<identifier> AT %<I|Q>* : <data type>
Example of the use of incompletely defined addresses:
FUNCTION_BLOCK locio
VAR
xLocIn AT %I*: BOOL := TRUE;
xLocOut AT %Q*: BOOL;
END_VAR
In this example, 2 local I/O variables are defined: a local input (%I*) and a local output variable (%Q*).
Define the addresses in the variable configuration in a global variable list (GVL) as follows:
Step |
Action |
---|---|
1 |
Execute the Add Object command. |
2 |
Add a Global Variable List (GVL) object to the Devices Tree. |
3 |
Enter the declarations of the instance variables with the definite addresses between the keywords VAR_CONFIG and END_VAR. |
When defining the addresses, note the following:
oSpecify the instance variables by the complete instance path and separate the individual POUs and instance names from one another by periods.
oIn the declaration, enter an address whose class (input/output) corresponds to that of the incomplete specified address (%I*, %Q*) in the function block.
oVerify that the data type agrees with the declaration in the function block.
<instance variable path> AT %<I|Q><location> : <data type>;
Configuration variables whose instance path is invalid because the instance does not exist are denoted as detected errors. An error is also detected if no definite address configuration exists for an instance variable assigned to an incomplete address.
Example for a variable configuration
Assume that the following definition for function block locio - see the previous example - is given in a program:
PROGRAM PLC_PRG
VAR
locioVar1: locio;
locioVar2: locio;
END_VAR
Then a corrected variable configuration (in a global variable list) will be:
VAR_CONFIG
PLC_PRG.locioVar1.xLocIn AT %IX1.0 : BOOL;
PLC_PRG.locioVar1.xLocOut AT %QX0.0 : BOOL;
PLC_PRG.locioVar2.xLocIn AT %IX1.0 : BOOL;
PLC_PRG.locioVar2.xLocOut AT %QX0.3 : BOOL;
END_VAR
NOTE: Changes on directly mapped I/Os are immediately shown in the process image, whereas changes on variables mapped via VAR_CONFIG are not shown before the end of the responsible task.
NOTE: In a global variable list, the keywords VAR_GLOBAL and VAR_CONFIG can only be used exclusively.