5 MODBUS RTU Protocol communication
CP340/CP341/CP440/CP441 Communication and Programming
Entry-ID: 88867653, V1.0, 02/2014
49
S
ie
m
e
n
s
A
G
2014
A
ll r
ig
h
ts
r
e
s
e
rv
e
d
Fig. 87: Compile and save hardware configuration
5.2.3
Write communication program
1. Double-click OB1 to open OB1 programming screen. Invoke send program
block FB8 P_SND_RK from Libraries -> CP PtP -> CP341 and distribute instance
data block DB8 to it. Set the parameter LADDR as the input start logic address 256
in hardware configuration.
Fig. 88: Logic address of CP341
2. Create send data block DB1, in which the slave address is 2, the function code
is 3 and start address is 0. Read 4 register data. For use of the function code 3,
see Modbus Master Manual - 5.3: Function Code 03 - Read Output Registers.
Fig. 89: Send Data block DB1
3. Invoke Send Function block
The FB8 P_SND_RK parameter setting may be seen in the table below:
SF
"S" means send, which must be in capital form here.
LADDR
Start logic address in hardware configuration, which is 256 in this