Explainer
What CODESYS PROFINET acyclic record read and write needs
Short answer
Working cyclic PROFINET I/O in CODESYS proves the process data connection only. Reading or writing records acyclically requires calling the RDREC and WRREC function blocks from a running PLC task with the slot, subslot and index from the device documentation. The engineering tool's right-click read or write is a commissioning action, not a substitute for application logic.

On this page
Cyclic I/O working on your CODESYS PROFINET master answers one question: the process data connection is alive. It says nothing about record access. Acyclic record read and write needs application code on the controller: you call the record-service function blocks RDREC and WRREC from a running PLC task, addressed with the slot, subslot and index your device documentation defines. The right-click Read or Write command in the engineering tool transfers one value once during commissioning; it is not part of the running program and cannot react at machine speed. This article separates the two routes, explains the addressing both use, works a read and a write through with the arithmetic shown, and ends with the decision for each case: when a tool command is enough and when only PLC logic counts.
What acyclic record access is #
PROFINET carries process data cyclically, in a fixed mapping repeated on every network cycle. The acyclic read/write record services run on the same cable but work on request: the controller asks for one named data set, the device answers, and the transaction ends. The PROFINET organizations size cyclic payloads at typically 20 to 1440 bytes per device, while acyclic record volume is described as almost unlimited.
Every record lives inside one submodule, and three numbers address it: the slot selects the module, the subslot selects the submodule within it, and the index selects the data set inside that submodule. Record contents are defined by the device maker, not by CODESYS: parameter sets, diagnostic records, identification and maintenance data. One common case is device parameter access — reading IO-Link ISDU parameters over PROFINET acyclic record data wraps an ISDU exchange inside such a record read. Because each index belongs to one device family and firmware, keep a reference of Siemens RDREC and WRREC data record index numbers beside the device manual when you pick an index.
Why working cyclic I/O proves nothing about records #
A healthy cyclic connection proves the cable, the device addressing, the cyclic mapping and the connection state. It proves none of these: that an index exists in the device firmware, that the record accepts writes, that your length matches, or that the device is in the operating state the record requires. The services also fail separately — a record transaction returns its own error status, distinct from the connection diagnosis.
Keep the two diagnoses apart. If cyclic I/O is dropping, resolve that first; for CODESYS-side connection faults such as fixing PROFINET device ID read errors in CODESYS scans, the diagnosis runs at scan level and differs from a rejected record transaction. Change nothing in the cyclic mapping to chase a record error; that adds a second fault without fixing the first.
Decision: cyclic I/O healthy, record transaction fails — the fault is in the record addressing, the length or the device state, not the network.
The right-click read or write in the engineering tool #
The engineering tool's online commands — the device parameter dialog or the network view's record read and write — transfer one value once, from the engineering station, while you commission. They are legitimate and fast for that job. Three limits matter:
- They run in the engineering tool, not in the controller. The machine cannot call them after an event, on a timer or from an operator button.
- A dialog value can be project configuration rather than a live reading; check which one it shows before trusting it.
- Whether a written value survives a restart is a property of the device and the command, not something the dialog lets you control.
One safety note belongs here because it covers both routes: a record write that changes motion, limits or interlocks belongs in a stopped or otherwise safe machine state, whatever tool performs it.
Decision: one value, once, while commissioning — the online command is enough. Anything the machine must do itself needs code.
Calling RDREC and WRREC from a running task #
Both blocks follow the IEC 61131-3 function block pattern. RDREC reads a record from the device into a buffer you declare; WRREC transfers a buffer to the device. You set the addressing — slot, subslot, index — plus the data length and the buffer; the block returns a done indication, an error and status, and for a read the actual returned length.
The transaction spans several PLC cycles, so the handshake matters:
- Trigger the request once, not every scan.
- Call the block every cycle until it reports done or error.
- Keep the address inputs and the buffer stable for the whole transaction.
- Use one block instance per device so two transactions cannot interleave.
Structured Text is not required. RDREC and WRREC are plain function blocks, so ladder or function block diagram calls them identically; the trade-offs between the IEC 61131-3 PLC languages for each control task are a separate choice. For the call sequence in detail, how to use RDREC for acyclic PROFINET record reads walks the block through cycle by cycle.
A worked read and write with real numbers #
The numbers below are a worked example. The real slot, subslot and index come from your device manual, and using a neighboring index is the most common failure.
Say the manual defines a readable and writable record at slot 1, subslot 1, index 16#0050, with a 4-byte payload: bytes 0 and 1 an unsigned scale factor, bytes 2 and 3 a signed setpoint, big-endian. Total: 2 + 2 = 4 bytes.
Read. Declare a receive buffer of 20 bytes, comfortably above the documented payload. Trigger RDREC once; when it reports done, the returned length is 4 bytes, which matches the documented payload, so decode bytes 0 to 1 as the unsigned value and bytes 2 to 3 as the signed value. A returned length of anything other than 4 means the request landed elsewhere — stop and decode nothing.
Write. The setpoint is 150 and the machine needs 175. In hexadecimal, 175 = 10 × 16 + 15, so the value is 16#00AF. Build the payload as 16#00, 16#00, 16#00, 16#AF — scale factor unchanged, setpoint big-endian — and give WRREC the documented length. When it reports done, read the record back with RDREC and confirm the returned length still matches and bytes 2 to 3 now read 16#00, 16#AF.
Decision: a write goes into machine code once a read of the same record returns the documented length.
The decision for each case #
- One value, once, during commissioning: the engineering tool's online read or write, after checking whether the dialog shows online data or project configuration.
- The machine must read or write a record during operation, on an event or on an operator command: RDREC and WRREC called from a PLC task. There is no tool-only route.
- The value must survive a restart: follow the device manual's activation and persistence rules for that index; some records need a separate save or reset command after the write.
- Record transaction fails while cyclic I/O is healthy: re-check slot, subslot, index and length against the device manual, confirm the operating state, and test a read of a documented record before attempting any write.
- Structured Text is the obstacle: call the same blocks from ladder or function block diagram; the language changes nothing about the service.
Questions asked
Can I read and write PROFINET records in CODESYS without Structured Text?
Yes. RDREC and WRREC are standard function blocks, so you can call them from ladder diagram or function block diagram as well as Structured Text; the language choice does not matter to the service. What matters is that the call runs inside a PLC task on the controller. The engineering tool's right-click read or write dialog is still only a commissioning action and cannot replace the block call in a running machine.
Where do the slot, subslot and index values come from?
From the device manufacturer. The GSDML description and the device manual define which module sits in which slot, which submodule owns the record and which index selects it, together with the permitted length and data layout. Because indices differ between devices and firmware versions, take the numbers from the documentation for your exact device rather than from another project, and read a known record before you attempt a write.
Why does a record read fail when cyclic I/O is working?
Cyclic transfer only proves the connection and the process data mapping. A record read can still fail on a wrong slot, subslot or index, a length the device rejects, a record that is read-only, or a device operating state that blocks access. Decode the function block status, confirm the addressing against the device manual, and test a read of a documented record before diagnosing the connection again.
What size receive buffer does a record read need?
At least the maximum length the device documentation states for that record, so the device can return the full payload without truncation. A larger buffer is harmless: the function block reports the actual returned length, and you decode only that many bytes. If the returned length is shorter than the documented payload, the request hit the wrong index or the wrong length, so decode nothing until you know why. An example 20-byte receive buffer comfortably covers a 4-byte payload.
Does writing a record always change the device permanently?
No. Some records act on a volatile working set and need a separate save, download or reset command to survive a power cycle; others take effect only in a particular operating state. The device manual states the activation and persistence rules for each index. After a write, read the record back and perform the documented persistence step, or the setting can revert on the next restart.