Modbus is a widely used protocol in industrial automation for serial communication. It facilitates communication between multiple devices connected to the same network, allowing for the monitoring and control of industrial equipment.
Modbus is a communication protocol developed by Modicon systems (now Schneider Electric) in 1979. It is used for transmitting information over serial lines between electronic devices. The protocol is simple, robust, and widely adopted in industrial environments.
Modbus supports different communication modes:
Modbus RTU is a binary protocol and the most common implementation. It uses a compact, binary representation of data for communication.
Modbus ASCII uses ASCII characters for communication. It is less efficient than RTU but easier to read and debug.
Modbus TCP/IP allows Modbus communication over Ethernet networks using TCP/IP protocol.
Modbus messages consist of four main parts:
The address of the slave device (1 byte). In Modbus TCP/IP, this is replaced by an IP address.
Indicates the type of operation to be performed (1 byte).
The data to be transmitted or received (variable length).
CRC (Cyclic Redundancy Check) for RTU or LRC (Longitudinal Redundancy Check) for ASCII (2 bytes).
Modbus supports various function codes for different operations:
To read holding registers from a slave device, a Modbus RTU message might look like this:
| Device Address | Function Code | Starting Address | Quantity of Registers | Error Check (CRC) | | 01 | 03 | 00 10 | 00 02 | xxxx |
This message requests to read 2 registers starting at address 0010 from the slave device with address 01.
Consider a Modbus RTU request to read 2 registers starting from address 0x0010:
The complete frame: 01 03 00 10 00 02 C4 0B
Modbus communication can be carried out using different types of cables, primarily based on the physical layer being used:
RS-485 is the most common physical layer used for Modbus RTU and ASCII communication. It allows for longer cable lengths and multiple devices on the same bus.
RS-232 is also used for Modbus communication but is limited to point-to-point connections and shorter distances compared to RS-485.
Modbus TCP/IP uses Ethernet for communication, allowing for easy integration into existing network infrastructures.
Modbus pinout configurations vary based on the physical layer being used. Below are the common pinout configurations for RS-485 and RS-232.
RS-485 typically uses a two-wire or four-wire configuration for differential signaling:
RS-232 typically uses DB-9 or DB-25 connectors with the following pinout: