Using the Variables window to access a Modbus Server device variables


Once a Modbus Server device has been defined, you can use the Workbench to access the variables supported by the Modbus Server device. Additionally connection information is collected and displayed for each Modbus client that is actively connected to the Modbus Server device.

  1. From the Workbench left pane, select the Variables icon. The Variables window appears as the right pane.

    The Variables window provides a tree format that lists the started devices in the node. The devices must be in the Started state to be included in the Variables window. Each device can be expanded to show the variables that reside in that device.
  2. You can expand or collapse the tree format to zoom in or out on a device’s variables. When you get to an individual data element, you have access to the Read and Write functions to read a device’s data element or write a device’s data element. For information on data types and data conversion supported by the Modbus Server, see Modbus Server supported access.
  3. You must ensure that the appropriate levels of security access privileges are in place to restrict the access to data elements to those personnel who have the proper knowledge and understanding when reading or writing device data elements. For more information, see System administration > Security.

A Modbus Server device has variables that represent the four data regions that a Modbus enabled device would contain: Coils, Discrete Inputs, Input Registers, and Holding Registers. Users with the appropriate levels of security access privileges are able to write values to these variables. These values can then be read by Modbus clients that are connected to the Modbus Server device. Connected Modbus clients will have the ability to write to the Coils and Holding Registers variables.

There are also variables associated with the Modbus Server device that provide information concerning the Modbus clients that are connected to the Modbus Server device.

Variable Description
Connections
An array whose elements contains information on each individual connection to the Modbus Server device. The number of elements in the array is equal to the value specified in the Maximum Connections field on the Modbus Server device definition panel for Ethernet based connections. There will only be one element in this array for Modbus Server devices that are defined to support a serial RS-232 connection.
Active Connections
The count of Modbus clients that are currently connected to the Modbus Server device.
Accepted Connections
A counter that is incremented each time a Modbus client successfully connects to the Modbus Server device.
Rejected Connections A counter that is incremented each time a Modbus client's attempt to connect to the Modbus Server device was rejected. A client may be rejected because the value entered in the Maximum Connections field on the Modbus Server device definition has been reached. A client could also be rejected if the IP Address of the client is prohibited from connecting to the Modbus Server device based on the definitions that were specified on the Access List field of the Modbus Server device.




The Connection array contains information about each Modbus client connected to the Modbus Server device. The connection information saved for each client is shown below.

Variable Description
IP Address The IP Address of the client connected to the Modbus Server device. This value is shown only for servers that use an Ethernet connection.
Connect Time The date and time that the client connected to the Modbus Server device. This value is shown only for servers that use an Ethernet connection.
Last Message Time The date and time of the last message received from the Modbus client.
Messages Received The total number of messages received from the Modbus client.
Read Requests Received The total number of read requests that were received from the Modbus client.
Write Requests Received The total number of write requests that were received from the Modbus client.
Messages An array of twenty elements that contain information about each message received.


The message information saved for each Modbus client connection is shown below.

Variable Description
Timestamp The date and time of message received from the Modbus client.
Message Length The length of the message received from the Modbus client.
Modbus Function The Modbus function code contained in the message. The following function codes will be seen in this field.
  • 1 - Read Coils
  • 2 - Read Discrete Inputs
  • 3 - Read Holding Registers
  • 4 - Read Input Registers
  • 5 - Write a single Coil
  • 6 - Write a single Register
  • 15 - Write multiple Coils
  • 16 - Write multiple Holding Registers
Contents An array of twenty elements that hold the byte values of the message. Messages that are greater than twenty bytes in size will display only the first twenty bytes of the message.