- Frame format
- Devices / Masters
- Modbus RTU/TCP gateway (Volison)
- USB to RS485 converters
- Modbus RTU/TCP gateway (NITOT)
- Devices / Slaves
- PBX systems
- Upload Arduino code
Modbus RTU/TCP gateway (Volison)
This is a multifunctional serial Modbus gateway, which integrates Modbus TCP, Modbus RTU and Modbus ASCII protocol. It can be used to seamlessly integrate Modbus Ethernet devices with Modbus serial devices. Using this guide, you can see how to wire the slaves to it, how to set up, and there is an example how use.
Connect the Modbus RTU/TCP gateway to PC
You can connect maximum of 247 slaves (such as relay board, temperature sensor etc.) in parallel to the Modbus RTU/TCP gateway. Each device need to be set the same serial port parameters including baud rate, data bits, stop bits and parity. Furthermore, each device must be have an unique slave ID. The Figure 1 shows how to wire these devices to the gateway. If the devices have not got the same voltage requirements, they must be operated from a separated power supply. Finally, you need an Ethernet cable to connect the Modbus gateway to the PC.
Figure 1 - Modbus RTU/TCP gateway wiring diagram
Specifications of Modbus gateway
|Power supply||DC 9 - 48V|
|Maximum current||200 mA|
|Working ways||RTU Master - TCP Slaver
TCP Master - RTU Slaver
ASCII Master - TCP Slaver
TCP Master - ASCII Slaver
|Supported serial ports||RS232 / RS422 / RS485|
Setting up the Modbus RTU/TCP gateway
For successful communication, you need to change the network settings of your computer so that the computer and the Modbus gateway are in a common subnet. The following Table 2 shows an example what should be set when the gateway uses its default settings.
|Computer network settings should be||Gateway default network settings|
After successful configuration, open your web browser and type the IP address of the Modbus gateway: 192.168.10.254 to the browser URL bar. After the page have loaded, you will see the overview (Figure 3) of the gateway. In this surface, you can configure all the gateway setting including network, serial and modbus settings.
Figure 3 - Modbus RTU/TCP gateway overview
Under network settings (Figure 4), you can customize the Modbus gateway network setting. You can communicate with the gateway using these settings. Only change it if necessary, otherwise leave it in the default settings.
Figure 4 - Modbus RTU/TCP gateway network settings
Maximum of 247 devices can be connected in parallel to the Modbus gateway and their serial port settings such as baud rate, data bits and stop bits of these devices need to be match with each other. These settings must be specified for the Modbus gateway under serial setting (Figure 5). The timeout determines every packet by determining the time interval between characters. The interface determines the type of the serial port.
Figure 5 - Modbus RTU/TCP gateway serial settings
In modbus operating settings shown on Figure 6, the operation mode determines the way of working. In this case (TCP Master - RTU Slaver), the network is the Modbus TCP master device, and the serial port is the Modbus RTU slave device. The connections sets the maximum connection to the Modbus gateway. The default port number of the standard Modbus TCP protocol is 502, but you can also modify it according to your own application. The master device needs a response timeout time when accessing slave device. This time is the message timeout. The ID mapping in auto ID mode, the gateway does not make any change on the request frame. If it changed to fixed, the gateway change the the slave ID of the request Modbus frame to the set value in Fixed ID Value textbox.
Figure 6 - Modbus RTU/TCP gateway modbus settings
For more information about how to set up the gateway, please download the documentation.
Latch channel 1 of a relay board using Modbus TCP
Let's take a 4 channel relay board. After you have connected it the Modbus gateway, attached the gateway to the PC via Ethernet cable and configured it, open the Modbus gateway settings on your web browser. The serial port parameters of this relay board are fixed. So, you need to set these settings (baud rate: 9600, parity: even, data bits: 8, stop bits: 1) in serial settings menu then select the interface as RS-485 and press Submit.If you would like to latch channel 1 using Modbus RTU, you should send this Modbus RTU message in hex format:
|01 06 00 01 04 00 DA CA|
This Modbus RTU message is equal to the following Modbus TCP message:
|00 01 00 00 00 06 01 06 00 01 04 00|
So you need to put the the RTU message into the TCP frame without CRC, like the Figure 7 shows.
Figure 7 - Modbus RTU and TCP
Let's see this Modbus TCP/IP message in more detail. The first 2 bytes (0x0001) are the transaction ID that is the identification of the Modbus request/response transaction. The next 2 bytes (0x0000) are the protocol ID. The protocol ID 0 identifies the Modbus protocol. It followed bye 2 bytes (0x0006) that are the message length in byte. Then, there is a unit ID (0x01) that is equal to the slave ID in RTU message. Finally, there are the function code and the data field came from Modbus RTU message. The following Table 3 summarizes these.
|Octet(s)||Description||Format||In this example|
|00 01||transaction ID||hex-octet||the ID of this Modbus request is 1|
|00 00||protocol ID||hex-octet||protocol ID 0 identify the Modbus protocol|
|00 06||message length||hex-octet||the message is 6 bytes long|
|01||unit ID||hex-octet||unit ID equal to the slave ID of the relay board|
|06||function code||hex-octet||function code, described in the guide of the relay board|
|00 01 04 00||data||hex-octet||data, described in the guide of the relay board|