Data Table Read and Write
![]() | 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.
- 1. Now compile the project and switch to the EtherNet/IP™ scanner.
- 2. Open the Explicit MSG tab:
- 3. Move the mouse over the empty box, right-click and select Add to add the data:
- 4. The Add Symbols ... dialog appears. Tick the data that you want to use later:
- The data are now available in the dialog.
- 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.
- 1. Under Controller Tags enter variables Test and iTest, both as DINT. Now a little code must be written for the Allen-Bradley (AB) controller.
msg(msgTest); (* Program language: Structured Text *)
"msgTest" must be of type MESSAGE. - 2. Then click on the msgTest variable and configure the function block.
- 3. Set the message type to CIP Data Table Read. Under Source Element enter the name that you used in the TwinCAT project.
- 4. Then open the Communication tab. Here you set the controller from which you want to read the variable Test.
- 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.
The variable Test (on the AB side) is copied to the variable Test2 (on the Beckhoff side).
Transferring STRING variables
A STRING has a different data format on the Rockwell controller than on the TwinCAT controller. The library Tc2_EthernetIP features a data structure called RSL5K_STRING, which facilitates the use of STRING. You must use this in order to be able to use STRING. The corresponding conversions are also available in the library. Only STRING 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:
As shown in the image above, a [*] placeholder can also be used with an ARRAY 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.