Function Code 3 ($03) - Read Holding Registers
Description
Modbus function code $03 is a request to read holding registers. In its default configuration the RIO-471x0
responds to this command with analog input register information. To configure the RIO to respond to a
function code 3 request with analog output 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 $03
_MW results in $83
_MW1
contains
$01
or
$02
When using the MB command with Modbus function code $03, response data will be stored in the array
referenced in the command line. When using @AN[], @AN[] contains the response data, which can either be
stored to a variable or transmitted via serial port or ethernet.
Ways to use function code 3 with Galil commands:
1.
MB command in raw packet mode
2.
MB command with Modbus function code 3
3.
@AN[] (see @AN[] in the command reference)
Operating as a slave
The RIO will accept different starting address ranges for a read holding 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 holding 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 holding 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 $0020 if MI is 0, and from $0000 to $0010 if
MI is 1 (Byte Count = 2*NumberOfRegisters, where NumberOfRegisters is equal to the number of analog
inputs you are trying to read multiplied by 2 if MI is 0, or 1 if MI is 1). The RIO will respond with a byte
count field equal to the byte count field in the request packet. The RIO will respond with a register value
field consisting of either 2 bytes (counts) or 4 bytes (32-bit floating point) per analog input in ascending
order from the analog input referenced in the address.
RIO-47xxx
Chapter 3 Communication
●
21