Functional description¶
W-Modbus is designed to be simple to use, in that it requires little intervention from an external CPU.
RS485 Interface¶
The RS485 interface of the W-Modbus module consist of 4 digital signals:
UART_TXD
, UART_RXD
, RS485_RE
and RS485_DE
. They can be used to interface
an RS485 driver. For details on how to connect an RS485 driver IC, see the
Pin assignments page.
NOTE: Signals on the RXD
pin must NOT exceed VDD! For 5 V
logic, a level shifting circuit (such as a resistor devider) must be used!
RS485 bus configuration¶
The writing of RS485 configuration to the W-Modbus device can be done regardless of the current app mode.
An RS485 configuration written to a W-Modbus gateway applies not only to itself, but also acts as the default for W-Modbus nodes in the same network. The default can be overridden, by writing RS485 configurations to mesh nodes individually. Mesh nodes other than the one being written will be unaffected. This feature allows Modbus devices with differing RS485 configuration to communicate in the same Modbus network.
NOTE: Individually written RS485 configurations, called local configurations, are lost on restarts, meaning the default RS485 configuration set on the gateway node will be used instead.
Commissioning¶
Commissioning a W-Modbus system is performed in the following steps:
-
Put the W-Modbus module connected to the Modbus Master into "Commissioning Gateway" mode via the SPI or UART management interfaces.
-
Put the W-Modbus modules connected to the Slave devices into "Commissioning Mesh" mode via the SPI or UART management interface.
-
Devices in mesh commissioning mode will join the gateway node and receive network credentials. In order to determine when this has happened, the
COMMISSIONING
field/register can be read via the SPI or UART management interfaces. When the value ofCOMMISSIONING
is1
, the mesh node is ready. A mesh node usually takes around one minute to fully join the network, but this process can take longer depending on the physical environment (like walls and radio interference). -
Optional: The RS485 bus communication parameters can be configured via the SPI or UART management interface. Any RS485 configuration written to the gateway node acts as the default for all mesh nodes in the network. Mesh nodes with a locally set RS485 configuration will ignore this default. RS485 configuration written to a mesh node will only affect that one mesh node. The RS485 configuration can be written during both the commissioning and secure network states.
-
Optional: Once all mesh nodes are ready, as indicated by the
COMMISSIONING
field/register, the system can be validated by having the Modbus Master device poll Modbus Slave devices as if the Modbus devices were connected by a cable. -
Set the W-Modbus module connected to the Master device to "Secure Gateway" mode via the SPI or UART management interface. At this point, the Gateway will broadcast a message to all mesh nodes in the network, instructing all devices to perform a synchronized restart after 10 seconds. After the restart has been performed, the W-Modbus Commissioning Gateway will enter "Secure Gateway" mode, and all connected Commissioning Mesh nodes will enter "Secure Mesh" mode. The commissioning process is now complete. The mesh nodes will search for the gateway again after the synchronized restart, and communicate securely using encryption, until explicitly decommissioned.
Decommissioning¶
Decommissioning a mesh node from a network can be done by utilizing the
DEVICE_RESET
field/register using the SPI or
UART management interfaces. The node will
restart automatically, at which point the device can be commissioned again.
To decommission an entire mesh network at once, switch the Secure Gateway into any other mode using SPI or UART. The gateway will send a broadcast, instructing currently connected nodes in the network to decommission. In the same manner as described in the Commissioning section, this broadcast also makes connected mesh nodes perform a synchronized restart 10 seconds after receiving the broadcast. After the synchronized restart, each connected mesh node will switch to commissioning mesh mode.
Detection of connected device¶
A W-Modbus mesh node, after booting, will begin scanning for connected devices on addresses 1 through 255. Devices that respond are added to a list at the end of a scan cycle. A maximum of 16 devices are supported with the current version of the firmware. Scanning will repeat as long as the device has power, meaning devices will be automatically added/removed depending their connectivity. The first repeat is done after a minute, and as long as the list of addresses is not empty and unchanged, the repeat interval is doubled until it reaches 16 minutes. If the list of addresses changes or is empty, the repeat interval is reset to 1 minute.
To scan for a slave/server device, the W-Modbus Module will send read commands on the RS485 bus, requesting the value of the HREG (Function code 3) at register address 0. This command is repeated for all possible Modbus addresses. Any Modbus device of class 0 or higher is expected to respond to this read command, either with a register value or a Modbus exception.
To find which devices the W-Modbus Module have found so far, the
SERVER_ADDRESSES
field/register can be polled via the
SPI or
UART management interfaces. Note that
SERVER_ADDRESSES
won't be updated until after a full scan cycle is
completed.
Networking¶
W-Modbus is based on MiraMesh 2.9.0. For information on how the networking stack works, see the documentation about MiraMesh networks.
Practical considerations¶
MiraMesh is designed for robustness and power efficiency in interference-ridden radio environments. These environments can come with a cost to throughput and latency; and while throughput limitations usually are negligible when using Modbus, latency requirements, can potentially pose an issue.
As a general rule, allow 50 ms of latency per network jump from the root node in Round Trip Time (RTT). For example, a node that is 3 jumps away may introduce a latency of 150 ms. This may have to be considered when configuring timeout parameters on a modbus Master.
Our recommendation is to set communication timeout parameters of any Modbus Master to at least 1000 ms.
Firmware Update¶
The firmware of the W-Modbus module can be updated using Nordic Semiconductor's nRF Connect app, available for both Mobile and Desktop devices.
To update the device, the module needs to be put in bootloader/DFU mode. This can be accomplished in one of two ways:
- Set
BOOTLOADER_ENABLED
to1
using the SPI or UART interface. - Drive the BOOTLOADER pin low while booting the module with the nRESET pin. Once the module has booted into DFU mode, the BOOTLOADER pin doesn't need to be driven any longer.
Once in DFU mode, the module can be found in nRF Connect's list of Bluetooth devices. Connect to the device and use the zip-file found here to update to the latest version of our firmware.
The module will boot in application mode again if no BLE activity has occurred in 2 minutes. Performing a reset via the nRESET-pin will also immediately boot the module in application mode again.
For detailed instructions as well as the latest firmware, please look at our support page.