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:
Read data from a formatted file or
Copy data from memory to a formatted file. For further information, refer to Non-Volatile Memory Organization.
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. The outputs are retained for one cycle and 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:
|
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:
|
WARNING | |
---|---|
This table describes the output variables:
Output |
Type |
Comment |
---|---|---|
xDone |
BOOL |
|
xBusy |
BOOL |
|
xError |
BOOL |
|
eError |
Indicates the type of the data file copy detected error. |
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=> );