Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Modbus TCP server scenario, which allows you to use 3d-party Modbus clients to send function code commands to the KNOT's IP address using Modbus TCP/IP connection (TCP port 502). You can use any Modbus Client software (there are plenty on the internet) or it can be easily written/configured in Python. In this case, the KNOT "translates/bridges" Modbus TCP/IP requests to Modbus RTU.
  • Modbus RTU controller scenario (available only starting with v7.10beta510), which allows you to send function code commands directly from the RouterOS command line via Modbus/RTU.

...

Once the board is connected to the Modbus device, the only thing that needs to be altered/checked in the settings is the "Modbus" port configuration:

[admin@MikroTik] > /port print
Flags: I - inactive
 #   DEVICE NAME                            CHANNELS USED-BY                         BAUD-RATE
 0          modbus                                 1                                 9600    
 1          modem                                  5                                 115200

By default, a port with the name "modbus" is assigned to the Modbus service, but the service itself is disabled. In order to activate the "Modbus" service, you need to issue the command, as shown below:

[admin@MikroTik] > /iot modbus print
       disabled: yes
  hardware-port: modbus
       tcp-port: 502
        timeout: 1000ms
[admin@MikroTik] > /iot modbus set disabled=no

Additionally, when you want to allow Modbus clients to communicate with the Modbus server using TCP(502)/IP protocol, you need to make sure that the IP address is configured accordingly and that this IP+502 TCP port is accessible from the outside (in case "slave" devices are connecting from the WAN side). You can find information on how to configure the firewall using the firewall manual.

...

Info
Available only starting with v7.10beta510.

Sub-menu: /iot modbus transceive

PropertyDescription
address (integer:0..255; Default: )

Specify device address or unit ID.

function (integer:0..255; Default: )

Specify the function code.

For example:

  • function=3 → Read Holding Register function code;
  • function=6 → Write Single Holding Register function code.
data (string, max length 504; Default: )

Input data string that usually specifies register address and data to be sent.

For example:

  • data=20000001

The data string is 4 bytes long. "0x2000" is the command to the register (2 bytes long) and "0x0001" (2 bytes long) is the device's address.

See the Modbus device's specifications for the exact data string that needs to be sent.

values (integer:0..4294967295; Default: )

An alternative way to send the data (see data parameter above). In this case, each value specified represents 1 byte of the data payload/string.

For example:

  • values=32,0,0,1

Equals to the output of data=20000001. 32(dec)=0x20(hex), 0(dec)=0x00(hex), 0(dec)=0x00(hex), 1(dec)=0x01(hex) → 0x20000001.

An example of sending function code 3 command using the "transceive" feature:

...