Chapter 8. Communication Function
8-71
z The variable which saves the read data must be array type. The size of array type must be the same or bigger
than the size of the data of read. If it’s smaller, the error code is marked in STATUS.
z The previously read data is saved from the array variable, RD_DB1[0].
z The remnant part of an array variable is redundancy, after the variable is filled with the previously read data.
2) MOD0304
Function block Description
Input
REQ: Execute function block when it’s 1(rising edge)
CH : Set communication channel (0 ~ 1)
SLV_STNO:
Input the number of the slave station
FUNC: Input the function code. It supports function code 03 and 04
SLV_ADDR: The address to read from the slave station
NUM: The data size to read from
the slave station
Output
RD_DATA: A variable name to save the data that is read
The number of arra
is
to be declared as same as or bigger than data size.).
NDR: If it ends without error, output 1 and keep the value till the call for the next
function block.
ERR: If an error occurs, output 1 and keep the value till the call for the next
function block.
STATUS: When an error occurs, output an error code.
(1) Function
This is a function block that can execute either function code 03 or 04 for reading words in Modbus protocol
communication. Function code 03 reads Holding Registers and function 04 reads Input Registers.
(2) Error
It outputs error codes to output STATUS. Refer to “Error codes” for the detailed.
(3) Example of the program
z It assumes that GM7U main unit is the master and it reads the station no. 17 of a Modicon product.
z The master reads the Holding Registers 40108 ~ 40110 of the slave station no. 17. The status of the Holding
Registers of the slave station is supposed to be as follows and the previously read data are saved in any array
variable RD_DWO of the 40-sized WORD type.
Holding Registers 40110 40109 40108
Register status 16#0064 16#0000 16#022B