I’m wondering if there is an easy way to convert a 16-bit integer tag value into two 8-bit tag values (one for the high byte, one for the low byte).
Here’s how i’ve been doing it:
- I have an integer value coming into an OPC tag.
- I make an expression tag that converts the integer into a binary string using the toBinary function. The toBinary function seems to strip leading zeros, so I also have some code to pad the binary string with zero’s to make it 16 bits long.
- I make 2 more expression tags. One tag reads the first 8 characters/bits of the binary string, the other reads the second 8 characters/bits. Now I have the high and low bytes of my original integer stored in 2 separate tags, as binary strings.
- I make 2 more expression tags. I use the fromBinary function to convert the two 8-bit binary strings into integers.
Anyone know of a more straight forward way to accomplish this?
Note: I know I can consolidate some of the expression tags, it’s just easier to explain my question this way.