Operation
WebRelay-10 Users Manual
3.4.8 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 representing one relay. The
least significant bit of the lower byte represents Relay 1 and the 2nd bit of upper byte representing Relay
10.
Upper Byte
Lower Byte
Bit 15 14
13
12
11
10
9
8
7
6
5
4
3
2
1
Bit 0
X
X
X
X
X
X
Relay
10
9
8
7
6
5
4
3
2
Relay
1
Start Address (2 bytes):
0x0000 (relay 1) – 0x0009 (relay 10)
Relay Quantity (2 bytes):
0x0001 – 0x000A
Byte Count (1-2 bytes):
0x01 – 0x02
Output Value (1-2 bytes):
0x0000 – 0x03FF
Request
Relay states are controlled by specifying the start address of the first relay to be controlled, the count of
the relays to be affected, and the relay state byte(s). Only the lower byte needs to be specified when
relays 1 - 8 are changed. Both bytes must be specified if relays 9 or 10 are affected.
Modbus TCP Request Frame Example – Write Coils 7 ON, 8 OFF, and 9 ON
Field Name
Length
Function
Example Data
Transaction Identifier
2 bytes
Synchronization number.
0x0001
Protocol Identifier
2 bytes
Zero for Modbus/TCP
0x0000
Message Length
2 bytes
Number of bytes in frame (below)
0x0009
Unit Identifier
1 byte
Slave Address (0xff if not used)
0xFF
Function Code
1 byte
Write Multiple Coils
0x0F
Data
8-9 bytes
Start address (0x0000 – 0x0009)
Relay quantity (0x0001 – 0x000A)
Byte count (0x01 – 0x02)
Lower byte value (0x00 – 0xFF)
Upper byte value (0x00 – 0x03)
0x0006
0x0003
0x01
0x05
TX String: 00 01 00 00 00 08 FF 0F 00 06 00 03 01 05
Only coils that are in the address and count range will be affected by the output value. Consequently, an
output value of 0xFFFF would be used to energized all of the relays in the range or 0x0000 to turn them
OFF
. In the above example, the output value 0xFF would turn relays 7-9 ON.
page 74
Xytronix Research & Design, Inc.