Modbus Protocol Communication
Modbus Protocol Communication
Modbus
Protocol
Table of Contents
1. ..................................................................................................................................................... 2
Introduction .................................................................................................................................... 2
1.1 Industrial Communication ................................................................................................ 2
1.1.1 Data Transmission Modes ............................................................................................. 2
1.1.2 Serial and Parallel transmitter ....................................................................................... 3
1.1.3 Type of serial portal ....................................................................................................... 3
2. ..................................................................................................................................................... 6
Modbus Application Protocol......................................................................................................... 6
2.1 Modbus Communication ...................................................................................................... 6
2.1.1 Protocol Data Unit (PDU) ......................................................................................... 6
2.1.2 Application Data Unit (ADU) ................................................................................... 6
2.2 Modbus Protocol (media) ............................................................................................... 10
2.2.1 Modbus RTU ........................................................................................................... 10
2.2.2 Modbus ASCII ......................................................................................................... 13
2.2.3 Modbus TCP/IP ....................................................................................................... 14
Compare RTU, ASCII, TCP/IP ............................................................................................ 15
Page | 1
1.
Introduction
1.1 Industrial Communication
Communication networks may be used in control systems to pass data between field
devices and PLCs, between different PLCs, or between PLCs and personal computers used for
operator interface, data processing and storage, or management information.
1.1.1 Data Transmission Modes
Page | 2
1.1.2 Serial and Parallel transmitter
Page | 3
RS232
Rs-485(Modbus)
◼ Thermal Resistance is connected to the last slave to create a decay of the traveling
wave.
Page | 4
RS-422
Page | 5
2.
◼ Function Code: Indicates the type of operation to be performed (e.g., read, write,
diagnose).
◼ Data: Contains the data associated with the function code, such as the address of the
data to be read or written and the actual data values.
◼ Ex: | 0x03 | 0x00 0x6B |
2.1.2 Application Data Unit (ADU)
Application Data Unit (ADU) is the complete message that is sent between a master and a slave
device.
◼ Each device has its own address. Data is sent to the slave's address and it responds
with a message containing its address.
Page | 7
ADU For ACSII
1) Sending Data
3) Message framing
Page | 8
ADU For TCP/IP
Page | 9
2.2 Modbus Protocol (media)
The Communication protocols is the way to trans-receive the data with a set of rules that
sends or receives between two or more devices. The communication protocol is the media or
channel between two or more communicating devices.
2.2.1 Modbus RTU
One of the oldest and most widely used Modbus implementations, operates over serial
communication lines like RS232 (point to point) and RS485 (master and many slave), Uses a
master-slave architecture, Only one master and up to 247 slave devices, After 32 slaves, a
repeater is used to increase the number.
1: Master/Slave
• Only one master and slaves up to 247, you can use more than one master, but mast
separate them to not work at the same time “interlock”
• Every slave has a unique address start from 1
What about address 0??
address 0 has a special purpose for broadcast:
Broadcast Communication:
• Purpose: Used for broadcast messages.
• Function: Allows the master to send a message to all slave devices on the network
simultaneously.
• Responses: Slave devices do not respond to broadcast messages. This prevents collision
and ensures efficient communication.
2 : Frame data format
Data transmitted as frames including address, function code, PDU, and CRC and data send in
binary encoding
Page | 10
Start
The Modbus RTU standard specifies a 3.5-character silence period between each message, so
you can tell where one message ends and the next begins. The period varies depending on
baud rate
Function code
Error Checking:
- Uses Cyclic Redundancy Check (CRC) for error detection.
Page | 11
3: Modbus RTU Setup
1- Identify the Components:
• Master Device: Typically a PLC, HMI, or SCADA system.
• Slave Devices: Sensors, actuators, or other Modbus-enabled devices.
2- Choose the Communication Medium:
• RS232: Suitable for short distances (up to 15 meters).
• RS485: Ideal for longer distances (up to 1200 meters) and multiple devices.
3- Configure Device Addresses:
• Each slave device must have a unique address (1-247).
• Address 0 is reserved for broadcast messages.
4- Set Communication Parameters:
• Baud Rate: Common values are 9600, 19200, or 38400 bps.
• Data Bits: 7 or 8 (Usually 8 bits).
• Parity: is an error-checking method used in serial communication to ensure data integrity
during transmission.
◼ None - No error detection, fastest and simplest.
◼ even - Adds a bit to ensure an even number of 1s, provides basic error detection
◼ odd - Adds a bit to ensure an odd number of 1s
• Stop Bits: 0 or 1 or 2.
◼ 1 Stop Bit: Provides a balance between speed and reliability. Suitable for most
general-purpose serial communication.
◼ 2 Stop Bits: Offers better data integrity and error detection at the cost of slightly
slower transmission. Ideal for critical applications where data integrity is more
important
Page | 12
2.2.2 Modbus ASCII
Modbus ASCII - also for use over RS-232 or RS-485 lines, uses ASCII characters instead
of binary, making it more readable but less efficient, and it uses less effective LRC error
checking. ASCII mode uses ASCII characters to begin and end messages. Modbus ASCII
messages require twice as many bytes to transmit the same content as a Modbus RTU message.
1: Modbus frame
Start Character:
• Represented by a colon (:).
• Indicates the beginning of a new message.
LRC (Longitudinal Redundancy Check):
• It consists of 2 ASCII characters.
• Used for error checking to ensure data integrity.
End Characters:
• Represented by a Carriage Return (CR) and Line Feed (LF).
• Marks the end of the message.
Page | 13
2.2.3 Modbus TCP/IP
Modbus TCP/IP is a simple Modbus protocol running on Ethernet over a TCP interface.
1. Communication Medium:
o Uses Ethernet networks, making it suitable for modern industrial automation
systems.
o Allows communication over local area networks (LANs) and wide area networks
(WANs).
2. Addressing:
o Utilizes IP addresses to identify devices on the network.
o Each device on the network has a unique IP address.
2: RTU Frame
Page | 14
Compare RTU, ASCII, TCP/IP
Page | 15