5 MODBUS RTU Protocol communication
Set "Monitoring Time for" "Transfer of parameters to modules(100ms)" to a
value as small as 3000 (=300s), by which an adequately long time may be
guaranteed to download the used load protocol driver into the CP card.
5.3.3
Write communication program
1. Open OB1. Just as ASCII communication, invoke SFB12 and SFB13 from the
library, and distribute the instance data blocks. The instance data block for SFB12
is DB12, and the data block for send data is DB1.
Fig. 104: Send Data block DB1
2. Invoke Send Function block. The used slave address is 5, the function code is
FC01, the start address is 0, and the statuses of 16 output bits are read. When
using different function code for communication, the definition of the request
telegram may be seen in the related description in MODBUS MASTER Manual -
Chapter 5: Function code.
Fig. 105: Invoke SFB12 in OB1
3. The supplementary instruction for SFB12 used in Modbus RTU communication
is seen below, and other parameters are defined similarly to those in CP441 ASCII
communication, for which the forgoing chapters may be referred to.
Name
R_ID
LEN
CP340/CP341/CP440/CP441 Communication and Programming
Entry-ID: 88867653,
V1.0,
comments
For distinguishing of different blocks in a same connection, the value range
in Modbus RTU communication is 0-255, and DW#16#1 is used in this
example.
The value range depends on the used function code. Please refer to the
table below.
02/2014
58