;

How to use Modbus

Modified on Wed, 27 Mar 2024 at 02:25 PM


Introduction

Modbus is a communication protocol commonly used in industrial automation to facilitate the exchange of data between different devices, such as sensors, controllers, and actuators. Modbus can be used to query and set Node configuration options from LAN devices. LAN device executing the query can then relay the data forward for example to a SCADA supervisory system.


Modbus has become a widely adopted standard in the industry. There are variants of the Modbus protocol of which Tosibox implementation support the Modbus TCP/IP. Modbus standard ensures interoperability and compatibility between devices from different manufacturers that support Modbus communication.


Modbus is supported on Lock 150, 210, 250, 500 and Tosibox 175, 350, 375, 610, 650, 670, 675, 695 starting with firmware 5.5.0.


Configuring the Node

Enabling and configuring Modbus is done on Advanced Settings page.



Settings:

  • Enable Modbus server - When enabled Modbus server is started and Node is listening to client requests
  • Listen IP - IP address that the Node accepts Modbus requests from. Use 0.0.0.0 if all addresses should be accepted
  • Master for Internet/VPN access states - When enabled overrides digital I/O settings, when disabled digital I/O will override possible Modbus commands. In both cases Modbus overrides UI settings always. Applies to Internet access enabled and VPN access enabled commands.


After enabling the Modbus server it listens on port 502 on WLAN access point and all physical LAN interfaces. Modbus data update rate is around 10 seconds.


If Modbus clients asks data rarely (e.g. once a minute), first query may yield 0xFFFF value. Client must wait a few seconds and ask again.


Modbus uses simple TCP/IP request-response protocol, it does not have connected/disconnected states. If a Modbus client goes offline Modbus server on the Node will not be notified. Node keeps the last state that was set until explicitly changed.


Registers

DataData valueRegisters first - last relative to 40001Return value if data is not availableComment

GNSS latitude

64-bit IEEE-754 floating point (little-endian)

0 - 3

Registers: 4

NaN

Returns 0xFFFF on devices without GNSS

GNSS longitude

64-bit IEEE-754 floating point (little-endian)

4 - 7

Registers: 4

NaN

Returns 0xFFFF on devices without GNSS

GNSS UTC time, seconds since midnight

64-bit IEEE-754 floating point (little-endian)

4 - 7

Registers: 4

NaN

GNSS data does not outdate, i.e. the latest info will be be posted as long as there is no new coordinates.

Returns 0xFFFF on devices without GNSS

GNSS talker ID

two-byte talker ID

12

Registers: 1

0

List of talkers can be found e.g. from NMEA Revealed 

Bytes are written in memcpy style so first byte is little end. For example if receiving value is 20551 = 0x5047, little end is 0x47 ('G') and big end 0x50 ('P') → 20551 means talker ID 'GP'.

Returns 0xFFFF on devices without GNSS

GNSS locking/fix status either as quality or as pos mode

Unsigned 16-bit integer (little-endian)

13

Registers: 1

0xFFFF

Values 0-9

  • 0 - Fix not available

  • 1 - GPS fix

  • 2 - Differential GPS fix

  • 3 - PPS fix

  • 4 - Real Time Kinematic

  • 5 - RTK float

  • 6 - Estimated (dead reckoning)

  • 7 - Manual input mode

  • 8 - Simulation mode

Values > 32: pos mode character as ASCII

  • N - No fix

  • A - Autonomous GNSS fix

  • D - Differential GNSS fix

  • E - Estimated/Dead reckoning fix

  • F - RTK float

  • R - RTK fixed

Returns 0xFFFF on devices without GNSS and if value is not available

Mobile signal strength (RSRP in dBm)

Unsigned 16-bit integer (little-endian)


14

Registers: 1

0xFFFF

Supports both internal and external modems. If both modems are in one Node, internal modem gets priority over external modem

Mobile signal strength (RSSI in dBm)

Unsigned 16-bit integer (little-endian)

15

Registers: 1

0xFFFF


Supports both internal and external modems. If both modems are in one Node, internal modem gets priority over external modem

Internet connection interface

Unsigned 16-bit integer (little-endian)

16

Registers: 1

0xFFFF

  • 0 - Not Connected

  • 1 - WAN Connected

  • 2 - Cellular connected internal modem

  • 3 - Cellular connected external modem

  • 4 - LAN connected

  • 5 - WLAN client

  • 10 - connected with unknown interface

Tosibox Cloud connection status

Unsigned 16-bit integer (little-endian)

17

Registers: 1

0xFFFF

  • 0 - Not OK

  • 1 - OK

VPN connection count

Unsigned 16-bit integer (little-endian)

18

Registers: 1

0xFFFF

Number of open VPN tunnels. 

Count may include also VPNs that are not actually functional (e.g. VPN's that are still being established or malfunctioning, but not yet closed).

Internet access enabled

(Read/Write)

Unsigned 16-bit integer (little-endian)

19

Registers: 1

0xFFFF

  • Change takes control and remains in effect until disabling Modbus server from UI

  • If “Master for Internet/VPN access states“ is disabled, writing will result in Modbus exception: illegal data address

Read and write values:

  • 0 - internet access disabled

  • 1 - internet access enabled

VPN access enabled

(Read/Write)

Unsigned 16-bit integer (little-endian)

20

Registers: 1

0xFFFF

  • Change takes control and remains in effect until disabling Modbus server from UI

  • Note that this will cut Tosibox Cloud connection and it will be indicated on the Node Status page

  • If “Master for Internet/VPN access states“ is disabled, writing will result in Modbus exception: illegal data address

Read and write values:

  • 0 - VPN access disabled

  • 1 - VPN access enabled