Modbus has become a de facto standard communication protocol for communication between industrial electronic devices in a wide range of buses and network. The Weble universal gateway supports both the Master and Slave roles over the following 3 variations of the protocol.
In most cases the modbus driver is used as a master in order to retrieve the Modbus slaves data (such as energy meters data), and to forward that information to another protocol like Bacnet, or to the cloud with MQTT.
The modbus driver can also acts as a transparent Modbus TCP to RTU gateway using the forward to serial driver parameter (no routes configuration needed) when configuring the modbus TCP slave such as shown in the schema below.
For detailed informations about the Modbus protocol, refer to this source https://www.simplymodbus.ca/
For the Modbus RTU serial line wiring it is important to follow the rs485 general guidelines: modbus wiring guidelines article
In this introduction, modbus TCP is used instead. The setup here is one modbus TCP slave and one modbus TCP master running on the same device. The slave TCP server will be listening on the default port 502 and the master TCP client will connect to the slave on the loopback ip address 127.0.0.1. As it is often the case in modbus, the master in this tutorial cyclically polls the slave registers.
The first step is to create the modbus slave, select the Type tcpSlave, and the Mode local slave. (Side note: selecting the forward to serial mode would make the TCP slave act as a transparent Modbus TCP slave to RTU master gateway as shown on the schema above.)
Once the gateway is inserted, start the gateway. If the 502 TCP port is not used by another driver / process, the driver starts without issues. Once the driver is started, insert the holding registers from %M1
to %M10
using the default Slave Unit ID (here 1) by selecting the number of addresses and set it to 10. After clicking the Save button, the 10 addresses are inserted.
Once the addresses are inserted, it is possible to manually set the initial values by double clicking on the Value field as shown below.
Create the modbus by inserting a modbus gateway and selecting tcpMaster for the Type parameter. The host address here is the loopback address 127.0.0.1 (localhost).
Afer starting the master gateway, it is possible to insert the holding registers here starting at the first register : %M1
. By selecting 10 for the number of addresses it will insert addresses %M1
, M2
, ...
, until %M10
. An important parameter is to configure the polling rate in milliseconds. In this example it is configured to 10000 ms, which translates to 10 seconds. It means that the modbus master will send read requests every 10 seconds to refresh the register values.
Once the addresses are inserted, the modbus master should be able to read all inserted registers and update the values when they change after a poll. As shown in the screenshot below the values on the master match the values previously configured on the slave.
The parameters of the modbus driver are divided here in 4 categories:
In the table below, there is the type parameter used to select the correct type of the modbus driver, and 2 other parameters (unitId and registerOffset) that impact the addressing scheme (see chapter 3 about addresses).
Label | JSON Key | Description |
---|---|---|
Type | type | Selects the role and the phyisical link layer. There is 4 supported types: rtuMaster , rtuMaster , tcpMaster , or tcpSlave . |
Default unit ID | unitId | The default modbus slave identifier (0-255). This id can also be specified at the address level. For example the address %M100 uses the default slave id, but the address %M2-100 uses the slave id 2 . |
Address offset | registerOffset | Offset (integer number) applied to the modbus registers addresses. An offset of -1 is often used to match the modbus slave manufacturer documentation. With an offset of 0 , the first holding register is %M0 , while with an offset of -1 , the first holding register is %M1 |
Standard serial parameters for rs485 modbus RTU communication.
Label | JSON Key | Description |
---|---|---|
ASCII | ascii | Activates or deactivates the modbus ascii framing where frames start with ":" and end with a new line "\r\n" while the rest of the frame (the modbus packet) is written on the line using hexadecimal characters 0–9, A–F. If the parameter is false, then standard modbus RTU is used instead where modbus packets are sent directly on the line (binary encoded). |
Serial Port | serialPort | Selects the serial interface (hardware). Could be an USB to rs485 adapter or the native serial port of the hardware. |
BaudRate | baudRate | Serial line transmission speed in bauds (bits/seconds). |
Parity | parity | Defines the parity bit for the serial characters / bytes. N for none, E for even, O for odd, and S for space. |
Stopbit | stopBit | Number of end bits sent at the end of each serial character / byte |
[hidden] | dataBit | Number of data bits per serial character / byte. Normally it is always 8 for modbus so that parameter is hidden. |
Label | JSON Key | Description |
---|---|---|
Port | port | IP port on which the modbus TCP slave waits for new connections (usually port 502). |
Host | host | only applies when acting as Master. It is the IP or domain name used to reach the modbus slave device. |
The master here
Label | JSON Key | Description |
---|---|---|
RequestTimeout | requestTimeout | Defines the response waiting delay in milliseconds before triggering the timeout error. |
IdleTimeout | idleTimeout | Defines a pause in milliseconds between each new modbus request |
IgnoreFirstValuesMs | ignoreFirstValuesMs | At boot, ignores the first values during an initial delay in milliseconds. It is sometimes useful to avoid reading invalid values from a slave which needs time to correctly initialize its modbus registers after a reboot. |
OnErrorValue | onErrorValue | If a modbus register cannot be read due to an error such as timeout, ILLEGAL_DATA_VALUE, or any other error, a pre-defined configured value (usually 0) can be sent on the register address. If the parameter is left empty, then the value is not updated in case of errors. |
Error retries | errorRetries | If there is an error during a modbus read request, retries to interogate the slave x times before triggering the error. |
It is possible with type tcpSlave to act as a transparent modbus gateway and forward the received modbus requests on the serial line for modbus RTU slaves, or to another modbus TCP slave. When this forward mode is activated, the tcpSlave acts as a forward master and forward the requests to the slaves, and then also forward back the slave responses to the initial modbus TCP master at the origin of the requests.
Label | JSON Key | Description |
---|---|---|
Mode | mode | Only applies to the type tcpSlave. Choose the operating mode of the TCP slave : local slave , forward to serial , and forward to tcp |
FillWithZeros | fillWithZeros | Only applies if the slave is of type rtuSlave or if the tcpSlave mode is local slave . If set to true , it initialize all unused registers with 0 s at start. If set to false , sends the error ILLEGAL_DATA_VALUE until a value is set. |
Forward to ASCII | forwardAscii | Only applies when the tcpSlave mode is forward to serial . Defines if the serial forward master uses the ASCII encoding or the standard modbus RTU. |
Forward Serial | forwardSerial | Only applies when the tcpSlave mode is forward to serial . Defines the serial port to be used by the forward master. |
Forward Baudrate | forwardBaudRate | Only applies when the tcpSlave mode is forward to serial . Defines the serial baud rate to be used by the forward master. |
Forward parity | forwardParity | Only applies when the tcpSlave mode is forward to serial . Defines the serial parity check method to be used by the forward master. |
Forward StopBit | forwardStopBit | Only applies when the tcpSlave mode is forward to serial . Defines the number of stop bits to be used by the forward master. |
[hidden] | forwardDataBit | Only applies when the tcpSlave mode is forward to serial . This parameter is hidden as it is normally always fixed to 8. |
Forwad Host | forwardHost | Only applies when the tcpSlave mode is forward to tcp . Defines the host (ip or domain name) used to reach the modbus TCP slave that will ultimately receive the forwarded requests. |
Forward Port | forwardPort | Only applies when the tcpSlave mode is forward to tcp . Defines the TCP port used to reach the modbus TCP slave that will ultimately receive the forwarded requests. |
Forward Req Timeout | forwardRequestTimeout | Only applies when the tcpSlave mode is forward to tcp or forward to serial . It is the forward master timeout delay in milliseconds before triggering the timeout error. |
Forward Idle Timeout | forwardIdleTimeout | Only applies when the tcpSlave mode is forward to tcp or forward to serial . It is the forward master minimum pause in milliseconds between new modbus requests. |
the gateway JSON definition for the master and slave gateways described in the getting started section :
{
"name": "modbus slave",
"driver": "modbus",
"description": "",
"active": 1,
"json": {
"type": "tcpSlave",
"ascii": false,
"host": "192.168.1.99",
"port": 502,
"unitId": 1,
"registerOffset": -1,
"serialPort": "",
"requestTimeout": 3000,
"idleTimeout": 20,
"baudRate": 19200,
"parity": "N",
"stopBit": 1,
"ignoreFirstValuesMs": 0,
"onErrorValue": "",
"errorRetries": 2,
"mode": "local slave",
"fillWithZeros": true,
"forwardSerial": "",
"forwardBaudRate": 19200,
"forwardStopBit": 1,
"forwardHost": "",
"forwardPort": "",
"forwardRequestTimeout": 500,
"forwardIdleTimeout": 0
}
}
{
"name": "modbus master",
"driver": "modbus",
"description": "",
"active": 1,
"json": {
"type": "tcpMaster",
"ascii": false,
"host": "127.0.0.1",
"port": 502,
"unitId": 1,
"registerOffset": -1,
"serialPort": "",
"requestTimeout": 3000,
"idleTimeout": 20,
"baudRate": 19200,
"parity": "N",
"stopBit": 1,
"ignoreFirstValuesMs": 0,
"onErrorValue": "",
"errorRetries": 2,
"mode": "local slave",
"fillWithZeros": false,
"forwardSerial": "",
"forwardBaudRate": 19200,
"forwardStopBit": 1,
"forwardHost": "",
"forwardPort": "",
"forwardRequestTimeout": 500,
"forwardIdleTimeout": 0
}
}
Modbus addresses have the following structure:
%[type][optional slave unit id-][memory address]
The modbus addresses are sub-divided in 4 main types:
%M
. Example of holding registers : %M0
, %M1
, %M3
, ... , %M65535
.%Q
. Example of input registers : %Q0
, %Q1
, %Q3
, ... , %Q65535
.%MX
. Example of coils : %MX0
, %MX1
, %MX3
, ... , %MX65535
.%QX
. The address name prefix for coils is %QX
. Example of discrete inputs : %QX0
, %QX1
, %QX3
, ... , %QX65535
.It is possible to set the slave unit id in the address, as in %M2-1
(holding register 1 of slave unit id 2) or %QX1-4
(discrete input 4 of slave unit id 1). The slave unit id is coded on 8 bits and ranges from 0 to 254. Defining the slave id is particularly useful when the modbus driver acts as a master and communicates on the rs485 line with multiple slave units. If the slave id is not specified in the address name (as in %M1
or %QX4
), then the slave id defaults to the Default unit ID gateway parameter.
Many slave devices documentation are numbering the memory addresses starting from 1 instead of 0 (%M1
being the first register and %M65536
the last one), so a -1 correction offset often needs to be configured in the Address offset gateway parameter.
The main parameters of the modbus addresses are
The following table lists all the addresses parameters
Label | JSON Key | Description |
---|---|---|
Datatype | datatype | Specifies the encoding of the values such as int16BE (big endian signed integer stored on one register), floatBE (big endian 32 bits floating point stored on 2 consecutive modbus registers), etc... |
Scale | scale | Applies a multiplicative factor before emitting the new value value * scale . This parameter is useful for simple unit conversions. |
Offset | offset | Applies an offset before emitting the new value (useful for unit conversions). value + offset . If the scale is defined, the offset is applied after the multiplication (value*scale) + offset . |
COV increment | cov | Specifies the minimum change of value (COV) necessary between the last emitted value and the new value in order to emit the new value. This paramter can reduce the CPU usage of the system. |
Polling (ms) | readLoopDelay | If the driver acts as Master, it defines the polling frequency in ms such as 10000 to refresh every 10 seconds. Note that it also supports the CRON format for precisly scheduled pollings (useful for energy monitoring applications). |
Double read | doubleRead | If the driver acts as Master, it makes two consecutives reads to ensure the correctness of the new value. |
Group | group | If the driver acts as master, it permits to set a group integer identifier to addresses. If consecutive registers/addresses are configured with the same group (such as group 1 or 2 ), then the master attempts, instead of doing one query per address, to read all the registers of this group at once using a single modbus request. It can be used to optimize the polling loop or to suite special slave requirements. |
Store value | remanent | If the driver acts as Slave, then it specifies wether to store on not the values on the disk. If the slave values are not stored on the disk, they are lost after the system reboot. Store values : "never" , "always" , or a delay in milliseconds such as 60000 to save the address value on the disk every minutes. |
The datatype permits to specify how to decode/encode values from/into the raw modbus registers binary data.
As a modbus register is 16 bits wide, some datatypes require to read multiple consecutive registers. For example the datatype doubleBE
is 64 bits wide and spans over 4 consecutive registers. E.g. if the address %M1
is a doubleBE
, it will in fact read the bits from registers %M1
, %M2
, %M3
, and %M4
. It follows that the next address value should only start from register %M5
. Addresses registers should never overlap in practice.
The table below lists all supported datatype encodings (new encodings can be implemented on customer demand).
Datatype | Description |
---|---|
int16BE | Signed 16-bit integer in big-endian format (most significant byte first) |
int16LE | Signed 16-bit integer in little-endian format (least significant byte first) |
uint16BE | Unsigned 16-bit integer in big-endian format (most significant byte first) |
uint16LE | Unsigned 16-bit integer in little-endian format (least significant byte first) |
int8 | Signed 8-bit integer |
uint8 | Unsigned 8-bit integer |
int32BE | Signed 32-bit integer in big-endian format (most significant byte first) |
int32LE | Signed 32-bit integer in little-endian format (least significant byte first) |
uint32BE | Unsigned 32-bit integer in big-endian format (most significant byte first) |
uint32LE | Unsigned 32-bit integer in little-endian format (least significant byte first) |
int64BE | Signed 64-bit integer in big-endian format (most significant byte first) |
uint64BE | Unsigned 64-bit integer in big-endian format (most significant byte first) |
int64LE | Signed 64-bit integer in little-endian format (least significant byte first) |
uint64LE | Unsigned 64-bit integer in little-endian format (least significant byte first) |
floatBE | 32-bit floating-point number in big-endian format (IEEE 754) |
floatLE | 32-bit floating-point number in little-endian format (IEEE 754) |
doubleBE | 64-bit floating-point number in big-endian format (IEEE 754) |
doubleLE | 64-bit floating-point number in little-endian format (IEEE 754) |
bcd8 | 8-bit binary-coded decimal (BCD) |
bcd16BE | 16-bit binary-coded decimal (BCD) in big-endian format (most significant byte first) |
bcd32BE | 32-bit binary-coded decimal (BCD) in big-endian format (most significant byte first) |
bit | Single bit (0 or 1) |
mod10000_2_BE | Value multiplied by 10000 and represented as a 32-bit signed integer in big-endian format (most significant byte first) |
mod10000_2_LE | Value multiplied by 10000 and represented as a 32-bit signed integer in little-endian format (least significant byte first) |
mod10000_3_BE | Value multiplied by 10000 and represented as a 32-bit signed integer in big-endian format (most significant byte first) |
mod10000_3_LE | Value multiplied by 10000 and represented as a 32-bit signed integer in little-endian format (least significant byte first) |
mod10000_4_BE | Value multiplied by 10000 and represented as a 32-bit signed integer in big-endian format (most significant byte first) |
mod10000_4_LE | Value multiplied by 10000 and represented as a 32-bit signed integer in little-endian format (least significant byte first) |
bcd16LE | 16-bit binary-coded decimal (BCD) in little-endian format (least significant byte first) |
bcd32LE | 32-bit binary-coded decimal (BCD) in little-endian format (least significant byte first) |
hex_1 | 16-bit hexadecimal value |
hex_2 | 32-bit hexadecimal value |
hex_3 | 48-bit hexadecimal value |
hex_4 | 64-bit hexadecimal value |
hex_5 | 80-bit hexadecimal value |
hex_6 | 96-bit hexadecimal value |
hex_7 | 112-bit hexadecimal value |
hex_8 | 118-bit hexadecimal value |
ascii_1 | 16-bit character ASCII value |
ascii_2 | 32-bit character ASCII value |
ascii_3 | 48-bit character ASCII value |
ascii_4 | 64-bit character ASCII value |
ascii_5 | 80-bit character ASCII value |
ascii_6 | 96-bit character ASCII value |
ascii_7 | 112-bit character ASCII value |
ascii_8 | 128-bit character ASCII value |
int32BE_sw | Signed 32-bit integer in big-endian format with swapped bytes |
int32LE_sw | Signed 32-bit integer in little-endian format with swapped bytes |
uint32BE_sw | Unsigned 32-bit integer in big-endian format with swapped bytes |
uint32LE_sw | Unsigned 32-bit integer in little-endian format with swapped bytes |
int64BE_sw | Signed 64-bit integer in big-endian format with swapped bytes |
uint64BE_sw | Unsigned 64-bit integer in big-endian format with swapped bytes |
int64LE_sw | Signed 64-bit integer in little-endian format with swapped bytes |
uint64LE_sw | Unsigned 64-bit integer in little-endian format with swapped bytes |
floatBE_sw | 32-bit floating-point number in big-endian format with swapped bytes |
floatLE_sw | 32-bit floating-point number in little-endian format with swapped bytes |
doubleBE_sw | 64-bit floating-point number in big-endian format with swapped bytes |
doubleLE_sw | 64-bit floating-point number in little-endian format with swapped bytes |
bcd32BE_sw | 32-bit binary-coded decimal (BCD) in big-endian format with swapped bytes |
mod10000_2_BE_sw | Value multiplied by 10000 and represented as a 32-bit signed integer in big-endian format with swapped bytes |
mod10000_2_LE_sw | Value multiplied by 10000 and represented as a 32-bit signed integer in little-endian format with swapped bytes |
mod10000_3_BE_sw | Value multiplied by 10000 and represented as a 32-bit signed integer in big-endian format with swapped bytes |
mod10000_3_LE_sw | Value multiplied by 10000 and represented as a 32-bit signed integer in little-endian format with swapped bytes |
mod10000_4_BE_sw | Value multiplied by 10000 and represented as a 32-bit signed integer in big-endian format with swapped bytes |
mod10000_4_LE_sw | Value multiplied by 10000 and represented as a 32-bit signed integer in little-endian format with swapped bytes |
bcd32LE_sw | 32-bit binary-coded decimal (BCD) in little-endian format with swapped bytes |
hex_2_sw | 2-digit hexadecimal value with swapped bytes |
hex_3_sw | 3-digit hexadecimal value with swapped bytes |
hex_4_sw | 4-digit hexadecimal value with swapped bytes |
hex_5_sw | 5-digit hexadecimal value with swapped bytes |
hex_6_sw | 6-digit hexadecimal value with swapped bytes |
hex_7_sw | 7-digit hexadecimal value with swapped bytes |
hex_8_sw | 8-digit hexadecimal value with swapped bytes |
ascii_2_sw | 2-character ASCII value with swapped bytes |
ascii_3_sw | 3-character ASCII value with swapped bytes |
ascii_4_sw | 4-character ASCII value with swapped bytes |
ascii_5_sw | 5-character ASCII value with swapped bytes |
ascii_6_sw | 6-character ASCII value with swapped bytes |
ascii_7_sw | 7-character ASCII value with swapped bytes |
ascii_8_sw | 8-character ASCII value with swapped bytes |
int16BE_sb | Signed 16-bit integer in big-endian format with swapped bytes |
int16LE_sb | Signed 16-bit integer in little-endian format with swapped bytes |
uint16BE_sb | Unsigned 16-bit integer in big-endian format with swapped bytes |
uint16LE_sb | Unsigned 16-bit integer in little-endian format with swapped bytes |
int8_sb | Signed 8-bit integer with swapped bytes |
uint8_sb | Unsigned 8-bit integer with swapped bytes |
int32BE_sb | Signed 32-bit integer in big-endian format with swapped bytes |
int32LE_sb | Signed 32-bit integer in little-endian format with swapped bytes |
uint32BE_sb | Unsigned 32-bit integer in big-endian format with swapped bytes |
uint32LE_sb | Unsigned 32-bit integer in little-endian format with swapped bytes |
int64BE_sb | Signed 64-bit integer in big-endian format with swapped bytes |
uint64BE_sb | Unsigned 64-bit integer in big-endian format with swapped bytes |
int64LE_sb | Signed 64-bit integer in little-endian format with swapped bytes |
uint64LE_sb | Unsigned 64-bit integer in little-endian format with swapped bytes |
floatBE_sb | 32-bit floating-point number in big-endian format with swapped bytes |
floatLE_sb | 32-bit floating-point number in little-endian format with swapped bytes |
doubleBE_sb | 64-bit floating-point number in big-endian format with swapped bytes |
doubleLE_sb | 64-bit floating-point number in little-endian format with swapped bytes |
bcd8_sb | 8-bit binary-coded decimal (BCD) with swapped bytes |
bcd16BE_sb | 16-bit binary-coded decimal (BCD) in big-endian format with swapped bytes |
bcd32BE_sb | 32-bit binary-coded decimal (BCD) in big-endian format with swapped bytes |
mod10000_2_BE_sb | Value multiplied by 10000 and represented as a 32-bit signed integer in big-endian format with swapped bytes |
mod10000_2_LE_sb | Value multiplied by 10000 and represented as a 32-bit signed integer in little-endian format with swapped bytes |
mod10000_3_BE_sb | Value multiplied by 10000 and represented as a 32-bit signed integer in big-endian format with swapped bytes |
mod10000_3_LE_sb | Value multiplied by 10000 and represented as a 32-bit signed integer in little-endian format with swapped bytes |
mod10000_4_BE_sb | Value multiplied by 10000 and represented as a 32-bit signed integer in big-endian format with swapped bytes |
mod10000_4_LE_sb | Value multiplied by 10000 and represented as a 32-bit signed integer in little-endian format with swapped bytes |
bcd16LE_sb | 16-bit binary-coded decimal (BCD) in little-endian format with swapped bytes |
bcd32LE_sb | 32-bit binary-coded decimal (BCD) in little-endian format with swapped bytes |
hex_1_sb | 1-digit hexadecimal value with swapped bytes |
hex_2_sb | 2-digit hexadecimal value with swapped bytes |
hex_3_sb | 3-digit hexadecimal value with swapped bytes |
hex_4_sb | 4-digit hexadecimal value with swapped bytes |
hex_5_sb | 5-digit hexadecimal value with swapped bytes |
hex_6_sb | 6-digit hexadecimal value with swapped bytes |
hex_7_sb | 7-digit hexadecimal value with swapped bytes |
hex_8_sb | 8-digit hexadecimal value with swapped bytes |
int32BE_sw_sb | Signed 32-bit integer in big-endian format with swapped bytes |
int32LE_sw_sb | Signed 32-bit integer in little-endian format with swapped bytes |
uint32BE_sw_sb | Unsigned 32-bit integer in big-endian format with swapped bytes |
uint32LE_sw_sb | Unsigned 32-bit integer in little-endian format with swapped bytes |
int64BE_sw_sb | Signed 64-bit integer in big-endian format with swapped bytes |
uint64BE_sw_sb | Unsigned 64-bit integer in big-endian format with swapped bytes |
int64LE_sw_sb | Signed 64-bit integer in little-endian format with swapped bytes |
uint64LE_sw_sb | Unsigned 64-bit integer in little-endian format with swapped bytes |
floatBE_sw_sb | 32-bit floating-point number in big-endian format with swapped bytes |
floatLE_sw_sb | 32-bit floating-point number in little-endian format with swapped bytes |
doubleBE_sw_sb | 64-bit floating-point number in big-endian format with swapped bytes |
doubleLE_sw_sb | 64-bit floating-point number in little-endian format with swapped bytes |
bcd32BE_sw_sb | 32-bit binary-coded decimal (BCD) in big-endian format with swapped bytes |
mod10000_2_BE_sw_sb | Value multiplied by 10000 and represented as a 32-bit signed integer in big-endian format with swapped bytes |
mod10000_2_LE_sw_sb | Value multiplied by 10000 and represented as a 32-bit signed integer in little-endian format with swapped bytes |
mod10000_3_BE_sw_sb | Value multiplied by 10000 and represented as a 32-bit signed integer in big-endian format with swapped bytes |
mod10000_3_LE_sw_sb | Value multiplied by 10000 and represented as a 32-bit signed integer in little-endian format with swapped bytes |
mod10000_4_BE_sw_sb | Value multiplied by 10000 and represented as a 32-bit signed integer in big-endian format with swapped bytes |
mod10000_4_LE_sw_sb | Value multiplied by 10000 and represented as a 32-bit signed integer in little-endian format with swapped bytes |
bcd32LE_sw_sb | 32-bit binary-coded decimal (BCD) in little-endian format with swapped bytes |
hex_2_sw_sb | 2-digit hexadecimal value with swapped bytes |
hex_3_sw_sb | 3-digit hexadecimal value with swapped bytes |
hex_4_sw_sb | 4-digit hexadecimal value with swapped bytes |
hex_5_sw_sb | 5-digit hexadecimal value with swapped bytes |
hex_6_sw_sb | 6-digit hexadecimal value with swapped bytes |
hex_7_sw_sb | 7-digit hexadecimal value with swapped bytes |
hex_8_sw_sb | 8-digit hexadecimal value with swapped bytes |
Modbus slaves usually use different registers depending on their manufacturer and model. It is often necessary to read the slave documentation to know which registers to read, and how the data is encoded (datatype). Then it is necessary to manually configure the addresses in the Modbus gateway. All these steps are time consuming and repetitive, especially when working with several slaves of the same model. In order to solve this problem, model files can be defined to automatically import the configuration.
It is straightforward to import a model from model files. Once the popup is open, it is possible to select the model file, and then choose the range of unit ids to import in the gateway. In the screenshot below, the inepro PRO380 model is imported twice from slave unit id 1 to slave unit id 2.
After the confirmation of the import, the addresses with the correct datatype and description are automatically imported.
It is easy to create a model from your current modbus gateway configuration. The first step is to select one of the address belonging to the slave unit id from which you would like to export the model.
Some model files are provided below as examples. The format of the file is JSON and can be editted with any text or code editor. Usually companies keep and maintain their own list of models.
Example of the Inepro model in JSON format :
{
name : "Inepro",
registers : {
"%M16384" : {
description :"Serial ",
json:{
datatype :"hex_2",
readLoopDelay :100
}
},
"%M20482" : {
description :"Phase 1 line to neutral volts.",
json:{
datatype:"floatBE",
readLoopDelay:100
}
},
"%M20484" : {
description :"Phase 2 line to neutral volts.",
json:{
datatype:"floatBE",
readLoopDelay:100
}
},
"%M20486" : {
description :"Phase 3 line to neutral volts.",
json:{
datatype:"floatBE",
readLoopDelay:100
}
},
"%M20492" : {
description :"Phase 1 current.",
json:{
datatype:"floatBE",
readLoopDelay:100
}
},
"%M20494" : {
description :"Phase 2 current.",
json:{
datatype:"floatBE",
readLoopDelay:100
}
},
"%M20496" : {
description :"Phase 3 current.",
json:{
datatype:"floatBE",
readLoopDelay:100
}
},
"%M20524" : {
description :"Phase 1 power factor ",
json:{
datatype:"floatBE",
readLoopDelay:100
}
},
"%M20526" : {
description :"Phase 2 power factor ",
json:{
datatype:"floatBE",
readLoopDelay:100
}
},
"%M20528" : {
description :"Phase 3 power factor ",
json:{
datatype:"floatBE",
readLoopDelay:100
}
},
"%M20500" : {
description :"Phase 1 power in Watt.",
json:{
datatype:"floatBE",
readLoopDelay:100,
}
},
"%M20502" : {
description :"Phase 2 power in Watt.",
json:{
datatype:"floatBE",
readLoopDelay:100
}
},
"%M20504" : {
description :"Phase 3 power in Watt.",
json:{
datatype:"floatBE",
readLoopDelay:100
}
},
"%M24576" : {
description :"Import Wh since last reset (2).",
json:{
datatype:"floatBE",
readLoopDelay:100
}
},
"%M24600" : {
description :"Export Wh since last reset (2).",
json:{
datatype:"floatBE",
readLoopDelay:100
}
}
}
}
{
id: 58111,
alias: null,
name: "%M2-16383",
description: "Serial ",
log: null,
json: { datatype: "hex_2", readLoopDelay: 100 },
gateway_id: 8,
value: "00000000",
value_string: "00000000000000000000000000000000",
value_date: 1700727461541,
status: 'online',
status_date: 1700727461540
}
{
id: 58138,
alias: null,
name: "%M1-24599",
description: "Export Wh since last reset (2).",
log: null,
json: { datatype: "floatBE", readLoopDelay: "*/15 * * * *", cov: 0.1 },
gateway_id: 8,
value: 0,
value_string: "00000000000000000000000000000000",
value_date: 1700727461517,
status: 'online',
status_date: 1700727461515
}