Beijer Electronics (formerly QSI Corporation)

Manufacturer of Mobile Data and Human Machine Interface Terminals.
It is currently Fri Nov 24, 2017 6:15 am

All times are UTC - 7 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Wed Jun 17, 2009 9:52 am 
Offline
User avatar

Joined: Thu Mar 02, 2006 2:12 pm
Posts: 487
Location: Salt Lake City, Utah
Here is some sample code of how you might use the RegisterValueChanged, and CoilValueChanged events of the MBSlaveV2 object. This is only if your going to use the Qlarity-based terminal as a Modbus slave. If your going to use the terminal as a Modbus master, than see this tutorial:
http://www.qsicorp.com/pdf/?id=appnote/ ... bus_master

Code:
func RegisterValueChanged(register as unibyte, length as unibyte)
    dim i as integer
    dim tmpF as float
    dim tmpI as integer

    'each register is 16 bits, reading two registers for 32 bit variables
    for i = register to register+length-1 step 2
        if register == 1 then
            tmpF := me.GetRegisterFloat(true, register)
            label_1.value = _formatFloat(tmpF, 0, 2, _FLOAT_NORMAL)
        elseif register == 3 then
            tmpI := me.GetRegisterInteger(true, register)
            label_2.value = str(tmpI)
        endif
    next
endfunc


Code:
func CoilValueChanged(coil as unibyte, length as unibyte)
    dim i as integer

    for i = coil to coil+length-1
        if coil == 1 then
            checkbox_1.isChecked = me.GetCoil(true, coil)
        elseif coil == 2 then
            'etc...
        endif
    next
endfunc

_________________
Ron L.

http://www.beijerelectronicsinc.com/


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

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