Revision 1.1
WebSwitch™ Users Manual
3.4 Modbus Operation
WebSwitch™ can be controlled (and read) using Modbus/TCP protocol. This provides a standard means
of using WebSwitch™ in conjunction with devices and software from other manufacturers. This section
contains the information necessary to communicate with WebSwitch™ using Modbus/TCP. This is not a
tutorial on Modbus and it is assumed that the reader is already familiar with Modbus. Detailed Modbus
information can be found at http://www.modbus.org.
WebSwitch™ functions as a Modbus server (slave). Client (master) devices and software open a
connection with WebSwitch™ on port 502 (unless another Modbus port is selected) and sends
commands or requests to read the state of the outlet, read the input, or change the outlet state. When
WebSwitch™ receives a command, it will perform the desired function and return a response. The
underlying structure of these commands can be found in the next sections, although most software and
Modbus devices can be configured by reading through the following section only.
There are generally two ways that Modbus software and PLCs communicate with a Modbus device. The
first is by specifying the Modbus function code/memory type and an address. The second, sometimes
called PLC addressing, requires the address only. Under PLC addressing, the function code/memory
type is a given based on the PLC address. Once the address is known, the data size must be specified.
The inputs and outlets are discrete data types. The sensor readings are 32 bit floating point numbers.
For these, a quantity of two registers must be read starting at the desired address. The table below gives
commonly used function code/memory types, data sizes, and equivalent PLC addresses for accessing
the device. The data size will be the same regardless of the addressing mode.
Function Code
and Address
Data Size
PLC Address Mode
485
PLC Address Mode
584/984
Read Outlet 1
State
Function code 01
Address 0
Discrete
1
1
Read Outlet 2
State
Function code 01
Address 1
Discrete
2
2
Write Outlet 1
Function code 05
Address 0
Discrete
1
1
Write Outlet 2
Function code 05
Address 1
Discrete
2
2
Read Input 1
State
Function code 02
Address 0
Discrete
1001
10001
Read Input 2
State
Function code 02
Address 1
Discrete
1002
10002
Read Sensor 1
Function code 03
Address 272
32 Bit Float
(2 Registers)
4272
40272
Read Sensor 2
Function code 03
Address 274
32 Bit Float
(2 Registers)
4274
40274
Read Sensor 3
Function code 03
Address 276
32 Bit Float
(2 Registers)
4276
40276
Xytronix Research & Design, Inc.
73