Beijer Electronics (formerly QSI Corporation)

Manufacturer of Mobile Data and Human Machine Interface Terminals.
It is currently Sat Nov 18, 2017 5:52 pm

All times are UTC - 7 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Wed Nov 14, 2012 1:16 pm 
Offline

Joined: Mon Sep 24, 2012 12:58 pm
Posts: 2
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.


Top
 Profile  
 
PostPosted: Thu Nov 15, 2012 10:10 am 
Offline
User avatar

Joined: Thu Mar 02, 2006 2:12 pm
Posts: 487
Location: Salt Lake City, Utah
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

_________________
Ron L.

http://www.beijerelectronicsinc.com/


Top
 Profile  
 
PostPosted: Fri Nov 16, 2012 12:16 pm 
Offline

Joined: Mon Sep 24, 2012 12:58 pm
Posts: 2
I had to switch to using a VirtualRegister but your code snippet works perfectly.
Thanks again Ron


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 7 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group