Posted 4 Feb 2020 I am working with integer/word in Gx Works 2, and i am wondering if there is a easy, smart way to split it into two bytes. Example : i get two values in data type byte, this is combined into integer in the gateway and im getting both values in the integer. i then need to split them up again. Maybe poorly explained, but i hope its understandable. Any tips is appreciated! Share this post Link to post Share on other sites
Posted 4 Feb 2020 Use "AND" (to mask out the upper byte) and "SHR" (shift-bits right to move the upper byte into a new word): Lower Byte: AND [data] 16#00FF -> [outData1] (will only pass the lower byte to the output) Upper Byte: SHR [data] K8 [outData2] (will shift the upper 8 bits 8 positions to the right). Will this work? Share this post Link to post Share on other sites
Posted 5 Feb 2020 Interesting! I will try this when i get back to work. Thanks! Share this post Link to post Share on other sites
Posted 5 Feb 2020 Take a look at the WTOB instruction, it's quite handy but then you need to convert your integer to word format Share this post Link to post Share on other sites
Posted 28 Jan 2022 I am having similar problem. How to send two bytes data into one word. I want to send first byte into lower word and second byte into upper word. Share this post Link to post Share on other sites