Creating virtual Modbus TCP element

Connecting Modbus devices

Related articles are:

Connecting Modbus devices

Description

A virtual "Modbus TCP" sensor is used to read and write data from external equipment via Modbus TCP/IP protocol.
Support the Wake-on-LAN standard that allows a remote device to be turned on or awakened by a network message.

Adding the Modbus reading virtual element

To create a "Modbus TCP (reading)" element, press add button "" inside the "Group tree" or "System tree" menu. Then choose "Modbus TCP (reading)". A modal window will appear:

Click on the "Modbus TCP (reading)". Modbus element form will be opened:

Fields in the form available for change:

Name

Description

Name

Description

Name

Created element name

User-defined type

Defines the icon to be displayed in the "System tree"

Units of measurement

The unit of measure in which the value is displayed in the "System tree"

Minimum value

Determines the minimum measurement range, when the value is out of range, the sensor goes into "Not connected" state

Maximum value

Determines the maximum measurement range, when the value is out of range, the sensor goes into a "Not connected" state

Alarm and warning levels

Defines the alarm and warning thresholds, as for other sensors, see Sensor configuration

Hysteresis

Option of setting the hysteresis state, see Sensor configuration

Expression

Function of the form f (x). The default value for the sensor is equal to the measured value: "x", ie corresponds to the expression "x". To calculate the indirect value of the sensor is possible to use an arbitrary expression, which are permissible "(", ")", as well as:

  •  

    • operators: "+", "-", "*", "/", "%" (remainder of the division), "^" (exponentiation);

    • functions: "abs","sqrt","exp","ln","log","sin","cos","tan","asin","acos","atan";

    • constants: "pi" (3.1415926...), "e" (2.7182818...)

        For example: "0.1*x+0.5"

 

The Modbus TCP configuration is available in the "Additional" tab:

Fields in the form available for change:

Name

Description

Name

Description

IP address

Modbus TCP slave IP address of external equipment

Port

Modbus TCP slave port (default 502)

Slave address

Slave address of Modbus TCP

Register index

Modbus protocol register start address in hexadecimal view, like 0F4A

Function code

The following functions are supported:

  • 0x01 - Read Coil Status

  • 0x02 - Read Input Status

  • 0x03 - Read Holding Register

  • 0x04 - Read Input Register

Data type

Determines how to present the data:

  • 16 bits signed int

  • 16 bits unsigned int

  • 32 bits signed int

  • 32 bits unsigned int

  • 32 bits IEEE floating point

Data ordering

Determines byte order in Modbus protocol response message:

  • low byte first, low word first

  • low byte first, high word first

  • high byte first, low word first

  • high byte first, high word first

Polling period

Defines the time of polling the sensor value. From 10 seconds to 5 minutes. 

Wake-on-LAN function

Enable the Wake-on-LAN function. Wake-on-LAN function can only be enabled if the Polling period is from 1 minute and more. 

Waiting time

Waiting time until the remote device turns on after the Wake-on-LAN command. From 1 to 15 seconds.

Device MAC address

Wake-on-LAN command is sent for the MAC address of the remote device.  

To determine the MAC address of the remote device specified in the IP address field click "Get MAC". Make sure the remote device is turned on and is not in power-saving mode.

The Test button allows you to make a test connection with a Modbus device. In additional fields, the bytes sequence of connection, data is displayed, in hexadecimal form. Modbus raw answer - data of the received answer, without a header and checksum. Modbus value - contains the data value interpreted under the selected Data type. Do not forget that if the Wake-on-LAN function is enabled, before writing will be a delay at the set time Waiting time.

Adding the Modbus writing virtual element

To create a "Modbus TCP (writing)" element, press add button "" inside the "Group tree" or "System tree" menu. Then choose "Modbus TCP (writing)". Modbus element form will be opened:

Fields in the form available for change:

Name

Description

Name

Description

Name

Created element name

IP address

Modbus TCP slave IP address of external equipment

Port

Modbus TCP slave port (default 502)

Slave address

Slave address of Modbus TCP

Register index

Modbus protocol register start address in hexadecimal views, like 0F4A

Function code

The following functions are supported:

  • 0x05 - Write Single Coil

  • 0x06 - Write Single Register

Writing value

Decimal integer value that will be writing in the specified register

Wake-on-LAN function

Enable the Wake-on-LAN function

Waiting time

Waiting time until the remote device turns on after the Wake-on-LAN command. From 1 to 15 seconds.

Device MAC address

Wake-on-LAN command is sent for the MAC address of the remote device.

To determine the MAC address of the remote device specified in the IP address field click "Get MAC". Make sure the remote device is turned on and is not in power-saving mode.

The Test button allows you to make a value entry immediately into the Modbus register. Do not forget that if the Wake-on-LAN function is enabled, before writing will be a delay at the set time Waiting time.

Now the Modbus TCP writing can be inserted as a THEN task in logic schemes: