EtherCAT-IOLink Gateway
 
Loading...
Searching...
No Matches
Steps to Read/Write Data from/to an IO-Link Device using TwinCAT

This section describes how to read/write data from/to an IO-Link using TwinCAT. For this purpose, the Object 0x40n0 (IO-Link Service Data Channel n) is used. The description of this Object is shown below:

Subindex Name Type Access Value Range
1 Control UINT8 RW 0: no control action
2: write
3: read
2 Status UINT8 RO 0: no activity
1: busy
2: success
4: error
0xFF: failure
3 Index UINT16 RW
4 Subindex UINT8 RW
5 Length UINT8 RW
6 Data Array of Bytes (0..254) RW

In this example, it is used the touch sensor Autosen AC901 connected in Port 1.

To set up the connection between the Gateway and TwinCAT, please refer to Start TwinCAT - Basic Project.

  1. Click on the tab “Online” and press a button "PreOp".
    PREOP Mode
  2. Click on the tab "CoE-Online" and go to the object 0x4000 and set Control to 0.
  3. Wait approximately 3 seconds. The Status shall be "no activity" (0).

To read from IO-Link device:

  1. Set Index, Subindex and Length. For example, to read the serial number, set Index to 21, Subindex 0, Length 16 Bytes and Control to 3.
  2. Wait approximately 3 seconds. The Status is changed and the information is shown in Data.
    TwinCAT - Data Read

To write to IO-Link device:

  1. Set Index, Subindex, Data and Length. For example, to modify the LED color in the idle state, set Index to 264, Subindex 0, Length 1 Bytes, Data to a valid value (please refer to datasheet) and Control to 2.
    TwinCAT - Data Write
  2. You will see the LED color changing and the Status is changed.