Introduction

What is a data instance reference?

At a Glance

It is only possible to reference a data instance by address for certain data instances that belong to the EDT family. These instances are:

  • internal variables (%M<i>, %MW<i>, %MD<i>, %MF<i>)

  • constants (%KW<i>, %KD<i>, %KF<i>)

  • inputs/outputs (%I<address>, %Q<address>)

NOTE: Instances %MD<i>, %MF<i>, %KD<i>, and %KF<i> are not available for Modicon M340 and Modicon M580.

Reference by Direct Addressing

Addressing is considered direct when the address of the instance is fixed, or, in other words, when it is written into the program.

Examples:

References by Indexed Address

Addressing is considered indexed when the address of the instance is completed with an index.

The index is defined either by:

  • a value belonging to an Integer type

  • an arithmetical expression made up of Integer types

An indexed variable always has a non-indexed equivalent:

The rules for calculating <j> are as follows.

Object<i>[index]

Object<j>

%M<i>[index]

<j>=<i> + <index>

%MW<i>[index]

<j>=<i> + <index>

%KW<i>[index]

<j>=<i> + <index>

%MD<i>[index]

<j>=<i> + (<index> x 2)

%KD<i>[index]

<j>=<i> + (<index> x 2)

%MF<i>[index]

<j>=<i> + (<index> x 2)

%KF<i>[index]

<j>=<i> + (<index> x 2)

Examples:

During compilation of the program, a check verifies that:

  • the index is not negative

  • the index does not exceed the space in the memory allocated to each of these three data types

Word Extract Bits

It is possible to extract one of the 16 bits of single words (%MW, %SW; %KW, %IW, %QW).

The address of the instance is completed with the rank of the extracted bit (<j>).

Examples:

Byte Extract Bits

It is possible to extract one of the bits of a byte

The address of the extracted bit is accessible via:

  • The name of the corresponding byte.

  • The rank defining its position in the byte. (a number between 0 and 7)

Example:

MyByte is a variable of type BYTE. MyByte.i is a valid BOOL if 0 <= i <= 7

MyByte.0, MyByte.3 and MyByte.7 are valid BOOL.

MyByte.8 is invalid.

Creating a Structure type with extracted bit

The user can create structure type using extracted bit.

The Bit Rank dialog box is accessible by right clicking on the instance or data type which type must be:

  • WORD

  • UINT

  • INT

  • BYTE

  • an extracted bit with a compatible parent

Bit and Word Tables

These are a series of adjacent objects (bits or words) of the same type and of a defined length.

Presentation of bit tables:

Type

Address

Write access

Discrete I/O input bits

%Ix.<i>:L

No

Discrete I/O output bits

%Qx.<i>:L

Yes

Internal bits

%M<i>:L

Yes

Presentation of word tables:

Type

Address

Write access

Internal words

%MW<i>:L

%MD<i>:L

%MF<i>:L

Yes

Constant words

%KW<i>:L

%KD<i>:L

%KF<i>:L

No

System words

%SW50:4

Yes

Examples:

  • %M2:65 Defines an EBOOL table from %M2 to %M66

  • %M125:30 Defines an INT table from %MW125 to %MW154