MEMCPY

MEMCPY 1:

The function MEMCPY can be used to copy the values of PLC variables from one memory area to another.

FUNCTION MEMCPY : UDINT

VAR_INPUT
    destAddr      : UDINT;
    srcAddr       : UDINT;
    n             : UDINT;
END_VAR

destAddr: start address of the target memory area.

srcAddr: start address of the source memory area.

n: number of bytes to be copied.

 

The function copies n bytes from the memory area that starts at srcAddr to the memory area that starts at destAddr.

Return parameter

Meaning

0

Incorrect parameter values. destAddr == 0 or srcAddr==0 or n == 0

> 0

If successful, the number of bytes copied (n).

 

Example of a call in FBD

VAR
    Buffer1    : ARRAY[0..3] OF BYTE;
    Buffer2    : ARRAY[0..3] OF BYTE;
    CpyResult  : UDINT;
END_VAR

 

MEMCPY 2:

In the example, 4 bytes are copied from Buffer2 to Buffer1.

Requirements

Development environment

Target system type

PLC libraries to include

TwinCAT v2.7.0

PC or CX (x86)

PLCHelper.Lib

TwinCAT v2.8.0

PC or CX (x86)

TcSystem.Lib

TwinCAT v2.10.0 Build >= 1301

CX (ARM)

TcSystem.Lib