0% found this document useful (0 votes)
9 views

Modbus Protocol Communication

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Modbus Protocol Communication

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

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

1.1.3 Type of serial portal


There are several types of data communication interfaces, each of which is designed for
specific applications based on the required set of parameters and protocol structure. Serial data
interfaces include RS-232, RS485, RS-422, CAN, I2C, I2S, LIN, SPI, and SMBus, but RS-232,
RS-485 and RS-422 are still the most reliable and common ones.

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

◼ If you have an RS 422 device and want to use it as RS 485

Page | 5
2.

Modbus Application Protocol


2.1 Modbus Communication
Modbus operates on the master/slave principle. This means that there must be at least one
master and at least one slave.
Modbus protocols: RTU – ASCII – TCP/IP
2.1.1 Protocol Data Unit (PDU)
the Protocol Data Unit (PDU) plays a crucial role in the exchange of data between devices

◼ 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.

Specific for Modbus type RTU – ACSII – TCP/IP


Page | 6
ADU For RTU

◼ Device Address: Identifies the slave device.


◼ PDU: Contains the function code and data.
◼ Error Checking Field (CRC): Used to detect errors in transmission.

◼ 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

2) Using LRC For Chack Error

3) Message framing

LRC (Longitudinal Redundancy Check):


• Simpler: Easier and faster to compute.
• Less Robust: Suitable for simpler communication environments.
• Use Case: Commonly used in Modbus ASCII communication.
CRC (Cyclic Redundancy Check):
• Complex: More complex but highly effective.
• More Robust: Detects a wider range of errors.
• Use Case: Commonly used in Modbus RTU communication and other robust protocols.

Page | 8
ADU For TCP/IP

MBAP (Modbus Application Protocol) Header


◼ The MBAP header is used to provide information required for communications at the
application layer of the Modbus TCP protocol.
◼ It contains metadata, such as transaction ID, protocol ID, and message length, which
are crucial for managing the communication process.
Breakdown of the Example (ADU):
00 0F 00 00 00 06 07 03 00 07 00 02
MBAP Header (First 7 Bytes: 00 0F 00 00 00 06 07)
• Transaction Identifier (00 0F):
A unique identifier assigned to match requests and responses.
• Protocol Identifier (00 00):
Always 00 00 in Modbus TCP, indicating the Modbus protocol.
• Length (00 06):
Specifies the number of remaining bytes in the PDU (06 bytes in this case).
• Unit Identifier (07):
Identifies the target device or slave in the Modbus network.

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

You might also like