0% found this document useful (0 votes)
35 views23 pages

LeDucMinh Scada

Uploaded by

Thuận Trần
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views23 pages

LeDucMinh Scada

Uploaded by

Thuận Trần
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

International School - Hanoi National

University
----------

Practice 1 Modbus communication


Name : Le Duc Minh
Student ID: 21070156
Course : Scada

Ha Noi 2024

1
Contents
1 Modbus RTU ............................................................................................................................... 3
a. Coilds Connection.............................................................................................................. 6
b. Input Status ....................................................................................................................... 8
c. Read Holding Registers .................................................................................................... 10
d. Read Input Registers ........................................................................................................ 13
2. Modbus TCP/IP ........................................................................................................................ 15
a. Coils connection .............................................................................................................. 16
b. Input status...................................................................................................................... 18
c. Read Holding Registers .................................................................................................... 19
d. Read Input Registers ........................................................................................................ 22

2
1 Modbus RTU
Modbus RTU (Remote Terminal Unit) connection is a commonly used communication method
in industrial automation and control systems, designed to enable data exchange between a
Master and multiple Slave devices over a serial communication line. In Modbus RTU, data is
transmitted in binary format, making it efficient and compact, ideal for environments requiring
reliable communication over longer distances. The RTU format uses an 8-bit encoding system
with a cyclic redundancy check (CRC) to ensure data integrity, and the protocol operates on
popular serial interfaces like RS-232, RS-485, or RS-422, with RS-485 being preferred due to its
support for longer distances and multiple devices on the same network.

In a Modbus RTU network, a Master device initiates communication by sending a message


containing a Slave address, a function code, data, and a CRC for error-checking. Each Slave on
the network has a unique address and only responds if it matches the address in the Master’s
request. If no errors are detected, the addressed Slave will execute the requested action—such
as reading or writing data—and reply to the Master with the requested information. The
network operates in half-duplex mode, meaning that data flows in one direction at a time,
either from Master to Slave or vice versa, reducing potential communication conflicts on the
line.

Due to its straightforward, reliable structure, Modbus RTU is widely used in industries such as
manufacturing, utilities, and building automation, allowing multiple devices like PLCs, sensors,
and actuators to communicate seamlessly on a single network. It remains a popular choice for
connecting devices in industrial environments, especially in setups requiring high reliability and
straightforward implementation with minimal overhead.

3
First we need to install Launch Virtual Serial Port Driver, Modbus Pool, Modbus Slave. Then we
open the Launch Virtual Serial Port Driver and setting a Pair connection: COM 15 and COM 20.

Then we open both Modbus Pool and Modbus Slave and setting the connection to Serial Port,
then we set Serials Setting in Modbus Pool COM 20 to COM 15, for the Modbus Slave we also
setting COM 15 to COM 20 in the Serials Setting.

4
At the start, both the Slave ID and Master ID values in Modbus Slave and Modbus Poll are set
to 0.

5
a. Coilds Connection

We set the function at both Modbus Slave and Modbus Pool to Read Coils (0x). The Modbus
Read Coils (0x) function is one of the basic operations in the Modbus protocol, used to read the
status of coils. Coils are usually digital outputs that can be either on or off (0 or 1) and often
represent devices like relays or LEDs. When using this function, the Master device requests the
Slave device to provide the current status of one or more coils. Specifically, Function Code 0x01
(Read Coils) is used to ask a Slave to return the state of coils from a starting address for a
specified number of coils. The coils are addressed from 0 to 65,535. In response, the Slave
device returns a series of bits, with each bit representing the status of one coil—1 if the coil is
on and 0 if it’s off. For instance, if the request is to read coils 0 through 7 and their current
states are 10101011, the Slave will return a byte with that bit pattern, indicating each coil's
status. This function is valuable for monitoring on/off device states within industrial control
systems.

6
7
b. Input Status

Read Discrete Inputs, is used to read the status of digital input signals from a Slave device.
Discrete inputs are signals with only two possible states, typically represented as on or off (0 or
1), and are often used to receive status information from sensors or switches. When the
Master requests to read discrete inputs, it uses Function Code 0x02, with the address range for
discrete inputs typically spanning from 10001 to 165536 (referred to as 1x to distinguish it from
other modes like 0x or 3x). The Slave responds with a sequence of bits, each representing the
state of one discrete input (1 for on, 0 for off). This function is useful in monitoring sensor or
switch states within industrial environments where input statuses need to be checked
periodically or upon change.

8
9
c. Read Holding Registers

Read Holding Registers in Modbus is designed for reading values from holding registers, which
are writable memory locations in the Slave device that store various types of data, such as
analog input or output values, configurations, or counters. The Master uses Function Code
0x03 to request values from holding registers, which typically have an address range from
30001 to 365536, referenced as 3x. The Slave responds with the data in the specified register
range. This function is essential for reading important device data, settings, or parameters, and
is widely used in applications needing continuous data collection.

10
11
12
d. Read Input Registers

Read Input Registers is a Modbus function for reading data from input registers, which are
read-only memory locations in the Slave device that hold analog or input data. The Master
sends a request using Function Code 0x04 to read these input registers, generally ranging from
addresses 40001 to 465536, designated as 4x. The Slave returns the values in these registers,
which often contain measurements or status information from sensors or other inputs. This
function is commonly used for retrieving real-time data from sensors in industrial monitoring
systems.

13
14
2. Modbus TCP/IP
Modbus TCP/IP is a variation of the Modbus protocol that allows communication over TCP/IP
networks, such as Ethernet, enabling devices to connect over local networks or even the
internet. In Modbus TCP/IP, the standard Modbus message structure is encapsulated within
TCP packets, facilitating data transfer between a Master and multiple Slave devices over a more
flexible and widely supported infrastructure compared to serial communication. Each device is
identified by an IP address and port number, with the default port for Modbus TCP/IP being
502, allowing it to integrate seamlessly with other networked systems in industrial and building
automation environments.

In a Modbus TCP/IP network, the Master, often a PC or PLC, sends requests to one or more
Slave devices by specifying the IP address of the desired device. Modbus TCP/IP operates on a
client-server model, where the Master functions as the client and the Slaves as servers,
responding to requests to read or write data. Because the protocol operates over TCP, it
provides a connection-oriented and error-checked communication channel, which improves
reliability and allows multiple Masters to communicate with the same Slave if needed. Each
message includes a header called the MBAP (Modbus Application Protocol) header, which
replaces the traditional CRC found in RTU since TCP handles error-checking.

15
Modbus TCP/IP is widely used in industrial settings requiring connectivity over modern
networks, such as factory automation, energy management, and process control, enabling data
acquisition, monitoring, and control from remote or distributed locations. Its compatibility with
Ethernet and TCP/IP networks makes it an attractive choice for applications requiring high-
speed communication, broader device support, and integration with IT systems.

a. Coils connection

16
17
b. Input status

18
c. Read Holding Registers

19
20
21
d. Read Input Registers

22
23

You might also like