AT Declaration

Overview

In order to link a project variable with a definite address, you can assign variables to an address in the I/O Mapping view of a device in the controller configuration (device editor). Alternatively you can enter this address directly in the declaration of the variable.

Syntax

<variable name> AT <address> : <data type>;
<address> : %<memory area prefix> ( <size prefix> )? <memory position

A valid address has to follow the keyword AT. For further information, refer to the Address description. Consider possible overlaps in case of byte addressing mode.

This declaration allows assigning a meaningful name to an address. Any changes concerning an incoming or outgoing signal may only be done in a single place (for example, in the declaration).

Consider the following when choosing a variable to be assigned to an address:

  • Variables requiring an input cannot be accessed by writing. The compiler intercepts this detecting an error.

  • AT declarations only can be used with local or global variables. They cannot be used with input and output variables of POUs.

  • AT declarations are not allowed in persistent variable lists.

  • If AT declarations are used with structure or function block members, all instances will access the same memory location of this structure / function block. This corresponds to static variables in classic programming languages such as C.

  • The memory layout of structures is determined by the target as well.

Examples

xCounterHeat7 AT %QX0.0: BOOL;
xLightCabinetImpulse AT %IX7.2: BOOL;
xDownload AT %MX2.2: BOOL;

Note

If boolean variables are assigned to a BYTE, WORD or DWORD address, they occupy 1 byte with TRUE or FALSE, not just the first bit after the offset.

The memory size for input, output, and memory data (declarations with AT %I, %Q and %M) is predefined by the target device and can be overwritten in the properties of an application object for PacDrive controllers (PacDrive LMC Eco, PacDrive LMC Pro/Pro2).