Introduction to the creation of virtual Modbus TCP elements
A virtual Modbus TCP sensor is used to read and write data from external devices, counters, and sensors via the Modbus TCP/IP protocol. Please note that your IoT-enabled Didactum measuring and control device must be equipped with firmware version "didactum-2.8.3-b333" or higher. Didactum devices support the Modbus TCP/IP protocol from this firmware version onwards.
Adding the virtual element Modbus-TCP Read
To create a "Modbus TCP (Read)" element in the IoT-enabled measurement and control system, go to the "System Tree" menu and then click the "+" button in the upper right corner. The "Add a new element" selection menu will then appear.
After clicking on "Modbus TCP (Read)," a new window labeled "Modbus TCP (Read)" will open.
Description of the settings in the menu “TCP mode (read)”:
| # | Name | Description |
| 1 | Name: | Label / name of the element (can be named individually). |
| 2 | User‑defined type: | Defines the symbol displayed in the “System tree” of the Didactum system. |
| 3 | Units of measurement: | The unit in which the value is displayed in the “System tree”. |
| 4 | Minimum value: | Defines the minimum measurement range; if the value is outside this range, the sensor switches to the state “Not connected”. |
| 5 | Maximum value: | Defines the maximum measurement range; if the value is outside this range, the sensor switches to the state “Not connected”. |
| 6 | Alarm and warning levels: | Alarm and warning thresholds of the Modbus TCP element are configured here. |
| 7 | Hysteresis: | Option to create a hysteresis function for the Modbus‑TCP read element. |
| 8 | Expression: | Function of the form f(x). The default value for the sensor equals the measured value: “x”, i.e., corresponds to the expression “x”. To calculate an indirect sensor value, any of the following allowed expressions can be used: "(", ")", as well as: • Operators: "+", "-", "*", "/", "%", "^" (power); • Functions: "abs", "sqrt", "exp", "ln", "log", "sin", "cos", "tan", "asin", "acos", "atan"; • Constants: "pi" (3.1415926...), "e" (2.7182818...) Example: "0.1*x+0.5" |
On the “Additional” tab of the “Modbus TCP (read)” menu the following fields are available:
Description of the menu items:
| # | Name | Description |
| 1 | IP address | Modbus TCP slave IP address of the external equipment. |
| 2 | Port | Modbus TCP slave port (standard port: 502). |
| 3 | Register index | Starting address of the Modbus protocol registers in hexadecimal notation, e.g. “0F4A”. |
| 4 | Function code | The following functions are supported by the Didactum system: • 0x01 – Read Coil Status • 0x02 – Read Input Status • 0x03 – Read Holding Register • 0x04 – Read Input Register |
| 5 | Data type | Defines how the data should be interpreted: • 16 bits signed int • 16 bits unsigned int • 32 bits signed int • 32 bits unsigned int • 32 bits IEEE floating point |
| 6 | Data ordering | Determines the byte order in the Modbus protocol response: • low byte first, low word first • low byte first, high word first • high byte first, low word first • high byte first, high word first |
| 7 | Polling period | Defines the time interval for querying the sensor value. Polling intervals from 10 seconds up to a maximum of 5 minutes are supported. |
Additional notes: Using the “Test” button you can establish a test connection to a Modbus device. Additional fields display the byte sequence of the connection data in hexadecimal format.
“Modbus raw answer” – contains the received answer data without header and checksum. “Modbus value” – contains the data value interpreted according to the selected data type.
Adding the virtual Modbus TCP element "write"
To create a "Modbus TCP (write)" element in the SNMP-compatible Didactum measurement and control system, click the "+" button in the "System Tree" menu. Select the "Modbus TCP (write)" entry. The Didactum device will then open the following menu:
The following fields are offered to you in this menu:
| # | Name | Description |
| 1 | Name: | Label / name of the element (can be named individually). |
| 2 | IP address: | Modbus‑TCP slave IP address of the external device. |
| 3 | Port: | Modbus‑TCP slave port (standard 502). |
| 4 | Register index: | Starting address of the Modbus protocol registers in hexadecimal notation, e.g. “0F4A”. |
| 5 | Function code: | The following functions are supported by the Didactum monitoring & control device: 0x05 – Write Single Coil 0x06 – Write Single Register |
| 6 | Write value: | Decimal integer value that is to be written to the specified register. |
Notes: Using the “Test” button you can immediately write a value into the Modbus register. Now writing via Modbus TCP can be added as an action in the “Logic Schemes” menu entry: