Skip to content

Data assembling and splitting

edited February 2020 in PLCnext Engineer

Hello,
    There are some data assembling and splitting blocks in "Safety IEC 61131-3" group, like "BYTES_TO_WORD", "WORDS_TO_DWORD". However, the PLC I am working on does not support these block.
From what I feeling, these blocks do the normally data conversion in the memory like most of the PLCs do.

Why are not these blocks provided in the normal "IEC61131-3" group? Where can I find the library for these block?

Thanks

Comments

  • Hello,

    Not sure why the developers felt the need to include these Safety functions, with no equivalents for non-safety PLCs. In any case these are very simple functions, and the same thing can be achieved in one or two lines of ST, for example:


    MyWord.B0 := MyByte1;
    MyWord.B1 := MyByte2;(* Assemble two BYTE values into one WORD *)

    MyDword.W0 := MyWord1;
    MyDword.W1 := MyWord2;(* Assemble two WORD values into one DWORD *)

    MyWord := SHL(TO_WORD(MyByte2), 8) OR MyByte1;
    MyDword := SHL(TO_DWORD(MyWord2), 16) OR MyWord1;(* Alternatively, in one line, something like: *)

    Hope this helps.

    ~ Martin.

     

     

Sign In or Register to comment.