Beijer Electronics (formerly QSI Corporation)
http://www.qsiforums.com/

Modbus register returns two unsigned integers.
http://www.qsiforums.com/viewtopic.php?f=6&t=4485
Page 1 of 1

Author:  Rbyte [ Wed Nov 14, 2012 1:16 pm ]
Post subject:  Modbus register returns two unsigned integers.

From a G72 I am trying to read data from an input register from a power inverter using the MBgaugeV2 object. The register format is a chain of two 8 bit unsigned integers. Vartype is mb_int16. I just want to read the high data which happens to be the percent of motor load but I can't seem to properly convert the value to get a reading. I tried using the following code which isn't giving me the proper value which should be a hex value (64 representing a full load).

func ValueChanged()
dim data[] as byte
data = GetBytes(value,true)
lbltest5.value = str(data)
endfunc

How should the data be converted to just read the high data value? I can read all the register that return one 16 bit unsigned register. I am just having problems with this data format.

Author:  Ron L. [ Thu Nov 15, 2012 10:10 am ]
Post subject:  Re: Modbus register returns two unsigned integers.

Using an MBVirtualRegister, the code would look something like this:

Code:
init commobj := modbuscomm
init parent := default
init register := 1
init vartype := mb_uint16

func ValueChanged()
    dim data[] as byte

    data := GetBytes(unibyte(me.intValue), true)
    lbltest5.value = str(data)
endfunc

Author:  Rbyte [ Fri Nov 16, 2012 12:16 pm ]
Post subject:  Re: Modbus register returns two unsigned integers.

I had to switch to using a VirtualRegister but your code snippet works perfectly.
Thanks again Ron

Page 1 of 1 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/