Operation
3.4.7 Write Single Coil
This function allows you to control relays one at a time.
Relay Address (2 bytes):
Relay Value (1 byte):
Padding (1 byte):
Request
Modbus TCP Request Frame Example – Write Coil 3 ON
Field Name
Transaction Identifier
Protocol Identifier
Message Length
Unit Identifier
Function Code
Data
Tx String: 00 01 00 00 00 06 FF 05 00 02 FF 00
Response
WebRelay-10 Response Frame Example – Write Coil 3 ON
Field Name
Transaction Identifier
Protocol Identifier
Message Length
Unit Identifier
Function Code
Data
Rx String: 00 01 00 00 00 06 FF 05 00 02 FF 00
Errors
Single Coil Write Error Function Code (1 Byte): 0x85
Exception codes (1 Byte):
page 72
Modbus Function Code 05 (0x05)
–
0x0000 (Relay 1) – 0x00009 (Relay 10)
0x00 (ON)), 0xFF(OFF)
0x00
Length
Function
2 bytes
Synchronization number.
2 bytes
Zero for Modbus/TCP
2 bytes
Number of bytes in frame (below)
1 byte
Slave Address (0xff if not used)
1 byte
Write Coil
4 bytes
Relay address (0x0000 – 0x0009)
Relay value (0x00, 0xFF)
Padding (0x00)
Length
Function
2 bytes
Synchronization number.
2 bytes
Zero for Modbus/TCP
2 bytes
Number of bytes in frame (below)
1 byte
Slave Address (0xff if not used)
1 byte
Write coil
4 bytes
Relay address (0x0000 - 0x0009)
Relay value (0xFF, 0x00)
Padding (0x00)
0x01 – Function not supported.
0x02 – Address out of range.
0x03 – Incorrect relay value or padding value.
WebRelay-10 Users Manual
Example Data
0x0001
0x0000
0x0006
0xFF
0x05
0x0002
0xFF
0x00
Example Data
0x0001
0x0000
0x0006
0xFF
0x05
0x0003
0xFF
0x00
Xytronix Research & Design, Inc.
Need help?
Do you have a question about the WebRelay-10 X-WR-10R12-I and is the answer not in the manual?
Questions and answers