serial ethernet device servers
   Home   |  Sitemap
serial ethernet device servers
EtherPAD Modbus Configuration
serial ethernet device servers
Introduction

Modbus is a proprietary protocol used mostly in the process control industry. A Modbus device is used as either a Master or Slave device and these devices are normally physically connected to each other with a serial RS232/RS485 cable. Two EtherPADs configured back-to-back for Modbus operate as a Modbus Bridge, connecting the Modbus master and slave devices logically, via Ethernet, thereby also providing network connectivity to the Modbus devices.

Not all Modbus devices are created equal. Therefore, a number of configuration options on the EtherPAD Modbus Bridge are available to configure the Bridges for optimal performance. A Modbus Bridge (EtherPAD/EtherPAD) can be configured as a Slave Bridge (connected serially to one or more Modbus Slave devices) or as a Master Bridge (connected serially to a Modbus Master device). An EtherPAD can also be configured for the Modbus ASCII or Modbus RTU serial protocols and Modbus/TCP or Modbus/UDP network protocols.

It is necessary to understand the implications of the configuration options, as incorrect configuration will adversely affect the performance of the EtherPAD. Brief explanations of the different timeouts and their dependencies are described in the serial port configuration and Master/Slave configuration sections hereafter.

If problems are encountered setting up the devices, it is advisable to connect the dedicated configuration port to a terminal application, such as HyperTerminal (19200, 8, N, 1). Set the Debug Modbus option and Enable Debug Output. All errors will be displayed on the serial configuration port, which will assist in finding the specific problem. Once the problem has been resolved, reset the Debug Modbus option as enabling the debug options adversely affects the performance of the EtherPAD.

Top of page
serial ethernet device servers
Typical Modbus setup

EtherPad Modbus Typical Setup

A Typical Modbus setup

Top of page
serial ethernet device servers
Modbus ID Mapping

All Modbus master and Slave devices are identified by using one or more IDs (Identification Numbers). Any message sent to or from a Modbus device must have a valid ID contained in the message. If the ID(s) of the Master and Slave(s) devices differ, the IDs can be remapped to the correct numbers, therefore eliminating the need to re-configure the serial devices.

The EtherPAD's Unit ID mapping provides translation between the device ID on the serial interface and the ID transmitted on the Modbus/TCP network connection, and vice versa.

Example
The Mapping 3..3 -> 4..4 will rewrite queries received from the Modbus Master device for address 3 to address 4 before sending the query over the network to the Modbus/TCP Slave. Replies from the Modbus/TCP Slave are then mapped back from address 4 to address 3 before forwarding the reply back to the Modbus Master device.

The following examples show how Unit IDs can be specified:
  • 3..3 -> 3..3 - no address mapping will be performed for device ID 3.
  • 15..20 -> 15..20 - no address mapping will be performed for device IDs between 15 and 20.
  • 10..20 -> 80..90 - all device IDs between 10 and 20 will be mapped to a device ID between 80 and 90.


If a query was received for a device ID that has no matching entry in the Mapping Table, an exception will be returned immediately to the Modbus Master device.

Normally mapping on the serial Slave device is not necessary: the remote ID(s) (from the network) is/are the same as the local unit ID(s) to the serial device.

Consider the following mapping example:

EtherPad Master Bridge Mapping Table

Master Bridge

EtherPad Slave Bridge Mapping Table

Slave Bridge

The Master Bridge will receive messages from the Master Serial device (local unit) with IDs 1 to 3. These IDs are translated to a network ID (remote unit) in the range 6 to 8. The Slave bridge will only accept messages from the network (remote unit) in the range 6..8. These IDs are translated to 10..12 before being passed to the slave serial device(s).

When sending the reply, the Slave Bridge will only accept messages with IDs 10 to 12 from the serial slave device. These IDs will be translated to remote IDs 6 to 8 before being sent via the network to the Master Bridge. The Master Bridge will then translate IDs 6 to 8 back to the local (serial) IDs 1 to 3 before transmitting them to the serial master device.

Top of page
serial ethernet device servers
Serial Interface Settings for Master or Slave

Serial Interface Settings for Modbus Master/Slave

Serial Interface Settings for Modbus Master/Slave

Browser:
  • Click Serial Application
  • Click Change Serial Parameters

Serial Parameters

Serial Parameters

Serial Interface - the name of the serial interface under configuration.

Data Bits - the number of data bits (5, 6, 7 or 8). The default is 8.

Stop Bits - the number of stop bits (1 or 2). The default is 1.

Parity - the parity setting. The default is None.

Speed (Baud rate) - select the appropriate baud rate of the serial Modbus device.

Flow Control - this must be set to None for Modbus applications.

Connection Type - the type of serial connection to be used.
- RS232 - full-duplex direct serial connection to the device.
- RS422 - full-duplex 4-wire serial connection to the device.
- RS485 - half-duplex 2-wire serial connection to the device.

Protocol - the protocol used to communicate with the serial device. The available protocols are dependent on the optional features that are enabled. Select Modbus RTU or Modbus ASCII.
- Modbus/RTU - the Modbus protocol using RTU framing.
- Modbus/ASCII - the Modbus protocol using ASCII framing.

Protocol Options Message length and Message Terminator - These values are ignored for Modbus applications.

Message Timeout - Defines the maximum time between characters received from the serial device (Master or Slave device). For the Bridge to determine the end of a message received from the serial device, the Bridge will wait this amount of time for the next character. If no character is received, the EtherPAD assumes that the complete message has been received and the data is sent to the Slave device via the network. If this value is set too small, the complete message may not be received and data from the serial device will be lost. If this value is set too large, the performance of the Bridge will be negatively affected. Also take note that this timeout is influenced by the selected baud rate. Usually, the slower the baud rate, the larger the timeout.

For Modbus ASCII, a value of 1000 ms should be sufficient.
For Modbus RTU, the maximum value of 142 ms is allowed. Setting a higher value may cause your device to lock up during the boot sequence (you will need to serially reset to default factory settings to recover from this error).

For Modbus RTU, the values in following table can be used as a guideline. (These timeouts are dependent on the speed of the Modbus device and may need to be adjusted for optimal performance):

Modbus Message Timeout Guideline

Message Timeout Guideline

Top of page
serial ethernet device servers
Creating a MODBUS Master Bridge

A Modbus Master Bridge receives Modbus queries on the serial interface (from a Modbus Master device) and transmits them over the network to a Modbus/TCP Slave(s).

Browser:
  • Click Serial Application
  • Click the trident next to ADD:
  • Select Modbus Master Bridge from the drop-down box and click ADD
Adding a Modbus Bridge Application

Adding a Modbus Master Bridge Application

Enter the details on the following page:

Modbus Master Mapping Table

Modbus Master Mapping Table

Mapping Options
Local Unit ID - The device ID of queries transmitted/received from the Modbus Master device. Valid addresses are within the range 1 to 247.

Remote Unit ID - The device ID of queries to be transmitted/received over the Modbus/TCP or Modbus/UDP network connection. Valid addresses are within the range 1 to 247.

Serial Interface - The serial port on which queries are received and the replies transmitted.

Timeout - Defines the maximum time to wait (ms) for a reply message from the Modbus/TCP or Modbus/UDP slave device. If the time expires before a reply message is received, the reply will be assumed lost and an exception will be sent to the serial device. If set too short, the slave will not be able to reply in time and the message will be lost. When setting this value, the timeouts set for the slave device must be taken in consideration (see Slave Bridge settings).

Protocol - the network protocol to use - Modbus/TCP or Modbus/UDP.

Remote Host - the hostname or IP address to which the Modbus/TCP or Modbus/UDP queries will be sent.


Advanced Options

Click the Advanced Options button:

Modbus Advanced Options

Modbus Advanced Options

This page lists the advanced configuration options for the Modbus/TCP Master Bridge.

Network Timeout - Defines the time (in milliseconds) after which an idle network connection (TCP) is closed. If no activity (data sent to the slave device) occurs for this amount of time the network connection to the slave device is closed. If another message has to be sent, the network connection will have to be re-established. If this timeout is set to a small value, new network connections will have to be established for every new message sent to the slave device, which in turn will negatively affect the performance. In the above example, the timeout is set to 2000ms.

Note: This timeout must also be larger than the reply timeout defined above. If not, the TCP connection will terminate before the slave device is able to reply.

The Modbus bridge can handle multiple TCP connections from different devices, therefore unless there is a specific reason to close connections rapidly, this timeout should be set to a larger value, e.g. 10 seconds or even more.


Broadcast Table - The Broadcast Table lists the serial interfaces that are allowed to send Modbus broadcasts and to which Modbus/TCP or Modbus/UDP hosts those broadcasts will be forwarded.

If a Modbus broadcast is received and there is no corresponding entry in the Broadcast Table, the broadcast message will be dropped silently.


Top of page
serial ethernet device servers
Creating a MODBUS Slave Bridge

Browser:
  • Click Serial Application
  • Click the trident next to ADD:
  • Select Modbus Slave Bridge from the drop-down box and click ADD
Adding a Modbus Slave Application

Adding a Modbus Slave Bridge Application

Fill in the details on the following page.

Modbus Slave Mapping Table

Modbus Slave Mapping Table


Local Unit ID - the device ID of queries transmitted/received from the slave device. Valid addresses are within the range 1 to 247.

Remote Unit ID - the device ID of queries transmitted/received over the Modbus/TCP network connection. Valid addresses are within the range 1 to 247.

Serial Interface - the serial port on which queries will be transmitted and the replies received.

Serial timeout - defines the maximum overall time to wait (ms) for a complete reply message from the serial slave device. If the timeout expires before all the data is received from the serial device, an incomplete message will result in a CRC error and an exception reply will be sent to the master.

Note: The Message Timeout (inter-character timeout) must be taken into consideration when setting this value. The serial timeout may not be less than the inter-character timeout. If this timeout is set to a too small value, the slave device may not have enough time to reply, and the slave bridge will assume that there was no reply from the device.

Protocol - the network protocol to use i.e. Modbus/TCP, Modbus/UDP or both.


Advanced Options

Click the Advanced Options button:

Modbus Advanced Options

Modbus Advanced Options


Network Timeout - Defines the time for an idle network connection (TCP) to expire (in milliseconds). If no message is received from a master for this timeout, the slave device will assume that the network connection has been lost or terminated, and will close the connection. If this timeout is set to a small value, new network connections will have to be established from the master device with almost every new message to the serial device, which in turn will negatively affect the performance.

The Modbus Bridge can handle multiple TCP connections from different devices. Therefore, unless there is a specific reason to close connections rapidly, this timeout should be set to a larger value e.g. 30 seconds or more.

Note: if set to 0, the network timeout will be ignored and the slave bridge will not close the connection.

Broadcast Table - The Broadcast Table lists on which serial interfacesModbus broadcasts will be transmitted. If a Modbus broadcast is received and there is no corresponding entry in the Broadcast Table, the broadcast message will be dropped silently.

Top of page
serial ethernet device servers
Troubleshooting Modbus Applications

Error Messages
  • Invalid CRC Errors - The message timeout of the serial device setup may be too short.
  • Timeout waiting for response - Serial Timeout (slave device) or Timeout (master device) may be too short.
  • Socket error 1131 - Timeout reading data from the socket. This is a normal message for closing an idle socket.
  • Socket error 112A - Connection closed by remote side. This is a normal status message for an idle socket closed by remote side.
  • Discarding message shorter than 4 characters - Inter-character timeout may be too small.

Top of page
               Copyright © SAN People 2005
Serial-to-Ethernet Devices