What am I missing about reading ASCII from Modbus TCP in Ignition?

I have a modbus tcp device which outputs two ascii characters as a 16-bit unsigned int at one of its addresses. The rest of the address in this block are ordinary int16s. For the life of me I cannot find a way to cleanly treat the value of that tag associated with that HR or any derived tag as ascii characters. The closest I’ve come is using a transform script on a bound component in Perspective, but that does not feel ideal when, say, I might want to access that tag’s value in multiple places. What am I missing? Is there just no clean way to turn “01101000 01101001“ into “hi”? Do I need to write a somewhat complex expression to do this? What if I had 8 characters, or 16? What if I have to read a dozen different ascii values?

Try [device]1.HRSxxxx:2 maybe?

1 Like

Check your OPC Item Path to make sure it is addressed properly for a string.

Next check the appropriate advanced device settings on the gateway

1 Like

toString(char({[.]modbusregister} >> 8)) + toString(char({[.]modbusregister} & 255))

this “worked” in an expression tag for whatever value of “worked” you assign to this only covering the two-character case.

Show us the OPC Item Path, you shouldn't need to do this.


I understand how stupid integer→binary→ascii is, which is why I’m annoyed I’m doing it. Binary data got me nowhere because I can’t slice inside of expressions and I figured bitwise access was not the correct path.

This OPC Item path is derived from the block of Device Addresses I defined.

Don't use modbus address mapping in Ignition, only use direct modbus addressing.
This will give you much more control to define addresses easily and correctly for your tags.

Using the 1.HRSxxx:2 notation will automatically read ascii from the register as characters.

2 Likes

Awesome :smiley: