Open Sockets - Transactions, Requests, Rebuilds(ReqBuilt)
FactoryTalktotheHand said:
...Are you saying if he's also using Modbus TCP then the produced/consumed tag model won't work?...
No, I was saying if he was
only using Modbus TCP then the produced/consumed tag model won't work. If only Modbus TCP, gabidamir would have to use Explicit Messaging to implement Open Sockets communications.
Because Ethernet/IP and Modbus TCP can co-exist on the same network, Ethernet/IP is not impeded in anyway by the presence of Modbus TCP on the network. Ethernet /IP can continue to service normal functions like produced/consumed data, Distributed I/O, HMI communications, Messaging, et al.
gabidamir said:
...They say that upon a write function I need to clear the reqBuilt flag when there is new data to be written. My question is if the pollinterval is set to a certain value and my program writes the new data into the tags that the Modbus application is taking its data from why do I need to clear this flag?
Or is it that the command is only done if the flag is 0?
If so what about the reads? Isn't it the same?...
No, it's not the same for reads, and your program is not writing the
new data. At least not unless you instruct it to. Open Sockets is somewhat different to normal communications you may be used to...
When you configure an Open Sockets "Read" transaction, you are setting the parameters for the transaction to "Read" from a set address, or array of addresses, at a polled interval. Because the Master
does not influence the data being read from the address, or addresses, it only needs to "Build" the transaction once, and then continues to read in the data, regardless of whether that data is static, or dynamic. This way, a "Read" transaction is blindly polling the data without needing to refresh the transaction.
When you configure an Open Sockets "Write" transaction, you are setting the parameters for the transaction to "Write" to a set address, or array of addresses, at a polled interval. Because the Master
does have an influence on the data being written, it must rebuild the transaction each time the data to be written changes, else it will keep writing the value of the data when the transaction was first built i.e. potentially stale data.
Example "Write" Transaction:
PollInterval = 10 (10 x 100ms = 1sec)
TransType = 15 (Modbus - Write Multiple Coils)
BeginAddress = 99 (Start writing to 00100 (00 = Coils; 100 = address)
Count = 25 (25 Coil addresses will be written)
LocalOffset = 100 (Starting at index address 100 through 124)
When a "Write" transaction is called, a "Request" string is "Built" using the values you have set for the transaction. This string is used when a "Connection" is established with the other device. If the data being written changes, this "Request" string must be rebuilt in order to refresh the transactions data i.e. the "Request" string must be rebuilt. This is enabled by a reset of the "ReqBuilt" bit, forcing the transactions "Request" values to be refreshed.
The only other way to refresh the data to be written is to close and reopen the Connection, forcing a rebuild. but this is not efficient.
Regards,
George