How-to
Map a 32-byte IO-Link PROFINET item to a PLCnext array
Short answer
Expand the Process Data Item column and the input block's datatype shows as OctectString[32], which connects to one array of 32 bytes. Map the whole item to a single byte-array variable instead of scalars, then split it into eight 4-byte records in logic and accept each vibration value only when its record's PQI is valid.
On this page
Your PROFINET side is already healthy: the controller exchanges data with the IO-Link master and you read the sensor's other values. The vibration block is different only in shape. The item labelled input data 32 Bytes is one aggregate of 32 octets — expand the "Process Data Item" column and its datatype shows as OctectString[32] — so it connects to exactly one variable of matching size and shape: a byte array. Map the whole item to a single ARRAY[0..31] OF BYTE variable, then split that array in PLC logic into eight 4-byte records and check each record's PQI before you decode a vibration value. Scalars, lone four-byte variables and padded structures all fail because their size or layout does not match the item.
Read the datatype the item expects #
Click the > control at the top of the "Process Data Item" column in PLCnext Engineer and the view expands to show the datatype of every PROFINET variable. For the vibration block it reads OctectString[32]: a single aggregate of 32 octets, not eight separately mappable scalars. That display answers "which variable can I connect" by itself, because compatibility is decided by size and aggregate shape, never by the engineering meaning of the bytes inside.
| PLC-side variable | Connects to the item? | Why |
|---|---|---|
ARRAY[0..31] OF BYTE |
Yes | Contiguous, 32 byte elements, no other members |
| One REAL or DWORD | No | Four bytes offered against a 32-byte item |
| Eight separate 4-byte variables | No | The item is one aggregate and cannot be split at this boundary |
| A structure with padding or extra members | No | Total size or member layout differs |
Because the master hands the sensor's cyclic data over as ordinary PROFINET items, this path needs no IO-Link library on the controller; the controller-side library is a separate subject, covered in why the PLCnext IO-Link library will not run with a third-party master.
Declare the array and connect the item #
- Create a user-defined datatype in PLCnext Engineer: an array of BYTE with the bounds
0..31. PLCnext Engineer supports namespaces for user-defined data types, so the type can live under your application's namespace. - Instantiate one variable of that type, for example
InputBytes, in a scope the process-data mapping editor accepts. - Compile the declarations. If the variable is not offered as a target later, check its scope, compilation state, element type and element count before changing anything else.
- In the mapping view select the
input data 32 Bytesitem and connectInputBytesto it. Do not connect individual records at this boundary: the boundary transfers the raw image and your logic performs the second stage. - Compile the hardware and application configuration and download both to the controller.
Worked example: splitting a 32-byte block into 4-byte records #
Inputs, with where each comes from:
- Item length: 32 bytes, read from the
input data 32 Bytesitem in your PROFINET configuration. - Record length: 4 bytes per record including PQI, from the sensor's process-data layout, the same layout you already consumed on your previous controller.
- Record count: unknown, to be derived.
Rule in words: the record count is the item length divided by the record length, and record n occupies the byte indexes from (n − 1) × 4 up to n × 4 − 1.
Arithmetic:
- 32 bytes ÷ 4 bytes per record = 8 records.
- Record 1 covers bytes 0..3, record 2 covers bytes 4..7, record 3 covers bytes 8..11, and record 8 covers bytes 28..31.
- First byte of record n = 4 × (n − 1); for the third record that is 4 × 2 = 8.
Result: the block holds eight records, and the third record lives in InputBytes[8] through InputBytes[11].
Decision: map the item once at the PROFINET boundary and decode at these fixed offsets in logic. Accept a record's vibration value only when its PQI evaluates to valid process data; any record that fails its PQI is discarded, never converted.
Decode one record and check its PQI #
The byte count tells you nothing about byte order, signedness, scaling or where the PQI sits; those come from the sensor's process-data description. Two things are fixed and save you time: IO-Link process data is little-endian, so a value's least significant byte sits at the record's lowest index, and the PQI position is identical in every record of the block, so you confirm it once and reuse the check throughout. Vibration values arrive as cyclic process data; reading the sensor's parameters (ISDU) is a separate acyclic path, covered in reading IO-Link ISDU parameters over PROFINET acyclic record data.
- Copy one record's raw bytes into a working buffer with plain indexed assignments. The names below are illustrative:
InputBytesis your mapped array,Recthe record buffer,nthe record counter.
VAR
InputBytes : ARRAY[0..31] OF BYTE; (* mapped to the item "input data 32 Bytes" *)
Rec : ARRAY[0..3] OF BYTE; (* raw bytes of one record *)
n : INT := 3; (* record counter, 1 to 8; example: record 3 *)
k : INT := 0; (* byte index within the record *)
END_VAR
FOR k := 0 TO 3 DO
Rec[k] := InputBytes[4 * (n - 1) + k];
END_FOR
- Evaluate that record's PQI per the sensor description before you touch the value bytes.
- Only on valid PQI, assemble the value bytes in the documented order and apply the documented representation and scaling to reach engineering units.
- Repeat at each record offset.
The test that proves the copy: with n left at 3, Rec[0] must follow InputBytes[8] and Rec[3] must follow InputBytes[11] while the earlier bytes keep their own behavior. If Rec instead tracks the block's first bytes, the offset arithmetic is off by one record.
Prove the mapping online #
- Put
InputBytesin an online watch view and watch every element, not only the ones you expect to move. - Record the online states of the IO-Link port and the PROFINET device.
- Change the vibration condition on one sensor port: that record's value bytes must change while the other records stay logically independent.
- Break the sensor connection under controlled commissioning conditions, machine stopped and never on a running safety function, and confirm your logic discards the value through PQI instead of holding it as good data.
- Restore the connection and confirm valid PQI, moving bytes and a plausible decoded value together.
If the watched array is all zero or frozen, separate two cases before you change any datatype: the mapping may be inactive, or the master may be delivering a valid but unchanged image. The online port status and the PQI content tell the two apart.
Questions asked
Can I map eight separate 4-byte variables instead of one array?
Only if the master's device description offers the block as separate submodules you can configure. When the configuration exposes one aggregate item, the PLC side must be one variable of matching size and the split happens in logic. Check whether a smaller submodule can be selected in the PROFINET configuration before writing any code, because that would remove the second-stage decoding entirely.
Does the same method work for a 16-byte or 64-byte item?
Yes, with the same rule: connect an array with exactly the element count the datatype shows, then divide by the record length from the sensor's process-data description. For example, a 16-byte item with 4-byte records holds four records at byte offsets 0, 4, 8 and 12, and a 64-byte item with the same record length holds sixteen. The record length is the only number you take from the device documentation.
Where do the scaling and engineering units come from?
From the sensor's process-data definition, the IODD or the sensor manual, never from the array. The bytes you mapped are transport only: the definition fixes the value width, signedness, resolution per bit and the resulting unit, and you apply those only after the record's PQI check passes. The array itself carries no units at all.
What about data going the other way, to the sensor?
The same size-and-shape rule applies to output items. An output item of a given byte count connects to one array of exactly that many bytes, and your logic fills those bytes before the master transmits them. Map the whole output item as one array and compose the record layouts in code, mirroring what you did on the input side.