Removable Media Operations for IEC
See also: IEC 61131 Language Editor Programming
See also: Project Toolbox for IEC
Topic Menu
Home > View > Project Toolbox > Removable Media
Read from Static RM File 
Also called: Read_CF CF - CompactFlash - is a flash memory mass storage. Can also be referred to as RM - Removable Media.
Operator – Perform reading from a fixed File name on the Removable Media interface.
Inputs
EN : Enable input (TYPE : BOOL)
#TYPE: (TYPE : DINT) - This is the type of data that is read.
FILENAME: (TYPE : STRING) - This is the fixed filename to read the values from and enter into the controller.
OFFSET : (TYPE : DINT) - This parameter defines where in the file to start reading data. This can be a constant value or a 32-bit controller registers.
NUM: (TYPE : INT) - This determines the number of element to read. It should be a constant. Data Type is INT.
DEST[ ]: (TYPE : ANY[]) - This is a controller register where the read data is placed. Because each element can require more than one 16-bit registers (DINT Double Integer - [Data Type DINT] - A 32-bit signed value. Double Integers are used where the value of the data is expected to be in the range of -2,147,483,648 to +2,147,483,647., REAL
These numbers use IEEE 754-1985 format to store numbers in following ranges.
32-bit single-precision floating point (REAL) – -3.40282E+38 to +3.40282E+38
64-bit double-precision floating point (LREAL) – -1.79769E+308 to +1.7976E+308
Floating Point refers to both REAL and LREAL data types., UDINT
Unsigned Double Integer - [Data Type UDINT] - A 32-bit unsigned value. Unsigned Double Integers are used where the value of the data is expected to be in the range of 0 (zero) to 4,294,967,296., ASCII
ASCII - American Standard Code for Information Interchange - ASCII-coded characters are single-byte values in the range of 0 (zero) to 127. Codes in the range 128 to 255 are not defined by the ASCII standard, but rather by the equipment manufacturer. types) and more than one element can be read at a time this can fill a large number of registers from this starting point.
#FILETYPE : (TYPE : DINT) - This defines the extension of the file name.
Note: User should specify #filetype as either 0 or 1 depending upon the requirement.
0 = Bin filetype format
1 = CSV filetype format.
Outputs
STATUS : (TYPE : DINT) - This is a 32-bit controller register used to show the status of the function block. The first 16-bit register is a status code; see the possible status codes in the status section below. The second 16-bit register shows the number of elements successfully read
Remarks
1) FILENAME - This is a constant. It can be up to 147 characters long that includes sub directories (i.e. "my_data\test.csv"). File and directory names are limited to the old DOS 8.3 convention. This is 8 characters for the name and 3 characters for an extension with a period (.) separating them. See also: Filename Counters . String expressions must be written between single quote marks.
2) Status Values Returned by Removable Media Function Blocks
Value | Description |
---|---|
0 | Operation completed successfully |
-1 |
End of file was reached before completing |
-2 |
Function is active, waiting for operation to complete |
-3 |
Function is waiting on another RM function to complete |
-4 |
Function block is inactive (usually no power flow) |
1 |
Card present but unknown format |
2 |
No card in slot |
3 |
Card present, but not supported |
4 |
Card swapped before operation was complete |
5 |
Unknown error |
66 |
File / Path specified does not exist |
73 |
Bad file descriptor (corrupt file) |
77 |
Attempt to open / rename file that is open |
81 |
Specified file already exist |
86 |
Function block contains illegal parameter |
88 |
Too many open files* |
92 |
Attempt to write failed |
94 |
Sharing violation* |
95 |
No disk present* |
96 |
Directory structure corrupt |
98 |
Incorrect data format |
1000 |
List Bad Path (check for path, "\" must be used) |
1001 |
List Path too long |
1002 |
List Empty |
1003 |
List Permission |
1004 |
List wait update |
ST Language
(* RD is a declared instance of READ_RM function block *)
RD (EN, #TYPE, FILENAME, OFFSET, NUM, DEST[], #FILETYPE);
STATUS := RD.Status;
FBD Language
LD Language
IL Language
(* RD is a declared instance of READ_RM function block *)
NOTE: From FW 16.32 (XLPrime), FW 15.66 (IMX28) and FW 15.62 (XLPlus) onwards, for Enhanced IEC Removable Media Write and Read blocks -
Number of elements in Removable Media Write or Read blocks must be equal to or less than source or destination variable array size. If the source or destination variable array size is less than the number of elements to Write or Read then the block will return status values as 86 - Function block contains illegal parameter when executed.
Return to the Top: Removable Media Operations for IEC
Read from Variable RM Filename 
Also called: Read_CF CF - CompactFlash - is a flash memory mass storage. Can also be referred to as RM - Removable Media.2
Operator – Perform reading a comma separated value file from the Removable Media interface where the filename is obtained from OCS registers.
Inputs
EN : Enable input (TYPE : BOOL)
#TYPE: (TYPE : DINT) - This is the type of data that is read.
FILENAME: (TYPE : STRING) - This is the filename to read obtained from OCS registers.
OFFSET : (TYPE : DINT) - This parameter defines where in the file to start reading data. This can be a constant value or a 32-bit controller registers.
NUM: (TYPE : INT) - This determines the number of element to read. It should be a constant. Data Type is INT.
DEST[ ]: (TYPE : ANY[]) - This is a controller register where the read data is placed. Because each element can require more than one 16-bit registers (DINT, REAL, UDINT, ASCII types) and more than one element can be read at a time this can fill a large number of registers from this starting point.
#FILETYPE : (TYPE : DINT) - This defines the extension of the file name.
Note: User should specify #filetype as either 0 or 1 depending upon the requirement.
0 = Bin filetype format
1 = CSV filetype format.
Outputs
STATUS : (TYPE : DINT) - This is a 32-bit controller register used to show the status of the function block. The first 16-bit register is a status code; see the possible status codes in the status section below. The second 16-bit register shows the number of elements successfully read
Remarks
1) FILENAME - The filename is stored in contiguous block of OCS registers and has a limit of 147 characters and must be terminated with a NULL Null Termination - To place a NULL character (character code 0) at the end of ASCII data. Some functions require NULL Termination to be able to determine the end point of the ASCII data since that data may vary in length from one time to the next. (byte containing zero). A percent (%) symbol before the register name is required indicate the file is in a register. This shows that"%R1234" is a valid register reference. File and directory names are limited to the old DOS 8.3 convention. This is 8 characters for the name and 3 characters for an extension with a period (.) separating them. See also: Filename Counters . Data Type is USINT
Unsigned Short Integer - [Data Type USINT] - An 8-bit unsigned value. Unsigned Short Integers are used where the value of the data is expected to be in the range of 0 (zero) to 255. / BYTE: Unsigned 8 bit Integer. Unsigned small integer constant expressions are used valid integer values (between 0 and 255) and must be prefixed with "USINT#'.
2) Status Values Returned by Removable Media Function Blocks
Value | Description |
---|---|
0 | Operation completed successfully |
-1 |
End of file was reached before completing |
-2 |
Function is active, waiting for operation to complete |
-3 |
Function is waiting on another RM function to complete |
-4 |
Function block is inactive (usually no power flow) |
1 |
Card present but unknown format |
2 |
No card in slot |
3 |
Card present, but not supported |
4 |
Card swapped before operation was complete |
5 |
Unknown error |
66 |
File / Path specified does not exist |
73 |
Bad file descriptor (corrupt file) |
77 |
Attempt to open / rename file that is open |
81 |
Specified file already exist |
86 |
Function block contains illegal parameter |
88 |
Too many open files* |
92 |
Attempt to write failed |
94 |
Sharing violation* |
95 |
No disk present* |
96 |
Directory structure corrupt |
98 |
Incorrect data format |
1000 |
List Bad Path (check for path, "\" must be used) |
1001 |
List Path too long |
1002 |
List Empty |
1003 |
List Permission |
1004 |
List wait update |
ST Language
(* RD is a declared instance of READ_RM2 function block *)
RD (EN, #TYPE, FILENAME, OFFSET, NUM, DEST[], #FILETYPE);
STATUS := RD.Status;
FBD Language
LD Language
IL Language
(* RD is a declared instance of READ_RM2 function block *)
NOTE: From FW 16.32 (XLPrime), FW 15.66 (IMX28) and FW 15.62 (XLPlus) onwards, for Enhanced IEC Removable Media Write and Read blocks -
Number of elements in Removable Media Write or Read blocks must be equal to or less than source or destination variable array size. If the source or destination variable array size is less than the number of elements to Write or Read then the block will return status values as 86 - Function block contains illegal parameter when executed.
Return to the Top: Removable Media Operations for IEC
Write to Static RM Filename 
Also called: Write_CF CF - CompactFlash - is a flash memory mass storage. Can also be referred to as RM - Removable Media.
Operator – Perform writing a comma separated value onto a fixed File name on the Removable Media interface.
Inputs
EN : Enable input (TYPE : BOOL)
#MODE: (TYPE : DINT)
This is the writing mode for the function:
Create - create a new file, error if file DOES exist
Append - add data to end of existing file, error if file does NOT exist
Create / Append - create the file if it does not exist, append if the file does exist
Overwrite - if the file exists overwrite with a new file
#TYPE: (TYPE : DINT) - This is the type of data that is written. There is no type or size information encoded in a CSV file and it is the programmer’s responsibility to write data to a file using the correct type.
FILENAME: (TYPE : STRING) - This is the fixed filename to write the values from the controller.
SRC[ ] : (TYPE : ANY i.e. DINT[], REAL[], UDINT[], ASCII[] types) - This is a controller register where the data to write is located. Because each element can require more than one 16-bit registers (DINT, REAL, UDINT, ASCII types) and more than one element can be written at a time this can require a large number of registers from this starting point.
NUM: (TYPE : INT) - This determines the number of element to write it can be a constant or 16-bit controller register.
COL/ROW: (TYPE : INT) - This defines the format for writing data to the CSV file.
#FILETYPE: (TYPE : DINT) - This defines the extension of the file name.
Note: User should specify #filetype as either 0 or 1 depending upon the requirement.
0 = Bin filetype format
1 = CSV filetype format.
#END OF ROW: (TYPE : BOOL) - Setting this option will cause the row to end at the end of this write function.
Outputs
STATUS : (TYPE : DINT) - This is a 32-bit controller register used to show the status of the function block. It indicates the operation’s success/failure code. The first 16-bit register is a status code; see the possible status codes in the status section below. The second 16-bit register shows the number of elements successfully read.
Remarks
1) FILENAME - This is a constant. It can be up to 147 characters long that includes sub directories (i.e. "my_data\test.csv"). File and directory names are limited to the old DOS 8.3 convention. This is 8 characters for the name and 3 characters for an extension with a period (.) separating them. See also: Filename Counters
2 ) COL/ROW - This can be a constant. When a CSV file is written to a table format it can be viewed in a column / row format like a spreadsheet. Setting this parameter determines the number of elements to write in a row before a new row is started. Setting this value to zero will disable the generation of new rows and will generate all data as a single row.
Examples:
3 Columns Per Row | ||
---|---|---|
1 | 2 | 3 |
4 | 5 | 6 |
7 | 8 | 9 |
5 Columns Per Row | ||||
---|---|---|---|---|
1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 |
3) Status Values Returned by Removable Media Function Blocks
Value | Description |
---|---|
0 | Operation completed successfully |
-1 |
End of file was reached before completing |
-2 |
Function is active, waiting for operation to complete |
-3 |
Function is waiting on another RM function to complete |
-4 |
Function block is inactive (usually no power flow) |
1 |
Card present but unknown format |
2 |
No card in slot |
3 |
Card present, but not supported |
4 |
Card swapped before operation was complete |
5 |
Unknown error |
66 |
File / Path specified does not exist |
73 |
Bad file descriptor (corrupt file) |
77 |
Attempt to open / rename file that is open |
81 |
Specified file already exist |
86 |
Function block contains illegal parameter |
88 |
Too many open files* |
92 |
Attempt to write failed |
94 |
Sharing violation* |
95 |
No disk present* |
96 |
Directory structure corrupt |
98 |
Incorrect data format |
1000 |
List Bad Path (check for path, "\" must be used) |
1001 |
List Path too long |
1002 |
List Empty |
1003 |
List Permission |
1004 |
List wait update |
ST Language
(* WR is a declared instance of WRITE_RM function block *)
WR (EN, #MODE, #TYPE, FILENAME, SRC[], NUM, COL/ROW, #FILETYPE, #ENDOFROW);
STATUS := WR.Status
FBD Language
NOTE: Categories are abbreviated in example. Below are the full forms:
-
EN
-
#MODE
-
#TYPE
-
Filename
-
Src[]
-
Num
-
Col/Row
-
#FileType
-
#EndofRow
LD Language
NOTE: Categories are abbreviated in example. Below are the full forms:
-
EN
-
#MODE
-
#TYPE
-
Filename
-
Src[]
-
Num
-
Col/Row
-
#FileType
-
#EndofRow
IL Language
(* WR is a declared instance of WRITE_RM function block *)
NOTE: From FW 16.32 (XLPrime), FW 15.66 (IMX28) and FW 15.62 (XLPlus) onwards, for Enhanced IEC Removable Media Write and Read blocks -
Number of elements in Removable Media Write or Read blocks must be equal to or less than source or destination variable array size. If the source or destination variable array size is less than the number of elements to Write or Read then the block will return status values as 86 - Function block contains illegal parameter when executed.
Return to the Top: Removable Media Operations for IEC
Write to Variable RM Filename 
Also called: Write_CF CF - CompactFlash - is a flash memory mass storage. Can also be referred to as RM - Removable Media.2
Operator – Perform writing a comma separated value file to the Removable Media interface where the filename is to be obtained from OCS registers.
Inputs
EN : Enable input (TYPE : BOOL)
#MODE: (TYPE : DINT)
This is the writing mode for the function:
Create - create a new file, error if file DOES exist
Append - add data to end of existing file, error if file does NOT exist
Create / Append - create the file if it does not exist, append if the file does exist
Overwrite - if the file exists overwrite with a new file
#TYPE: (TYPE : DINT) - This is the type of data that is written. There is no type or size information encoded in a CSV file and it is the programmer’s responsibility to write data to a file using the correct type.
FILENAME: (TYPE : USINT) - This is the filename to write obtained from OCS registers.
SRC[ ] : (TYPE : ANY i.e. DINT[], REAL[], UDINT[], ASCII[] types) - This is a controller register where the data to write is located. Because each element can require more than one 16-bit registers (DINT, REAL, UDINT, ASCII types) and more than one element can be written at a time this can require a large number of registers from this starting point.
NUM: (TYPE : INT) - This determines the number of element to write it can be a constant or 16-bit controller register.
COL/ROW: (TYPE : INT) - This defines the format for writing data to the CSV file.
#FILETYPE: (TYPE : DINT) - This defines the extension of the file name.
Note: User should specify #filetype as either 0 or 1 depending upon the requirement.
0 = Bin filetype format
1 = CSV filetype format.
#END OF ROW: (TYPE : BOOL) - Setting this option will cause the row to end at the end of this write function.
Outputs
STATUS : (TYPE : DINT) - This is a 32-bit controller registers used to show the status of the function block. The first 16-bit register is a status code; see the possible status codes in the status section below. The second 16-bit register shows the number of elements successfully read.
Rename
1) FILENAME - The filename is stored in contiguous block of OCS registers and has a limit of 147 characters and must be terminated with a NULL (byte containing zero). A percent (%) symbol before the register name is required indicate the file is in a register. This shows that"%R1234" is a valid register reference. File and directory names are limited to the old DOS 8.3 convention. This is 8 characters for the name and 3 characters for an extension with a period (.) separating them. See also: Filename Counters
USINT - Unsigned Short Integer: An 8-bit unsigned value. Unsigned Short Integers are used where the value of the data is expected to be in the range of 0 (zero) to 255.
2 ) COL/ROW
This can be a constant. When a CSV file is written to a table format it can be viewed in a column / row format like a spreadsheet. Setting this parameter determines the number of elements to write in a row before a new row is started.
3) Status Values Returned by Removable Media Function Blocks
Value | Description |
---|---|
0 | Operation completed successfully |
-1 |
End of file was reached before completing |
-2 |
Function is active, waiting for operation to complete |
-3 |
Function is waiting on another RM function to complete |
-4 |
Function block is inactive (usually no power flow) |
1 |
Card present but unknown format |
2 |
No card in slot |
3 |
Card present, but not supported |
4 |
Card swapped before operation was complete |
5 |
Unknown error |
66 |
File / Path specified does not exist |
73 |
Bad file descriptor (corrupt file) |
77 |
Attempt to open / rename file that is open |
81 |
Specified file already exist |
86 |
Function block contains illegal parameter |
88 |
Too many open files* |
92 |
Attempt to write failed |
94 |
Sharing violation* |
95 |
No disk present* |
96 |
Directory structure corrupt |
98 |
Incorrect data format |
1000 |
List Bad Path (check for path, "\" must be used) |
1001 |
List Path too long |
1002 |
List Empty |
1003 |
List Permission |
1004 |
List wait update |
ST Language
(* WD is a declared instance of WRITE_RM2 function block *)
WD (EN, #MODE, #TYPE, FILENAME, SRC[], NUM, COL/ROW, #FILETYPE, #ENDOFROW);
STATUS := WD.Status
FBD Language
NOTE: Categories are abbreviated in example. Below are the full forms:
-
EN
-
#MODE
-
#TYPE
-
Filename
-
Src[]
-
Num
-
Col/Row
-
#FileType
-
#EndofRow
LD Language
NOTE: Categories are abbreviated in example. Below are the full forms:
-
EN
-
#MODE
-
#TYPE
-
Filename
-
Src[]
-
Num
-
Col/Row
-
#FileType
-
#EndofRow
IL Language
(* WD is a declared instance of WRITE_RM2 function block *)
NOTE: From FW 16.32 (XLPrime), FW 15.66 (IMX28) and FW 15.62 (XLPlus) onwards, for Enhanced IEC Removable Media Write and Read blocks -
Number of elements in Removable Media Write or Read blocks must be equal to or less than source or destination variable array size. If the source or destination variable array size is less than the number of elements to Write or Read then the block will return status values as 86 - Function block contains illegal parameter when executed.
Return to the Top: Removable Media Operations for IEC
Rename RM File 
Also called: Rename_CF CF - CompactFlash - is a flash memory mass storage. Can also be referred to as RM - Removable Media.
Operator – Perform renaming a file on the Removable Media card. The data in the file is not changed.
Inputs
EN : (TYPE : BOOL) - The rung state in a LD diagram is always Boolean. Blocks are connected to the rung with their input and output. The "EN" input is a trigger condition The block is executed only if EN is TRUE.
OLDNAME: (TYPE : STRING) - This is the original filename to rename.
NEWNAME: (TYPE : STRING) - This is the new filename. This can be a constant or a controller registers and has the same requirements as the old filename.
Outputs
STATUS : (TYPE : DINT) - This is a 16-bit controller registers used to show the status of the function block. The first 16-bit register is a status code. See the possible status value in the status section below.
Remarks
1) OLDNAME - The filename should be fixed (String) and cannot be obtained by reading from a contiguous block of registers in the OCS, and may includes sub directories (i.e. "my_data\test.csv"), Where a fixed string is used, it may be up to 147 characters long. File and directory names are limited to the old DOS 8.3 convention. This is 8 characters for the name and 3 characters for an extension with a period (.) separating them. See also: Filename Counters . USINT / BYTE: Unsigned 8 bit Integer. Unsigned small integer constant expressions are used valid integer values (between 0 and 255) and must be prefixed with "USINT#'.
2) Status Values Returned by Removable Media Function Blocks
Value | Description |
---|---|
0 | Operation completed successfully |
-1 |
End of file was reached before completing |
-2 |
Function is active, waiting for operation to complete |
-3 |
Function is waiting on another RM function to complete |
-4 |
Function block is inactive (usually no power flow) |
1 |
Card present but unknown format |
2 |
No card in slot |
3 |
Card present, but not supported |
4 |
Card swapped before operation was complete |
5 |
Unknown error |
66 |
File / Path specified does not exist |
73 |
Bad file descriptor (corrupt file) |
77 |
Attempt to open / rename file that is open |
81 |
Specified file already exist |
86 |
Function block contains illegal parameter |
88 |
Too many open files* |
92 |
Attempt to write failed |
94 |
Sharing violation* |
95 |
No disk present* |
96 |
Directory structure corrupt |
98 |
Incorrect data format |
1000 |
List Bad Path (check for path, "\" must be used) |
1001 |
List Path too long |
1002 |
List Empty |
1003 |
List Permission |
1004 |
List wait update |
ST Language
(* RENAME is a declared instance of RENAME_RM function block
RENAME (EN, OLDNAME, NEWNAME) ;
STATUS := RENAME.STATUS;
FBD Language
LD Language
ENO/Rung Power - This function passes power once the Status returns a 0, assuming power is still applied to the function. Should power be lost to the Rename function before it is finished, however, the function will still complete. The block is executed only if EN is TRUE then ENO also is TRUE. (i.e.) The "ENO" output always represents the same status as the "EN" input. Data type is BOOL.
IL Language
(* RENAME is a declared instance of RENAME_RM function block *)
Return to the Top: Removable Media Operations for IEC
Copy RM File 
Also called: Copy_CF CF - CompactFlash - is a flash memory mass storage. Can also be referred to as RM - Removable Media.
Operator – Performs copying of a file on the Removable Media card. The data in the file is not changed.
Inputs
EN : The rung state in a LD diagram is always Boolean Boolean- [Data Type BOOL] - A single bit, binary value, or register/variable. Boolean points have only two possible values, 'TRUE' or 'FALSE'.. Blocks are connected to the rung with their input and output. The "EN" input is a trigger condition The block is executed only if EN is TRUE (TYPE : BOOL)
Source: (TYPE: String) - This is the name of the file to be copied.
Dest: (TYPE: String) - This is the file which will be created containing the copied data
Outputs
STATUS : (TYPE : DINT Double Integer - [Data Type DINT] - A 32-bit signed value. Double Integers are used where the value of the data is expected to be in the range of -2,147,483,648 to +2,147,483,647.) - This is a 16-bit controller registers used to show the status of the function block. See the possible status codes in the status section below.
Remarks
1) Source & Dest - The filename should be fixed (String) and cannot be obtained by reading from a contiguous block of registers in the OCS, and may includes sub directories (i.e. "my_data\test.csv"), Where a fixed string is used, it may be up to 147 characters long. File and directory names are limited to the old DOS 8.3 convention. This is 8 characters for the name and 3 characters for an extension with a period (.) separating them. See also: Filename Counters
2 ) Status Values Returned by Removable Media Function Blocks
Value | Description |
---|---|
0 | Operation completed successfully |
-1 |
End of file was reached before completing |
-2 |
Function is active, waiting for operation to complete |
-3 |
Function is waiting on another RM function to complete |
-4 |
Function block is inactive (usually no power flow) |
1 |
Card present but unknown format |
2 |
No card in slot |
3 |
Card present, but not supported |
4 |
Card swapped before operation was complete |
5 |
Unknown error |
66 |
File / Path specified does not exist |
73 |
Bad file descriptor (corrupt file) |
77 |
Attempt to open / rename file that is open |
81 |
Specified file already exist |
86 |
Function block contains illegal parameter |
88 |
Too many open files* |
92 |
Attempt to write failed |
94 |
Sharing violation* |
95 |
No disk present* |
96 |
Directory structure corrupt |
98 |
Incorrect data format |
1000 |
List Bad Path (check for path, "\" must be used) |
1001 |
List Path too long |
1002 |
List Empty |
1003 |
List Permission |
1004 |
List wait update |
3) System Registers used with Removable Media
%SR175 Status - This shows the current status of the Removable Media interface.
0 |
Removable Media Interface OK |
1 |
Card Present but unknown format |
2 |
No card in slot |
3 |
Card present, but not supported |
4 |
Card swapped before operation was complete |
5 |
Unknown error |
6 |
Access Protected |
%SR176 Free Space - This 32-bit register shows the free space on the Removable Media card in bytes.
%SR178 Card Capacity - This 32-bit register shows the total card capacity in bytes.
ST Language
CP (CP_EN,'Testfile.csv','HORNER.csv') ;
Status := CP.Status;
FBD Language
LD Language
EN/Rung Power - This function passes power once the Status returns a 0, assuming power is still applied to the function. Should power be lost to the Copy function before it is finished, however, the function will still complete. The block is executed only if EN is TRUE. The output always represents the same status as the "EN" input. Data type is BOOL.
IL Language
Return to the Top: Removable Media Operations for IEC
Delete RM File 
Also called: Delete_CF CF - CompactFlash - is a flash memory mass storage. Can also be referred to as RM - Removable Media.
Operator – Perform deletion of a file on the Removable Media card.
Inputs
EN : The rung state in a LD diagram is always Boolean. Blocks are connected to the rung with their input and output. The "EN" input is a trigger condition The block is executed only if EN is TRUE (TYPE : BOOL)
FILENAME: (TYPE : STRING) - This is the filename to delete.
Outputs
STATUS : (TYPE : DINT) - This is a 16-bit controller registers used to show the status of the function block. See the possible status codes in the status section below.
Remarks
1) FILENAME - The filename should be fixed (String) and cannot be obtained by reading from a contiguous block of registers in the OCS, and may includes sub directories (i.e. "my_data\test.csv"), Where a fixed string is used, it may be up to 147 characters long. File and directory names are limited to the old DOS 8.3 convention. This is 8 characters for the name and 3 characters for an extension with a period (.) separating them. See also: Filename Counters
2 ) Status Values Returned by Removable Media Function Blocks
Value | Description |
---|---|
0 | Operation completed successfully |
-1 |
End of file was reached before completing |
-2 |
Function is active, waiting for operation to complete |
-3 |
Function is waiting on another RM function to complete |
-4 |
Function block is inactive (usually no power flow) |
1 |
Card present but unknown format |
2 |
No card in slot |
3 |
Card present, but not supported |
4 |
Card swapped before operation was complete |
5 |
Unknown error |
66 |
File / Path specified does not exist |
73 |
Bad file descriptor (corrupt file) |
77 |
Attempt to open / rename file that is open |
81 |
Specified file already exist |
86 |
Function block contains illegal parameter |
88 |
Too many open files* |
92 |
Attempt to write failed |
94 |
Sharing violation* |
95 |
No disk present* |
96 |
Directory structure corrupt |
98 |
Incorrect data format |
1000 |
List Bad Path (check for path, "\" must be used) |
1001 |
List Path too long |
1002 |
List Empty |
1003 |
List Permission |
1004 |
List wait update |
3) System Registers used with Removable Media
%SR175 Status - This shows the current status of the Removable Media interface.
0 |
Removable Media Interface OK |
1 |
Card Present but unknown format |
2 |
No card in slot |
3 |
Card present, but not supported |
4 |
Card swapped before operation was complete |
5 |
Unknown error |
6 |
Access Protected |
%SR176 Free Space - This 32-bit register shows the free space on the Removable Media card in bytes.
%SR178 Card Capacity - This 32-bit register shows the total card capacity in bytes.
ST Language
(* DELETE is a declared instance of DELETE_RM function block *)
DELETE (EN, FILENAME);
STATUS := DELETE.STATUS;
FBD Language
LD Language
ENO/Rung Power - This function passes power once the Status returns a 0, assuming power is still applied to the function. Should power be lost to the Rename function before it is finished, however, the function will still complete. The block is executed only if EN is TRUE then ENO also is TRUE. (i.e.) The "ENO" output always represents the same status as the "EN" input. Data type is BOOL.
IL Language
(* DELETE is a declared instance of DELETE_RM function block *)
Return to the Top: Removable Media Operations for IEC
Filenames - RM Function Blocks
See also: Filename Counters
The OCS Removable Media function blocks support the flash with a DOS/Windows standard fat-16 file system. All names must be limited to the "eight dot three" format where the filename contains eight characters a period then a three-character extension. The entire filename including any path must be less than or equal to 147 characters. When creating filenames and directories it is sometimes desirable to include parts of the current date or time. There are six special symbols that can be entered into a filename that are replaced by the OCS with current time and date information.
Symbol | Description |
---|---|
$Y | Substitutes the current 2-digit year, ex. 2004 = 04 |
$M |
Substitutes the current month with a 2-digit code, ex. March = 03 |
$D |
Substitutes the current 2-digit day, ex. 22nd = 22 |
$h |
Substitutes the current 2-digit hour in 24-hour format, ex. 4pm = 16 |
$m | Substitutes the current 2-digit minute |
$s |
Substitutes the current 2-digit second |
$p |
Substitutes the currently displayed 4-digit screen number (1-1023) (Intended mainly for screen capture), ex. Screen 53 = 0053 |
The following are examples of the substituted time/date filenames:
Current date and time: March 1, 2004 3:45:34 PM
Filename: Data$M$D.csv = Data0301.csv
Filename: Year$Y\Month$M\aa$D_$h.csv = Year04\Month03\aa01_15.csv
Filename: Month_$M\Day_$D\$h_$m_$s.csv = Month_03\Day_01\15_45_34.csv
NOTE:
-
The user MUST specify the filename extension like .csv, .pgm, .bmp or .jpeg. It is not automatically added.
-
All the symbols start with the dollar sign ($) character. Date symbols are in upper case, time symbols are in lower case.
-
In order to use the above six special symbols in IEC, user must configure an extra $ sign ($ is the escape character used in IEC to allow user to enter an hexadecimal
A base-16 numbering system which uses the symbols 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F for numeral. code directly in the string) as shown in example below:
Current date and time:March 1, 2004 3:45:34PM
Filename: Data$$M$$D.csv = Data0301.csv
Filename: Year$$Y\Month$$M\aa$$D_$$h.csv = Year04\Month03\aa01_15.csv
Filename: Month_$$M\Day_$$D\$$h_$$m_$$s.csv = Month_03\Day_01\15_45_34.csv
Return to the Top: Removable Media Operations for IEC