Using Old S7-300 FMs and CPs with Data Record Numbers > 1
8 DPV1 SFBs According to PNO AK 1131
8.1 Reading a Data Record from a DP Slave with SFB 52
"RDREC"
Note
The SFB52 "RDREC" interface is identical to the FB "RDREC" defined in the standard "PROFIBUS Guideline PROFIBUS Communication and Proxy Function Blocks according to IEC 61131-3".
Description
With the SFB52 "RDREC" (read record) you read a data record with the number INDEX from a DP Slave component (module or modules) that has been addressed via ID.
Specify the maximum number of bytes you want to read in MLEN. The selected length of the target area RECORD should have at least the length of MLEN bytes.
TRUE on output parameter VALID verifies that the data record has been successfully transferred into the target area RECORD. In this case, the output parameter LEN contains the length of the fetched data in bytes.
The output parameter ERROR indicates whether a data record transmission error has occurred. In this case, the output parameter STATUS contains the error information.
Operating principle
The SFC 52 "RDREC" operates asynchronously, that is, processing covers multiple SFC calls. Start the job by calling SFC52 with REQ = 1.
The job status is displayed via the output parameter BUSY and bytes 2 and 3 of output parameter STATUS. Here, the STATUS bytes 2 and 3 correspond with the output parameter RET_VAL of the asynchronously operating SFCs (see also Meaning of REQ, RET_VAL and BUSY with Asynchronously Operating SFCs).
长沙工控帮教育科技有限公司整理
Data record transmission is completed when the output parameter BUSY = FALSE.
Parameters Declaration Data type Memory Area Description
REQ INPUT BOOL I, Q, M, D, L, constant REQ = 1: Transfer data record ID INPUT DWORD I, Q, M, D, L, constant Logical address of the DP Slave
component (module or submodule) For an output module, the highest value bit must be set.
For a combination module, the smaller of the two addresses should be specified.
INDEX INPUT INT I, Q, M, D, L, constant Data record number.
MLEN INPUT INT I, Q, M, D, L, constant maximum length in bytes of the data record information to be fetched VALID OUTPUT BOOL I, Q, M, D, L New data record was received and valid BUSY OUTPUT BOOL I, Q, M, D, L BUSY = 1: The read process is not yet
terminated.
ERROR OUTPUT BOOL I, Q, M, D, L ERROR = 1: A read error has occurred.
STATUS OUTPUT DWORD I, Q, M, D, L Call ID (bytes 2 and 3) or error code LEN OUTPUT INT I, Q, M, D, L Length of the fetched data record
information
RECORD IN_OUT ANY I, Q, M, D, L Target area for the fetched data record.
Error Information
See Receiving an Interrupt from a DP Slave with SFB54 "RALRM"
长沙工控帮教育科技有限公司整理
8.2 Writing a Data Record in a DP Slave with SFB53
"WRREC"
Note
The SFB52 "WRREC" interface is identical to the FB "WRREC" defined in the standard "PROFIBUS Guideline PROFIBUS Communication and Proxy Function Blocks according to IEC 61131-3"
Description
With the SFB52 "WRREC" (write record) you transfer a data record with the number INDEX to a DP Slave component (module) that has been addressed via ID.
Specify the byte length of the data record to be transmitted. The selected length of the source area RECORD should, therefore, have at least the length of LEN bytes.
TRUE on output parameter DONE verifies that the data record has been successfully transferred to the DP Slave.
The output parameter ERROR indicates whether a data record transmission error has occurred. In this case, the output parameter STATUS contains the error information.
Operating principle
The SFC 53 "WRREC" operates asynchronously, that is, processing covers multiple SFC calls. Start the job by calling SFC53 with REQ = 1.
The job status is displayed via the output parameter BUSY and bytes 2 and 3 of output parameter STATUS. Here, the STATUS bytes 2 and 3 correspond with the output parameter RET_VAL of the asynchronously operating SFCs (see also Meaning of REQ, RET_VAL and BUSY with Asynchronously Operating SFCs).
Please note that you must assign the same value to the actual parameter of RECORD for all SFB53 calls that belong to one and the same job. The same applies to the LEN parameters.
长沙工控帮教育科技有限公司整理
Data record transmission is completed when the output parameter BUSY = FALSE.
Parameters Declaration Data type Memory Area Description
REQ INPUT BOOL I, Q, M, D, L, constant REQ = 1: Transfer data record ID INPUT DWORD I, Q, M, D, L, constant Logical address of the DP Slave
component (module or submodule) For an output module, the highest value bit must be set.
For a combination module, the smaller of the two addresses should be specified.
INDEX INPUT INT I, Q, M, D, L, constant Data record number.
LEN INPUT INT I, Q, M, D, L, constant maximum byte length of the data record to be transferred
DONE OUTPUT BOOL I, Q, M, D, L Data record was transferred
BUSY OUTPUT BOOL I, Q, M, D, L BUSY = 1: The write process is not yet terminated.
ERROR OUTPUT BOOL I, Q, M, D, L ERROR = 1: A write error has occurred.
STATUS OUTPUT DWORD I, Q, M, D, L Call ID (Bytes 2 and 3) or error code
RECORD IN_OUT ANY I, Q, M, D, L Data record
Error Information
See Receiving an Interrupt from a DP Slave with SFB54 "RALRM"
长沙工控帮教育科技有限公司整理
8.3 Receiving an Interrupt from a DP Slave with SFB 54
"RALRM"
Note
The SFB52 "RALRM" interface is identical to the FB "RALRM" defined in the standard "PROFIBUS Guideline PROFIBUS Communication and Proxy Function Blocks according to IEC 61131-3"
Description
The SFB "RALRM" receives an interrupt with all corresponding information from a peripheral module (centralized structure) or from a DP Slave component. It supplies this information to its output parameters.
The information in the output parameters contains the start information of the called OB as well as information of the interrupt source.
Call the SFB54 only within the interrupt OB started by the CPU operating system as a result of the peripheral interrupt that is to be examined.
Note
If you call SFB54 "RALRM" in an OB for which the start event was not triggered by peripherals, the SFB supplies correspondingly reduced information on its outputs.
Make sure to use different instance DBs when you call SFB 54 "RALRM" in different OBs. If you want to evaluate data that are the result of an SFB54 call outside of the associated interrupt OB you should moreover use a separate instance DB per OB start event.