MODBUS RTU, ASCII, TCP 5 1. Description English MODBUS ASCII/RTU is a master-slave communication protocol, able to support up to 247 slaves connected in a bus or a star network. The protocol uses a simplex connection on a single line. In this way, the communication messages move on a single line in two opposite directions. Modbus Protocol PDF format version of the MODBUS Protocol The original was found at. When controllers are setup to communicate on a Modbus network using RTU (Remote Terminal Unit) mode, each eight-bit byte in a message contains two four-bit hexadecimal characters. The main advantage of this mode is that its greater character density allows.
In this article, we are going to explain all aspects related to Modbus RTU communication. What is the difference between Modbus RTU vs ASCII and Modbus RTU vs TCP/IP? How to test Modbus RTU protocol with Modbus RTU monitoring software.
Contents
- What is the Modbus RTU protocol?
- How does Modbus RTU work?
What is the Modbus RTU protocol?
The Modbus RTU protocol is a means of communication that allows data exchange between programmable logic controllers (PLCs) and computers. Electronic devices can exchange information over serial lines using the Modbus protocol.
It has become widely accepted and is used extensively in the construction of Building Management Systems (BMS) and Industrial Automation Systems (IAS). Its adoption has been spurred on by its ease-of-use, reliability, and the fact that it is open-source and can be used royalty free in any device or application.
The protocol was developed and published by Modicon® in 1979 for use with its programmable logic controllers. It is built using a master/slave architecture and supports serial devices that use the RS232/RS485/RS422 protocols. Modbus is often used in scenarios where multiple instrumentation and control devices transmit signals to a central controller or system to gather and analyze data. Industrial automation and supervisory control and data acquisition (SCADA) systems often employ the Modbus protocol.
- 01What is the Modbus ASCII protocol?
- 03How to scan a Modbus message
Manual Modbus Rtu Pdf
What does Modbus RTU stand for?
Modbus RTU (Remote Terminal Unit) is one of the two transmission modes defined in the original Modbus specification. The two modes are Modbus RTU and ASCII and are both designed to be used with serial devices supporting the RS232, RS485, and RS422 protocols. A distinguishing characteristic of Modbus RTU is its use of binary coding and strong CRC error-checking. Modbus RTU is the implementation of the Modbus protocol that is most often used in industrial applications and automated production facilities.
How to test Modbus RTU with Serial Port Monitor
There are a few situations where the use of a Modbus RTU tester can be very helpful. If you are developing or debugging serial devices or applications, you would like to be able to monitor and analyze data transmission between devices and applications. Another instance where a Modbus RTU monitoring utility will prove indispensable is if you are charged with maintaining the network and associated devices in an automated industrial production facility.
Serial Port Monitor by Eltima is a Modbus RTU software. It is a comprehensive and full-featured application that enables the monitoring and analysis of all Modbus RTU interface activity on your system. Any devices supporting the RS232, RS485, and RS422 protocols can have their transmissions monitored and analyzed to assist in debugging or development tasks.
This software tool has been designed with a flexible and user-friendly interface, built-in terminal, and data exporting capabilities. It is a valuable resource for diagnosing Modbus RTU communication issues in the Windows environment. Here are some highlights from the list of features that are part of Serial Port Monitor.
- Analysis of Modbus RTU activity. This serial port sniffer can open any serial port, even those already opened by another application, and immediately begin monitoring all activity moving through that interface. Real-time data collection lets you quickly track down issues and problems. The monitored data can be redirected to files or copied to the clipboard to be used for later analysis.
- Monitor multiple serial ports simultaneously. Using this feature lets you watch your applications interacting with multiple ports or devices within the same monitoring session. The captured data is presented in a first-in-first-out basis in a central log file to simplify its analysis.
- Choose between multiple data views. There are four views that can be used separately or seen all at the same time. They are the table, line, dump, and terminal modes and they can each offer a different insight into your data. The dump view lets you investigate port settings, and you can employ monitoring filters to reduce screen clutter and concentrate on the events that are important.
- Emulation of data transmission. You can send data to serial devices in various formats such as string, binary, decimal, and hex to monitor the reaction of the serial device to specific commands or data strings.
- Session playback option. You can repeat a transmission to a serial port to obtain more precise monitoring information. Sessions can be compared with each other and differences automatically highlighted for easy analysis.
- Export monitored data in various formats. You can export your data to a file in HTML, ASCII text, UNICODE text or Exсel CSV format and can have currently monitored data appended to a previously saved file.
- User-friendly interface. Serial Port Monitor is designed to allow access to serial ports and interfaces without the need for any programming skills. Filters to control the data displayed are easily customized in the application’s toolbar.
- Track input/output control codes. You can obtain the complete details and parameters of all serial input/output control codes (IOCTLs) using Serial Port Monitor.
This Modbus RTU protocol analyzer should be in the toolbox of anyone who works extensively with serial devices and the Modbus protocol. You can use it in either RTU or ASCII mode, making it a versatile software utility. It is an efficient solution that allows you to monitor all of the serial interfaces on your system with no additional hardware requirements. Eltima’s Serial Port Monitor runs on the Windows 10 operating system as well as Windows Server 2012 and 2016.
- 01Decode the Modbus message
How does Modbus RTU work?
The Modbus protocol is basically a system that processes requests and responses from electronic devices. The master/slave architecture is used with the master making requests that are responded to by the slave devices.
What is a Modbus RTU master?
A Modbus RTU master is the central device that makes requests for information from the connected slave devices. A central controller in an automated production system can play the role of a Modbus RTU master. A Modbus implementation has one master. Master devices obtain information from the slaves and can also write to the registers of the slave devices.
What is a Modbus RTU slave?
The Modbus RTU slave is the device that responds to the request made by the master device. It cannot initiate information transfers and is in a holding pattern until responding to a request made by the master.
As stated, there is one master device in a Modbus RTU implementation and there can be up to 247 slave devices. Each slave device is identified by a slave address of from 1 to 247.
At the heart of the Modbus protocol is the component known as the Protocol Data Unit (PDU). The PDU consists of a function code and data and is constructed consistently regardless of the Modbus transmission mode used. The function code specifies what data is being requested by the master.
In the Modbus RTU transmission mode, additional information is wrapped around the PDU to create the full Application Data Unit (ADU). In the signal stream and before the function code, in Modbus RTU mode a slave ID of 1 byte is sent to identify the slave device that should satisfy the request. Appended to the PDU is a 2 byte CRC which makes sure that the right amount of bytes were sent and received.
Modbus devices support four data tables which are used to facilitate communication between devices. They are Discrete Inputs, Discrete Outputs (Coils), Input Registers, and Holding Registers. The registers perform different functions and are not all included in every device. In some cases, only the holding registers are used for I/O functionality.
Field | Access | Size | Description |
---|---|---|---|
Discrete Inputs | used as inputs | ||
Coils Outputs | used to control discrete | ||
Input registers | used for input | ||
Holding registers | used for a variety of things including inputs, outputs, configuration data, etc. |
Function codes indicate how the master interacts with the slave device specified in the slave ID. Based on the function code sent, the master device may read one of the slave’s registers, or write to them.
Slaves return error codes when they receive a packet that contains an error in the request. Error codes are returned for issues such as the request for an illegal function, illegal register addresses that cannot be reached by the specified slave, and messages indicating that the slave device is busy or has experienced a failure.
Modbus RTU requires that you know or define parameters such as baud rate, character format (8 bits no parity, etc), and slave ID when initiating communication. A mismatch in any of these parameters will result in the failure of your communication attempt.
Modbus RTU vs TCP
Modbus Rtu Tutorial Pdf
Modbus RTU is one of the original transmission modes that were defined in the Modbus protocol. Modbus TCP is a recently developed extension to the protocol that allows Modbus protocols to be carried over TCP/IP networks. The inherent latency and other aspects of communicating over a network, necessitated some modification over how to keep requests and responses in synch with each other, and ensure that the wrong data is not received from a slave device.
Modbus TCP exhibits a difference in how the PDU is wrapped when compared to Modbus RTU. The TCP frame that contains the PDU begins with a MODBUS Application Protocol (MBAP) transaction identifier of 2 bytes rather than the slave ID. There is also no need for the CRC to perform error checking as the TCP layer handles that function.
Modbus RTU vs ASCII
Since they were both parts of the original Modbus protocol specification, you might be wondering what's the difference between Modbus ASCII and Modbus RTU. Modbus RTU employs binary coding and CRC error-checking. These choices were made for the sake of efficiency and are the main reason that the RTU mode is the one most commonly used in industrial settings. As you might have guessed, Modbus ASCII uses ASCII characters when sending messages.
The use of ASCII characters make the messages more human-readable but are a less efficient means of transmission. Another major difference is in the level of error checking that is performed. Modbus ASCII uses the less effective LRC method of error-checking rather than the stronger CRC of the RTU mode.
Though both Modbus RTU and Modbus ASCII are designed to be used with serial devices and protocols, they are incompatible with each other due to the differences outlined above. If you work with serial devices, you should be prepared to make use of the Modbus protocol.
Serial Port Monitor
Version 7.0.342 (13th Jan, 2018) Release notes
Category: Communication Application
Contents:
- How to test Modbus ASCII communication?
What is the Modbus ASCII protocol?
Modbus is a serial communication protocol developed by the Modicon corporation in 1979. It was originally designed to be used with the company’s programmable logic controllers (PLCs). Modbus is an open protocol that supports serial devices that use the RS232/RS485/RS422 protocols. Its simplicity and the fact that manufacturers can incorporate it into their products at no charge has helped it become the most popular method of connecting industrial electronic devices.
There are two main styles of transmission that are used when employing the Modbus protocol. They are Modbus RTU and Modbus ASCII. This article is meant to be an advanced Modbus ASCII tutorial. We will start with an overview of Modbus that is pertinent to both the ASCII and RTU implementations of the protocol.
Modbus addresses the issue of sending information between electronic devices over serial lines. The protocol is implemented in an architecture that follows the master/slave model. The Modbus master is in charge of requesting information from the other devices. There is one Modbus master in a standard Modbus Network.
The master requests information from the slave devices, which can number up to 247. Each slave device is identified by a slave address of between 1 and 247. The process by which the master queries the slave and receives information returned from the slave is what is meant by Modbus communication. In addition to requesting information from the slave, the master device can also write to the slave device’s internal registers.
- 01Modbus RTU communication guide
- 03Modbus Decoder: How to analyze Modbus protocol
Serial data is exchanged between devices in bitstreams where each bit is a voltage. Binary data is exchanged with a 1 being denoted by a negative voltage and a zero is represented by a positive voltage.
The Modbus protocol defines function codes and the encoding scheme for transferring data as either single points (1-bit, coils) or as 16-bit data registers. Data packets are encapsulated according to the transmission method in use. The Modbus protocol uses four distinct tables to store data in the slave devices. There are two coils which store discrete on or off values and two registers which store numerical values. In the case of Modbus ASCII, messages are passed using the ASCII character set, making them more easily readable by human eyes.
How to test Modbus ASCII communication with Modbus protocol Analyzer?
If you are working with serial devices and the Modbus protocol there is a good chance that at some point you will need to engage in some debugging or monitoring of your serial data transmission. Modbus Analyzer (Serial Port Monitor) is a dedicated software application developed by Eltima Software that can be used to analyze and diagnose data transmission traveling through your system’s serial interfaces.
In order to better appreciate how a Modbus ASCII test tool like Modbus protocol Analyzer can help you, let’s take a look at the Modbus ASCII data and message format.
Modbus ASCII data format
Modbus ASCII uses the ASCII character set to represent hexadecimal characters that each contain 4 bits of data. There are 10 bits in each byte in Modbus ASCII mode. They consist of:
- 1 start bit
- 7 data bits with the least significant bit sent first
- 1 bit for parity completion
- 1 stop bit
Modbus ASCII message format
The format of Modbus ASCII messages consists of a start character which is a colon “:” and the end of the message is defined by a carriage return and line feed. This enables the space between the messages to be variable and make Modbus ASCII suitable for transmission through certain modems.
Modbus Sniffer software can be extremely helpful in debugging, monitoring, and diagnosing issues in a Modbus network. It can be used in for both Modbus RTU and ASCII implementations.
Using this tool allows you to:
- Analyze serial port activity - You can open any serial port in your system even if it already in use by another application. Use real-time data collection to quickly diagnose issues of all serial port activity.
- Monitor multiple serial ports at one time - A central log file will hold all of your monitored data in a first-in-first-out basis for easier analysis.
- View your data in four different formats - Use these various views singly or in combinations to gain more insight into your data. Table, line, dump, and terminal mode let you view your data in the way that suits your needs.
- Emulation of data transmission - You can emulate data transmission to serial devices in various formats such as string, binary, decimal, and hex.
- Export your monitored data - You can export your data to files in HTML, ASCII text, UNICODE text or Exсel CSV format. New data can be appended to previously saved files.
All told, Modbus Protocol Analyzer is an essential tool for those working with serial devices and the Modbus protocol.
- 01How to parse a Modbus message
- 02Serial communication protocols in embedded systems
What is the difference between Modbus ASCII and RTU?
Both Modbus ASCII and RTU were introduced as part of the original Modbus protocol specification. The two variations use the same master/slave architecture and are very similar. They are both designed to work with serial devices, but are not compatible with each other due to differences that we will discuss below.
The main differentiating factor is that Modbus RTU employs binary coding where the aptly named Modbus ASCII uses the ASCII character set. Modbus RTU performs error-checking using the stringent CRC method whereas Modbus ASCII uses the less effective LRC error-checking method. The data format is also slightly different as the RTU variation uses a start bit, 8 data bits, and a stop bit as opposed to the ASCII data format that we looked at earlier.
The combination of binary coding and CRC error-checking make Modbus RTU suitable to industrial applications as it lends itself to more efficient transmission than the alternative of ASCII characters. When choosing between Modbus RTU vs ASCII, RTU is the first choice if performance is a consideration.
Modbus ASCII vs TCP
There is one more flavor of Modbus to consider and that is Modbus TCP. This is simply an implementation of Modbus that runs over a TCP/IP network. The main difference between Modbus ASCII and Modbus TCP is that the LRC error-checking that is required by Modbus ASCII is performed by the IP layer.
How do you convert Modbus ASCII to the Modbus RTU protocol?
As we mentioned earlier the Modbus ASCII and Modbus RTU protocols are not compatible with each other. Devices employing the two protocols cannot communicate directly with each other. But there are ways to get the devices talking to each other.
To do this you will need to use a hardware solution called a Modbus ASCII to RTU converter. This type of device is basically a translator that reads data from one device and then stores it internally in another protocol for use by the second device. In this way devices using any Modbus variation can communicate with each other.
Serial Port Monitor
Version 7.0.342 (13th Jan, 2018) Release notes
Category: Communication Application