Modbus Training file__.pdf (3.3 MB)
Modbus is a serial communication protocol that was developed by Modicon, now Schneider Electric, in 1979 for use with its programmable logic controllers (PLCs).
Modbus Protocol
Modbus is a master/slave or client/server protocol. It means that one device, the master (usually a computer or a PLC), initiates all communication. Other devices, known as slaves or servers, respond by supplying the requested data to the master, or by taking the action requested in the query.
In Modbus, data is sent in discrete packets. A packet includes fields for the device address, the function code (indicating the kind of request), data, and an error-checking field.
Working Principle of Modbus
Here’s an example to illustrate how Modbus might work:
Let’s say we have a master device (such as a PLC) and three temperature sensors (slave devices), each with a unique address (1, 2, and 3 respectively).
The master device sends a message to the first temperature sensor asking for the current temperature. The message includes the address of the sensor (1), the function code for “read holding registers” (which corresponds to a numerical code, in this case, 03), and the specific address of the register that contains the temperature data.
The temperature sensor receives the message and checks the address to ensure it’s the intended recipient. If the address matches its own, it continues processing the message.
The sensor then checks the function code to determine what action to take. In this case, the function code requests a read of a holding register. The sensor then reads the register specified in the message.
The sensor sends a response to the master device. This response includes its own address, the function code, the data length, the requested data (the temperature), and an error-checking field.
The master device receives the response, verifies the error-checking field, and then uses the data as needed (for example, to adjust the environment or alert an operator if the temperature is too high).
This process then repeats for the other temperature sensors (with addresses 2 and 3). The master device can also send messages to multiple devices at once, or send commands to write data to the devices, following a similar process.
One important thing to remember is that Modbus is just a protocol, meaning it’s a standard way of exchanging data - it doesn’t specify the physical medium or the type of data line (wiring) used for communication. It can be used with different types of communication lines, such as RS-485, RS-422, RS-232, or TCP/IP over Ethernet.