Introduction to Modbus Serial Communication
When working with digital panel meters and controllers, a lot of engineers have asked us for…
An Introduction to Modbus® Serial Communications
Digital panel meters are available with a wide range of features and options. One feature common on more advanced digital panel meters is Modbus serial communications, often with RS-485, RS-232, or USB connections available. Precision Digital's PROVU® Series is a good example of this.
This article will discuss what Modbus communications is, some popular ways to use it, and explain some of the terms often associated with using it.
What is Modbus?
Modbus.org defined Modbus as follows.
"MODBUS is an application-layer messaging protocol… It provides client/server communication between devices connected on different types of buses or networks."1
To understand what Modbus is, look at each statement in that definition.
Modbus is a way for two devices to communicate digitally. Modbus "provides client/server communication between devices." This means that Modbus allows two or more devices to communicate data to each other. One device is a client, which initiates a request to another device, the server. The server executes the required actions and responds to the client.2 The ability to communicate complicated requests and information mean much more can be done with this type of digital communication than with a single analog signal. For example, while a traditional level transmitter may communicate a single process variable to another device on a 4-20 mA output, a Modbus level transmitter might be able to communicate top level, interface level, temperature, and alarm data; all on a 3-wire RS-485 network (more on that later).
"MODBUS is an application-layer messaging protocol… between devices connected on different types of buses or networks." As an application-layer protocol, the Modbus specification defines how two devices communicate in terms of what an information request looks like, how a meter responds, where data is stored, etc. The physical-layer, the mechanical wiring and electrical specifications for communicating with Modbus, can vary. The standard does not define the physical layer; the wiring and electrical signals used between the Modbus devices. This is why Modbus can be used over common serial communications methods such as RS-232, RS-485, USB connections, etc. As long as all the devices communicate with Modbus on compatible connections, the Modbus system will work. Converters are readily available from one physical layer standard to another (ie: RS-485 to USB converters), to make wiring a Modbus network even easier.
In summary, Modbus is a means for two or more devices, such as transmitters, digital panel meters, PLCs, and more, to communicate digitally across various types of networks. This communication allows the devices to share more data, more accurately, than with traditional process industry methods, such as 4-20 mA or 0-10 V signals.
The Advantages of a Modbus Process Measurement System
Modbus communications can have a major impact on your industrial process. Assuming some (preferably all) the devices in your application are Modbus enabled; the advantages of using this serial communications are numerous. Two common advantages are the ability to easily use multivariable transmitters and the increased accuracy from a digital measurement and display system.
Multivariable level transmitters are becoming more commonly available and more popular. These devices are capable of measuring multiple process variables. One common application is tanks with oil and water. The transmitter can sense the top level, interface level of the two liquids, and the average temperature in the tank. The most accurate and most convenient way to read this information is with a serial communications option, such as a Modbus. A Modbus scanner can display one or more of these variables with just a few serial communication wires. Precision Digital's PD865 Snooper, for example, can poll (request information from) up to eight process variables, displaying one and allowing additional PD865 meters to display the other variables. (www.predig.com/PD865) This would require three wires for RS-485, wired in parallel to three PD865 Snoopers. In contrast, using traditional analog outputs and digital panel meters would require three isolated 4-20 mA signal loops with three isolated power supplies.
The reading of a digital value is also more accurate, as there is no analog signal inaccuracy or temperature drift in a Modbus system. The reading on the display is exactly what the transmitter is detecting.
This enhanced accuracy also benefits flow rate and total systems. From industrial batching to custody transfer, accurate flow rates and totals are critical in oil and gas transport. Every analog signal used in a system adds to the system inaccuracy. Several very accurate meters, transmitters, and displays can combine their error to make a measureable inaccuracy in the system as a whole. The more parts of this system that use exact flow and total values transmitted by serial communications, the more accurate the system as a whole.
These two applications; mixed oil and water tank gauging and precise oil and gas flow measurement, are just two general examples of how almost any system can benefit from the use of Modbus serial communications. Other advantages include the simplicity of adding more devices into the Modbus network vs. a traditional network of analog signals; the ability of a centralized SCADA system to communicate with all levels of data acquisition devices directly; and simplified device programming possible with computer software which is a part of most Modbus devices.
The Basics of Using Modbus Devices
If you are interested in using a Modbus network for your next application, there are some key terms and concepts that are good to know. The following is a short summary of these terms.
Network Types: RS-485, RS-232, or USB, etc.
All of these are network types that can be used with Modbus. As stated earlier, Modbus is an application-layer protocol. This means it can be used over a variety of physical-layer networks, including RS-485, RS-232, USB, and more.
All Modbus devices on a network need to have the ability to connect to each other. To do this, they must have the same communications method (ie: RS-485), or the system must include serial communications adapters to connect the different networks. For example, RS-485 to RS-232 adapters are very common and inexpensive, and allow a RS-485 network of Modbus transmitters to connect to the RS-232 connection common on most desktop computers.
Each type of network has its own advantage.
Example of Half-Duplex (3-wire) RS-485 Wiring
- RS-485: This is a full (5-wire) or half-duplex (3-wire) network. The network is multi-drop, meaning it can have a large number of devices wired in parallel on the same network. It can function over long distances, of up to 4,000 ft (1219 m). This communications method is common on industrial devices. Most personal computers do not have an RS-485 connection, so a USB or RS-232 converter is needed to connect to an RS-485 network to them.
Example of a Common RS-232 Connector
- RS-232: This is most commonly available as the 9-pin serial port common on older desktop computers. This communication method is still used when a single Modbus device needs to connect to an older piece of hardware that does not have a USB connection, or when wiring distances of up to 1,000 ft (305 m) are required.
Example of Common USB Cables
- USB: The Universal Serial Bus (USB), USB 2, and USB 3 are very common communication methods common on modern devices and personal computers. USB is a simple and easy way to connect a Modbus network or device to a personal computer. A number of standardized USB connector sizes exist, such as Type A, Type B, mini, and micro USB. USB device cables are very short, less than 16 feet 5 inches (5 meters). While this can be extended, the range is still short compared to RS-232 and RS-485. Because of this, most devices in an industrial plant will be connected to a RS-485 or RS-232 network on the plant floor, and then use a USB converter where the USB enabled device or personal computer is located.
- Ethernet: This network type is standard Ethernet protocol; the same used on an office internal computer network. The advantage of this protocol is that the devices can be accessed from anywhere on the network, which is often installed throughout a facility. With a web server device, the device can be accessed from anywhere with an internet connection and proper network security credentials. These can be more complicated to setup, and are often not necessary for gauging and process control applications. Ethernet and web server adapters/converters are available to connect the other network types to an Ethernet network. This allows other network types to connect to Ethernet by configuring just one Ethernet device, rather than every device in the network. For complex devices that need to each be available remotely via Ethernet or the internet, having onboard Ethernet or web server capabilities saves on wiring and setup time, as well as and configuration complexity.
Common Communications Settings
Other common specifications for Modbus devices have to do with the serial communication protocol parameters. These are common parameters that often need to be set by a user.
- Device Address/Slave ID: Usually programmable for 1 – 247 devices, each device on the Modbus network requires a unique address. This allows devices on the network to know what data packets are relevant to them, and which are meant for other devices.
- Baud Rate: This is the communications speed in bits per second (bps). This must be identical for all devices on the network. This is usually in the range of 300 - 19,200 bps.
- Data Format: ( 8 bit (1 start bit, 1 or 2 stop bits, etc.) The number of start bits, stop bits, etc. is used to configure the Modbus data packet. This should match on all devices on the network.
- Parity: (Even, odd, or none with 1 or 2 stop bits) Like the data format, this relates to the Modbus data pack configuration. It should match on all devices on the network.
Many other possible serial communications parameters may be set by a user in a Modbus device. Byte-to-byte timeouts, transmit delays, and other settings are often available, but the default settings are often sufficient for simple networks. Networks that are slow, have many network adapters, or are particularly complex may require these parameters to be set for non-default values.
Modbus Registers and Tables
Defined for all Modbus enabled devices, Modbus tables are charts used to define the Modbus registers used in a device. Each piece of information accessible by Modbus in a device has a Modbus register. Each register will have a data type and register number. For example, a Precision Digital PD6000 digital panel meter stores the process variable in registers 40001-40002 as a floating point variable. The Modbus register table for the PD6000 defines this, and gives useful information - this is a read only register, and the table defines the allowable range of values in the register.4
When configuring a Modbus network, the information in these tables is entered into the various devices that read information. For example, if using a Modbus scanner to read the values from a multivariable level transmitter, the scanner will be programmed with the transmitter Modbus address/Slave ID as well as the register number and data types for each piece of information to be read from the transmitter (ie: top level, interface level, and temperature).
While often confusing to read through on their own, these Modbus tables are a tool for programming the Modbus master device (the scanner in the above example). They are not intended as an instruction manual or application guide, and are only used when referencing the data a Modbus master will read from a Modbus slave device. Don't be intimidated by the complexity of a Modbus table!
Don't Be Intimidated
To someone unfamiliar with Modbus and serial communications, the terms and tables can be overwhelming. It is important to remember that modern Modbus industrial devices are easier to setup than ever, and are designed to be used by instrumentation technicians, not just computer programmers and electrical engineers.
- "Modbus Technical Resources." The Modbus Organization. Web. 3 May 2013. http://modbus.org/specs.php
- "Modbus Application Protocol Specification V1.1b3." The Modbus Organization. 26 April 2012. Pag 4. Web. 3 May 2013. PDF. http://modbus.org/docs/Modbus_Application_Protocol_V1_1b3.pdf
- "Universal Serial Bus" Wikipedia: The Free Encyclopedia. Wikimedia Foundation, Inc. 7 May 2013. Web. 7 May 2013. http://en.wikipedia.org/wiki/Universal_Serial_Bus
- "ProVu® Series Modbus® Register Tables" Precision Digital Corporation. Web. 7 May 2013. http://www.predig.com/PD6000/#Documentation
Modbus® is a Registered Trademark of Schneider Automation Inc.