User Manual

Communication
109357_en_00 PHOENIX CONTACT 145 / 196
11.2.3 Modbus/TCP
In the case of Modbus/TCP, a special header (Modbus Application Header [MBAP]) is
prefixed to the Modbus header. This Modbus/TCP message is then transmitted via an IP-
based network in a TCP frame.
The EMpro acts as Modbus/TCP server and opens port 502 for communication with any
Modbus/TCP clients. This port cannot be configured by the user.
Since TCP is a connection-oriented protocol, a client first has to establish a TCP connection
with the EMpro to exchange data via Modbus/TCP.
The number of Modbus/TCP connections that can be open in parallel on each version of the
EMpro product family is limited to four.
If there are already four open Modbus/TCP connections on the EMpro, additional
connection queries on port 502 are rejected.
Additionally, to enable Modbus/TCP communication, the user has to make sure that this
port is enabled in the network.
The MBAP contains a field that is declared as unit identifier in the specification. This unit
identifier is comparable with the device address of Modbus/RTU. However, it is not relevant
for the EMpro in the case of Modbus/TCP and is ignored by the device since the address
already has a unique address in a network through its IP address. An exception applies if
the device is operated in gateway mode (see Section “Modbus gateway” on page 145).
The Modbus TCP specification recommends using 255 as unit identifier for queries.
All EMpro versions support the Modbus TCP protocol.
11.2.4 Modbus gateway
EMpro versions with an RS-485 interface can optionally be operated in gateway mode.
By default upon delivery, the gateway mode is not active. In this case, the device acts as
Modbus TCP server on the Ethernet interface and as Modbus/RTU slave on the RS-485
interface.
When the gateway function is activated, the device behaves as Modbus gateway on the
Ethernet interface and, in parallel, continues to operate as Modbus TCP server (can be
reached via unit identifier == 255).
On the RS-485 interface, the device now acts as Modbus/RTU master. As master, the
EMpro can now independently send queries in the network (note: there must be no other
master in the system).
As Modbus gateway, the device converts an incoming Modbus TCP message (that does
not have the unit identifier 255 in the MBAP header) into a Modbus RTU message and
forwards it to the appropriate receiver in the Modbus RTU network. On the TCP side,
the unit identifier is used for addressing the Modbus RTU receiver. In turn, the response is
converted from Modbus/RTU format back to Modbus/TCP format and is sent to the
querying client as Modbus/TCP response.