Introduction:
Welcome to the first of four postings in May about Modbus. Yes, it will be marvelous. This one will be about why we still use Modbus. The next three will focus on three key applications of Modbus in industrial automation: Monitoring, Datalogging, and Control of slow processes.
What is Modbus:
Modbus was developed by Modicon back in the mid-70’s for linking Modicon Programmable Logic Controllers (PLC) and Input Output (I/O) devices. They developed a very simple set of messaging commands based on a query/response or, as they termed it, master/slave. There was one master, and all other devices were slaves. The master had complete control over the bus. The slaves only responded when queried.
Modicon kept the copywrite, but they published it, letting others use it. Then, much later, they made it open. The fact that it was easy to implement and publish explains why so many vendors decided to use it. Modbus is still very popular.
Three versions are used to this day. Two are serial versions: Modbus ASCII and Modbus RTU. One is Ethernet-based, called Modbus TCP.
Why is it still used?
One would think that fifty-year-old technology would be passe. However, like Ethernet, which is around the same age, Modbus works and does very well in specific applications.
First, both the serial and ethernet versions are easy to implement. The specifications are not very big, and the amount of code and CPU power used is minimal. This means that you can put it in almost anything. I purchased a small temperature and humidity sensor on Amazon for $20.00 CAD. It has Modbus RTU using RS-485 on board. It is not an excellent implementation of Modbus, but it works.
Next, both the serial and ethernet versions are easy to use, and everybody supports them. I do not know of a Human Machine Interface (HMI) or PLC that does not support either Modbus RTU, Modbus TCP, or both. The code to implement the master is also minimal and easy to implement. It is also easy to use. Once you understand the message commands, all you have to do is find out where the slave device puts the data you want.
It could be argued that modern protocols like PROFINET are easier because the data is pre-defined and, in most cases, auto-populates. However, the extra work involved with Modbus cannot be described as hard. Also, let’s face it: there is no way to get either PROFINET or PROFIBUS into a $20 sensor the size of your watch.
Lastly, Modbus does not care about time like the other modern protocols do. With Modbus, the Modbus slave can receive a query every 500 ms or once a day or once a month. The protocol does not care. This makes it ideal for monitoring.
Modbus TCP has the added benefit that because it uses the TCP/IP protocol, it can work over the internet very easily. You can have a device on the other side of the planet and get a Modbus TCP response back from it!
Best Practices for Modbus RTU/ASCII
As with most serial protocols, getting the wiring correct is critical. Both Modbus RTU and ASCII run on either RS-232 or RS-485 physical layer. Recommended Standard 232 is a point-to-point physical layer. RS-485 is a multi-drop. Both are pretty easy to wire. However, miswiring does happen. I supported Modbus on a technical support hotline, and my standard questions when communications do not occur are:
-
-
- Did you verify the baud rate, number of data bits and parity?
- Did you verify the address?
- If you are using RS-232, did you try switching pins 2 and 3?
- If you are using RS-485, did you try swapping A&B lines?
-
The reason for the last two questions is that mislabeling is common. In fact, there are conflicting definitions in the marketplace. For example, most vendors define A to be – and B to be +. However, some define A to be + and B to be -.
Best Practices for Modbus TCP
Modbus TCP uses standard industrial Ethernet cables. Bad cables are possible, but there are cable testers that can solve that problem. The best practice for Modbus TCP is to test each cable as you install them and verify that they are under 100 meters in length and correctly wired.
The other best practice is to have the right tools. In particular, if you are doing a lot of Modbus TCP work, then having a good Ethernet Monitor and Test Access Point is valuable. An Ethernet monitor like HMS Diagnostic’s Atlas will monitor the health of your network and let you know if there are any major problems before they bring down the network. This is a handy tool to have around.
The most popular protocol analyzer for Ethernet is Wireshark. To use Wireshark, you need a way to ‘TAP’ into the network and bring both streams of data into your computer. This is where having a good TAP (Test Access Point) comes in. We have various ways to do this, depending on your application. Below is one solution from Anybus called EtherTAP.
Connecting Modbus RTU to Modbus TCP
There are thousands and thousands of Modbus RTU devices out there. Most modern control systems are Ethernet-based. Therefore, having an easy way to connect a Modbus RTU device to Modbus TCP is very important.
The easiest way to connect Modbus RTU to Modbus TCP that I know is by using the MDB-E by 4next Technology Systems. This is a very easy-to-use gateway. You set it up using a web interface, and you can be up and running in a matter of minutes.
Future
Modbus TCP is still going strong. This technology is about to expand. In Process Automation, there is a new physical layer being introduced for Process Instruments called the Advanced Physical Layer (APL). APL is an Ethernet physical layer and is a subset of Single Pair Ethernet (SPE). Many vendors are now adding Modbus TCP over APL to their instruments. This is a vote for the future of Modbus TCP if I ever heard of one.
Modbus ASCII is rare these days. I have not seen it in the field for years. Modbus RTU on the other hand has seen a resurgence. There are many new devices being released with it on board. Using Modbus RTU over RS-485 is still popular, particularly for small projects.
How do you learn about Modbus?
In general, there are many websites with Modbus information. Modbus.org has a lot of free information on Modbus and there are also many books on this topic.
As for formal training, there is only one that we know of, which is our course called Modbus Troubleshooting and Maintenance. Like our other Troubleshooting and maintenance courses, this course is focused on the practical aspects of the protocol. It has many hands-on exercises to show you how the protocol works and what issues you may run into. Click here to get more information on the Modbus Troubleshooting and Maintenance course.