Write Single Coil (Modbus Function Code 05 (0X05)) - ControlByWeb WebRelay-Quad X-WR-4R1-5 User Manual

Hide thumbs Also See for WebRelay-Quad X-WR-4R1-5:
Table of Contents

Advertisement

Revision 2.2b
0x02 - Incorrect starting address / quantity of outputs combination
Character String Example:
char read_coils_mb_response[] = {0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0xff, 0x01, 0x01, 0x01};

3.3.2 Write Single Coil (Modbus Function Code 05 (0x05))

Request
Modbus/TCP:
Transaction identifier (2 Bytes): 0x0001
Protocol identifier (2 Bytes): 0x0000
Length (2 Bytes): 0x0006
Unit identifier (1 Byte): 0xff
Modbus:
Function code (1 Byte): 0x05 (write coil)
Output address (2 Bytes): 0x0000 – 0x0003 (specifies relay)
Output value (1 Byte): 0xff - turn relay on, 0x00 - turn relay off
Padding (1 Byte): 0x00
char write_coil_mb_request[] = {0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0xff, 0x05, 0x00, 0x00, 0xff,
0x00 };
Response
Modbus/TCP:
Transaction identifier (2 Bytes): 0x0001
Protocol identifier (2 Bytes): 0x0000
Length(2 Bytes): 0x0006
Unit identifier (1 Byte): 0xff
Modbus:
Function code (1 Byte): 0x05 (write coil)
Reference number (2 Bytes): 0x0000
Data (1 Byte): 0xff - relay on, 0x00 - relay off
Padding (1 Byte): 0x00
Modbus Error:
Function code (1 Byte): 0x85
Exception code (1 Byte): 0x01 or 0x02
Exception codes:
0x01 - Function code not supported
0x02 - Incorrect starting address / quantity of outputs combination
char write_coil_mb_response[] = {0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0xff, 0x05, 0x00, 0x00,
0xff, 0x00 };
Xytronix Research & Design, Inc.
WebRelay-Quad
Users Manual
TM
page 29

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the WebRelay-Quad X-WR-4R1-5 and is the answer not in the manual?

This manual is also suitable for:

Webrelay-quad x-wr-4r1-iWebrelay-quad x-wr-4r1-e

Table of Contents