Communication via Function Blocks
FB 2 P_RCV Parameters
Communication via Function Blocks 如果想去掉该提示,请访问并下载:
http://www.jisupdfeditor.com/
长沙工控帮教育科技有限公司整理
6-11
CP 340 Point-to-Point Communication ASE00053578-05
The figure below illustrates the behavior of the parameters NDR, LEN and ERROR, depending on how the EN_R and R inputs are wired.
EN_R
R
NDR
LEN (length) ERROR
Enable receive Completion without error Receiving Completion with error No receive RESET Completion without Receiving Completion with errorReceiving deactivated error
Figure 6-2 Time Sequence Chart for FB 2 P_RCV
Note
The EN_R must be set to statical “1”. During the receive request, the EN_R parameter must be supplied with RLO “1” (result of logic operation).
Time Sequence Chart for FB 2 P_RCV
Communication via Function Blocks 如果想去掉该提示,请访问并下载:
http://www.jisupdfeditor.com/
长沙工控帮教育科技有限公司整理
6-12 CP 340 Point-to-Point Communication ASE00053578-05
6.3.2 Outputting Message Texts to a Printer
The P_PRINT function block (FB 4) is available to you for outputting message texts to a printer. The P_PRINT function block (FB 4) sends a process message to the CP340, for example. The CP340 logs the process message on the connected printer.
The P_PRINT FB sends a message text containing up to four variables to the CP340. You configure the message texts using the CP340: Point-to-Point Communication, Parameter Assignment parameterization interface (see Sections 2.2.4 and 2.3.5). The P_PRINT FB is called statically (without conditions) for data transmission either in the cycle or in a time-controlled program.
The pointers (to data blocks) for the format string and the four variables can be reached by means of the DB_NO and DBB_NO parameters. The pointers must be stored without gaps and in a specific sequence in the parameterized data block. This is the pointer DB (see Figure 6-3).
The transmission of the message text is initiated by a positive edge at the REQ input. The format string of the message text is sent first, followed by variables 1 to 4.
Depending on the volume of data involved, a data transmission may run over several calls (program cycles).
The P_PRINT FB can be called in the cycle when the signal state at the R parameter input is ”1”. This aborts the transmission to the CP 340 and sets the P_PRINT FB back to its initial state. Data already received by the CP 340 is sent to the communication partner. If a signal state of ”1” is applied statically at the R input, the transmission of print requests is deactivated.
The LADDR parameter specifies the address of the CP 340 to be addressed.
The DONE output shows ”request completed without errors”. ERROR indicates whether an error has occurred. If there was an error, the
corresponding event number is displayed in STATUS (see Section 8.3). If there were no errors, STATUS has a value of 0. DONE and ERROR/STATUS are also output when the P_PRINT FB is reset (see Figure 6-4). In the event of an error, the binary result (BR) is reset. If the block is terminated without errors, the binary result has a status of ”1”.
Note
The P_PRINT function block does not have a parameter check, which means that if there are invalid parameters, the CPU may switch to STOP mode.
Before the CP 340 can process an activated request after the CPU has chan-ged from STOP to RUN mode, the CP CPU start-up mechanism of the P_PRINT FB must be completed (see Section 6.5). Any requests initiated in the meantime do not get lost. They are transmitted to the CP 340 once the start-up coordination is completed.
Introduction
Outputting Message Texts
Communication via Function Blocks 如果想去掉该提示,请访问并下载:
http://www.jisupdfeditor.com/
长沙工控帮教育科技有限公司整理
6-13
CP 340 Point-to-Point Communication ASE00053578-05
Block Call
STL Representation LAD Representation
CALL P_PRINT, I_PRINT
REQ: =
R: =
LADDR: =
DB_NO: =
DBB_NO: =
DONE: =
ERROR: =
STATUS: =
I_PRINT P_PRINT
EN ENO
REQ DONE
R ERROR
LADDR STATUS
DB_NO DBB_NO
Note
The EN and ENO parameters are only present in the graphical representation (LAD or FBD). To process these parameters, the compiler uses the binary result (BR).
The binary result is set to signal state ”1” if the block was terminated wi-thout errors. If there was an error, the BR is set to ”0”.
The P_PRINT FB works with an I_PRINT instance DB of 39 bytes, whose DB number is specified in the call. The data in the instance DB cannot be accessed.
Note
Exception: If the error STATUS == W#16#1E0F occurs, you can consult the SFCERR variable for more details of the error (see Section 8.3). This error variable can only be loaded via symbolic access to the instance DB.
What to Do
Assignment in the Data Area,
Instance DB
Communication via Function Blocks 如果想去掉该提示,请访问并下载:
http://www.jisupdfeditor.com/
长沙工控帮教育科技有限公司整理
6-14 CP 340 Point-to-Point Communication ASE00053578-05
The P_PRINT FB uses the DB_NO and DBB_NO parameters to access a pointer DB in which the pointers to the data blocks containing the message texts and variables are stored in a fixed order. You have to create the pointer DB.
Figure 6-3 shows the structure of the pointer DB addressed by means of the DB_NO and DBB_NO parameters of the P_PRINT DB.
DBW n
Pointer to 1st variable
Pointer to 2nd variable
Pointer to 3rd variable
Pointer to 4th variable
Pointer to format string
Figure 6-3 Structure of the Pointer DB for the P_PRINT Function Block (FB)
The permissible DB numbers are CPU-specific. If a DB number of 16#00 is specified for a pointer to a variable, this variable is interpreted as not being there and the pointer is set on the next variable or the format string.
If the DB number for the pointer to the format string is 16#00, the print request is aborted and the event number 16#1E43 displayed at the STATUS parameter output of the P_PRINT FB.
The variable or format string begins at the parameterized DBB number. The variables can have a maximum length of 32 bytes, and the format string can have a maximum length of 150 bytes.
If the maximum length is exceeded, the print request is aborted and the event number 16#1E41 displayed at the STATUS parameter output of the
P_PRINT FB.
The entry length in the pointer DB is to be set for each display type (data type) independently from the precision used.
Assignment in the
Communication via Function Blocks 如果想去掉该提示,请访问并下载:
http://www.jisupdfeditor.com/
长沙工控帮教育科技有限公司整理
6-15
CP 340 Point-to-Point Communication ASE00053578-05
The table below lists the parameters of the P_PRINT function block (FB 4).
Table 6-4 FB 4 P_PRINT Parameters
Name Type Data Type Description Permitted Values, Comment
REQ INPUT BOOL Initiates request at
posi-tive edge
R INPUT BOOL Aborts request Current request is aborted, and
printer output is blocked.
LADDR INPUT INT Basic address of the
CP 340
The basic address is taken from STEP 7.
DB_NO INPUT INT Data block number Pointer to pointer DB1:
CPU-specific (zero not permit-ted)
DBB_NO INPUT INT Data byte number 0 DBB_NO 8162
Pointer as of data byte
DONE2 OUTPUT BOOL Request completed
wi-thout errors
STATUS parameter == 16#00;
ERROR OUTPUT BOOL Request completed with
errors
STATUS parameter contains er-ror details.
STATUS OUTPUT WORD Error specification If ERROR == 1, STATUS parameter contains error details.
1 The pointers to variables and format string are stored in the pointer DB in a fixed order (see Figure 6-3).
2 The DONE parameter is available for a single CPU cycle after the send request has been completed correctly.
FB 4 P_PRINT