When programming Modbus Commands, correct sequencing of the Client Commreqs is of great importance. Otherwise, communication does not work reliably. Repeated PLC Fault messages like “Mailbox Queue full” or “Backplane communications with PLC fault; lost request” further indicate an issue. Worst case, the Ethernet interface may cease operation.
The most common error cause is Commreqs being executed permanently, or more often than the Ethernet Interface can handle them. The program needs to strictly follow a few rules to avoid errors:
- Commreqs must always be executed with a one shot.
- On the same channel, only one Commreq may be active at a time.1) Every Commreq must be monitored for completion (with, or without success) before sending a new one. Only a close command, may be sent any time.
- The correct sequence of operation is opening a channel and then continuously reading or writing data on it. The application should not close a channel unless it really wants to stop communication. It is however advantageous to send a close command after the Modbus Channel Bit drops or an attempt to open the channel failed.
1) Commreqs to different channels may be active at the same time.
The attached logic block demonstrates best practices establishing a connection to a Modbus slave and continuously read and write data.
Import the block into a project and call it every sweep. Follow instructions in the commentary to adapt logic for application needs.
The block can be easily copied for use with multiple channels.
Note: The logic uses some %R areas for status word, fault collection and Modbus commands. Make sure to adjust addresses so they do not conflict with existing logic.
References
GFK-2224 TCP/IP Ethernet Communications for PAC Systems™