Function Code 4 ($04) - Read Input Registers
Description
Modbus function code $04 is a request to read input registers. In its default configuration the RIO-471x0
responds to this command with analog output register information. To configure the RIO to respond to a
function code 4 request with analog input information see the MV command in the command reference.
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 $04
_MW results in $84
_MW1
contains
$01
or
$02
When using the MB command with Modbus function code $04, response data will be stored in the array
referenced in the command line. When using @AO[], @AO[] contains the response data, which can either be
stored to a variable or transmitted via serial port or ethernet.
Ways to use function code1 with Galil commands:
1.
MB command in raw packet mode
2.
MB command with Modbus function code 4
3.
@AO[] (see @AO[] in the command reference)
Operating as a slave
The RIO will accept different address ranges for a read input registers request depending on the state of the
MI command. If MI is set to 0 (register data is volts in 32-bit floating point), the RIO will accept a read input
registers request with an address range of $0000-$000E. If MI is set to 1 (register data is counts in 16-bit
decimal), The RIO will accept a read input registers request with an address range of $0000-$0007. The RIO
will accept a request with a quantity of registers field up to $0008 if MI is set to 0, and $00010 if MI is set to
1. The RIO will respond with a byte count ranging from $0000 to $0010 if MI is 1, and from $0000 to $0020
if MI is 0 ((byte count = 2*NumberOfRegisters, where NumberOfRegisters is equal to the number of analog
outputs you are trying to read multiplied by 2 if MI is 0, or 1 if MI is 1). The RIO will respond with an input
registers field consisting of either 2 bytes (counts) or 4 bytes (32-bit floating point) per analog output register
in ascending order from the analog output referenced in the address.
24 Chapter 3 Communication
RIO-47xxx