Message optimization


Recommended Posts

I have a number of tags being read, They are inside a structure in the plc and are a mix of Integer and Real values.

Even though all registers are sequential when a monitor the communications each datatype is being requested independantly.

This means that for the 10 registers, Daq is actually making 4 seperate data requests.

All channels are in the same group and are being read by the ReadGroup command.

Is there anyway to have DAQ relise that these are sequential holding registers and read them in one message.

Or would using an OPC with some message optimization be a valid alternative ?

Thanks in advance.

Link to comment
Share on other sites

DAQFactory does not currently optimize across varying I/O types, however, you can pretty easily handle this manually, especially if you are only doing 10 registers. Simply read the data in as standard U16 registers, then use the To. functions to convert consecutive registers into single values and then stuff them into channels. Obviously you'd need to do this in script, but since you are using ReadGroup already, I presume you are using script already.

1) Use the device.myDevice.ReadHoldingU16() function. The result will be an array with multiple columns and a single row.

2) Use myChannel.addValue() to shove the results into a channel, iterating through the array.

3) any place you need to convert to a float, use To.rwFloat (it might be one of the others, but my guess off the cuff is rwFloat). So, if the first two registers are U16, but the 3rd and 4th need to be combined into a float, and the data is in a variable called datain, it be something like:

To.rwFloat(concat(transpose(from.uword(datain[0][2]),0), transpose(from.uword(datain[0][3]),0)))

We have to take the 2 byte registers and convert them into bytes before we can recombine into a float. The transpose() function is needed to get everything in the right dimension.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.