In the previous article we saw basics of modbus communication so in this article we will learn which is basic modbus communication type in embedded System.
Modbus is a widely used industrial communication protocol that enables different devices to communicate with each other over a network. It is a serial communication protocol that was developed in 1979 to allow industrial electronic devices to communicate with each other in a simple and cost-effective manner.
Modbus is commonly used in building automation, industrial control, and other applications where devices need to communicate with each other. It is often used in embedded systems, which are small computer systems that are embedded in other devices.
Table of Contents
There are basically five types of Modbus communication protocols:
- Modbus TCP/IP – (Transmission control protocol) Speed: 10/100 Mbit/s.
- Modbus RTU – (Remote terminal unit)serial binary protocol of the Master/Slave type
- JBUS – limited set of communication messages of the Modbus RTU type
- MODBUS PLUS – peer-to-peer protocol, 1Mbit/s.
- Modbus ASCII – serial ASCII protocol of the Master/Slave type
We basically use following functions in modbus protocol:
- Read Holding Registers (Read Output Registers)
- Read Input Registers
The Modbus communication protocol can be used for the following devices/ companys :
Honeywell, Thermax, Hypel, Tronic Control, heat meters and many others.
1. Modbus TCP/IP (Transmission control protocol):
We know that in modbus communication mostly use protocol is TCP/IP hence in this article we will see basic frame format of TCP/IP Protocol and it’s common settings:
Modbus TCP/IP frame format:
The following is an example of a Modbus RTU request for obtaining the AI value of the input holding registers
from registers # 30108 to 30110 with the address of the device 5.
The following is an example of a Modbus RTU request for obtaining the AI value of the input holding registers
from registers # 30108 to 30110 with the address of the device 5.
05 04 006B 0003 7687
05 | Device address SlaveID (5) |
04 | Input Function Code |
006B | Address of the first register (30108-30001 = 107 = 6B hex) |
0003 | The number of required registers (reading 3 registers from 30108 to 30110) |
6543 | Checksum CRC |
Transaction ID: Defiend by the Master to uniquely identify each slave request.
Protocol ID: Defiend by the Master, will mostly 00 00, which corresponds to the Modbus protocol.
Length: defined by the Master, identifying the number of bytes in the message, also defined addresses length from start to end.
Unit ID: 1 byte is set to Master. It is defined by the Slave device to uniquely identify the Slave device.
Also read : CAN VS MODBUS protocol
MODBUS TCP/IP basic settings:
Step 1st: Open modnus Go to connect bar and click on it.
Step 2nd: Enter the provided ip of your device
Step 3rd: (We know that in an Ethernet network, the device address is its IP address. following point must be remember 1. you should need to your system in same subnet mask an d in same class. )
Select the TCP Port: 502
2. Modbus RTU – (Remote terminal unit)
Modbus RTU (Remote Terminal Unit) is a type of Modbus communication that uses binary coding and is typically used over serial connections. In Modbus RTU, the data is transmitted in a binary format over a serial communication link. The data is typically transmitted in the form of frames, with each frame containing a function code, address, and data.
Modbus RTU is a popular choice for industrial communication because it is simple and efficient. It requires minimal hardware, as it can be implemented using a simple serial communication link, such as a RS-232 or RS-485 connection. Modbus RTU is also widely supported by a variety of different devices, making it easy to connect different devices and systems together.
Modbus RTU is commonly used in building automation, industrial control, and other applications where devices need to communicate with each other. It is often used in embedded systems, which are small computer systems that are embedded in other devices.
Modbus RTU Framework
The Modbus RTU framework consists of a set of rules and protocols that define how devices communicate with each other using the Modbus RTU protocol. It includes a set of function codes that define the types of actions that can be performed, such as reading or writing data from a device, as well as a set of rules for formatting and transmitting the data.
In Modbus RTU, the data is transmitted in the form of frames, with each frame containing a function code, address, and data. The function code specifies the type of action that is being performed, such as reading or writing data. The address specifies the location of the data, such as a particular register or memory location. The data is the actual data being transmitted, which can be a single value or a series of values.
Modbus RTU also includes error checking mechanisms to ensure the integrity of the data being transmitted. This includes a cyclic redundancy check (CRC) to verify the integrity of the data, as well as a slave ID to identify the device that is transmitting the data.
Overall, the Modbus RTU framework provides a simple and efficient way for devices to communicate with each other and exchange data using the Modbus RTU protocol.
How do Modbus devices communicate?
Modbus devices communicate with each other using a serial communication link. In a Modbus network, one device is designated as the master, and the other devices are slaves. The master initiates communication with the slaves, sending requests for data and issuing commands to the slaves. The slaves respond to these requests and execute the commands from the master.
Modbus uses a simple request-response communication model. The master sends a request to a slave, and the slave responds with the requested data or acknowledges the command. The communication between the master and slave follows a set of rules and protocols defined by the Modbus protocol.