Understanding settings
The settings are always processed by the system in JSON format, before they are sent to the gateway, and are divided into 2 parts:
slaveDefinitions
In slaveDefinitions, you decide what you will read. There are a number of settings for each slave:
Field | Value (as in example) | Description |
---|---|---|
"address" | 3 | The slave id of the modbus slave. |
"type" | "generic-rtu" | To choose which register you want to read, specify generic-rtu. |
"baudrate" | 9600 | The transmission rate in bits per second. Set the same baud rate here as on the modbus slave. |
"bus"" | 101 | The expansion bush where the RTU expansion card is inserted:
|
"serialConfig" | { "baudrate": 19200, "parity": 0, "stopbits": 2, "handshake": 0, "databits": 8 } | Use this notation to set advanced serial communication parameters, such as the number of data bits, stop bits and parity bits, and the handshake protocol. |
"databits" | 8 | The number of bits used for data transmission per character. |
"parity" | 0 | The type of parity check you want:
|
"stopbits" | 2 | The number of stop bits per character:
|
"handshake" | 0 | Transmission control type:
|
Example of a slaveDefinitions block
"slaveDefinitions": [
{
"name": "modbus.rtu",
"slaves": [
{
"address": 3,
"type": "generic-rtu",
"busdefinitiontype": 100,
"baudrate": 9600,
"bus": "101"
},
{
"address": 4,
"type": "generic-rtu",
"busdefinitiontype": 100,
"bus": "101",
"serialconfig": {
"baudrate": 19200,
"parity": 0,
"stopbits": 2,
"handshake": 0,
"databits": 8
}
}
]
}
]
slaveSettings
For each slave that you have defined in slaveDefinitions, you can determine in slaveSettings which registers you actually want to read. First of all, you start by determining the name, always in the following format:
modbus.rtu.mb_uart{bus_id}. {slave_id}
bus_id: the last digit of the bus that you wrote in slaveDefinitions. For bus 101 it is 1 and for bus 102 it is 2.
slave_id: the slave ID that you have specified in slaveDefinitions.
For example: modbus.rtu.mb_uart1.3 → Bus 101 = 1, Slave ID = 3.
Furthermore, in measurementPaths you determine which modbus registers you want to read.
Field | Value (as in example) | Description |
---|---|---|
"measurementPath" | "voltage.uv" | The name of the path on which the data is put. |
"functionCode" | 4 | Type of register to be read:
|
"startAddress" | 0 | The modbus address you want to read. |
"dataType" | 1 | Type of data to be read:
|
"factor" | 1 | This determines the factorization of the read value.
|
"minValue" (Optional) | 0 | If a minimum value has been entered, it will not be forwarded if the measurement is below this value. |
"maxValue" (Optional) | 500 | If a maximum value has been entered, it will not be forwarded if the measurement is above this value. |
"firstBit" (optional) | 7 | If you want to read one or more bits from a register, enter the first bit here. Choose Int16 as the data type (type 1 in the gateway settings).
|
"lastBit" (optional) | 7 | If you want to read one or more bits from a register, enter the last bit here. Choose Int16 as the data type (type 1 in the gateway settings).
|
Example of a slaveSettings block
"slaveSettings": [
{
"name": "modbus.rtu.mb_uart1.3",
"settings": {
"measurementPaths": [
{
"measurementPath": "voltage.uv",
"functionCode": 4,
"startAddress": 0,
"dataType": 1,
"factor": 1,
"minValue": 0,
"maxValue": 500
}
]
}
},
{
"name": "modbus.rtu.mb_uart1.4",
"settings": {
"measurementPaths": [
{
"measurementPath": "alarm_1",
"functionCode": 3,
"startAddress": 1,
"dataType": 1,
"factor": 1,
"minValue": 0,
"maxValue": 1,
"firstBit": 7,
"lastBit": 7
}
]
}
}
]
Example of a complete settings definition
{
"slaveDefinitions": [
{
"name": "modbus.rtu",
"slaves": [
{
"address": 3,
"type": "generic-rtu",
"busdefinitiontype": 100,
"baudrate": 9600,
"bus": "101"
},
{
"address": 4,
"type": "generic-rtu",
"busdefinitiontype": 100,
"baudrate": 9600,
"bus": "101"
}
]
}
],
"slaveSettings": [
{
"name": "modbus.rtu.mb_uart1.3",
"settings": {
"measurementPaths": [
{
"measurementPath": "voltage.uv",
"functionCode": 4,
"startAddress": 0,
"dataType": 1,
"factor": 1,
"minValue": 0,
"maxValue": 500
}
]
}
},
{
"name": "modbus.rtu.mb_uart1.4",
"settings": {
"measurementPaths": [
{
"measurementPath": "alarm_1",
"functionCode": 3,
"startAddress": 1,
"dataType": 1,
"factor": 1,
"minValue": 0,
"maxValue": 1,
"firstBit": 7,
"lastBit": 7
}
]
}
}
]
}