Modbus/TCP gateway:
Connecting serial Modbus/RTU slaves to a Modbus/RTU master
The Com-Server works here in Modbus/TCP gateway mode. Incoming Modbus/TCP requests from the network are converted into Modbus/RTU requests. In the return direction, the response datagrams of the slaves are converted and forwarded to the master using the original transaction ID.
Quick Startup
-
Configure the RS485 2-wire mode via the internal DIP switches: 1,2,5 = ON, rest = OFF. Activation of the termination (switches 6 and 7) depends on the existing RS485 bus structure. A physical RS485 segment may contain a maximum of two termination networks.
-
Provide the power supply and the connection of the serial RTU device to the Com-Server, e.g. with the RS485 screw-in adapter.
-
Assign the IP parameters (IP address, subnet mask, gateway) to the Com-Server using WuTility.
-
Set the serial transmission parameters on the Com-Server to match the connected RTU device. The handshake must be None.
-
Activate Modbus/TCP Gateway. mode and specify a timeout.
-
Important: The settings made must be saved via the logout page.
The Com-Server now works as a Modbus/TCP gateway and expects connections on the standard port 502/TCP. In the respective Modbus/TCP master, treat the serial Modbus/RTU device located behind the Com-Server as a Modbus/TCP device. In other words, the address of the Com-Server with TCP port 502 is specified as the target IP. The Modbus addresses and Modbus function codes to be used must be taken from the documentation of the RTU device. They are used unchanged in the Modbus/TCP master.
Example:
Settings on a Modbus/TCP master for reading register 8192 (decimal) with Function Code 3. The RTU device is located on the serial port of the Com-Server with IP 10.40.21.28 and operates at Address 1.
Possible problems
Activation of the Modbus/TCP gateway operating mode and the current network-side connection status can be found on page Setup Port x → Port State. The page is not self-updating and must therefore be updated manually by pressing F5:
Connection State
An existing TCP connection to a Modbus/TCP master is displayed in the 2nd line of the Connection State.
Absence of the line In Use ... indicates network-side problems. Check:
- The destination IP address and destination port number used in the Modbus/TCP master
- Whether the port number set for the gateway service in the Com-Server is set to the default value 502 (Setup Port x → TCP/IP Mode → Port List)
- The network connection between the Modbus/TCP master and Com-Server
- Whether firewalls in the infrastructure are blocking the connection
Further Modbus-specific information can be found on the page Setup Port x → TCP/IP Mode → Modbus/TCP Gateway → Debug.
Counter Fast Requests
When Gateway mode is activated in the Com-Server, the Response Timeout is also configured. This is started when a request is forwarded to the serial RTU slave and stopped when a response is received or the time has elapsed. If the response timeout is active, further requests arriving on the network side are discarded by the Com-Server and recognized as Fast Requests. Possible causes:
- The response timeout on the Modbus master should always be greater than that on the Com-Server and must take into account the response time of the respective slave as well as the runtimes of the serial data and the network latencies.
Counter Response Timeout
If the response timeout started with the forwarding of a request expires without a response from the serial slave being received, this event is added to the Counter Response Timeout. Possible causes:
- Mismatching serial transmission parameters on the Com-Server and the serial RTU slave
- Bus polarity reversed on the RS485 side
- Cable break, incorrect pin assignment etc. on the RS485 side
- Response timeout too low in the basic mode settings Modbus/TCP Gateway (especially in conjunction with Ghost Responses)
- The slave ID configured in the Modbus/TCP master does not match the address set on the RTU slave
Counter Ghost Responses
The response of the RTU slave arrived after expiration of the Response Timeout configured in the Com-Server. Ghost responses can no longer be assigned to a Modbus/TCP and are discarded by the Com-Server. Possible causes:
- Response timeout too low in the basic settings of the Modbus/TCP Gateway mode (especially in conjunction with Response Timeouts)
Counter CRC16 receive error
The Com-Server has received a response from the RTU slave with erroneous checksum. Possible causes:
- EMC problems
- Excessive attenuation of the RS485 cable, e.g. due to excessively long cable
- More than two terminations on the RS485 segment
Send PDU Request
The documentation for Modbus/RTU slaves is not always clear with regard to the register assignment and the register addresses to be used. For these cases, a Com-Server in operating mode Modbus/TCP Gateway offers the option of freely formulating and sending RTU requests in hexadecimal format. The Modbus checksum is automatically added by the Com-Server. Responses from the slave are also displayed in hex format on the website.