Skip to main content

Modbus

Modbus is a common protocol for communication with industrial devices. This implementation is based on version 1.1b3.

The Modbus Target is split in two communication modes: Modbus TCP and Modbus Serial (RTU).

Modbus TCP Configuration

The Modbus TCP Target has the following parameters:

  • Host: Host name or IP Address of the client.
  • Port: Client. Default is 502.
  • TargetType: The type is always ModbusTcp for this Target.
  • Endianness: Byte endianness. Can be BigEndian, LittleEndian, BigEndianFlipped or LittleEndianFlipped. The flipped variants swaps the two bytes in a Modbus register.

For the common parameters, see the Introduction.

Corresponding Edge configuration and Device Twin definition to activate the Modbus TCP Target service:
https://localhost:5050/Targets
Modbus TCP Target Settings

Modbus Serial (RTU) Configuration

The Modbus Serial Target has the following parameters:

  • PortName: Port name of the serial port. E.g. COM1
  • Endianness: Byte endianness. Can be BigEndian, LittleEndian, BigEndianFlipped or LittleEndianFlipped. The flipped variants swaps the two bytes in a Modbus
  • BaudRate: Serial baud rate. Can be 4800, 9600, 19200, 38400, 57600, 115200
  • DataBits: Number of data bits. Default is 8.
  • StopBits: Number of stop bits. Can be One, Two or OnePointFive
  • Rs485DriverEnable: Enable RS485 mode.
  • Handshake: Can be None, XOnXOff, RequestToSend or RequestToSendXOnXoff
  • Parity: Can be None, Odd, Even, Mark or Space
  • TargetType: The type is always ModbusSerial for this Target.

For the common parameters, see the Introduction.

Corresponding Edge configuration and Device Twin definition to activate the Modbus Serial Target service:
https://localhost:5050/Targets
Modbus Serial Target Settings

Data Streaming

Modbus is a address based protocol, therefore no discovery or name based signal access is possible. The syntax for the signal name is: Name,DeviceId,Address,RegisterType,DataType,ArrayLength. The fields DataType and ArrayLength are optional.

  • Name: The output signal name.
  • DeviceId: The Device ID of the Modbus device.
  • Address: The start address of the signal to read.
  • RegisterType: Type of the Modbus register
    • di: Discrete Inputs
    • c: Coil
    • ir: Input Register
    • hr: Holding Register
  • DataType (optional when connecting to Coils or Discrete Inputs)
    • x: Boolean. When reading a register, the bit position can be added in square brackets. E.g. x[5].
    • b: Byte
    • w: UInt16
    • dw: UInt32
    • lw: UInt64
    • si: SByte
    • i: Int16
    • di: Int32
    • li: Int64
    • r: Float
    • dr: Double
    • c: Char ASCII (1 Byte)
    • wc: Char Unicode (2 Bytes)
    • s: String ASCII (1 Byte). The length of the string must be added in square brackets. E.g. s[12].
    • ws: String Unicode (2 Bytes). The length of the string must be added in square brackets. E.g. ws[12].
  • ArrayLength: Length of the array to read. If not present, it defaults to 1.

Endianness

The byte endianness can either be set globally in the Target settings or at signal level. Therefore, add

  • .be (Big Endian),
  • .bef (Big Endian, flipped bytes in Modbus register),
  • .le (Little Endian) or
  • .lef (Little Endian, flipped bytes in Modbus register)

to the DataType.

The Signals to read or write are configured in the Router.

For information how signals are named and labeled in Data Lakes, please read the Data Lake documentation.