Periodic write of channel group


Recommended Posts

I have a channel group that contains a mixture of user-input values and values computed by DF with the user inputs and measured process values, about 20 channels total.   This group is set up to be read by a remote Wonderware instance, and the channels have been set up as Modbus  slave registers.    I can [usually] read the channels but for some reason Wonderware has issues with it.

If I set the channels up as writes (SetRegister) I find that I cannot set a timing nor offset.   Typically writes are event-driven, so that's expected, but I'd like to write the group en-masse periodically.  There doesn't exist a WriteGroup() analgous to ReadGroup(), and even if there were, I don't want the individual channels writing event-triggered as they're computed in script.

Two approaches have occurred to me:   (1) Disable the comm device before the computations (which are close together in script) and reenable when complete, but I doubt that the group would then automatically write, just from having been reenabled, or (2) leave the channels as Test Channels in the channel table, and create a new array variable.   As the variables are calculated, append them to the array, then when complete, execute the write from script.

Any other approaches that seem viable?

Link to comment
Share on other sites

I think I'm confused.  So DAQFactory is the Modbus slave?  Ah, so the issue is that you can't update the channels so that Wonderware gets them all at the same time.  You may have to use a flag to tell Wonderware when to read the channels.  Set the flag to 0 to tell Wonderware to stop looking, update the channels, then set it back to 1.  Are you on serial or Ethernet?  That will make a big difference.

Link to comment
Share on other sites

  • 2 weeks later...

Originally, DF WAS a TCP server, but Wonderware for whatever reason was having trouble getting a response to the polled registers.

Round 2:   Installing a Modbus RTU (slave) to Modbus/TCP (server) gateway.  I want DF to be the RTU master, so that I can control the frequency and timing of data transfer to the gateway.   What I didn't realize is that outgoing (write) channels are ONLY event driven on a write (which most times is what you want).   You can't enter timing and offset in the channel table, and there's no WriteGroup() equivalent to ReadGroup().    So my problem was that as I calculated the 20-25 values in sequence, each time I calculate one, DF is going to generate a one-channel write, which is not what I want.   What I want is to write all 25 or whatever on a timed interval, analogous to the way reads are done. 

I ended up using option (2) above.   Create a new array variable, execute MyArray.Append(CalcedVarNN) as I calculate the variables, then do a single write of the entire array from sequence on a time schedule.

Link to comment
Share on other sites

To make it easier, I would use Test channels, then in the Event of the test channel, have it update the array:

MyArray[3] = mychannel[0]

Don't use Append since you need the values in a certain location.  Remember, you can do:

global x

x[3] = 4

and it will automatically expand the array to 4 elements (filling with 0's).

Anyhow, this way you can continue to use channels, which are a bit easier with the user interface elements, having the array automatically update.  Then as you said, in script, send the whole array to the other software in a single function call.

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.