Client / Master Operation

One possible application for the operation of a controller as (Open)Modbus on TCP/IP client is for example the linking of sensors with Ethernet connection supporting the Modbus protocol. With this application the controller operates as Modbus client and sends telegrams for reading or writing data to the corresponding sensor which in turn generates a corresponding answer. Since (Open)Modbus on TCP/IP is a standardized protocol, every device supporting this protocol can be connected this way independent of the device type and manufacturer.

For our design example a closed installation-internal network is used. The network consists of three subscribers, one controller and two temperature sensors with Ethernet connection. The devices are connected to each other via a switch. The controller shall have the IP address 10.49.91.253. The sensors shall have the IP addresses 10.49.91.251 and 10.49.91.252.

../_images/aeb436e2628880880a3313902549f160

Example for OpenModbus on TCP/IP - controller operated as client

Planning the sensors (setting the IP address) as Modbus server is not subject of this description. For information about this, please contact the corresponding manufacturer.

The parameters Task timeout and Omb time are relevant for controller operation as Modbus client and were already set in the OMB SETUP.

The Task timeout parameter determines how long the client shall wait for the server’s answer after the transmission of the request to the server before the process is aborted with an error message. For the network considered in our example the default value of 20 x 100 ms can be maintained or even reduced. However, for larger networks with high utilization it can be necessary to increase this value. The valid values for the task timeout parameter range from 1 x 100 ms to 60000 x 100 ms. Here it has to be observed that the controller normally cannot access a server either until it has received its answer or until the timeout has expired. This is why the task timeout value should be dimensioned in a way that no abortion occurs even during temporarily higher utilization. On the other hand, the time reserve should not be too high in order to enable the detection of communication errors as early as possible for a correspondingly high connection performance. For this example a task timeout value of 20 x 100 ms (default) is selected.

The Omb time specifies how long the connection shall be maintained after reception of the response telegram. Modbus is based on TCP/IP. One characteristic of this protocol is that a logical communication connection is first established, then the data are exchanged and finally the connection is closed again. The process for establishing and closing the connection takes some time. If data communication between the controller and the servers shall only be performed in longer intervals it makes sense to close the connection immediately after data communication is finished. This avoids unnecessary long blocking of the Modbus access. For fast cyclic data exchange between the client and the server the frequency of connection establishment and closing can be reduced by setting a higher “omb time”.

Caution

It has to be observed that the concerning Modbus access (socket) is blocked for other clients as long as the connection is established. If a Modbus server only has a logical access, this results in the fact that no other client can access this server during this time. As long as the connection is established, it also seizes a socket on the controller side. Under certain circumstances this can lead to the fact that not enough sockets can be made available for other protocols during this time.

For this example it is committed that the controller operating as Modbus client shall request the temperature every second from the sensors operating as Modbus servers. Since no other client is accessing the sensors, the connections can be kept open for 1 second. The remain open time is restarted for each connection after each reception of a response from the corresponding server. Therefore, please enter the value 10 x 100 ms here.

The three TCP parameters Send timeout, Connect timeout and Close timeout are related to the TCP protocol used by Modbus. They are considered for client operation as well as for server operation. In the corresponding input fields the respective times have to be specified in milliseconds where 0 is the respective default timeout value. Valid values are 0 to 2.000.000.000.

The Send timeout parameter determines how long the controller shall attempt to send a request to a server. Normally the default value 0 which corresponds to 31 seconds can be kept.

The Connect timeout parameter determines how long the controller shall attempt to establish a TCP connection to a server. Normally the default value 0 which corresponds to 31 seconds can be kept.

The Close timeout parameter determines how long the controller shall attempt to close a TCP connection to a server. Normally the default value 0 which corresponds to 13 seconds can be kept.

The Swap parameter is also relevant for both the client operation and the server operation. With this parameter you can determine whether the two bytes in the words shall be swapped automatically during the transmission of data words. Swapping the word data can be necessary if devices with different processor types are used. If, for example, a server is operating in Motorola format, the word data from the operand memory sent by the controller have to be converted from Intel format into Motorola format (Swap = TRUE) prior to the actual transmission to the server. In the opposite direction the word data of the server are converted into Intel format before they are written to the operand memory of the controller.

Since all subscribers used in this example are processing the data in Motorola format, the Swap parameter has to be set to TRUE.

Thus, the Open Modbus parameter settings are as follows:

../_images/da4ff1d2e38bcdb00a33139000eba54e

The creation of the configuration data is now completed. Continue as described in section “4.3 General procedure for configuring the Communication Module” and download the configuration data to the Ethernet Communication Module.