two 16-bit variables combining into a 32-bit

mikeardy
2018-12-03
2018-12-03
  • mikeardy - 2018-12-03

    Hi,
    I have two words that I need to combine into a 32-bit one
    word1 must be the Most Significant one
    and word2 must be the Last Significant one
    how could I achieve this point?
    Thank you

     
  • alwoso - 2018-12-03

    Hi mikeardy!

    The direct way in structured text would be

    DWord := SHL(WORD_TO_DWORD(word1), 16) OR WORD_TO_DWORD(word2);

    which makes a binary OR between the two variables after shifting the word1 to the most significant position.

    Good luck!

    Alfred

     
  • dFx

    dFx - 2018-12-03

    If you need it to be stored, the declaring a union datatype may help.

     

Log in to post a comment.