Function Code 2 ($02) - Read Discrete Inputs
Description
Modbus function code $02 is a request to read discrete inputs. This will read digital inputs from an RIO
configured as a slave.
Operating as a master
The function code of the response can be queried with the _MW command. If an exception occurred, the
exception code of the response can be queried with _MW1.
Example:
Normal Response
Exception Response
_MW results in $02
_MW results in $82
_MW1
contains
$01
or
$02
When using the MB command with Modbus function code $02, response data will be stored in the array
referenced in the command line. When using @IN[], @IN[] contains the response data, which can either be
stored to a variable or transmitted via serial port or ethernet.
Ways to use function code 2 with Galil commands:
1.
MB command in raw packet mode
2.
MB command with Modbus function code 2
3.
@IN[] (see @IN[] in the command reference)
Operating as a slave
The RIO will accept a read discrete inputs request with a starting address ranging from $0000-$000F,
referencing digital inputs 0-15. The RIO will accept a request for up to all 16 of its digital inputs, with a
quantity of inputs range of $0001-$0010.
The RIO will respond with a byte count of either $01 or $02, which describes the number of bytes of digital
inputs being returned (byte count = quantity of inputs/8; if the remainder is not 0, byte count = quantity of
inputs/8 +1). The RIO will respond with a input status of 1 or 2 bytes (equal to the byte count) ranging from
$0001-$FFFF, with each bit representing the state of a digital input (1 or 0). The LSB of the first input status
byte refers to the input addressed by the request packet.
Coil Mapping
Coil Addresses
Coil Addresses
0
Digital Input 0
8
Digital Input 8
1
Digital Input 1
9
Digital Input 9
2
Digital Input 2
10
Digital Input 10
3
Digital Input 3
11
Digital Input 11
4
Digital Input 4
12
Digital Input 12
5
Digital Input 5
13
Digital Input 13
6
Digital Input 6
14
Digital Input 14
7
Digital Input 7
15
Digital Input 15
RIO-47xxx
Chapter 3 Communication
●
19
Содержание RIO-47**0
Страница 2: ......
Страница 93: ...RIO Dimensions RIO 471xx Units in centimeters RIO 47xxx Appendix 87...
Страница 94: ...RIO 472xx Units in millimeters 88 Appendix RIO 47xxx...
Страница 107: ...Internal 56 64 Zero Stack 53 RIO 47xxx Index 101...