Appendix a: modbus communication, Implementation basics, Table 1: exception codes – RLE LD5000 User Manual
Page 78

Appendix A: Modbus Communication
User Guide: LD5000
70 970.484.6510
www.rletech.com
APPENDIX A: MODBUS COMMUNICATION
This document describes the Modbus communications protocol as supported by the LD5000 Water Leak
Detection System. It includes details and information on how to configure the LD5000 for
communications via Modbus network.
A-1
IMPLEMENTATION BASICS
The LD5000 is capable of communicating via the half-duplex RS-485 serial communication standard. The
LD5000 is configured to act as a slave device on a common network. The RS-485 medium allows for
multiple devices on a multi-drop network. The LD5000 is a slave only device and will never initiate a
communications sequence.
A-1.1 Modes of Transmission
The Modbus protocol uses ASCII and RTU modes of transmission. The LD5000 supports only the RTU
mode of transmission, with 8 data bits, no parity and one stop bit. Every Modbus packet consists of four
fields:
• Slave Address Field
• Function Field
• Data Field
• Error Check Field (Checksum)
A-1.1.1 Slave Address Field
The slave address field is one byte in length and identifies the slave device involved in the
transaction. Valid address range is between 1 and 254. Dip Switch #1 sets the address. The
firmware program constantly reads dip Switch #1. Any changes are updated on the fly. Close the
SW1 positions that correspond to the binary number of the address.
A-1.1.2 Function Field
The function field is one byte in length and tells the LD5000 which function to perform. The
supported functions are 03 (Read 4xxxx output registers), 04 (Read 3xxxx input registers), 06
(Preset single register) and 16 (Preset multiple registers).
A-1.1.3 Data Field
The data field of the request is a variable length depending on the function. The data fields for the
LD5000 are 16-bit registers, transmitted high order byte first (big-endian).
A-1.1.4 Error Check (Checksum) Field
The checksum field lets the receiving device determine if the packet has transmission errors. The
LD5000 RTU mode uses a 16-bit cyclic redundancy check (CRC-16).
A-1.2 Exception Responses
If a Modbus master sends an invalid command to the LD5000 or attempts to read an invalid register, an
exception response is generated. The response packet will have the high order bit of the function code set
to one. The data field of the exception response contains the exception error code.
Table 1: Exception Codes
Code Name
Description
01
Illegal Function
The function code is not supported
02
Illegal Data Address
Attempt to access an invalid address
03
Illegal Data Value
Attempt to set a variable to an invalid value