Revision 1.1
WebSwitch™ Users Manual
3.4.2 Read Discrete Inputs (Modbus Function Code 02 (0x02)) (Model XRDI-WS3P only)
This function returns the state of the discrete inputs.
Valid Starting Address and Quantity of coils combinations:
Valid starting address can fall in the range of 0x0000 and 0x0001. Valid quantities can fall in the range of
0x0001 and 0x0002. The only restriction is that the sum of the starting address and the quantity of coils
must not be greater than 0x0002. For example, if you want to read 0x0002 bits, both inputs, then the
starting address must be 0x0000. On the other hand, you may want to read the second input only. This
can be achieved by starting at address 0x0001 and using a quantity of 0x0001.
Request
Modbus/TCP:
Transaction identifier (2 Bytes): 0x0001
Protocol identifier (2 Bytes): 0x0000
Length (2 Bytes): 0x0006
Unit identifier (1 Byte): 0xff
Modbus:
Function code (1 Byte): 0x02 (read discrete input)
Starting address (2 Bytes): 0x0000 (0x0000 or 0x0001)
Quantity of inputs (2 Bytes): 0x0001 (0x0001 or 0x0002)
Character String Example:
char read_inputs_mb_request[] ={0x00, 0x01, 0x00, 0x00, 0x00, 0x06,
0xff, 0x02, 0x00, 0x00, 0x00,0x01 };
Response
Modbus/TCP:
Transaction identifier (2 Bytes): 0x0001
Protocol identifier (2 Bytes): 0x0000
Length (2 Bytes): 0x0004
Unit identifier (1 Byte): 0xff
Modbus:
Function code (1 Byte): 0x02 (Read discrete input)
Byte count (1 Byte): 0x01
Input status: 0x00 (input off), 0x01 (input on)
Data Byte (hex)
LS Data Bits (binary)
Input 2 State
Input 1 State
0x00
1
0000
Low
Low
0x01
1
0001
Low
High
0x02
1
0010
High
Low
0x03
1
0011
High
High
Xytronix Research & Design, Inc.
77