Programming Example for Standard Function Blocks 
  9.6 Activation, Startup Program and Cyclic Program 
Point-to-point connection CP 440 Installation and Parameter Assignment 
Manual, 09/2007, A5E00057742-03 
133 
9.6 Activation, Startup Program and Cyclic Program 
9.6.1 "CP440 SEND RECV" Program Example 
Activation, Startup Program 
The start-up program is located in the OB 100. 
The control bits and the counters are reset in the startup procedure. 
Cyclic Program 
The cyclic program is defined in the organization block OB 1. 
In the example, the function blocks FB 9 "RECV_440" and FB 10 "SEND_440" work together 
with the functions FC 21 and FC 22 as well as with the data blocks DB 21 and DB 22 as 
instance DBs and DB 42 and DB 43 as send or receive DBs. 
In the example the function blocks are assigned parameters partly via constants and partly 
via symbolically addressed actual operands. 
Data Transmission 
Data transmission takes place from the CP 440 on slot 4 to the CP 440 on slot 5. If you work 
with other communication partners, the FC 22 (RECEIVE) is not called. 
Description of FC 21 (SEND) 
The "Generate edge P_SEND_REQ" program section: 
SEND_440 is run through once at the start with SEND_REQ=0.SEND_REQ is then set to 1. 
The SEND_440 job is started when a signal state change from "0" to "1" is detected at the 
SEND_REQ control parameter. 
When SEND_DONE=1 or SEND_ERROR=1, SEND_REQ is reset to 0. 
"SEND_DONE=1" program section: 
If the transfer is successful, SEND_DONE is set to "1" at the parameter output of 
SEND_440. 
To distinguish between consecutive transfers, a send counter (SEND_COUNTER_OK) is 
included in data word 0 of the source block DB 42. 
"SEND_ERROR=1" program section: 
If SEND_440 runs through with SEND_ERROR=1, the SEND_COUNTER_ERR error counter 
is incremented in data word 2. The SEND_STATUS is copied, because it is overwritten with 
0 in the next run, which means it will not be possible to read it out. 
Description of FC 22 (RECEIVE) 
该文档是极速PDF编辑器生成,
如果想去掉该提示,请访问并下载:
http://www.jisupdfeditor.com/