Ethernet Communications Modules, 3rd Edition, Rev. D
5-20
Chapter 5: MODBUS TCP for H0/H2/H4-ECOM100
1
2
3
4
5
6
7
8
9
10
11
12
13
14
A
B
C
D
Step 2: Load Number of Bytes to Transfer
The second Load (LD) instruction determines the
number of bytes which will be transferred between
the master and slave in the subsequent WX or RX
instruction. The value to be loaded is in BCD format
(decimal), from 1 to 128 bytes. Requesting an even
number of bytes, generates a Modbus message using
Function 03, Read Holding Registers. If you need
to Read Input Registers, Function Code 04, enter an
odd number of bytes. For example, to read 10 Input
Holding Registers, enter 2 (bytes/word) X 10 registers
+ 1, 21 bytes. This will request ten 30001 range
addresses from the Modbus server (slave) device.
Step 3: Specify Master Memory Area
The third instruction in the RX or WX sequence is
a Load Address (LDA) instruction. Its purpose is to
load the starting address of the memory area to be
transferred. Entered as an octal number, the LDA
instruction converts it to hex and places the result in
the accumulator.
For a WX instruction, the CPU sends the number
of bytes previously specified from its memory area
beginning at the LDA address specified.
For an RX instruction, the CPU reads the number of bytes previously specified from the
server, placing the received data into its memory area beginning at the LDA address specified.
NOTE: Since V-memory words are always 16 bits, you may not always use the whole word. For example, if
you only specify to read 3 bytes, you will only get 24 bits of data. In this case, only the 8 least significant
bits of the last word location will be modified. The remaining 8 bits are not affected.
Step 4: Specify Slave Memory Area
The last instruction in our sequence is the WX or RX
instruction itself. Use WX to write to the server, and
RX to read from the server. All four of our instructions
are shown to the right. In the last instruction, you must
specify the starting address and a valid data type for the
server.
1 2 8
(BCD)
#ofbytes to transfer
LD
K128
6 0 00
(octal)
LDA
O40600
4
Starting addressof
client transferare a
V40600
BSLBSM
015
V40601
BSLBSM
015
LD
K114
LD
K128
LDA
O40600
RX
V0
SP122