IMDHMIControls LibraryShop main store

How-to

Read and write IO-Link parameters from CODESYS over EtherNet/IP

Industrial networks Published 6 min read

Short answer

Read ISDU parameters with an EtherNet/IP explicit message to CIP class 16#83, instance set to the physical port, service 75 for reads and 76 for writes, and gate every request on the cyclic PQI byte (bit 7 PQ and bit 5 DevCom). Identify the device on each port with an ISDU read of index 19, subindex 0.

On this page
  1. The ISDU mapping onto EtherNet/IP
  2. Qualify the port with the cyclic PQI byte
  3. The request, step by step
  4. Reading the product ID from port 1 of an eight-port master
  5. Writing a parameter
  6. Prove the path in two stages
  7. Questions asked

The 765-4501 has no dedicated CODESYS library the way the 750-657 does, and you do not need one. IO-Link parameter traffic rides in EtherNet/IP explicit messages: CIP class 16#83, instance set to the physical port number, attribute 0, service 75 (16#4B) for an ISDU read and 76 (16#4C) for an ISDU write. The request body is three bytes — index low, index high, subindex — and a write appends the parameter bytes. Gate every request on that port's cyclic PQI byte, not on the event log: bit 7 (PQ) says the qualifier is valid and bit 5 (DevCom) says a device is communicating. Identify what is on each port with an ISDU read of index 19, subindex 0, then write settings to the indexes that device's own documentation defines.

The ISDU mapping onto EtherNet/IP #

Every IO-Link device carries its parameters in ISDU, the Indexed Service Data Unit, and reads and writes them through that service. The integration work published through ODVA maps IO-Link onto CIP networks, which is why this mapping is not a WAGO quirk: the SIOL-EI8B master manual names service 75 (0x4B) Read_ISDU with ISDU access on CIP class 131 (0x83), and an ifm AL1220 exposes the same read and write access through its IO-Link Requests object. The 765-4501 answers the identical class and services.

Request field Value Role
CIP class 16#83 (decimal 131) ISDU access
Instance physical port number, 1 through 8 one instance per master port
Attribute 0 fixed for ISDU calls
Service, read 75 (16#4B) Read_ISDU
Service, write 76 (16#4C) ISDU write
Request body index low byte, index high byte, subindex a write appends its data bytes after these three

In CODESYS you drive this with the explicit-message block from the EtherNet/IP services library; the working routines use ENIP.Generic_Service, built and run on a PFC200 750-8217 under CODESYS V3.5 SP19 Patch 7. The call mechanics are the same ones behind set up a CODESYS adapter for explicit CIP messaging to Logix: class, instance, attribute, service code, a byte buffer and a size. Over PROFINET instead of EtherNet/IP, the equivalent access is reading IO-Link parameters over PROFINET acyclic record data.

Qualify the port with the cyclic PQI byte #

The master's cyclic process image carries one PQI byte per port; the assembly layout is part of what an EtherNet/IP IO-Link master exposes to your PLC. Read it before every request:

Bit Name Set means
3 Event the port has an IO-Link event
5 DevCom an IO-Link device is present and communicating
6 DevErr an error or warning exists
7 PQ the qualifier data is valid

Query a port only when bit 7 and bit 5 are both set. Check bit 6 separately and report it; device presence alone is not health. The remaining bits are reserved.

The event log looks like an alternative but is not. Object 65 (class 16#41) at attribute 2 reports the state of the log itself, and a Get Attribute Single (16#0E) query against it was tried for port presence without returning an active-port answer. Use the PQI byte for this decision.

The request, step by step #

  1. Confirm the EtherNet/IP device state is IoDrvEthernetIp.AdapterState.RUNNING before any explicit call.
  2. Read the target port's PQI byte from the cyclic image and proceed only with PQ and DevCom set.
  3. Set the CIP class to 16#83, the instance to the physical port number, and the attribute to 0.
  4. Choose the service: 16#4B to read, 16#4C to write.
  5. Build the request body as index low byte, index high byte, subindex; for a write, append the parameter bytes.
  6. Pulse the execute input once per command and monitor done, busy, error and a watchdog timer while the call is active.
  7. On a read, save the received-data size before interpreting the buffer; on a write, count success only when done is set without error.
  8. Clear the caller's command and return to idle after completion or error, so the next request cannot replace an active call.

With io_index declared as WORD, io_subindex as BYTE and io_length as WORD, both working routines encode the body the same way:

write_data[0] := TO_BYTE(io_index);          (* index, low byte  *)
write_data[1] := TO_BYTE(SHR(io_index, 8));  (* index, high byte *)
write_data[2] := io_subindex;

generic_service.udiWriteDataSize := 3;              (* read request  *)
generic_service.udiWriteDataSize := io_length + 3;  (* write request *)

One detail from the field: the receive-size input — EIP_read_data_size in the wrapper that was shared — must be nonzero, or no data comes back at all.

Reading the product ID from port 1 of an eight-port master #

Your situation is a known device set with an unknown mix per port, so identification runs at startup. The inputs, each from the working setup:

  • Master: 765-4501, ports 1 through 8, instance equals the port number.
  • Target: port 1, whose PQI byte in the cyclic image reads 16#A0 in this run.
  • Identification index: 19, subindex 0 — the default the working function block ships with (io_index := 19).
  • Request: class 16#83, instance 1, attribute 0, service 16#4B.

The rule in words: mask the PQI byte against the two bits you need, split the index into a low and a high byte, and send three bytes.

The arithmetic:

  • 16#A0 AND 16#80 = 16#80, so PQ (bit 7) is set; 16#A0 AND 16#20 = 16#20, so DevCom (bit 5) is set; 16#A0 AND 16#40 = 16#00, so DevErr (bit 6) is clear. The port is queryable.
  • 19 decimal = 16#13, so the low byte is 16#13; SHR(19, 8) = 0, so the high byte is 16#00; the subindex byte is 16#00.
  • udiWriteDataSize := 3.

The result is the returned byte count plus the product-ID bytes, decoded against each device's documentation or IODD. The 765-1703 DIO Hub routine used exactly this read to confirm which device sat on a port before configuring it.

The decision: at startup, run this read on every port where (pqi AND 16#A0) = 16#A0, map each returned identifier against your known device set, and write parameters only to ports you have identified. Anything short of that mask, skip the port and log it; do not query it and do not assume a fixed port assignment.

Writing a parameter #

Same class, instance and attribute; the service becomes 76 (16#4C) and the body grows by the data bytes, so size the request at io_length + 3 and reject any request whose header plus payload would overflow the buffer you compiled. Index 64 (16#40) sets each port's input or output direction on a WAGO 765-1703 DIO Hub; that index belongs to that device, so take every other device's writable indexes and value ranges from its own documentation or IODD before writing from logic, because a wrong value reconfigures a live output.

Serialize the calls. Latch one read or write command, pulse the generic service's execute input, and monitor done, busy, error and a TON-based watchdog while it is active; clear the caller's command and return to idle after completion or error, so a new command never replaces an active call. Validate the port against the range your project actually configures — one shared routine accepted ports through 8, another checked GVL.max_iol_ports. And drop any port_number < 0 test: the port travels in a BYTE, which cannot be negative, so that check does nothing.

Prove the path in two stages #

  1. Perform the same ISDU read or write from the master's Web Based Management pages, and confirm the index, subindex, payload and the device's response there.
  2. Repeat it from CODESYS and compare the returned length and the returned bytes.

Matching results prove your message construction. A request that also fails in Web Based Management points at the device parameter; one that succeeds there but fails from the PLC points at the request encoding on the CODESYS side.

Questions asked

What do the event log states actually tell you on the 765-4501?

Reading the IO-Link Event Log, object 65 at class 16#41, with Get Attribute Single 16#0E at attribute 2 returns the state of the log, not of the port: 1 stopped, 2 empty, 3 present, 4 full with overwrite, 5 full with stop. None of those states is a substitute for the cyclic PQI byte, so decide whether a port can be queried from PQ bit 7 and DevCom bit 5.

How do I know my CIP class or service code was wrong?

EtherNet/IP IO-Link masters count unsupported CIP class errors: a message that addresses an invalid class increments that diagnostic counter instead of performing the access. If ISDU calls return nothing and that counter climbs, check the request fields first: class 16#83, instance equal to the physical port, attribute 0, service 16#4B for a read or 16#4C for a write.

How large can the ISDU data buffers be?

Buffer size is an implementation choice, not a documented master limit. One shared routine exposed ARRAY[0..255] OF BYTE for the data, while the revised block used 64-byte EtherNet/IP buffers with a 61-byte write-data input. Whatever you compile, reject any request whose 3-byte index header plus parameter payload would overflow it.

What timeout should the ISDU request watchdog use?

The shared routines used T#500S in the first version and T#100S in the revision; both are implementation values, not documented product requirements. Choose a timeout longer than the slowest parameter response you expect from the connected devices, latch one command at a time, and clear it on done or error so a retry never stacks behind an active call.

Keep reading

  • How-to

    Read and write Logix tags from CODESYS with CIP GenericService

    Read a Logix tag from CODESYS with CIP service 16#4C against the tag's Symbol Object instance at class 16#6B: send a two-byte element-count body, expect a two-byte type word first (16#C4 is DINT), and take the DINT value from bytes 2-5. Write with service 16#4D, sending type word, element count, then data. Rebuild the name-to-instance table after every download or online edit, because the controller reassigns instance numbers.

    Industrial networks

  • Explainer

    What an EtherNet/IP IO-Link master exposes to your PLC

    Full access to every port is decided by three documented items: the mode each port is configured in, the master's EtherNet/IP data map, and your PLC's client functions. Process data travels on the cyclic I/O connection; parameters need explicit CIP requests, and at 100 devices polled every 10 ms you would need 10,000 transactions per second, so bulk data belongs on the assembly connection.

    Industrial networks

  • Troubleshooting

    Why explicit writes to Omron assemblies fail over EtherNet/IP

    Your Set Attribute message carries service code E, which is Get Attribute Single, so it reads, succeeds and writes nothing — and the two codes are transposed, since Set Attribute Single is 10 hex. Even corrected, CS/CJ-series EtherNet/IP units do not accept explicit writes to assembly instances, because that service is optional in the specification. Carry the 240 bytes on a Generic Ethernet Module connection or use CIP Data Table Read and Write messages.

    Industrial networks