Download the PDF of the entire series of articles on Modbus
Modbus protocol is still one of the most popular communication protocols in the field of industrial automation despite its origins dating back to 1979. Its solid and long-lasting presence in the broad overview of industrial protocols is due to the fact that Modbus is a simple and direct protocol. It is also royalty-free and flexible so it can be freely implemented and adapted to the most varied applications.
The hardware and software resources required by the Modbus protocol are rather small and therefore it can be used also in systems based on small and cheap microprocessor. The simple and essential structure of the data transmitted allows for effective communication with a good ratio between the useful part of the information and the total number of bytes transmitted. The protocol also lends itself to partial implementations of commands, limited to specific requirements, as well as expansion with the addition of custom commands by the device manufacturer.
Very often the manufacturers of automation devices “fall” in the temptation to develop a fully proprietary communication protocol thinking of doing the simplest and most effective thing. However, these protocols are often a “bad copy” of an already simple and direct protocol such as Modbus, but are not compatible with this and with other standard protocols. This can be an advantage if they intend to constrain customers to their protocol but exclude interoperability with many other commercial devices and the possibility that the product itself is more marketable.
The Modbus protocol is based on fieldbus and this means it is suitable for exchanging information between devices physically distinct and positioned even at considerable distances between them. The realization of an automatic machine or a plant by means of a set of interconnected devices has many advantages such as:
• Possibility to realize the automation plant using commercial devices, made by different manufacturers and easily replaceable.
• Distribution of the various devices in strategic locations for the plant, even remote, with significant reduction and savings in I/O cabling.
• Fractionation of the plant resulting in simplification of design development and maintenance/repair operations.
The devices are interconnected by cables with only few conductive poles to form a distributed network even at high distances. The Modbus protocol provides several types of physical connection between the devices. In particular, the most common connection are:
• RS485 network – Serial Modbus Protocol
• Ethernet network – TCP/IP Modbus Protocol
The type of connection adopted defines what is normally called the “Physical layer” of the protocol, that is, the hardware on which the information is exchanged. In this series of articles, only the RS485 serial network Modbus protocol will be explained. Such serial network requires cables with only two poles to send data from any device to another.
The next level of protocol, the “Data Link layer”, is instead of software type and includes the specifications of the data frame (byte sequences) exchange between one device and the other. This part doesn’t address the meaning of the bytes but only deals with sending them on the fieldbus, checking timing and errors by checksum.
The Modbus protocol is of Master/Slave type and therefore there is always a network Master device that manages communication with one or more Slave devices.
Each exchange of information is originated by the Master who sends a bytes frame on the fieldbus containing a particular request, normally a read or write command of the informations contained in one of the Slave. All Slaves are normally receiving and listening to Master’s requests. Only the addressed Slave captures the information sent by the Master, executes the command and responds to the Master by sending its own information on the network.
The modalities according to which the possible requests of the Master and the corresponding Slave responses are encoded within the communication frames are defined by the next level of the protocol, also known as the “Application protocol”. It is with this last level of the protocol that the specific application of the device interacts, in the case of the Master usually the PLC automation program, in the case of the Slave the firmware for handling the specific I/O of the device. This layer constitutes the interface of the protocol with all the rest of the device software.
The description of the protocol, divided in subsequent implementation levels, is defined by the ISO/OSI model frequently used to represent communication protocols:
Note that in the case of the serial Modbus protocol, levels 3 to 6 are not used while these are part of a communication structured on an Ethernet network.
In the following articles of the “Modbus over RS485” series, the three levels used by the serial protocol will be analyzed in detail by referring to the official documentation of Modbus. In addition, a final article will provide information on the specific implementation of the protocol in the Overdigit Slave modules. This article represents a concrete example of the implementation of Modbus communication over RS485 and how the protocol can be expanded to increase its basic features.