03-11-2011 05:26 PM
Hi,
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?
03-11-2011 10:35 PM - edited 03-11-2011 10:36 PM
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.
03-14-2011 10:54 AM
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.
03-14-2011 11:14 AM
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.