Modbus TCP/RTU

Print version

8. Modbus TCP/RTU

Use of Modbus in RipEX.

RipEX supports Modbus RTU, Modbus TCP as well as their combinations:

Tab. 8.1:

 Centre
protocol
Remotes’ protocolRadio network behaviourAvailable with Operating mode
1RTURTUModbus RTU over Radio channelBridge, Router
1.1Multiple Masters RTURTUModbus RTU over Radio channelRouter
2TCPTCPTCP/IP protocol over Radio channelBridge, Router
3TCPTCPTCP/IP protocol locally between Modbus device and RipEX. TCP/IP overhead is not transferred over Radio channelRouter
4TCPRTUConversion of Modbus TCP to Modbus RTU on the remote unitsRouter
5TCPCombination of TCP and RTUUsing 3 and 4Router
6Multiple TCP and multiple RTU mastersCombination of TCP and RTUTCP master communicates with TCP or RTU slaves, RTU Master only communicates with RTU slaves, utilising 1.1 and 5Router

8.1. Modbus RTU

A standard simple network design with a single Master and several Slaves running Modbus RTU.

Modbus RTU

Fig. 8.1: Modbus RTU

In Bridge mode, set the type of communication interface (RS232 or RS485) for the COM port as well as the parameters of the serial interface, both for the Master and Slave.

In Router mode, set the COM port of your Master RipEX to Modbus (Mode of Connected device). To translate Modbus addresses to RipEX format and vice versa either use a mask (if RipEX addresses mirror the Modbus ones) or table. A table must be used if there are several Modbus slaves behind a single RipEX (RS485 or both COM1 and COM2). For more information refer to on-line help or chapter Protocols / Common parameters of the manual.

In addition, set Modbus to Slave on all remote units. If you intend to broadcast in Modbus, set the required parameters. For more information refer to on-line help or chapter Protocols / Slave of the manual.

8.1.1. Modbus RTU with multiple Masters

Modbus RTU with multiple Masters

Fig. 8.2: Modbus RTU with multiple Masters

RipEX allows for several Masters to operate at the same time and to communicate with the same Slaves. Router mode is presumed in this design. RipEX settings remain the same as above. Each Slave responds directly to the Master unit which queries it – i.e. if Master A issues a query to a Slave, the response is sent exclusively to Master A. If a single Slave is queried by two Masters at once, queries are resolved one by one. Query from the second Master is queued inside RipEX until it receives a response from Slave RTU on its serial interface or until 500 ms timeout has passed.

8.2. Modbus TCP

A standard simple network with a single Master and several Slaves running Modbus TCP. A TCP/IP connection is established and maintained between Master PLC and Slave RTU across the entire radio network.

In Bridge mode, no special setup is required. RipEX operates as an intelligent Bridge. For more information refer to on-line help or chapter ETH / Modbus TCP of the manual.

In Router mode, routing must be set up in the radio network. Communication between the IP address of the Modbus Master and IP addresses of all Modbus Slaves is necessary. Remember to set Modbus TCP/RTU and Terminal Servers (under Settings/Ethernet) to Off.

Modbus TCP

Fig. 8.3: Modbus TCP

8.3. Modbus TCP, local TCP/IP connection

Note – Only works in Router mode.

TCP connection is established only locally between Modbus devices and the connected RipEX units. TCP protocol overhead is not transmitted over the Radio channel. Secured TCP/IP transfer is not necessary because in Router mode every packet in the Radio channel is acknowledged on every radio hop. A packet is therefore repeated directly in the part of the network where it is lost, not across the entire radio network as in TCP/IP. This improves latency and increases network throughput.

Modbus TCP local

Fig. 8.4: Modbus TCP local

Set your Modbus TCP Master to use a single IP to communicate with Modbus TCP Slaves (RipEX ethernet IP) and set TCP port to 502. Communication begins on port 502 from where it is redirected to other RipEX ports, corresponding to the individual RTU’s, based on negotiation with the Modbus TCP Master.

To set up RipEX connected to Modbus TCP Master:

  • Set Modbus TCP/RTU to On. Type the port number on which the connected Modbus TCP Master initiates communication, by default 502, into “My TCP Port” field.

  • Select how you want to translate Modbus addresses to RipEX IP addresses (using mask or table). Set the UDP interface to Terminal server (TS1-TS5). Set the same TS for remote RipEX’s too.

[Note]Note

The maximum number of concurrent TCP/IP connections between a Modbus TCP device and RipEX is set to 10 due to limited computing capacity. (Note: The number of concurrently open TCP/IP connections can be increased using CLI if necessary.) Modbus TCP Master must be set to not open more than 10 TCP/IP connections at any given time.

To set up RipEX connected to Modbus TCP Slave:

  • Modbus TCP/RTU – Off

  • Terminal Servers – On

  • Set the Terminal Server (see RipEX Master settings) to TCP and set My Port to 502. Use the address of the connected Modbus Slave as the destination IP and fill in the destination port number which the connected Modbus Slave device scans for incoming communication.

  • Set Protocol to UNI and Mode of Connected device to Slave.

8.4. Master – Modbus TCP, slaves – Modbus RTU

Note – Only works in Router mode.

Master establishes a local TCP connection to RipEX using Modbus TCP protocol, as described in chap. 3. A packet is securely sent over the Radio network to RipEX to which the destination Slave is connected by COM port. The RipEX translates the packet to Modbus RTU format and sends it to the connected Slave using Modbus RTU protocol.

Modbus TCP - RTU

Fig. 8.5: Modbus TCP – RTU

To set up RipEX connected to Modbus TCP Master:

  • Select the type of translation from Modbus to RipEX IP address (mask or table), as described in chapter 3.

  • Set the UDP interface to COM1 or COM2 depending on the port that the remote RipEX uses to connect to the Slave device.

To set up RipEX connected to Modbus RTU Slave:

  • As described in chapter 1 set the appropriate COM to Modbus and the Mode of Connected to Slave.

8.5. Master Modbus TCP, slaves Modbus RTU or Modbus TCP

RipEX radio modems enable full featured cooperation between the Master using Modbus TCP and slave devices using Modbus RTU or Modbus TCP within a single network.

Modbus TCP, Slave RTU or TCP

Fig. 8.6: Modbus TCP, Slave RTU or TCP

To set up RipEX connected to Modbus TCP Master:

  • Set the translation from Modbus to RipEX IP addresses to table-based, as described in chapter 3.

  • For devices connected over Modbus RTU, set the UDP interface to COM1 or COM2 (as in chapter 4).

  • For devices connected over Modbus TCP, set the UDP interface to TS1-TS5, as described in chapter 3.

  • You can define address ranges in the table for greater ease of use.

To set up RipEX connected to Modbus RTU Slave:

  • See chapters 4 and 1 respectively.

To set up RipEX connected to Modbus TCP Slave:

  • See chapter 3.

8.6. Multiple Modbus TCP or Modbus RTU Masters and Slaves

Any combination of network designs described in chapters 1–5 is possible. The only limitation is that a Master with Modbus RTU cannot communicate with a Slave using Modbus TCP.

A Slave with Modbus RTU protocol may simultaneously communicate with masters using Modbus TCP and Modbus RTU. The network will deliver responses only to the Master which issued the queries using the appropriate protocol.

The individual settings are described in chapters 1–5.

Modbus TCP, Slave RTU or TCP

Fig. 8.7: Modbus TCP, Slave RTU or TCP