Specifications
Revision 2.4 WebRelay-Quadâ„¢
Users Manual
3.3.3 Write Multiple Coils (Modbus Function Code 15 (0x0F))
A single byte can be written to set the state of all four relays. To do this, set the starting address to
0, set the quantity of outputs to 4, and write a single byte with the appropriate value according to
the table below.
Data Byte
(hex)
LS Data Bits
(binary)
Relay 4 State Relay 3 State Relay 2 State Relay1 State
0x00 0000 off off off off
0x01 0001 off off off on
0x02 0010 off off on off
0x03 0011 off off on on
0x04 0100 off on off off
0x05 0101 off on off on
0x06 0110 off on on off
0x07 0111 off on on on
0x08 1000 on off off off
0x009 1001 on off off on
0x0A 1010 on off on off
0x0B 1011 on off on on
0x0C 1100 on on off off
0x0D 1101 on on off on
0x0E 1110 on on on off
0x0F 1111 on on on on
Alternatively, to modify the state of one, two, or three relays only, the starting address and quantity
of outputs can be set to values other than 0, and 4 respectively.
Request
Modbus/TCP:
Transaction identifier (2 Bytes): 0x0001
Protocol identifier (2 Bytes): 0x0000
Length (2 Bytes): 0x0008
Unit identifier (1 Byte): 0xff
Modbus:
Function code (1 Byte): 0x0f (write coil)
Starting address (2 Bytes): 0x0000 ~ 0x0003
Quantity of outputs (2 Bytes): 0x0001 ~ 0x0004
Byte count (1 Byte): 0x01
Output value (1 Byte): 0x00 ~ 0x0f (see table above)
Character String Example:
char write_mult_coil_mb_request[] =
{0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x01, 0x01,
0x0F };
Xytronix Research & Design, Inc. page 35










