6.4 MODBUS TCP Master Communication (SEND)
6.4 MODBUS TCP Master Communication (SEND)
6.4.1 Write Data into an External Device
Instructions
In master communication, PLC has the sending right, and executes communication by
sending commands to devices that support MODBUS, and receiving responses. Messages in
accordance with the protocol are automatically generated by PLC. In the user program,
reading and writing can be done simply by specifying the station no. and memory address and
executing SEND/RECV commands.
External device
supporting Modbus-TCP
(Hex) 01 10 00 00 00 02 04 00 64 00 00
(Hex) 01 10 00 00 00 02
Command message
Response message
・・・・・・・・・・・・・・
・・・・・・・・・・・・・・
0
DT101
100DT100
・・・・・・・・
・・・・・・
・・・・・・・・・・・・・・
0
40002
10040001
PLC
Specify and write address based on SEND command
Note: The above figure indicates the data part of Modbus function. In communication via LAN, a header including size information of the sent data is added.
Sample program
• Send a MODBUS command (16) from the LAN port of the CPU unit, and write the content of
PLC's data register DT100 - DT101 into the data area of an external device 40001 - 40002
(MODBUS address 0000H - 0001H).
• Confirm that Connection 1 is established in the master mode (X90), and that the sending
process is not in progress for the same port (Y90), and start up the SEND command.
• In the UNITSEL command, specify the slot No. (LAN port: U100) and the connection No. (U1).
• In the SEND command, specify and execute the PLC initial address (DT100), No. of data
(U2), MODBUS command (16 = H10), partner device station no. (H01), and initial address
(H0). For the address of the partner device, please check operating instructions, etc. of the
relevant device.
R0
R100
UNITSEL U100
U1
SEND.US DT0H1001 H0DT100 U2
R100
SEND
execution
relay
Settings for communication port
S1: CPU LAN port (U100)
S2: Connection 1 (U1)
SEND execution conditions
Clear to send flag: ON
Sending flag: OFF
Execute SEND command
S: Data saving area (DT100)
n: No. of sent data (U2)
D1: MODBUS code (H10) and
partner station no. (H01)
D2: "Transmit to" address (H0)
D3: Execution result code (DT0)
Clear to send
master
communication flag
X90 Y90
Sending master
communication flag
( )
DF
S1 S2
S n
D1 D2 D3
6-9