ADR

Overview

This address operator is not specified by the standard IEC 61131-3.

ADR returns the address of its argument in a DWORD. This address can be assigned to a pointer within the project.

NOTE: EcoStruxure Machine Expert allows you to use the ADR operator with function names, program names, function block names, and method names.

Refer to the chapter Pointers and consider that function pointers can be passed to external libraries. Nevertheless, there is no possibility to call a function pointer within EcoStruxure Machine Expert. In order to enable a system call (runtime system), set the respective object property (in the menu View > Properties... > Build) for the function object.

Example in ST

VAR
        piAddress1: POINTER TO INT;
        iVar1 : INT := 5;

        lwAddress2 : LWORD;
        iVar2 : INT := 10;

        xwAddress3 : _XWORD;
        iVar3 : INT;
END_VAR
piAddress1 := ADR(iVar1); // piNumber is assigned to address of iVar1
lwAddress2 := ADR(iVar2); // works for 64 bit run time system
xwAddress3 := ADR(iVar3); // works for 32 bit and 64 bit systems

Example in IL

LD     bVar
ADR
ST     dwVar

Considerations for Online Changes

Executing the command Online Change can move variables to another place in the memory. There is an indication during online change if copying is necessary.

The shift of variables may have the effect that POINTER TO variables point to invalid memory.

 WARNING
UNINTENDED EQUIPMENT OPERATION
Assign the value of any POINTER TO type variable(s) prior to the first use of it within a POU, and at every subsequent cycle.
Failure to follow these instructions can result in death, serious injury, or equipment damage.
NOTE: POINTER TO variables of functions and methods should not be returned to the caller of this function or passed to global variables.