Description of the function
The SET_VAL
function is used to
transfer data form a variable to another.
Public and Private variables are accessible by the EF and the variable path is taken from the Global variables.
PROCESS
scope according to the current location of the SET_VAL
instance.The additional parameters EN
and ENO
can also be configured.
OS Version Requirement
To use this EF in an application, the minimum required OS version for the CPU is:
Platform |
Minimum OS version |
---|---|
M340 |
3.30 |
M580 |
3.20 |
FBD representation

LD representation

IL representation
Representation:
CAL SET_VAL (WRITE_REQ := Write, DEST :=
VariablePath, DATA := InputValue, ERROR => SetValError, OUT => OutputValue)
ST representation
Representation:
SET_VAL (WRITE_REQ := Write, DEST := VariablePath,
DATA := InputValue, ERROR => SetValError, OUT => OutputValue);
Parameter Description
The following table describes the input parameters:
Parameter |
Data Type |
Significance |
---|---|---|
|
|
Set to 1, it writes the value from
the DATA parameter to the variable addressed
by the DEST parameter and move it to the Set to 0, it reads the variable value addressed by the DEST parameter and move it to the OUT parameter. |
|
|
Path of the variable to be written
with Example: 'MyVar.subfield[6]'. If variable path starts with
'.' character, the path is relative to the current location of the
NOTE: Variable of type DDT that contains BOOL with extracted bit definition
is not supported in the , so variable of this type will not be seen by input,
and output parameters of the EF.
|
|
|
Data to be written to the variable
identified in the |
(1) With
restrictions. The following data types mapped on (2) EBOOL and BOOL data types can be mixed. (3) STRING data types of different size can be mixed. (4) Except ARRAY |
The following table describes the output parameters:
Parameter |
Data Type |
Significance |
---|---|---|
|
|
Set to 1 in case of detected error. |
|
|
Provides the value of the variable
specified by the |
(1) With
the same restrictions than (2) EBOOL and BOOL data types can be mixed. (3) STRING data types of different size can be mixed. |
DATA
value and OUT
value,
and the variable addressed by DEST
value must match. The data type for DATA
is checked by the EF while the data type for DEST
is checked at runtime.Project Settings
The SET_VAL
EF can retrieve
variable definition in the PLC.
Enabling the option
allows access to private variables.For more detailed information refer to chapter Project Settings.
Error Codes
In case of detected error during the block execution, a message is displayed in the diagnostic buffer, which indicates the application error code.
The following table describes the detected application error codes:
Detected error code |
Description |
---|---|
APPLICATION ERROR 1 |
DEST parameter is a null string |
APPLICATION ERROR 2 |
DEST parameter is too long (>1000 characters) |
APPLICATION ERROR 3 |
DEST and DATA Type mismatch |
APPLICATION ERROR 4 |
Variable or field is not found in data dictionary |
APPLICATION ERROR 5 |
Variable path syntax error |
APPLICATION ERROR 6 |
Variable type is not an array |
APPLICATION ERROR 7 |
Array out of bounds |
APPLICATION ERROR 8 |
Array variable has too many subscripts |
APPLICATION ERROR 9 |
Array dimensions exceed the max supported |
APPLICATION ERROR 10 |
Extracted bit is not supported on variable type |
APPLICATION ERROR 11 |
Invalid extracted bit rank |
APPLICATION ERROR 12 |
Variable is read only |
APPLICATION ERROR 13 |
The data dictionary is not present in the application, enable it in the project settings |
APPLICATION ERROR 15 |
Internal error with sub-code |