Showing results for 
Search instead for 
Did you mean: 

Modbus Ethernet U16 vs I16 Data type


   I'm re-writting a piece of code that communicates Modbus Ethernet to the downstream device.   I'm using the Labview Modbus Library VIs.


The machine variables that I am trying to write are I16 (ie. I'm trying to write the value -22) but the Labview MBE library writes the values as U16.  


The U16 value that it generates is 65514 (from a I16 input of -22) 


anyone have an idea how I should fix this?   Would it be worth it to rewrite the Library files to output I16 instead of U16... I'm nervous this might cause other problems? 



0 Kudos
Message 1 of 4

Either typecast it or use the To U16 bullet to convert the number.


Or have you just tried wiring it up to see if it works?



The VISA functions just send it out as bytes in a string.  So your device will just interpret the bytes how it sees fit.

0 Kudos
Message 2 of 4

I agree... you would think that the number is broken down to binary and transferered... and then the device would end up with the I16 negative number... but, it doesn't!  the LV turns the -22 into 65514... and the device reads it as 65514.   

0 Kudos
Message 3 of 4

If the device thinks it is 65514, then it must be using U16 as well, just like LabVIEW.


The range of I16 is -32768 to 32767

The range of U16 is 0 to 65535


65514 is not within the range of an I16.

0 Kudos
Message 4 of 4