Revision 3.1
WebRelay
TM
Users Manual
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.4.4 Write Multiple Registers (Modbus Function Code 16 (0x10))
This is used to pulse the relay for a specified time. When WebRelay
TM
receives this command, it
immediately turns the relay coil on (if it is not on already on) and starts the pulse timer. The pulse time is
specified in the register value field and the time 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
TM
(commands may be
modbus, xml, html, or electrical input) before the pulse timer has expired, the pulse timer will be canceled
immediately and the new command will be executed.
Note that 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 (always start at this address)
Number of registers (2 Bytes): 0x0002 (always 2 registers)
Byte count (1 Byte): 0x04 (always 4 bytes)
Registers value (4 Bytes): 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
Length (2 Bytes): 0x0006
Unit identifier: 0xff
Modbus
Function code (1 Byte): 0x10 (Write Multiple Registers)
Starting address (2 Bytes): 0x0010
Number of registers(2 Bytes): 0x0002
Modbus Error:
Function code (1 Byte): 0x90
Exception code (1 Byte): 0x01 or 2 0x02
Exception codes:
0x01 - Function code not supported
0x02 - Incorrect starting address / byte count combination
char write_registers_mb_response[] = {0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0xff, 0x10, 0x00, 0x10, 0x00,
0x02 };
Xytronix Research & Design, Inc.
page 48