Convert signed int to unsigned int

I have a signed int coming from a Adam 6017 module and need to convert it to a unsigned int.

I have read other topic and you guys want me to change it in the Adam 6017 but I can not. What can I do?

What driver are you using to read the value?

OPC-DA COM Connection


Which OPC Server are you using? Is it possible that you can create an “alias” tag of some sort with a different datatype and do the conversion there?

If not, you might try the following: on the opc-com connection settings, turn on “request data types”. Then, on the tag (in Ignition), set the data type to “Int8”. Since we don’t actually have “unsigned” data types, it’s going to be necessary to use a larger data type anyhow, I’m just not sure if your source value is a 2 byte or 4 byte value.

Hope this helps,

No, it is not possible to set up the alias in the OPC service. We did enable the “request data types” but still reading a negative integer number.

It depends what you mean by needing to convert it to an unsigned int. If you’re reading a value in from an Adam 6017 I assume it’s a 16-bit integer. A signed 16-bit integer will have a range of −32,768 to 32,767. An unsigned 16-bit integer will have a range of 0 to 65,535. To change from signed to unsigned you would simply add 32,768 to the number.

To do this in Ignition, read your input in to a SQLTag (say tag1), then create an Expression SQLTag and make its expression something like {[~]tag1}+32768This does mean you need 2 SQLTags for each input, but they’re free :slight_smile: and if you’re creative with SQLTag names and folders it should still be clear what you’re doing.

Let us know if this is not what you are meaning.

I had the same question, with the same ADAM-6017 IO module and found a solution.

It is possible that this solution did not exist at the time of the original post back in 2012 but I thought I’d post the current solution for others like me who come across this post looking for answers.

The solution is to use “Holding Registers with 16 bit unsigned integer conversion” as the modbus type with the Ignition OPC-UA Server…

Change OPC Item path from:

For modbus address mapping change Modbus Type from:
Holding Register (Int16)
Holding Register (UInt16)


1 Like