Reading modbus TCP/IP in settings Gateway Impulse C07W
1
.
Requirements
To edit settings you need the user right "GatewaySettings" .
2
.
Understanding Settings
The settings are always processed in JSON format by the system before being sent to the gateway.
These JSON settings are divided into 2 parts:
SlaveDefinitions
In "slaveDefinitions" you determine what you will read out. Per "Slave" there are a number of settings:
- address: this is the IP address of the modbus slave you want to read out.
- slaveId: this is the slave ID of the modbus slave you want to read out.
- type:to choose which register to read, enter "generic-tcp" here.
Example of a SlaveDefinitions block:
"slaveDefinitions": [
{
"name": "modbus.tcp",
"slaves": [
{
"address": "192.168.2.11",
"port": 502,
"slaveId": 1,
"type": "generic-tcp"
},
{
"address": "192.168.2.12",
"port": 502,
"slaveId": 1,
"type": "generic-tcp"
}
]
}
]
SlaveSettings
For each slave you have defined in SlaveDefinitions, you can determine in SlaveSettings which registers you want to read out.
First, you start in SlaveSettings by defining the name, always in the following format:
modbus.tcp.{ip_adres}__{port}.{slave_id}
- -ip_address: is the IP address of the slave. Note: use "_" instead of a ".".
- - port: this is default 502 for modbus.
- - slave_id: the slave id you noted in the SlaveDefinitions.
For example: modbus.tcp.192_168_2_11__502.1 (IP address = 192.168.2.11. Slave id = 3).
Furthermore, in MeasurementPaths you determine which modbus registers you want to read out.
- measurementPath:this is the name of the path where the data will be put.
- functionCode:
- 1: Read Coil Status
- 2: Read Input Status
- 3: Read Holding Register
- 4: Read Input Register
- 5: Force Single Coil
- 6: Preset Single Register
- 15: Force Multiple Coils
- 16: Preset Multiple Registers
- startAddress:enter the modbus address you want to read.
- dataType:
- 1: Int16
- 2: Int32
- 3: Int64
- 11: UInt16
- 12: UInt32
- 13: UInt64
- 21: Float
- 22: Double
- 30: Bool
- minValue (optional): if a minimum value is entered, it will not be passed if the read value is below this value.
- maxValue (optional): if a maximum value is entered, it will not be passed if the read value is above this value.
- firstBit (optional): if you want to read one or more bits of a register, enter the first bit here.
- lastBit (optional): if you want to read one or more bits of a register, enter the last bit here.
You want to read bit X: "0000 0X00". In this case, you use "FirstBit": 2 and "LastBit": 2.
You want to read out bits XX: "XX00 0000". In this case you use "FirstBit": 6 and "LastBit": 7.
Choose Int16 (1 in the gateway settings) as the data type.
Example of a SlaveSettings block:
"slaveSettings": [
{
"name": "modbus.tcp.192_168_2_11__502.1",
"settings": {
"measurementPaths": [
{
"measurementPath": "voltage.uv",
"functionCode": 4,
"startAddress": 0,
"dataType": 1,
"factor": 1,
"minValue": 0,
"maxValue": 500
}
]
}
},
{
"name": "modbus.tcp.192_168_2_12__502.1",
"settings": {
"measurementPaths": [
{
"measurementPath": "alarm_1,
"functionCode": 3,
"startAddress": 1,
"dataType": 1,
"factor": 1,
"minValue": 0,
"maxValue": 1,
"firstBit": 7,
"lastBit": 7
}
]
}
}
]
3
.
Example of a complete settings definition
{
"slaveDefinitions": [
{
"name": "modbus.tcp",
"slaves": [
{
"address": "192.168.2.11",
"port": 502,
"slaveId": 1,
"type": "generic-tcp"
},
{
"address": "192.168.2.12",
"port": 502,
"slaveId": 1,
"type": "generic-tcp"
}
]
}
],
"slaveSettings": [
{
"name": "modbus.tcp.192_168_2_11__502.1",
"settings": {
"measurementPaths": [
{
"measurementPath": "voltage.uv",
"functionCode": 4,
"startAddress": 0,
"dataType": 1,
"factor": 1,
"minValue": 0,
"maxValue": 500
}
]
}
},
{
"name": "modbus.tcp.192_168_2_12__502.1",
"settings": {
"measurementPaths": [
{
"measurementPath": "alarm_1,
"functionCode": 3,
"startAddress": 1,
"dataType": 1,
"factor": 1,
"minValue": 0,
"maxValue": 1,
"firstBit": 7,
"lastBit": 7
}
]
}
}
]
}