MEMCPY block
Short summary
Name |
MEMCPY |
→POU type |
|
Category |
|
Conform to →IEC-standard |
not defined in IEC-standard |
Graphical interface |
|
Available since |
|
Functionality
The block copies the memory of one connected input value to another connected input value.
You enter the first input value at input SRC and the second input value at input DEST. At input LEN, enter the numer of bytes to be copied.
By default, value 0 is specified for the number of bytes.
Special cases:
In case of LEN = 0, the block automatically calculates the number of bytes to copy for SRC and DEST.
If the value for LEN is > than the maximally possible size of the input values DEST and SRC, the block copies until the maximally possible size of the input value. In this case, the output ENO is set to value FALSE.
If a STRING element with a length is connected to SRC or DEST, the length of the STRING buffer is used. The length of the STRING buffer is determined by the declaration.
STRING elements with a length are STRING variables declared by you; see " Declaration of STRING variables (incl. access)".If a STRING element without a length is connected to SRC or DEST , the length of the STRING buffer is also used. However, the length of the STRING buffer is determined by the resulting value.
STRING elements without a user-defined length are resulting, if you are using STRING functions or →character string literal.
Inputs, outputs
|
Identifier |
Description |
|
In-outs |
DEST |
REAL, LREAL, USINT, UINT, UDINT, ULINT, SINT, INT, DINT, LINT, TIME, BOOL, BYTE, WORD, DWORD, LWORD, STRING, CHAR, DATE_AND_TIME, DATE, TIME_OF_DAY , a →user-defined data type or a →function block
Further restriction: In the case of function blocks, no function blocks with a →generic data type are allowed. As a result of this restriction, you cannot use the following blocks as input of the current block: LIMITER_O, LIMITER_U, FORCEMRK, MAX_HOLD, MIN_HOLD, and
→vendor-function blocks that have been
declared with a generic data type. |
destination |
SRC |
REAL, LREAL, USINT, UINT, UDINT, ULINT, SINT, INT, DINT, LINT, TIME, BOOL, BYTE, WORD, DWORD, LWORD, STRING, CHAR, DATE_AND_TIME, DATE, TIME_OF_DAY , a →user-defined data type or a →function block
Further restriction: In the case of function blocks, no function blocks with a →generic data type are allowed. As a result of this restriction, you cannot use the following blocks as input of the current block: LIMITER_O, LIMITER_U, FORCEMRK, MAX_HOLD, MIN_HOLD, and
→vendor-function blocks that have been
declared with a generic data type. |
source |
|
Inputs: |
LEN |
UDINT |
the number of bytes to be copied |
Input EN and output ENO are available when →calling the block. See "Execution control: EN, ENO" for information on input EN and output ENO.
See:
"Blocks for safe logic" whether this block is supported for developing safety-relevant applications.
"Highlighting safe logic in the FBD-editor" for the effects when using the block as a block for safe logic .
Internal error diagnostic for block
The block checks the value connected to the inpu
ts
before it is executed.
If the value for
LEN
is > than the maximally possible size of the input values SRC and DEST
,
the output ENO of the block is set to value FALSE (or an equivalent).
Example for usage within ST-editor
PROGRAM Test
VAR
Var1 : BYTE :=
0
;
Var2 : BYTE :=
10
;
Var3 : DINT :=
0
;
Var4 : DINT :=
100
;
Var5 : DINT :=
0
;
Var6 : DINT :=
40000
;
END_VAR
MEMCPY(DEST := Var1, SRC := Var2, LEN :=
1
); (* The variable
'Var1'
evaluates to
'10'
. *)
MEMCPY(DEST := Var3, SRC := Var4, LEN :=
1
); (* The variable
'Var3'
evaluates to
'100'
. *)
MEMCPY(DEST := Var5, SRC := Var6, LEN :=
1
); (* The variable
'Var3'
evaluates to
'64'
. *)
END_PROGRAM
When creating your application within the ST-editor, enter a call of a block by typing the text as requested by the syntax or use Content Assist.