Function Description

The WRITE_REMOTE function is used to write the value of remote variables that are then exchanged between PLC applications.

When the EN input value is TRUE:

  • The WRITE_REMOTE communication function block allows to exchange the variable value between PLCs. Both located and unlocated variables can be written

  • It is possible to write any type of a named remote variable (located and unlocated) based on the variable name

  • The number of pins related to variables selection is fixed and cannot be modified by the user: 14 pins to specify local variables and 14 pins to specify remote variables. It is not required to connect all input and output pins.

NOTE: Names of remote variables specified in the R_VAR_x parameter can be modified during the runtime. This lead to relaunch the data verification process between the local and the remote PLCs.

The additional parameters EN and ENO can be configured.

CPU Firmware Limitation

The WRITE_REMOTE block is supported by:

  • M580 CPU with OS version V3.20 or later

  • M340 CPU with OS version V3.30 or later

To allow type verification based on checksum comparison (refer to Data Type Control), remote CPU must have following minimum firmware version:

  • M580 CPU with OS version V3.20 or later

  • M340 CPU with OS version V3.30 or later

NOTE: It is possible to exchange variables with a remote M580 or M340 CPU having an earlier firmware or another CPU supporting the Data Dictionary feature by de-activating the type verification based on checksum comparison using the CTRL parameter.

FBD Representation

Representation:

LD Representation

Representation:

IL Representation

Representation:

CAL WRITE_REMOTE_Instance CTRL:=WriteRemote_Control, ENABLE:=WriteRemote_Enable, ADDR:=Address, ABORT:=WriteRemote_Abort, R_VAR_1:=RemoteVariable_1, ..., R_VAR_14:=RemoteVariable_14, L_VAR_1=>LocalVariable_1, ..., L_VAR_14=>LocalVariable_14, DONE=>WriteRemote_Done, ACTIVE=>WriteRemote_Active, ERROR=>WriteRemote_ExecutionError, STATUS=>ErrorCode, EXT_STATUS=>ExtendedErrorCode)

ST Representation

Representation:

CAL WRITE_REMOTE_Instance (CTRL:=WriteRemote_Control, ENABLE:=WriteRemote_Enable, ADDR:=Address, ABORT:=WriteRemote_Abort, R_VAR_1:=RemoteVariable_1, ..., R_VAR_14:=RemoteVariable_14, L_VAR_1=>LocalVariable_1, ..., L_VAR_14=>LocalVariable_14, DONE=>WriteRemote_Done, ACTIVE=>WriteRemote_Active, ERROR=>WriteRemote_ExecutionError, STATUS=>ErrorCode, EXT_STATUS=>ExtendedErrorCode);

Parameter Description

The following table describes the input parameters:

Parameter

Type

Comment

CTRL

ARRAY_INT [0..3]

Control input parameter:

  • INT [0]: TIMEOUT maximum time to wait for the end of the WRITE_REMOTE function execution (in milliseconds)

  • INT [1]: set to 1 if the remote CPU firmware version is earlier than V3.30 for M340 and V3.2 for M580

NOTE: The type verification via the type checksum is not done in case of INT [1]. This verification only relies on the type length (for example, types of local and remote variables are considered as consistent if they have the same size in bytes).

ENABLE

BOOL

The function is performed when this parameter is ON.

ABORT

BOOL

The function is not performed (aborted) when this parameter is ON.

ADDR

ANY_ARRAY_INT

Array containing the PLC address, result of:

R_VAR_i

STRING

Identification (symbolic name) of a remote variable.

L_VAR_i

ANY

A local variable which is used to write the value to the remote device.

NOTE: The type of a local variable must match the type of a remote variable (see Data Type Control below).

The following table describes the output parameters:

Parameter

Type

Comment

DONE

BOOL

The requested function is properly performed and validated.

ACTIVE

BOOL

TRUE if the execution of the function block is in progress (writing the remote variable descriptors and their values).

ERROR

BOOL

A new non-zero status is received.

STATUS

INT

Provides the error code if an error is detected by the function block.

NOTE: The value of the STATUS parameter is 0 only if the value of the EXT_STATUS parameter is 0 for each variable access.

EXT_STATUS

ARRAY [1..14] OF INT

Provides the extended error code if an error is detected by the function block: one status for each variable access.

Rules of Use

The following remote data are supported by this function:

  • Elementary variables

  • Arrays (tables)

  • DDT instances without references (indirection kind =1)

The following types of syntax are supported:

  • MyVar

  • MyArray[2]

  • MyDdtArray[4].elem1

NOTE: The Array index must be an immediate value.
NOTE: A remote variable is addressed by its name or by its path name. For example, MyVar[2].elem1.

The WRITE_REMOTE communication function block writes first the definition, address and type of remote variables, and only then it writes variables themselves. This rule also applies to online modifications of the PLC server data, such as removing a variable or an FB instance.

The Data dictionary function must be activated both by a client PLC and by a server PLC.

The WRITE_REMOTE communication function block must be called and executed from the MAST, FAST, AUX0, or AUX1 task.

The allowed character set for a remote variable is Standard. If an Extended or Unicode character is used for a remote variable, then an error is detected and the “Variable is not found” message appears in the OFS server.

If the Only HMI variables setting is used in the Data dictionary (Tools > Project Setting > PLC embedded data ), the HMI variable attribute must be selected for variables exchanged with the WRITE_REMOTE function block. This is done either in a local application, or in a remote application.

NOTE: The Only HMI variables setting doesn’t have to be identical both in a local and in a remote applications.

Data Type Control

The WRITE_REMOTE communication function block writes variables with identical data types.

The Data Type control between local and remote variables is performed by default and applies to:

  • EDT

  • DDT

  • DDT ARRAY

  • Anonymous ARRAY

The control for User Type is done by the identical type checksum and by the type length.

Exported attributes of the defined source format are checked in the course of the identical type checksum control.

A minimum control for consistency based on the type length is always performed, while local and remote variables must have the same size in bytes.

The control by the type name is not performed due to the difference in definitions used by the client PLC and the PLC server.

To deactivate the Data Type control, use the CTRL parameter. Only the Data Type control based on the identical type checksum can be deactivated via the CTRL parameter.

NOTE: The STRING and STRING[n] Data Types are considered identical even if the string size is different. Only characters corresponding to the minimum length of local and remote variables are exchanged. The string truncation is performed only for string variables (STRING or STRING[n]). This rule does not apply for string variables inside DDTs.
NOTE: Premium and Quantum CPU family do not share the same memory alignment scheme as M580 and M340 family. DDT or array variables may not exchange correctly, completing with code 16#1309 (Length mismatch) in corresponding EXT_STATUS field. In order to avoid incorrect data exchange, DDT type in Premium or Quantum have to be modified. For more explanation refer to chapter DDT: Mapping Rules. Control Expert may indicates at build time where the alignment seems to be different. To enable this option, modify the property DDT mapping compatibility generates in Project Settings.

Hot Standby Mode Behavior

In the Hot Standby mode, WRITE_REMOTE performs the same way as other communication function blocks. Same programming rule should be followed as described in Asynchronous Communication Function Block.

When a switchover occurs, the IP address of the PLC target is switched over in the PLC server while the ongoing request is restarted in the Standby mode. Thus, the communication with the WRITE_REMOTE function block is restored and continues in a normal way.

NOTE: The definition of a remote variable is communicated to the Standby PLC together with the internal state of the WRITE_REMOTE communication function block.

PLC Simulator

The WRITE_REMOTE communication function block can be used with the PLC simulator of ongoing communication requests. Refer to EcoStruxure™ Control Expert, PLC Simulator for details.

Limitations

The following data mapped on ANY data type are not supported by this function:

  • IODDT instances

  • Device DDT instances containing EBOOL

  • DDT instances with a reference (indirection kind =1)

  • Arrays of EBOOL, EFB, and DFB

NOTE: This is the same behavior for the ANY parameter.

Other limitations:

  • The maximum number of variables is 14

  • The request size must not exceed 1 Kb. This means:

    • The total size of exchanged data must be less than 1 Kb

    • The sum of all strings described in all variable paths must be less than 1010 Bytes

    • If the request size is > 1 Kb, a status error is raised

  • The response time depends on the PLC cycle time and it is limited to the timeout value specified in the first word of the CTRL parameter.