Revision 3.1
WebRelay
TM
Users Manual
GET /state.xml?noReply=1 HTTP/1.1 (Ends with two \r\n)
The html request header with the password looks like this:
GET /state.xml?relayState=1&noReply=1 HTTP/1.1 (Ends with two \r\n)
Authorization: Basic bm9uZTp3ZWJyZWxheQ== (Ends with two \r\n)
where bm9uZTp3ZWJyZWxheQ== is the base 64 encoded version of the username and password
none:webrelay
A utility is provided at http://www.ControlByWeb.com/encoder that can be used to encode the password. The utility
is used by simply typing the string username:password into the website and pressing encode.
3.4 Modbus Operation
WebRelay
TM
can be controlled (and read) using Modbus/TCP protocol. This provides a standard means of using
WebRelay
TM
in conjunction with devices and software from other manufacturers. This section contains the
information necessary to communicate with WebRelay
TM
using Modbus/TCP. This is not a tutorial on Modbus and it
is assumed that reader is already familiar with Modbus. Detailed Modbus information can be found at
http://www.modbus.org.
It is important to note that when the control password in WebRelay
TM
is enabled, Modbus/TCP communications are
disabled. This is because Modbus/TCP does not provide a mechanism for password protection. Make sure the
control password is disabled (default) before using Modbus with WebRelay
TM
. Also note that the automatic reboot
functions are not available through Modbus.
WebRelay
TM
functions as a Modbus server (slave). Client (master) devices open a connection with WebRelay
TM
on
port 502 (unless another modbus port is selected) and sends commands or requests to to read the state of the relay,
read the input, or change the relay. When WebRelay
TM
receives a command, it will perform the desired function and
return a response. The following commands are available:
Read Coils (Modbus function 01) - read the status of the relay (and/or the input).
Read Discrete Inputs (Modbus function 02) - read the status of the input
Write Single Coil (Modbus function 05) - change the relay state
Write Multiple Registers (Modbus function 16) - pulse the relay
Multiple commands may be sent without closing and re-opening the connection, but if no data is transferred for 50
seconds the connection will time out. To keep the connection open, a read request can be sent periodically. Two
TCP sockets are available for Modbus communications. If two masters each have a socket open (or a single master
using two sockets) and a third master attempts to open a socket for Modbus communications, the request to open a
third socket will be rejected.
3.4.1 Read Coils (Modbus Function Code 01 (0x01))
This function returns the state of the relay coil. In addition, the optically isolated input can be read using
this function which allows full state of WebRelay
TM
to be read in a single transaction.
Valid Starting Address and Quantity of coils combinations
Starting address 0x0000 quantity of coils 0x0001 (read relay state only)
Starting address 0x0000 quantity of coils 0x0002 (read relay state and input state)
Starting address 0x0001 quantity of coils 0x0001 (read input state only)
Starting address 0x0001 quantity of coils 0x0002 (not valid)
Request
Modbus/TCP:
Transaction identifier (2 Bytes): 0x0001
Protocol identifier (2 Bytes): 0x0000
Xytronix Research & Design, Inc.
page 45