ModBus smartCORE module
Description
The "modbus" module primarily reads the ModBus registers of ModBus devices. These devices can be
- via a serial connection (ModBus/RTU)
- via TCP (ModBus/TCP)
be connected.
Interfaces & protocols used
- ModBus
JSON configuration
The following section describes the entire JSON configuration of the module and explains the individual parameters.
Example configuration
An example ModBus/TCP configuration is shown below:
{
"module": "ModBus",
"comment": "ModBus/TCP config",
"factory": "modbus",
"config": {
"version": 1,
"type": "modbus",
"enable": true,
"pollCycleInMilliseconds": 1000,
"transport": {
"type": "tcp",
"ipAddress": "192.168.0.1",
"ipPortNumber": 502,
"timeoutInMilliseconds": 200
},
"devices": [
{
"enable": true,
"deviceName": "Device Name",
"deviceAddress": 1,
"readChannels": [
{
"name": "Channel Name",
"address": 49152,
"registerType": "HoldingReg",
"registerFormat": "REAL",
"byteOrder": "ABCD",
"bitOffset": 0,
"unit": "",
"scale": 1.0,
"offset": 0.0
}
]
}
]
}
}
Global module parameters
Parameter name | Required | Data type | Meaningful value range | Default | Description |
---|---|---|---|---|---|
version | YES | INT | 1 | - | ModBus protocol version |
type | YES | STRING | "modbus" | - | Serial interface for communication |
enable | YES | BOOL | true | - | Switch for production of data in smartCHANNELs |
pollCycleInMilliseconds | YES | INT | 1 - | - | polling interval [ms] of ModBus accesses |
transport | YES | JSON object | - | configuration of the ModBus transport layer (see below) | |
devices | YES | JSON array of JSON objects | - | List of ModBus participants |
ModBus/TCP specific transport parameters ("transport")
Parameter Name | Required | Data Type | Meaningful Value Range | Default | Description |
---|---|---|---|---|---|
type | YES | STRING | "tcp" | Selection ModBus/TCP | |
ipAddress | YES | STRING | Valid IP address | IP address of the ModBus device | |
ipPortNumber | YES | INT | Valid IP port number | IP port number of the ModBus device (should be set to 502 unless otherwise specified) | |
timeoutInMilliseconds | YES | INT | 1 - | Timeout [ms] for TCP connection (should be set to 200 unless otherwise specified) |
ModBus/RTU specific transport parameters ("transport")
Parameter name | Required | Data type | Meaningful value range | Default | Description |
---|---|---|---|---|---|
type | YES | STRING | "rtu" | Selection ModBus/RTU | |
baudRate | YES | INT | Valid ModBus baud rate | Baud rate of the serial interface | |
dataBits | YES | INT | 5 - 8 | Data bits of the serial interface | |
encoding | YES | STRING | "rtu" | Encoding of the ModBus data (only "rtu" is supported) | |
parity | YES | STRING | "no", "even", "odd" | Parity of the serial interface | |
stopBits | YES | DOUBLE | 1.0, 1.5, 2.0 | Stop bits of the serial interface | |
portName | YES | STRING | Valid device file | Device file of the serial interface | |
terminationResistor | YES | BOOL | true, false | Switch for INTERNAL termination resistor | |
timeoutInMilliseconds | YES | INT | 1 - | Timeout [ms] for TCP connection (should be set to 200 unless otherwise specified) | |
deviceTimeoutInMilliseconds | No | INT | 0 - | 0 | Additional timeout [ms] between the queries of different ModBus participants |
ModBus device parameters ("devices")
Parameter Name | Required | Data Type | Meaningful Value Range | Default | Description |
---|---|---|---|---|---|
enable | YES | BOOL | true | Switch for activating the ModBus device | |
deviceName | YES | STRING | Name of the ModBus device | ||
deviceAddress | YES | INT | 1 - | Address of the ModBus device | |
readChannels | YES | JSON Array of JSON objects | see below |
ModBus channel configuration ("readChannels")
Parameter name | Required | Data type | Meaningful value range | Default | Description |
---|---|---|---|---|---|
name | YES | STRING | name of the smartCHANNEL | ||
address | YES | INT | Address of the ModBus register | ||
registerType | YES | STRING | Valid ModBus register type | Type of ModBus register ("InputReg", "HoldingReg", "Coil", "Status", "0x17" (read access only)) | |
registerFormat | YES | STRING | Valid ModBus register format | Format of the ModBus register ("I8", "I16", "I32", "I64", "UI8", "UI16", "UI32", "UI64", "REAL", "BOOL") | |
byteOrder | YES | STRING | Byte order of the ModBus register ("A" = MSB, "B" or "D" = LSB) | ||
bitOffset | YES | UINT | Bit offset of the value to be interpreted | ||
unit | YES | STRING | Unit of the smartCHANNEL | ||
scale | YES | DOUBLE | Scaling of the smartCHANNEL | ||
offset | YES | DOUBLE | Offset of the smartCHANNEL |
ModBus channel configuration ("readChannelGroups")
Alternatively, several channel configurations can be combined into a JSON array, so that the ModBus registers on which this group is based can be read in a single step can be read in a single step (if the register type is identical). This readChannelGroup array combined in this way can then be listed in the JSON array of the "readChannelGroups", e.g.
"readChannelGroups": [
[
{
"name": "Channel 1",
"address": 49152,
"registerType": "HoldingReg",
"registerFormat": "REAL",
"byteOrder": "ABCD",
"bitOffset": 0,
"unit": "",
"scale": 1.0,
"offset": 0.0
},
{
"name": "Channel 2",
"address": 49158,
"registerType": "HoldingReg",
"registerFormat": "REAL",
"byteOrder": "ABCD",
"bitOffset": 0,
"unit": "",
"scale": 1.0,
"offset": 0.0
}
]
]
Alternatively, "readChannels" or "readChannelGroups" can be specified.
Module information
Information | Value |
---|---|
Authors | optiMEAS Measurement and Automation Systems GmbH |
since smartCORE | 0.1 |
Module type | Producer |
Dependencies | NONE |