0% found this document useful (0 votes)
286 views3 pages

SFC 20 From Standard and System Functions

SFC 20 "BLKMOV" is used to copy the contents of a memory area (source area) to another memory area (destination area). The source can be parts of data blocks, memory bits, or process image partitions. The data is copied from the source to the destination in the direction of ascending addresses. The source data remains unchanged during copying. SFC 20 can be interrupted as long as the source is not from a data block only in load memory. Parameters specify the source and destination areas, and the return value indicates if errors occurred.

Uploaded by

Minuraj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
286 views3 pages

SFC 20 From Standard and System Functions

SFC 20 "BLKMOV" is used to copy the contents of a memory area (source area) to another memory area (destination area). The source can be parts of data blocks, memory bits, or process image partitions. The data is copied from the source to the destination in the direction of ascending addresses. The source data remains unchanged during copying. SFC 20 can be interrupted as long as the source is not from a data block only in load memory. Parameters specify the source and destination areas, and the return value indicates if errors occurred.

Uploaded by

Minuraj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

3 Copy and Block Functions

3.1 Copying Memory Area with SFC 20 "BLKMOV"

Description
You use SFC 20 "BLKMOV" (block move) to copy the contents of a memory area (= source area) to
another memory area (= destination area).
Permissible source areas are the following:
Parts of data blocks
Memory bits
Process-image partition (part process image) for inputs
Process-image partition (part process image) for outputs
The source parameter can be a part of the data block in the load memory which is not relevant to
program execution (DB compiled with the keyword UNLINKED).

Note
If your CPU contains SFC 83, you must use SFC 83 for reading data blocks that are not relevant to
program execution. If you use SFC 20, error W#16#8092 is output.

DB10. DBW4 A B
DB10. DBW6 C D
DB10. DBW8 E F Copy
DB10. DBW10 G H
Data is copied
in the direction of
ascending
addresses
MW 10 A B
MW 12 C D
MW 14 E F
MW 16 G H

Memory area

System Software for S7-300/400 System and Standard Functions Volume 1/2
Reference Manual, 05/2010, A5E02789976-01 97
Consistency of the source data and target data
Note that the source data remains unchanged while SFC20 "BLKMOV" executes. Otherwise the
consistency of the target data cannot be guaranteed.

Interruptability
As long as the source area is not part of a data block that only exists in the load memory, there is no
limit to the nesting depth.
If, however, SFC 20 is interrupted while copying from a DB that is not relevant to program execution,
the execution of SFC 20 can no longer be nested.

Parameter Declaration Data Type Memory Description


Area
SRCBLK INPUT ANY I, Q, M, D, L Specifies the memory area to be copied (source
area). Arrays of the data type STRING are not
permitted.
RET_VAL OUTPUT INT I, Q, M, D, L If an error occurs when the function is being
executed, the return value contains an error code.
DSTBLK OUTPUT ANY I, Q, M, D, L Specifies the memory area to which the data will be
copied (destination area). Arrays of the data type
STRING are not permitted.

Conditions for source and destination field

The source and destination field must not overlap. If the specified destination field is larger than the
source field, only the amount of data actually in the source field is copied to the destination field.
If the specified destination field (DSTBLK parameter) is smaller than the source field (SRCBLK
parameter), only as much data is copied as can be accommodated in the destination field.
If the real existing destination or source field is smaller than the size of the memory area for source or
destination field as set in the parameters (SRCBLK, DSTBLK), the behavior depends on the CPU
type:
S7-300 CPUs: No data is transferred. RET_VAL has the value W#16#837F.
The following applies to the S7-400 V4 CPUs (standard CPUs V4, H-CPUs V4 and V4.5): No data
is transferred.
The following applies to all other S7-400 CPUs: Data is transferred.
With all S7-400 CPUs, an error is shown in RET_VAL with the error code W#16#8122 or
W#16#8323. Make sure that you always evaluate these RET_VALs in your user program.
If the ANY pointer (source or destination) is of the type BOOL, the specified length must be divisible by
8 otherwise copying is not possible.
If you use variables of the data type STRING for the SRCBLK and DSTBLK parameters, STEP 7
interprets these variables as ARRAY of BYTE (including the two management bytes with the
maximum and current length). The results in SFC20 copying in bytes: This means that the byte with
the maximum length, the byte with the current length and the actual string are copied.
If the data type STRING is used for one of the parameters SRCBLK or DSTBLK or both, you will need
to set up the corresponding ANY pointer yourself. If the source is a string, as maximum only the
characters currently contained in the string will be copied. If source and destination are both strings,
the current length of the destination will be set to the number of copied characters.

Note
If a DB that is not runtime relevant is copied to work memory with SFC20 BLKMOV and, at the same
time, reloaded for example from a PG, the SFC may be delayed by several milliseconds. This causes
and extension of the OB cycle and can trigger the scan time watchdog. Avoid reloading this block at
times when the CPU is copying the block with SFC20.

Error Information

Error Code Explanation


(W#16#...)
0000 No error
8091 Nesting depth exceeded.
8092 SFC 20 "BLKMOV" cannot be executed because a unusable (write-protected, unrunnable on
unloaded) data block was accessed.
8xyy General error information, see Evaluating Errors with the Output Parameter RET_VAL

System Software for S7-300/400 System and Standard Functions Volume 1/2
Reference Manual, 05/2010, A5E02789976-01 99

You might also like