![Xytronix Research & Design ControlByWeb WebRelay-10 Скачать руководство пользователя страница 25](http://html1.mh-extra.com/html/xytronix-research-and-design/controlbyweb-webrelay-10/controlbyweb-webrelay-10_user-manual_892345025.webp)
Revision 1.01
WebRelay-10
TM
Users Manual
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 – 0x0009 (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 };
3.3.3 Write Multiple Coils (Modbus Function Code 15 (0x0F))
One to two bytes can be written to set the state of all 10 relays. Each bit represents one relay with the least
significant bit of the first byte representing relay 1 and the 2
nd
bit of byte two representing relay 10.
Request
Modbus/TCP:
Transaction identifier (2 Bytes): 0x0001
Protocol identifier (2 Bytes): 0x0000
Length (2 Bytes): 0x0008 – 0x0009 (Depending on how many relays)
Unit identifier (1 Byte): 0xff
Xytronix Research & Design, Inc.
page 25