DataFileCopy: Copy File Commands
This function block copies memory data to a file and vice versa. The file is located either within the internal file system or an external file system (SD card).
The DataFileCopy function block can:
oRead data from a formatted file or
oCopy data from memory to a formatted file. For further information, refer to Flash Memory Organization.
Library name: PLCSystemBase
Namespace: PLCSystemBase
To see the general representation in IL or ST language, refer to the chapter Function and Function Block Representation.
This table describes the input variables:
Input |
Type |
Comment |
---|---|---|
xExecute |
BOOL |
On rising edge, starts the function block execution. On falling edge, resets the outputs of the function block when any ongoing execution terminates. NOTE: With the falling edge, the function continues until it concludes its execution and updates its outputs, which are retained for one scan, and are then subsequently reset. |
sFileName |
STRING |
File name without extension (the extension .DTA is automatically added). Use only a...z, A...Z, 0...9 alphanumeric characters. |
xRead |
BOOL |
TRUE: copy data from the file identified by sFileName to the internal memory of the controller. FALSE: copy data from the internal memory of the controller to the file identified by sFileName. |
xSecure |
BOOL |
TRUE: The MAC address is always stored in the file. Only a controller with the same MAC address can read from the file. FALSE: Another controller with the same type of memory can read from the file. |
iLocation |
INT |
0: the file location is /usr/DTA in internal file system. 1: the file location is /usr/DTA in external file system (SD card). NOTE: If the file does not already exist in the directory, the file is created. |
uiSize |
UINT |
Indicates the size in bytes. Maximum is 65534 bytes. Only use addresses of variables conforming to IEC 61131-3 (variables, arrays, structures), for example: Variable : int; uiSize := SIZEOF (Variable); |
dwAdd |
DWORD |
Indicates the address in the memory that the function will read from or write to. Only use addresses of variables conforming to IEC 61131-3 (variables, arrays, structures), for example: Variable : int; dwAdd := ADR (Variable); |
|
UNINTENDED EQUIPMENT OPERATION |
Verify that the memory location is of the correct size and the file is of the correct type before copying the file to memory. |
Failure to follow these instructions can result in death, serious injury, or equipment damage. |
This table describes the output variables:
Output |
Type |
Comment |
---|---|---|
xDone |
BOOL |
TRUE = indicates that the action is successfully completed. |
xBusy |
BOOL |
TRUE = indicates that the function block is running. |
xError |
BOOL |
TRUE = indicates that an error is detected and the function block aborted the action. |
eError |
Indicates the type of the data file copy detected error. |
NOTE: If you write to memory variable within the area of the file write, a CRC integrity error results.
This example describes how to copy file commands:
VAR
LocalArray : ARRAY [0..29] OF BYTE;
myFileName: STRING := 'exportfile';
EXEC_FLAG: BOOL;
DataFileCopy: DataFileCopy;
END_VAR
DataFileCopy(
xExecute:= EXEC_FLAG,
sFileName:= myFileName,
xRead:= FALSE,
xSecure:= FALSE,
iLocation:= DFCL_INTERNAL,
uiSize:= SIZEOF(LocalArray),
dwAdd:= ADR(LocalArray),
xDone=> ,
xBusy=> ,
xError=> ,
eError=> );