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.
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.
Modbus Protocol Analyzer
Modbus Analyzer a professional and powerful system utility to display, log and analyze Modbus communication.
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.
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.
Requirements: Windows (32-bit and 64-bit): XP/2003/2008/Vista/7/8/10, Windows Server 2012, Windows Server 2012/2016/2019 , 9.16MB size Version 7.0.342 (13th Jan, 2018) Release notes Category: Communication Application