In contrast to other field busses, Modbus poses a simple alternative to transfer data. The Modbus protocol is open. It is based on Master / Slave communication. As a principle, every participant may transmit data in the network. In practice however, communication is always initiated by the master.
Types of transfer (selection)
- Modbus RTU
- Serial communication
- Binary data transfer
- RTU stands for Remote Terminal Unit
- Modbus TCP
- Extended Modbus RTU for TCP/IP networks
Modbus Master
- Requests data from Modbus slaves
- Acts as the client, as it doesn’t make data available
Modbus Slave
- Makes data available
- Acts as the server as it makes data available
Modbus Register
- Caution: depending on the device, the registration addresses with a 1 or 0
- A maximum of 216 registers are addressable, therefore 65536
- Enables access to data
- Access is via a register address and Modbus function and service respectively
- Are specific to each device
Functions or services
- Implements access to data
- Distinguishes
- Reading / writing / both
- Data width
- Data word, therefore 2 bytes
- Bit
- The implemented functions are dependent on the device
Request data
Configure the Modbus Master and Modbus Slave data connection
- Modbus TCP – network configuration (static IP address, net template)
- Modbus RTU – serial interface (baud rate, data bits, parity, stop bits)
The corresponding function has to be selected on Modbus Master to the one that Slave makes available
- Modbus RTU Slave ID: between 1 and 247 (0 stands for broadcast)
- Modbus TCP Unit ID: it has the same functionality as Slave ID. However there’s still the 255. In practice, it depends on the connected device which value has to be set. Then either a ModbusTCP Slave will be clearly identified in the network by means of its IP address. But when this Slave is a gateway of ModbusTCP on ModbusRTU, it can address several ModbusRTU Slaves. The Unit ID 255 is recommended to address the gateway itself.
- Modbus register
- The kind of register is specific to the device
- Counted are either from 0 or from 1
- Modbus function, e.g. READ_HOLDING_REGISTER
Example of necessary information for Modbus RTU
- Serial interface parameter, e.g. 9600 Baud, 8 data bits, 1 stop bit, no parity
- Slave address, e.g. 1
- Modbus register, e.g. 1000
- Modbus function e.g. READ_INPUT_REGISTER
Example of necessary information for Modbus TCP
- Slave IP address, e.g. 192.168.0.103
- Unit ID, e.g. 255
- Slave register, e.g. 1000
- Modbus function e.g. READ_HOLDING_REGISTER
Modbus in RevPi
The following virtual devices are available in RevPi Core and can be configured via PiCtory:
- ModbusRTU Master
- Application: RevPi Core requests data from another Modbus device
- ModbusRTU Slave
- Application: RevPi Core makes data available that can be requested by a master
- ModbusTCP Master
- Application: RevPi Core accesses data from another Modbus device
- ModbusTCP Slave
- Application: RevPi Core makes data available that can be accessed by a master
A maximum of 32 registers per virtual device can be used for input and output data. Should you need more, then you can simply configure several virtual Modbus devices. A total of 30 virtual devices can be configured.