TRB141 Modbus

From Wiki Knowledge Base | Teltonika Networks
Main Page > TRBxxx Gateways > TRB141 > TRB141 Manual > TRB141 WebUI > TRB141 Modbus

Summary[edit | edit source]

Modbus is a serial communications protocol. Simple and robust, it has become a de facto standard communication protocol and is now a commonly available means of connecting industrial electronic devices. This chapter is an overview of the Modbus TCP functionality for TRB141 devices.

Modbus TCP Slave[edit | edit source]

Modbus TCP Slave provides users with the possibility to set or get system parameters. The Modbus daemon acts as slave device. That means it accepts connections from a master (client) and sends out a response or sets some system related parameter in accordance with the given query.

The figure below is an example of the Modbus TCP window section and the table below provides information on the fields contained in that window:

Network trb14x manual modbus tcp slave settings.png

Field Value Description
Enable off | on; Default: off Turns Modbus TCP on or off.
Port integer [0..65535]; default: 502 TCP port used for Modbus communications.
Device ID integer [0..255]; default: 1 The device's Modbus slave ID. When set to 0, it will respond to requests addressed to any ID.
Allow Remote Access off | on; default: off Allows remote Modbus connections by adding an exception to the device's firewall on the port specified in the field above.
Enable custom register block off | on; default: off Allow custom register block, when enabled it opens three following settings:
  • Register file path
  • First register number
  • Register count
  • Register file path string; default: /tmp/regfile Path to file in which the custom register block will be stored. Files inside /tmp or /var are stored in RAM. They are removed after reboot, but do not degrade flash memory. Files elsewhere are stored in flash memory. They remain after reboot, but degrade flash memory (severely, if operations are frequent).
    First register number integer [1025..65535; default: 1025 First register in custom register block (1025-65536)
    Register count integer [1..64512]; default: 128 Register count in custom register block (1-64512)


    Modbus TCP Master[edit | edit source]

    A Modbus master device can request data from Modbus slaves. The Modbus TCP Master section is used to configure Modbus TCP slaves. To add a new slave click the "Add" button Network rutxxx trb14x manual add button.png, and then edit Networking rutx manual edit button v1.png: Network trb14x manual modbus tcp master add slave.png

    Button Description
    Edit Redirects you to the slave's configuration page (more information in [[{{{name}}} Modbus#Slave_device_configuration|section 3.1]])
    Delete Deletes the slave configuration
    Alarms Redirects you to the slave's alarm configuration page (more information in [[{{{name}}} Modbus#Alarm_configuration|section 3.3]])

    You can create a maximum of 10 slave configurations.

    Slave device configuration[edit | edit source]


    The figure below is an example of the Slave device configuration and the table below provides information on the fields contained in that section:

    Network trb14x manual modbus tcp slave device configuration.png

    Field Value Description
    Enabled off | on; default: off Turns communication with the slave device on or off.
    Name string; default: none Slave device's name, used for easier management purposes.
    Slave ID integer [0..255]; default: none Slave ID. Each slave in a network is assigned a unique identifier ranging from 1 to 255. When the master requests data from a slave, the first byte it sends is the Slave ID. When set to 0, the slave will respond to requests addressed to any ID.
    IP address ip; default: none Slave device's IP address.
    Port integer [0..65535]; default: none Slave device's Modbus TCP port.
    Period integer [1..6400]; default: 60 Interval at which requests are sent to the slave device.
    Timeout integer [1..30]; default: 5 Maximum response wait time.

    Requests configuration[edit | edit source]


    A Modbus request is a way of obtaining data from Modbus slaves. The master sends a request to a slave specifying the function code to be performed. The slave then sends the requested data back to the Modbus master. You can create a maximum of 64 request configurations for each slave device.

    The figure below is an example of the Requests configuration section and the table below provides information contained in the fields of that section:

    Network trb14x manual modbus serial master rs232 slave request configuration.png

    Field Value Description
    Name string; default: Unnamed Parameter Request name. Used for easier management purposes.
    Data type 8bit INT | 8bit UINT | 16bit INT, high byte first | 16bit INT, low byte first | 16bit UINT, high byte first | 16bit UINT, low byte first | 32bit float, Byte order 1,2,3,4 | 32bit float, Byte order 4,3,2,1 | 32bit float, Byte order 2,1,4,3 | 32bit float, Byte order 3,4,1,2; default: 16bit INT, high byte first How read data will be stored.
    Function Read coils (1) | Read input coils (2) | Read holding registers (3) | Read input registers (4) | Set single coil (5) | Set single coil register (6) | Set multiple coils (15) | Set multiple holding registers (16); default: Read holding registers (3) Specifies the type of register being addressed by a Modbus request.
    First Register integer [0..65535]; default: 1 First Modbus register from which data will be read.
    Register Count / Values integer [1..2000]; default: none Number of Modbus registers that will be read during the request.
    Enabled off | on; default: of Turns the request on or off.
    Test Network rutxxx trb14x manual test button.png - (interactive button) Generates a Modbus request according to given parameters in order to test the request configuration. You must first save the configuration before you can use the Test button.
    Delete [ X ] Network rutxxx trb14x manual delete button.png - (interactive button) Deletes the request.
    Add Network rutxxx trb14x manual add button.png - (interactive button) Adds a new request configuration.

    Alarm configuration[edit | edit source]


    Alarms are a way of setting up automated actions when some Modbus values meet user specified conditions. The figure below is an example of the Alarm configuration page and the table below provides information on fields that it contains:

    Network trb14x manual modbus tcp slave device alarm configuration.png

    Field Value Description
    Enabled off | on; default: off Turns the alarm on or off
    Function code Read Coil Status (1) | Read Input Status (2) | Read Holding Registers (3) | Read Input Registers (4); default: Read Coil Status (1) Modbus function used in Modbus request.
    Register integer [0..65535]; default: none Number of the Modbus coil/input/holding register/input register that will be read.
    Condition More than | Less than | Equal to | Not Equal to; default: Equal to When a value is obtained it will be compared against the value specified in the following field. The comparison will be made in accordance with the condition specified in this field.
    Value various; default: none The value against which the read data will be compared.
    Action SMS | Trigger output | MODBUS Write Request; default: MODBUS Write Request Action that will be taken if the condition is met. Possible actions:
    • SMS - sends and SMS message to a specified recipient(s).
    • Trigger output - turns on, off or inverts outputs.
    • Modbus Request - sends a Modbus Write request to a specified slave.
    SMS: Message string; default: none SMS message text.
    SMS: Phone number phone number; default: none Recipient's phone number.
    Trigger output: Output PIN1 | PIN2 | both; default: PIN1 Selects output.
    Trigger output: I/O Action Turn On | Turn Off | Invert; default: Turn On Action to be performed with selected output.
    MODBUS Write Request: IP address ip | host; default: none Modbus slave's IP address.
    MODBUS Write Request: Port integer [0..65535]; default: none Modbus slave's port.
    MODBUS Write Request: Timeout integer [1..30]; default: 5 Maximum time to wait for a response.
    MODBUS Write Request: ID integer [1..255]; default: none Modbus slave ID.
    MODBUS Write Request: Modbus function Set Single Coil (5) | Set Single Register (6) | Set Multiple Coils (15) | Set Multiple Registers (16); default: Set Single Coil (5) A function code specifies the type of register being addressed by a Modbus request.
    MODBUS Write Request: First register integer [0..65535]; default: none Begins reading from the register specified in this field.
    MODBUS Write Request: Values integer [0..65535]; default: none Register/Coil values to be written (multiple values must be separated by space character).

    Modbus Data to Server[edit | edit source]

    The Modbus Data to Server function provides you with the possibility to set up senders that transfer data collected from Modbus slaves to remote servers. To add a new data sender click the "Add" button Network rutxxx trb14x manual add button.png, and then edit Networking rutx manual edit button v1.png:

    Network trb14x manual modbus data to server add new.png

    Data sender configuration[edit | edit source]


    When you add a new data sender, you will be redirected to its configuration window. The figure below is an example of that window and the table below provides information on the fields that it contains:

    HTTP(S) Protocol Network trb14x manual modbus data to server http.png

    MQTT Protocol Network trb14x manual modbus data to server mqtt.png

    Enabled off | on; Default: off Turns the data sender ON or OFF
    Name string; Default: none Data sender's name. Used for easier management purposes
    Protocol HTTP(S) | MQTT; Default: HTTP Data sending protocol
    JSON format json string; Default: {"ID":"%i", "TS":"%t","ST":"%s","VR":"%a"} Provides the possibility to fully customize the JSON segment
    Segment count 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10; Default: 1 Max segment count in one JSON string sent to server
    URL host | ip; Default: none Address of the server to which the data will be sent.
    Period integer [1..86400]; Default: 60 Data sending frequency (in seconds)
    Data filtering All data | By slave ID | By slave IP; Default: All data Which data this sender will transfer to the server
    Retry on fail off | on; Default: no Specifies whether the data sender should retry failed attempts (Retry until successful)
    HTTP(S): Custom header string; Default: no Adds a custom header(s) to HTTP requests
    MQTT: Port integer [1..65535]; Default: 1883 Port number
    MQTT: Keepalive integer [1..640]; Default: 60 MQTT keepalive period in seconds [1-640]
    MQTT: Topic string; Default: " " MQTT topic to be used for publishing the data
    MQTT: Use TLS off | on; Default: off Use TLS to encrypt the data sent

    See also[edit | edit source]