Connect To ModBus Slave

Follow the guide Add Module to Apis Hive, but this time select a module of type ApisModbus from the "Module type" dropdown list.

  • After adding the module, select the new module named "ApisModbus" from the Solution Explorer.

Basic setup, communication interface

The module supports both serial (RTU) and TCP/IP (Modbus TCP) interface, depending on your server. In the Properties Editor, enter values for:

  1. TCP/IP based server:

    • Comm. type: TCP/IP
    • IP address: IP address of your Modbus slave module
    • Port: TCP port of your Modbus slave module
    • Poll interval: This needs to be set to other value than 0 for polling the values from the modbus slave module
    • Default Slaveaddress: Sets default Slaveaddress on each created item to this value, it can be changed on each item individually

  1. Serial communication based server :

    • Comm. type receive : Serial
    • Com port: Com port connected to the slave.
    • BaudRate: Baud rate of your slave serial setup.
    • DataBits: Data bits of your slave serial setup.
    • FlowControl: Handshake of your slave serial setup.
    • Parity: Parity of your slave serial setup.
    • StopBits: Stop bits of your slave serial setup.
    • Poll interval: This needs to be set to other value than 0 for polling the values from the modbus slave module

Add Items (registers)

Now follow the guide Add Items to a Module, but this time select the Modbus module and add items of one of the register types:

  • Coil
  • DiscretesInput
  • InputRegister
  • HoldingRegister

Example Holding register:

In the example we have created item HoldingRegister1. Assure SrcItemID is pointing to corresponding register address, check the Slaveadress if it's corresponding with the Slaveaddress of the Modbus Slave and set correct Valetype of the value in the register of the slave.

If all setting are correct the "HoldingRegister1" tag should be displaying the value of holding register 40001 of the slave.

Troubleshooting

If there's no connection or data received:

  • Use a third-party terminal application like wireshark, to check if the server is sending telegrams.
  • For a TCP/IP based server:
    • Check the firewall settings for the receiving port
    • Check the network connection to the server (ping)
  • Doublecheck ports, ip addresses, defaultslave addresses, poll interval and make sure that the SrcItemIDs are set up correctly to the Modbus standards depending on the valuetypes both on Modbus and Modbusslave modules etc.