Modbus Communication
Modbus Communication
its programmable logic controllers (PLCs). Simple and robust, it has since become one of
the de facto standard communications protocols in the industry, and it is now amongst the
most commonly available means of connecting industrial electronic devices.[1] The main
reasons for the extensive use of Modbus in the industrial environment are:
The development and update of Modbus protocols are managed by the Modbus
Organization, formed of independent users and suppliers of Modbus compliant devices.
Some of its prominent members are Precision Digital Corporation, Motor Protection
Electronics and FieldServer Technologies. Other companies, such as SoftDEL Systems
and SATEC Ltd., offer Modbus devices without being formal members of Modbus
Organization.
Protocol versions
Versions of the Modbus protocol exist for serial port and for Ethernet and other networks
that support the Internet protocol suite. Most Modbus devices communicate over a serial
EIA-485 physical layer [1]. There are many variants of Modbus protocols
Modbus RTU — This is used in serial communication & makes use of a compact,
binary representation of the data for protocol communication. The RTU format follows
the commands/data with a cyclic redundancy check checksum as an error check
mechanism to ensure the reliability of data. Modbus RTU is the most common
implementation available for Modbus. A Modbus RTU message must be transmitted
continuously without inter-character hesitations. Modbus messages are framed
(separated) by idle (silent) periods.
Modbus ASCII — This is used in serial communication & makes use of ASCII
characters for protocol communication. The ASCII format uses a longitudinal
redundancy check checksum. Modbus ASCII messages are framed by leading colon (':')
and trailing newline (CR/LF).
Modbus TCP/IP or Modbus TCP — This is a Modbus variant used for
communications over TCP/IP networks, connecting over port 502.[2] It does not require a
checksum calculation as lower layers already provide checksum protection.
Modbus over TCP/IP or Modbus over TCP or Modbus RTU/IP — This is a Modbus
variant that differs from Modbus TCP in that a checksum is included in the payload as
with Modbus RTU.
Modbus over UDP — Some have experimented with using Modbus over UDP on IP
networks, which removes the overheads required for TCP [3]
Data model and function calls are identical for the first 4 variants of protocols; only the
encapsulation is different. However the variants are not interoperable as the frame
formats are different.
[edit] Communication and devices
Each device intended to communicate using Modbus is given a unique address. In serial
and MB+ networks only the node assigned as the Master may initiate a command, but on
Ethernet, any device can send out a Modbus command, although usually only one master
device does so. A Modbus command contains the Modbus address of the device it is
intended for. Only the intended device will act on the command, even though other
devices might receive it (an exception is specific broadcastable commands sent to node 0
which are acted on but not acknowledged). All Modbus commands contain checking
information, ensuring that a command arrives undamaged. The basic Modbus commands
can instruct an RTU to change a value in one of its registers, control or read an I/O port,
as well as commanding the device to send back one or more values contained in its
registers.
There are many modems and gateways that support Modbus, as it is a very simple
protocol and often copied. Some of them were specifically designed for this protocol.
Different implementations use wireline, wireless communication, such as in the ISM
band, and even SMS or GPRS. One of the more common designs of wireless networks
makes use of the mesh topology. Typical problems the designers have to overcome
include high latency and timing problems.
Frame Format
All modbus variants choose different frame formats.
Start 3.5c idle at least 3-1/2 character times of silence (MARK condition)
Function 8 bits Indicates the function codes like read coils / inputs
Data n * 8 bits Data + length will be filled depending on the message type
End 3.5c idle at least 3-1/2 character times of silence between frames
Function 2 chars Indicates the function codes like read coils / inputs
Data n chars Data +length will be filled depending on the message type
Unit identifier is used with MODBUS/TCP devices that are composites of several
MODBUS devices, e.g. on MODBUS/TCP to MODBUS RTU gateways. In such case,
the unit identifier tells the Slave Address of the device behind the gateway. Natively
MODBUS/TCP-capable devices usually ignore the Unit Identifier.
Function
Function Name
Code
Physical Discrete Inputs Read Discrete Inputs 2
Read Coils 1
Bit access
Internal Bits or Physical Coils Write Single Coil 5
Write Multiple Coils 15
Physical Input Registers Read Input Register 4
Read Holding
3
Registers
Data Write Single Register 6
Access 16-bit Write Multiple
Internal Registers or Physical 16
access Registers
Output Registers
Read/Write Multiple
23
Registers
Mask Write Register 22
Read FIFO Queue 24
Read File Record 20
File Record Access
Write File Record 21
Diagnostics Read Exception Status 7
Diagnostic 8
Get Com Event Counter 11
Get Com Event Log 12
Report Slave ID 17
Read Device
43
Identification
Encapsulated Interface
Other 43
Transport
Implementations
Almost all implementations have variations from the official standard. Different varieties
might not communicate correctly between equipment of different suppliers. Some of the
most common variations are:
• Data types
o Floating point IEEE
o 32-bit integer
o 8-bit data
o Mixed data types
o Bit fields in integers
o Multipliers to change data to/from integer. 10, 100, 1000, 256 ...
• Protocol extensions
o 16-bit slave addresses
o 32-bit data size (1 address = 32 bits of data returned.)
o Word swapped data
Limitations
• Since Modbus was designed in the late 1970s to communicate to programmable
logic controllers, the number of data types is limited to those understood by PLCs
at the time. Large binary objects are not supported.
• No standard way exists for a node to find the description of a data object, for
example, to determine if a register value represents a temperature between 30 and
175 degrees.
• Modbus is restricted to addressing 247 devices on one data link, which limits the
number of field devices that may be connected to a master station (once again
Ethernet TCP/IP proving the exception).
• Modbus transmissions must be contiguous which limits the types of remote
communications devices to those that can buffer data to avoid gaps in the
transmission.
Trade group
The Modbus organization is a trade association for the promotion and development of
Modbus protocol.