Twin Config

Modbus slave setup and global settings are configured in the Module Twin, in the IoT Hub. The slave configuration supports both TCP and RTU connections and little / big Endian formats (if the slave uses reverse byte order / word order or not). In general, all slave id's must be unique.

In the desired properties, the following 3 keys can be used:

Settings The common settings include the interval between each publish of measurements from the Modbus Module, in milliseconds. If the value is not set, a default of 30 seconds is used. It also contains the basic scan interval that the modbus module executes read by. All tag sampling rates must be able to be factored into multipla of this scan rate. If it is set too low, the module will spend too much time on house keeping tasks.

TcpConfig A list of TCP slave connections, including ip address and information about byte/word order (dependent on processor architecture and individual implementations on the Modbus servers).

Required information SlaveConnection: Ip adress of the Modbus server

RtuConfig A list of RTU slave connections, including com port properties and information about byte/word order (dependent on processor architecture and individual implementations on the Modbus servers).

Required information SlaveConnection: Name of the com port BaudRate: Possible values are 9600, 14400 and 19200 DataBits: Possible values are 7 and 8 StopBits: Possible values are 0, 1, 2 and 3 (meaning 1,5 stopbits) Parity: Possible values are 0 = none, 1 = odd, 2 = even

Both ModbusTCPConfiguration and ModbusRTUConfiguration support an option to change the ByteOrder and WordOrder that the Modbus client should expect from the slave

Example configuration of tcp and rtu slaves, including common settings:


"settings": {
    "publishIntervalMs": 5000,
    "scanIntervalMs": 1000
},
"tcpConfig": {
    "slave01": {
        "name": "Slave01",
        "slaveConnection": "tc-site-dev.northeurope.cloudapp.azure.com",
        "hwId": "ModBusSimulator",
        "byteOrder": 1,
        "wordOrder": 0
    }
},
"rtuConfig": {
    "slave02": {
        "name": "Slave02",
        "slaveConnection": "<ip address>",
        "baudRate": 19200,
        "dataBits": 8,
        "stopBits": "None",
        "parity": "ODD",
        "byteOrder": 1,
        "wordOrder": 0
    }
}

Last updated

Was this helpful?