ABOUT MODBUS
What is Modbus?
The Modbus communication protocol is most popular automation protocol in the field of process automation and SCADA (Supervisory Control and Data Acquisition).
Knowing how to create Modbus based networks is essential for any automation engineer working in these occupation fields.
Being able to integrate devices from different manufacturers is a skill that is in demand and will ultimately make you more valuable and marketable in the industry.
Modbus is a communications protocol published by Modicon in 1979 for use with its Programmable Logic Controllers (PLCs). Modicon is now owned by Schneider Electric.
Modbus provides a common language for devices and equipment to communicate with one and another.
For example, Modbus enables devices on a system that measures temperature and humidity connected on the same network to communicate the results to a supervisory computer or PLC.
The development and update of Modbus protocols have been managed by the Modbus Organization. The Modbus Organization is an association of users and suppliers of Modbus compliant devices.
Types of Modbus
- Modbus RTU (Remote Terminal Unit):
- Communication: Serial communication (RS-232 or RS-485).
- Data Representation: Binary (compact, efficient).
- Typical Usage: Used in environments with limited bandwidth and real-time communication requirements.
- Modbus ASCII:
- Communication: Serial communication (RS-232 or RS-485). o Data Representation: ASCII characters (less efficient than RTU).
- Typical Usage: Easier to debug manually, used where human readability of the data is important.
- Modbus TCP/IP:
- Communication: Ethernet network. o Data Representation: Uses the same Modbus protocol wrapped in TCP/IP packets.
- Typical Usage: Suitable for modern networks, allows higher data rates and more devices.
Number of Devices
- Modbus RTU and Modbus ASCII:
- Up to 247 devices (addresses) can be connected to a single Modbus network.
Practically, the number might be lower due to communication line limitations.
- Modbus TCP/IP:
- Supports a virtually unlimited number of devices, constrained only by the network infrastructure. 256 devices on single IP address.
The original Modbus interface ran on RS-232 serial communication, but most of the later Modbus implementations use RS-485 because it allowed:
- Longer distances.
- Higher speeds.
- The possibility of multiple devices on a single multi-drop network.
Master-Slave Modbus communication over serial RS-485 physical media using two-wire transmit and receive connections.
On simple interfaces like RS232 or RS485, the Modbus messages are sent in plain form over the network and the network will be dedicated to only Modbus communication.
However, if your network requires multiple heterogeneous devices using a more versatile network system like TCP/IP over Ethernet, the Modbus messages are embedded in Ethernet packets with the format prescribed for this physical interface.
So in this case, Modbus and other types of mixed protocols can co-exist at the same physical interface at the same time.
Data Rate
- Modbus RTU and ASCII:
- Common baud rates: 1200, 2400, 4800, 9600, 19200, 38400, 57600, and 115200 bits per second (bps).
- The choice of baud rate depends on the application and the quality of the communication line.
- Modbus TCP/IP:
- The data rate depends on the Ethernet network (commonly 10 Mbps, 100 Mbps, or 1 Gbps).
Process of Data Flow
- Master-Slave Communication:
- Master Device: Initiates communication by sending a request to a slave.
- Slave Device: Responds to the master’s request.
- Only the master can initiate communication.
- Message Structure:
- Function Code: Specifies the action (e.g., read, write). o Data: Contains the necessary data (register addresses, values).
- Error Check: Ensures data integrity (CRC for RTU, LRC for ASCII).
- Communication Steps:
- Request: The master sends a request message to a specific slave device. o Processing: The slave processes the request and prepares a response. o Response: The slave sends a response message back to the master.
- Error Handling: If there’s an error, the slave sends an exception response.
Example of Modbus RTU Communication
- Master Request (Read Holding Registers):
- Device Address: 01
- Function Code: 03 (Read Holding Registers)
- Starting Address: 0000
- Quantity of Registers: 0002
- Error Check (CRC): 0xC40B
- Slave Response:
- Device Address: 01
- Function Code: 03
- Byte Count: 04
- Register Value 1: 0x1234
- Register Value 2: 0x5678
- Error Check (CRC): 0xFFFF
- The master’s query will consist of:
- Slave address (broadcast address).
- Function code with a read or write data command to the slave.
- The write command “Data” if a write command was initiated by the master.
- Error checking field.
- The error checking is a value the master or slave creates at the beginning of the transmission or response and then checked when the message is received to verify the contents are correct.
- A slave’s response consists of:
- Fields confirming it received the request.
- The data to be returned.
- Error checking data.
- If no error occurs, the slave’s response contains the data as requested.
- If an error occurs in the message query received by the slave, or if the slave is unable to perform the action requested, the slave will return an exception message as its response.
- The error check field of the slave’s message frame allows the master to confirm that the contents of the message are valid.
- In this article, you learned about what Modbus communication protocol is and the types of Modbus communication used in the industry.
In summary, Modbus is a versatile and widely-used protocol in industrial automation for connecting devices and transferring data efficiently. Its different types and adaptability to various communication media make it suitable for a range of applications.