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.

NOTE: For a safety application, the variable path is taken from 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

WRITE_REQ

BOOL

Set to 1, it writes the value from the DATA parameter to the variable addressed by the DEST parameter and move it to the OUT parameter.

Set to 0, it reads the variable value addressed by the DEST parameter and move it to the OUT parameter.

DEST

STRING

Path of the variable to be written with DATA input parameter value.

Example: 'MyVar.subfield[6]'.

If variable path starts with '.' character, the path is relative to the current location of the SET_VAL instance.

  • For example when SET_VAL is used within a DFB it can access any variable from this DFB (outputs(4), public, private, private DFB instances) with syntax .MyVar.

  • For example when SET_VAL is used within a Program Unit it can access any variable from this Program Unit (public, private, private DFB instances) with syntax .MyVar.

NOTE: Variable of type DDT that contains BOOL with extracted bit definition is not supported in the Data dictionary , so variable of this type will not be seen by input, and output parameters of the EF.

DATA

ANY (1) (2) (3)

Data to be written to the variable identified in the DEST input. If DATA input is not connected, the default value written is zero.

(1) With restrictions. The following data types mapped on ANY are not supported: IODDT instance, Device DDT instance, DDT instance that contains reference (REF), and ARRAY OF EBOOL, EFB and DFB.

(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

ERROR

BOOL

Set to 1 in case of detected error.

OUT

ANY (1) (2) (3)

Provides the value of the variable specified by the DEST input at all times.

(1) With the same restrictions than DATA parameter.

(2) EBOOL and BOOL data types can be mixed.

(3) STRING data types of different size can be mixed.

NOTE: The data types of the 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 Data dictionary must be enabled in order that SET_VAL EF can retrieve variable definition in the PLC.

Enabling the option Include DFB/PU private variables 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