Skip to content

Raw byte handling

Felix Weiß edited this page Jun 21, 2022 · 2 revisions

Writing raw byte arrays to registers

The target array in the PLC is a word array with the definition size ARRAY[0..9] OF WORD and a starting adress of DT2500.

That means the array exists in the memory from DT2500 to DT2509 and it can hold 20 bytes / 10 words.

var testBytes = new byte[20];

//write 0 - 19 to each byte
for (int i = 0; i < testBytes.Length; i++) {
    testBytes[i] = (byte)i;
}

await interf.WriteByteRange(2500, testBytes);

Reading raw byte arrays from registers

The byte array definition in the PLC is the same but this time we just want to read back 13 bytes in total.

var bytes = await interf.ReadByteRange(2500, 13);
Clone this wiki locally