Data Table Read and Write

Data Table Read and Write 1:

Please note the system requirements

Data Table Read and Write can only be used with the TC1200.

Like the Consumed and Produced tag, this function is used for communication between two EtherNet/IP controllers, with the difference that it is an acyclic communication. This enables data to be exchanged between two controllers which do not have to be transmitted cyclically, such as parameters, recipes or any other data. The data can be structures, arrays or a combination of both. TwinCAT enables data to be read from and written to a controller, and it is also possible to read or write data from TwinCAT using remote control. This is explained below by way of example:

Data that is to be sent or received via this service must be made known in the TwinCAT system. This data must be stored as a global variable in a folder ETHIP and in the flag area. The library Tc2_EthernetIP must also be included. It contains a function block for the DataTable read/write.
The data types must match in both PLCs.

Creating the variables:

Create a global variable list with the name ETHIP. Now add two variables as shown in the image below. The variables must have a fixed address and lie within the flag area (%MBx, x address). For non-located variables, the internal address could change during an online change; such variables are currently not supported. Now compile the project and switch to the EtherNet/IP scanner.

Data Table Read and Write 2:

Open the Explicit MSG tab:

Data Table Read and Write 3:

Move the mouse over the empty box, right-click and select Add to add the data:

Data Table Read and Write 4:

The dialog Add Symbols … appears Tick the data you want to use later: Data Table Read and Write 5:

The data are now available in the dialog.

Data Table Read and Write 6:

Next, recompile and restart the TwinCAT project. This is necessary if you change the data, e.g. the name, flag, address, type of variable, etc.

Read a TwinCAT variable from the Allen-Bradley controller

First, enter the TwinCAT controller in the configuration, as for the Consumed and Produced tags; proceed in the same way.

Under Controller Tags enter variables Test and iTest, both as DINT. Now some code has to be written for the Allen-Bradley (AB) controller.

msg(msgTest); (* Program language: Structured Text *)

"msgTest "must be of type MESSAGE.

Data Table Read and Write 7:

Then click on the msgTest variable and configure the function block. Data Table Read and Write 8:

Set the message type to CIP Data Table Read. Under Source Element enter the name that you used in the TwinCAT project.

Data Table Read and Write 9:

Then open the Communication tab. Here you set the controller from which you want to read the variable Test.

Data Table Read and Write 10:

Everything is now prepared for reading the variable.

The variable Test is read (on the Beckhoff side) and copied (on the AB side) to the variable iTest.

Writing a TwinCAT variable from the Allen-Bradley controller

A similar procedure must be followed when writing. In this case, the MSG command must describe the Data Table Write. The source element is the variable in the Allen-Bradley controller. The Destination Element is the TwinCAT variable. Again, select the TwinCAT controller under Communication.

Data Table Read and Write 11:

The variable Test (on the AB side) is copied to the variable Test2 (on the Beckhoff side).

Transferring STRING variables

On the Rockwell controller, STRINGS have a different data format than on the TwinCAT controller. The library Tc2_EthernetIP features a data structure called RSL5K_STRING, which facilitates the use of STRINGS. You must use this in order to be able to use STRINGS. The corresponding conversions are also available in the library. Only STRINGS with 82 characters or less may be used.

Data Table READ/WRITE from the Beckhoff controller

The PLC function block FB_CIP_DATA_TABLERDWR is used for DataTableRead/Write from the library Tc2_EthernetIP (see DataTableRDWR). The usage is very similar to that of the AB controller and is shown here as an example:

Data Table Read and Write 12:

As shown in the image above, a [*] placeholder can also be used with ARRAYs on the TwinCAT side. To this end, the ARRAY value is entered with an * in the variable name. The advantage is that only parts or just one element of an ARRAY is read or written. In other words, it is not necessary to read or write the complete ARRAY.
If you use an ARRAY in an ARRAY with * in each case, the index is entered for all [*] values. Example DataARRAY[*].ValueArray[*]: the index is entered for both.