This website uses cookies primarily for visitor analytics. Certain pages will ask you to fill in contact details to receive additional information. On these pages you have the option of having the site log your details for future visits. Indicating you want the site to remember your details will place a cookie on your device. To view our full cookie policy, please click here. You can also view it at any time by going to our Contact Us page.

Everything you ever wanted to know about Modbus

25 June 2019

After 30 years Modbus is still one of the most popular industrial networks, despite its simplicity. This could just be the reason for its popularity: just bits and bytes, understood by every programmer. But getting a new network to work is not always simple. Rob Hulsebos aims to make all things Modbus a bit clearer.

Modbus is a popular technology across both discrete and process automation. For vendors, it is simple to implement in a device, as no special electronic components are needed and the protocol stack software is easily made. For users, Modbus is easy to understand as the specification is small; the command set is bit and byte based, 1:1 corresponding with digital and analogue I/O or PLC memory. This is very familiar to all PLC programmers. 

Anyone wishing to implement Modbus will quickly find a multitude of open-source software and free utilities, and if this doesn’t suffice, writing an own protocol implementation from scratch should take no more than a few days for an experienced programmer.

Modbus peculiarities
However, Modbus has some peculiarities. First, there is not one Modbus but several. The best-known versions are Modbus/ASCII, Modbus/RTU and Modbus/TCP. These protocol variants are not compatible with each other, due to wiring and message format. There are also many vendor-specific extensions. 

Further, it does not (for the serial versions) specify how the network must be wired. This will usually be RS-232 or RS-485, with all their variations. Even for experienced Modbus users it can take some time before the wiring is correct. Additionally, RS-232 is a technology that is less and less known, since it is no longer available on PC’s and newer generations of users may have never seen it before. For Modbus/TCP devices an IP-address is needed and a subnet mask. This requires insight into how this works and how to get a new IP-address. Modbus itself does not specify how this must be configured, and how the application software must start the communication with a device. Knowledge about how to setup a TCP/IP network, possibly with a DHCP-server, is needed.

A vendor can decide to implement just a subset of the Modbus specification. But any two devices that need to communicate with each other must have an overlapping subset of commands. Luckily, most vendors support the most basic ‘read’ and ‘write’ commands so communication is always possible, but not always the way intended.

Finally, the receiving device must be able to understand the data that it gets. In the 1980’s, 16-bit processors were standard so Modbus supports these, but not the 32-bit, 64-bit and various floating-point datatypes. Vendors have devised their own solutions to support this, but they are not always compatible, leaving any conversion effort to the application programmer. This requires knowledge about how different CPU’s store data in memory, the so-called ‘little endian’ or ‘big endian’ format. For floating point data this is more difficult, as a (32, 64, 80) bit pattern cannot be simply used without some knowledge of the IEEE-754 standard.

Surprisingly, no one has ever published a book about Modbus covering all aspects of this protocol. Perhaps this can be explained by the simplicity of Modbus, but on the other hand I have seen many people struggling, and this led to my decision to collect all experience and course-material and write a book - Modbus the Manual - In 145 pages (A5) it describes all aspects of the network, the OSI-model, wiring (RS-232, RS-485), message formats, all protocol variants (including Modbus/TCP), data formats, error checks, and protocol stack implementation tips.

Modbus the Manual is available at: ISBN 978-946-386-7641 (English), via https://www.mijnbestseller.nl/shop or any bookshop. Priced at around €40.

Rob Hulsebos is a software-engineer with over 30 years experience in industrial networks.


Print this page | E-mail this page