Modbus is a widely used communication
protocol in industrial automation and control systems. There are several
variations of the Modbus protocol, each tailored for different communication
medium and network architectures. The two main variants are Modbus RTU and
Modbus TCP/IP, but there are others as well, such as Modbus ASCII.
V5 uses three communication protocols
as follow:
(a)
Modbus RTU (Remote Terminal Unit): It is a serial communication protocol. In Logic Ladder's V5 device, it operates over RS-485 connections.
RTU command contains -
(i) Device ID (Address)/Slave ID: It
identifies the specific device on the Modbus network. Each device on the
network has a unique address ranging from 1 to 247.
(ii) Function Code: The
function code specifies the type of action or operation to be performed by the
slave device like reading data from registers, writing data to registers, and
controlling device operations. In V5, Commonly used function codes are: 03-Holding
register & 04-Input Register.
(iii) Starting Register
Address: This parameter indicates the address of the first register
involved in the operation.
(iv) Length of Register
Address: This parameter specifies the number of consecutive registers to be
read or written.
(v) CRC (Cyclic Redundancy
Check): CRC is a method used for error checking in Modbus RTU communication.
It's a checksum calculated over the entire message (excluding the device ID and
CRC itself). The CRC ensures data integrity by detecting transmission errors.
Note : Also, To set Communication Port setting following details are required -
Baud rate
Parity(odd, even, none)
Stop bit
Hardware control.
(b) Modbus TCP/IP (Transmission Control Protocol/Internet
Protocol): It uses the TCP/IP stack for communication, making it
suitable for Ethernet networks.
TCP/IP command contains-
IP address, MBAP header, Slave ID,
Function Code, Data Address of the first register requested and total number of
registers requested.
MBAP Header (Modbus
Application Header): A new 7-byte header (000100000006) is added to the
start of the message. This header is
fixed for TCP/IP command.
(C) ASCII (American Standard Code for Information
Interchange): ASCII is a character encoding standard used for serial
communication. In ASCII mode, each byte of data is represented by two ASCII
characters and delimiter used is 10.
ASCII Command contains:
Start of each message with a
colon character ": " (hex 3A), end is terminated with the carriage
return and line feed characters (hex 0D and 0A). It is also having device id,
function code, starting register address, length and LRC. Each character is treated
as an ASCII character and replaced with it's hex value.
To calculate the LRC:
1. Add up all the data bytes in the message
(before converting to ASCII and without the initial colon and final CR/LF).
2. Throw away any bits that carry over 8 bits.
3. Make the result negative (by two’s
compliment) to get the LRC byte.
The sum of the resulting byte
stream with the LRC will then be 0 since adding the negative subtotal will make
the final total zero.