Beijer Electronics (formerly QSI Corporation)

Manufacturer of Mobile Data and Human Machine Interface Terminals.
It is currently Sun Nov 19, 2017 8:57 pm

All times are UTC - 7 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Thu Aug 04, 2011 5:38 am 
Offline

Joined: Wed Aug 03, 2011 8:44 am
Posts: 7
We're using a G-58 terminal as Modbus Master.
I found the function QueryInputCoils() which is indeed able to query multiple coils. The question is rather, how can I evaluate the response ?

As parameter obj, I assigned a MBVirtualCoilV2 object. If I query 3 coils, where is the response stored ? The property ischecked reflects the state of 1 coil only. Right ? What's about the other 2 coils :?:

Regards,
Tony :-)


Top
 Profile  
 
PostPosted: Thu Aug 04, 2011 8:01 am 
Offline
User avatar

Joined: Thu Mar 02, 2006 2:12 pm
Posts: 487
Location: Salt Lake City, Utah
If you're going to use that function that is more advanced Qlarity programming and you'll want to look at the code from one of the existing Modbus objects such as the MBVirtualCoil.

You'll want to create an object or you can use 'default' for the object name so the response is sent to globals. When the result of your query has finished, one message will be sent to the object or globals (if you used default). You'll want to create the necessary functions to handle the possible messages. Here is some sample code copied from the MBVirtualCoil that has these functions.

Code:
private func timeout(dummy as integer) returns boolean
    handles MB_TIMEOUT_ON_REPLY
    noSlaveResponse()
    return true
endfunc

private func queryreply(dummy as integer) returns boolean
    handles MB_RECEIVED_QUERY_REPLY
    dim response[] as boolean
    dim oldvalue, newvalue as boolean

    queryPending := false
    if ignoreQuery then
        ignoreQuery := false
        return true
    endif

    oldvalue := isChecked
    response = commobj.getquerycoilresponse()

    check error
        newValue := response[0]
    on error
        _clearException()
        valuechangefailed()
        return true
    enderr

    dontsend := true
    isChecked(newvalue)
    dontsend := false
    if oldvalue <> isChecked then
        valuechanged()
    endif

    return true
endfunc

private func queryReplyFailed(dummy as integer) returns boolean
    handles MB_QUERY_FAILED
    queryPending := false
    ignoreQuery := false
    QueryFailed()
    return true
endfunc


The MBVirtualCoil was designed to query a single coil. It will not work with more than one. You would have to design a new object. But I wouldn't go through the trouble, just make as many MBVirtualCoils as you need.

_________________
Ron L.

http://www.beijerelectronicsinc.com/


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 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