Memory Management


Memory Management

Library contains a number of functions which provide direct access to memory areas in the PLC runtime system of the PLC Controller. Default editor includes the library by default.


The fact that these functions allow direct access to the physical memory of the PLC. Misuse of such functions can result in a system crash, or in access to forbidden memory areas. So we need to be careful when we are using these function.


MEMCMP Compares the values of variables in two memory areas


MEMCPY Copies the values of variables from one memory area to another


MEMSET Sets the variables in a memory area to a particular value

Memcpy example




org : DINT :=12;

dest : DINT :=13;

another : DINT := 14;

myTimer : TON;

startTimer : BOOL := FALSE;




myTimer(IN:= startTimer, PT:=T#1S);


MEMCPY(ADR(dest), ADR(org),4);

MEMCPY(ADR(another), ADR(dest),4);


IF myTimer.Q = TRUE THEN

myTimer(IN:= FALSE);

org:= org +1;