1. About the Modbus protocol
Modbus is a common language used by electronic controllers. It allows controllers to communicate with each other, and with other devices over a network such as Ethernet. It has become a general industrial standard, and it lets control equipment from different manufacturers be connected into an industrial network for centralised monitoring and control.
The protocol defines a message structure that a controller can recognise and use, regardless of the network it communicates over. It describes how a controller requests access to another device, how it responds to requests from other devices, and how errors are detected and logged. It also specifies a common format for the layout and content of the message fields.
On a Modbus network, the protocol requires every controller to know its own device address, to recognise messages addressed to it, and to decide what action to take. Where a reply is required, the controller builds the response and sends it using the Modbus protocol. On other networks, messages containing the Modbus protocol are converted into the frame or packet structure used by that network. That conversion also extends the way node addresses, routing and error detection are handled for the specific network.
2. Transmission on a Modbus network
The standard Modbus port uses an RS-232C compatible serial interface, defining the connector pins, cabling, signal levels, baud rate and parity. Controllers can be networked directly or through a modem. Communication uses a master-slave technique: only one device (the master) can initiate a transaction (a query). The other devices (the slaves) respond according to the data the master requests. Typical masters are host computers and programmable instruments; a typical slave is a programmable controller.
The master can address a single slave or broadcast to all slaves. Addressed individually, a slave returns a message in reply; queried by broadcast, it makes no reply at all. The Modbus protocol defines the format of the master's query: device (or broadcast) address, function code, all the data to be sent, and an error-check field.
The slave's reply is also built by the Modbus protocol, and contains a field confirming the action taken, any data to be returned, and an error-check field. If an error occurs while the message is being received, or the slave cannot carry out the command, the slave builds an error message and sends that as its reply.
3. Transmission on other types of network
On other networks, controllers communicate peer-to-peer, so any controller can initiate communication with any other. A controller can therefore act as either master or slave within a single exchange. Multiple internal channels allow several transactions to take place at the same time.
At the message level, the Modbus protocol still applies the master-slave principle even though the network method is peer-to-peer. When a controller sends a message it is simply acting as the master and expects a reply from the slave. Likewise, when a controller receives a message it builds a slave-style reply and returns it to the sending controller.