Set up an Modbus Slave
Follow the guide Add Module to Apis Hive, but this time select a module of type ApisModbusSlave from the Module type drop down list, name it "ModbusSlave" in this case.
- After adding the module, select the new module named "ModbusSlave" from theSolution Explorer.
Basic setup, communication interface
The module supports both serial (RTU) and TCP/IP (Modbus TCP) interface, depending on your needs. In the Properties Editor, enter values for:
-
TCP/IP based server:
- Comm. type: TCP/IP
- IP address: The endpoint IP address of your ModbusSlave server.
- Port: The endpoint TCP port of your ModbusSlave server.
-
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.
-
Further in the Properties Editor:
- Default Slave address : Note! this is the initial property when new items are created.
- Assure the byte order and endianness is according to your needs
-
Press "Apply" when done.
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:
Give the Item a proper name like "Temp_Man_6". Assure SrcItemID is pointing to valid register address like "40002",check the Slaveadress and set correct Valetype of the value in the register of the slave. Ok
Expose data
To expose data, ModbusSlave Items must be connected to a source item . See Connecting Items
The Worker.Signal1 is now exposed to Modbus masters (clients) in Holding register 40002 as 8 byte float.
Trouble shooting
If no connection or data received:
- Use 3 party terminal application like putty to check if server is sending telegrams.
- Check firewall settings for the port.
- Check network connection to server, (ping)