Reading modbus RS-485 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 slave id of the modbus slave you want to read out.
- type: to choose which register to read out, enter here "generic-rtu".
- baud rate:the transmission rate expressed in bits per second. Set the same baud rate as on the modbus slave.
- bus: this is where the RTU expansion card is plugged in. If it is on expansion 1 you choose 102. If it is on expansion 2 choose 101.
- serialconfig: use this notation to set advanced serial communication parameters, such as the number of data bits, stop bits and parity bits, and which handshake protocol should be used.
baudrate: the transmission rate expressed in bits per second.
data bits: the number of bits used per character.
For parity, stop bits and handshake use the following ENUM values:
parity: - 0 (None): No parity check.
- 1 (Odd): The total number of data bits is always an odd number.
- 2 (Even): The total number of data bits is always an even number.
- 3 (Mark): The parity bit is always 1.
- 4 (Space): The parity bit is always 0.
stop bits:
- 0 (One): One stop bit is used.
- 1 (OnePointFive): One-and-a-half stop bits are used.
- 2 (Two): Two stop bits are used.
handshake:
- 0 (None): No handshake protocol is being applied.
- 1 (RequestToSend/ClearToSend): RTS/CTS flow-control.
- 2 (XOn/XOff): Software-based flow-control.
Example of a SlaveDefinitions block:
"slaveDefinitions": [
{
"name": "modbus.rtu",
"slaves": [
{
"address": 3,
"type": "generic-rtu",
"busdefinitiontype": 100,
"baud rate": 9600,
"bus": "101"
},
{
"address": 4,
"type": "generic-rtu",
"busdefinitiontype": 100,
"bus": "101",
"serialconfig": {
"baud rate": 19200,
"parity": 0,
"stop bits": 2,
"handshake": 0,
"data bits": 8
}
}
]
}
]
SlaveSettings
For each slave you have defined in SlaveDefinitions, you can determine in SlaveSettings which registers you want to effectively read out.
First, you start in SlaveSettings by defining 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 noted in the SlaveDefinitions. For bus 101 it is 1 and for bus 102 it is 2.
- slave_id: the slave id you noted in SlaveDefinitions.
For example: modbus.rtu.mb_uart1.3 (Bus 101, so we use 1. 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 out.
- 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 (type 1 in the gateway settings) as the data type.
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
}
]
}
}
]
3
.
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
}
]
}
}
]
}