Creating process data

Creating process data 1:

Incorrectly set address offsets for the EtherCAT slave interface lead to a crash.

For devices with Arm® processors, pay attention to the alignment and set the correct address offset in TwinCAT.

  • INT/WORD data types must be on an address offset with base 2.
  • REAL/DWORD/DINT data types must be on an address offset with base 4.

Up to 512 bytes of input and output data or 256 variables can be exchanged via the EtherCAT slave interface (X101, X102). The 512 bytes of input and output data cannot be created individually, since 512 variables are required for this.

To avoid an excessive number of links, it is advisable to store data in a data structure. Note that the data structures used are processed differently on an x86 system and an Arm® Cortex®-A9 processor. An Arm® Cortex®-A9 processor, for example, always assigns WORD variables (2 bytes) to an even address and DWORD variables (4 bytes) to an address that can be divided by 4.

Data structure sample:
    byTest :BYTE;
    udTest:UDINT;

Data structure with BYTE and UDINT variables

Arm® address

Arm® variable

x86 address

Arm® variable

Byte Offset 0

Byte

Byte Offset 0

BYTE

Byte Offset 4

UDINT

Byte Offset 1

UDINT

Sum: 8 bytes

Sum: 5 bytes

You can determine the length of a data structure on both systems using the SIZEOF command. If the length of the data structure is different, this indicates that the data structure is unsuitable.

You can solve the problem by smarter arrangement of the variables or by using filler or dummy variables.

Data structure with filler or dummy variables.

Arm® address

Arm® variable

x86 address

Arm® variable

Byte Offset 0

Byte

Byte Offset 0

BYTE

Byte Offset 1

BYTE (Dummy1)

Byte Offset 2

BYTE (Dummy2)

Byte Offset 3

BYTE (Dummy3)

Byte Offset 4

UDINT

Byte Offset 4

UDINT

Sum: 8 bytes

Sum: 8 bytes

Create process data as follows:

1. Under Devices in the tree view on the left, right-click on Inputs to create input variables.
Creating process data 2:
2. In the context menu, click Add New Item. The Insert Variable menu appears.
Creating process data 3:
3. Select the required variables and confirm with OK. Click the Create Array Type button to create data structures.
You have successfully created input variables. Repeat the steps to create output variables in the same way.