At a Glance

The DDTs are stored in the memory of the PLC in the order in which its elements are declared.

However, the following rules apply.

Principle for Premium and Quantum

The storage principle for Premium and Quantum is as follows:

  • the elements are stored in the order in which they are declared in the structure,

  • the basic element is the byte (alignment of data on the memory bytes),

  • each element has an alignment rule:

    • the BOOL and BYTE types are indiscriminately aligned on the odd or even bytes,

    • all the other elementary types are aligned on the even bytes,

    • the structures and tables are aligned according to the alignment rule for the BOOL and BYTE types if they only contain BOOL and BYTE elements, otherwise they are aligned on the memory's even bytes.

Principle for Modicon M340, M580, and Momentum

The storage principle for these PLCs is as follows:

  • elements are stored in the order in which they are declared in the structure,

  • the basic element is the byte,

  • one alignment rule and function of the element:

    • the BOOL and BYTE types are aligned on either even or uneven bytes,

    • the INT, WORD and UINT types are aligned on even bytes,

    • the DINT, UDINT, REAL, TIME, DATE, TOD, DT and DWORD are aligned on double words,

    • structures and tables are aligned according to the rules of their elements.

NOTE: It is possible that the alignment of data are not the same when the project is transferred from the simulator of Control Expert to a M340, M580, or Momentum PLC. So check the structure of the data of the project.
NOTE: Control Expert indicates where the alignment seems to be different. Check the corresponding instances in the data editor. See the page of Project settings to know how enable this option.

Modicon M580 Device DDT Alignment for I/O Scanning

Two modes of I/O scanning are proposed:

  • Legacy I/O scanning mode (used in Unity Pro ≤ V11.1) creates Device DDT structures aligned on 32 bits by default.

  • Enhanced I/O scanning mode (compatible for applications created with Unity Pro ≥ V12.0) creates Device DDT structures aligned on 16 bits by default.

NOTE:

Unity Pro is the former name of Control Expert for version 13.1 or earlier.

To keep the original alignment for applications created for Unity Pro ≤ V11.1, select the legacy I/O scanning mode.

Alignment mismatch illustration for Modbus TCP device:

  • Example of arrangement in legacy mode (32 bits alignment, array of 4 x BYTE). When 3 INT are transmitted, the structure in legacy mode creates 2 empty bytes that need to be considered in the global structure interpretation.

  • Example of arrangement in enhanced mode (16 bits alignment, array of INT). When 3 INT are transmitted, no empty bytes are added by the system, all the data in the structure are useful.

Examples

The following table gives some examples of data structures. In the following examples, structure type DDTs are addressed to %MWi. The word’s first byte corresponds to the least significant 8 bits and the word’s second byte corresponds to the most significant 8 bits.

For all the following structures, the first variable is mapped to the address %MW100:

First Memory Address

Description of the structure

Modicon M340, M580 or Momentum

Premium

Para_PWM1

%MW100 (first byte)

%MW100 (first byte)

 

t_period: TIME

%MW102 (first byte)

%MW102 (first byte)

 

t_min: TIME

%MW104 (first byte)

%MW104 (first byte)

 

in_max: REAL

       
   

Mode_TOTALIZER

%MW100 (first byte)

%MW100 (first byte)

 

hold: BOOL

%MW100 (second byte)

%MW100 (second byte)

 

rst: BOOL

       
   

Info_TOTALIZER

%MW100 (first byte)

%MW100 (first byte)

 

outc: REAL

%MW102 (first byte)

%MW102 (first byte)

 

cter: UINT

%MW103 (first byte)

%MW103 (first byte)

 

done: BOOL

%MW103 (second byte)

%MW103 (second byte)

 

Reserved for the alignment

The table below gives two examples of data structures with arrays:

First Memory Address

Description of the structure

Modicon M340, M580 or Momentum

Premium

EHC105_Out

%MW100 (first byte)

%MW100 (first byte)

 

Quit: BYTE

%MW100 (second byte)

%MW100 (second byte)

 

Control: ARRAY [1..5] OF BYTE

%MW104 (first byte)

%MW103 (first byte)

 

Final: ARRAY [1..5] OF DINT

       
   

CPCfg_ex

%MW100 (first byte)

%MW100 (first byte)

 

Profile_type: INT

%MW101 (first byte)

%MW101 (first byte)

 

Interp_type: INT

%MW102 (first byte)

%MW102 (first byte)

 

Nb_of_coords: INT

%MW103 (first byte)

%MW103 (first byte)

 

Nb_of_points: INT

%MW104 (first byte)

%MW104 (first byte)

 

reserved: ARRAY [0..4] OF BYTE

%MW106 (second byte)

%MW106 (second byte)

 

Reserved for the alignment of variable Master_offset on even bytes

%MW108 (first byte)

%MW107 (first byte)

 

Master_offset: DINT

%MW110 (first byte)

%MW109 (first byte)

 

Follower_offset: INT

%MW111 (entire word)

-

 

Reserved for the alignment