Revision 2.2b
Modbus:
Function code (1 Byte): 0x05 (write coil)
Starting address (2 Bytes): 0x0000
Quantity of outputs (1 Byte): 0xff - relay on, 0x00 - relay off
Modbus Error:
Function code (1 Byte): 0x8f
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.4 Write Multiple Registers (Modbus Function Code 16 (0x10))
This is used to pulse the relay(s) for a specified time. When WebRelay-Quad
immediately turns the appropriate relay coil(s) on (if not on already on) and starts the pulse timer. The
relay(s) are selected by writing the pulse time to the register(s) associated with the appropriate relay(s). The
pulse time is specified in the register value field and can range from 0.1 seconds to 86400 seconds (1 day).
When the pulse time expires, the relay coil will be turned off. If a pulse time command is sent with a value
greater than 86400, the pulse timer will be set to 86400. If a pulse time command is sent with a value less
than 0.1, the pulse timer will be set to 0.1. If any commands are sent to WebRelay-Quad
be modbus, xml or html) before the pulse timer has expired, the pulse timer will be canceled immediately
and the new command will be executed.
The pulse time is provided in IEEE 754 floating point format. The four data bytes are treated as two
individual big endian 16-bit words but the least significant word is sent first. In other words, the 32-byte
floating point number represented as ABCD is sent as CDAB. In the example shown below, the relay will
pulse for 10 seconds. Ten seconds is represented using a floating point number of 41200000. It is
transferred as 00004120.
Request
Modbus/TCP:
Transaction identifier (2 bytes): 0x0001
Protocol identifier (2 bytes): 0x0000
Length (2 bytes): 0x000b
Unit identifier (1 byte): 0xff
Modbus:
Function code (1 Byte): 0x10 (Write Multiple Registers)
Starting address (2 Bytes): 0x0010 (0x0010 relay1, 0x0012 relay 2, 0x0014 relay 3, 0x0016 relay
4)
Number of registers (2 Bytes): 0x0002 (2 registers for each relay to be pulsed)
Byte count (1 Byte): 0x04 (2 times the number of registers)
Register value (4 Bytes for each relay to be pulsed): 00 00 41 20 (10 second pulse time)
char write_registers_mb_request = {0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0xff, 0x10, 0x00, 0x10,
0x00, 0x02, 0x04, 0x00, 0x00, 0x41, 0x20 };
Response
Modbus/TCP:
Transaction identifier (2 Bytes): 0x0001
Protocol identifier (2 Bytes): 0x0000
Xytronix Research & Design, Inc.
WebRelay-Quad
Users Manual
TM
receives this command, it
TM
(commands may
TM
page 31
Need help?
Do you have a question about the WebRelay-Quad X-WR-4R1-5 and is the answer not in the manual?