Modbus Ascii Communication Test Example; Calculation Of The Lrc (Longitudinal Redundancy Code) - ABB TPU2000 Technical Manual

Modbus/modbus plus/ modbus tcp/ip automation
Table of Contents

Advertisement

Modbus ASCII Communication Test Example

The easiest method to initiate communications in the Modbus protocol is to read known discrete and register data.
As per the TPU2000/TPU2000R Modbus register documentation, the unit catalog number is resident at Register
40133. A list of the register definitions of the TPU2000/TPU2000R is presented and explained in the next section.
A Read Holding Register Modbus Command is explained. Documentation is available from Groupe Schneider
further describing the Modbus ASCII emulation characteristics. The explanation contained within this document is
intended to be a quick start guide to communication initiation.
The length of the catalog number is 12 characters or 6 registers. The following command string format, when
sent will retrieve the catalog number from the unit.
: 01 03 00 83 00 06 73 lf cr
The above string in Modbus ASCII format should be sent:
3A 30 31 30 33 30 30 38 33 30 30 30 36 37 33 0D 0A
The string is translated as such:
Colon (in HEX), unit address = 01 (in HEX), Read Holding Registers (Code 3 in HEX), data memory desired
address –1 = 132 decimal (0084 in HEX), number of registers read = 6 (0006 in HEX), message calculated LRC
code 72 ( 37 32), and line feed (0D) and (0A).
A typical response shall include the following:
: Address number (01), Read Holding Registers Command (Code 3 in HEX), Byte Count Returned in decimal (0C
in HEX 12 bytes in decimal) , Data Register 40133 = 3538 hex – 58 ASCII, Data Register 40134= 3743 hex , 7C
ASCII , Data Register 40135 = 3034, 04 ASCII Data Register 40136 = 3132 hex, 32 ASCII Data Register 40137 =
3631 HEX, 61 ASCII Data Register 40138 = 3131HEX, 11 ASCII, and calculated LRC =79 (HEX) and line feed
with carriage return (0D 0A).
The aforementioned response would be returned as such:
3A 30 31 30 33 30 43 35 38 37 43 30 34 31 32 36 31 31 31 37 39 0A 0D.

Calculation of the LRC (Longitudinal Redundancy Code)

Modbus ASCII protocol uses a Longitudinal Redundancy Code to verify correct reception of the command. This
error check is used in addition to the parity option (used by the UART in the PC) and other data such as the byte
count which verifies data returned. The process for calculation of the checksum is described as such:
1. Add all bytes in the message except for the colon, line feed, and carriage return. Exclude the LRC
checksum which in included in the message structure.
2. Invert all bits in the word after the addition.
3. Add 1 to the inverted result. This is the checksum.
An example is as follows:
Command sent:
3A 30 31 30 33 30 30 38 33 30 30 30 36 37 33 0D 0A
Decode of the data from ASCII to HEX yields.
TPU2000/2000R Modbus/Modbus Plus Automation Guide
245

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Tpu2000r

Table of Contents