Function Code 1 ($01) - Read Coils
Description
Modbus function code $01 is a request to read coils. This will read digital outputs 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 $01
_MW results in $81
_MW1
contains
$01
or
$02
When using the MB command with Modbus function code 1, response data will be stored in the array
referenced in the command line. When using @OUT[], @OUT[] contains the response data, which can either
be stored to a variable or transmitted via serial port or ethernet.
Ways to use function code $01 with Galil commands:
1.
MB command in raw packet mode
2.
MB command with Modbus function code1
3.
@OUT[] (see @OUT[] in the command reference)
Operating as a slave
The RIO will accept a read coils request with a starting address ranging from $0000-$000F, referencing
digital outputs 0-15. The RIO will accept a request for up to all 16 of its digital outputs, with the quantity of
coils ranging from $0001-$0010.
The RIO will respond with function code $01 followed by a byte count of
either $01 or $02, which describes the number of bytes of digital outputs being returned (byte count =
quantity of outputs/8; if the remainder is not 0, byte count = quantity of outputs/8 +1). The RIO will respond
with a coil status of 1 or 2 bytes (equal to the byte count) ranging from $0001-$FFFF, with each bit
representing the state of a digital output (1 or 0). The LSB of the first coil status byte refers to the output
addressed by the request packet.
Coil Mapping
Coil Addresses
Coil Addresses
0
Digital Output 0
8
Digital Output 8
1
Digital Output 1
9
Digital Output 9
2
Digital Output 2
10
Digital Output 10
3
Digital Output 3
11
Digital Output 11
4
Digital Output 4
12
Digital Output 12
5
Digital Output 5
13
Digital Output 13
6
Digital Output 6
14
Digital Output 14
7
Digital Output 7
15
Digital Output 15
RIO-47xxx
Chapter 3 Communication
●
17