4 ASCII protocol communication
CP340/CP341/CP440/CP441 Communication and Programming
Entry-ID: 88867653, V1.0, 02/2014
32
S
ie
m
e
n
s
A
G
2014
A
ll r
ig
h
ts
r
e
s
e
rv
e
d
4.4.3
Write communication program
1. Double-click OB1 to open the programming screen. Invoke SFB12 BSEND from
Libraries-> Standard library-> System function blocks, and distribute instance
data block DB12 to it and create send data block DB1.
Fig. 52: Send Data block DB1
2. Invoke send function block. The SFB12 BSEND parameters are set as shown in
the table below:
Name
Data
type
comments
REQ
BOOL
send request bit, rising edge trigger, which is M0.0 in this
example
R
BOOL
Cancel communication
ID
WORD
Local ID number, which is obtained from the PtP connection
properties and is hexadecimal.
R_ID
DWORD
Distinguish double word, which may be any data. However, if the
program uses multiple BSEND blocks, different serial numbers
shall be distributed to them.
SD_1
ANY
Data send area. DB area is used in this example, and the send
data are in 5 bytes.
Other addresses and data types may also be used for access,
and the detailed information may be obtained from Step7 SFB12
online help.
LEN
WORD
Send data length, which is counted in bytes.
DONE
BOOL
Send complete bit, which is set as 1 if the task completes and has
no error.
ERROR
BOOL
Error bit, which is set as 1 in case of error.
STATUS
WORD
Status word, indicating error code. The specific information may
be seen in online diagnosis of module or from CP441 Manual -
Chapter 9: Diagnosis information
Table 10: Parameter definition of SFB12 BSEND