It is possible to generate a file with PLC data and attach it to an email or store it in the device memory.
The PLC can send data as user-defined text (TXT) or in a Microsoft Excel compatible file format (CSV). The range of the PLC data registers and the file name are defined in a tag with a special syntax. This tag is placed as a string in the PLC program and is read when the start of the operation has been recognized.
The maximum number of characters for the command tag (including the brackets) is 128.
The following commands are executed by the user-friendly function blocks of the FP-I4C Library.
The syntax examples show the command letters in bold print:
For CSV attachments: {A_D_00200_00066_S04_filename.csv}
For text attachments: {A_D_00200_00001_T01_filename.txt}
To read the contents of a line of a stored file (00200: string start address of the text to find, 00300: target address of the new text): {A_D_00200_00300_r01_filename.txt}
To replace the contents of a line of a stored file (00200: string start address of the text to find, 00300: target address of the new text): {A_D_00200_00300_m01_filename.txt}
To test if a file exists: {A_D_00200_00000_P01_filename.txt}
No data will be written to the PLC if the number of PLC registers is set to 0.
The tag must start with {A_
Example: {A_
Values:
Example: D_
Values:
CSV: First PLC register address to read
TXT: Start of Control FPWIN Pro7 string header
Example: 00200_
Values:
CSV: Number of PLC registers to read
Example: 00066_
TXT: Start of Control FPWIN Pro7 string header to read or to replace text with r or m; 00001_
to transmit data or 00000_
for a test command with P
Example: 00001_
Values:
CSV:
K,k: Cell terminator ',' (comma)
S,s: Cell terminator ';' (semicolon)
P: Restore an existing CSV file data from the data storage location back to the PLC.
F: Send a file from the data storage location via email.
D: Delete a file from the data storage location.
T,t: Write and forward a TXT file via email.
a: Append a string to an existing TXT file. If the file does not exist, a new file is created.
r: Search for a line that contains the text specified by Pointer to start of data 1.
Each line must be terminated with LF (line feed control code). If the text of data 1 begins with * (asterisk), the search text can be at any position within the line. The read result or error information is stored in data 2.
m*: Replace a line that contains the text specified by Pointer to start of data 1.
Each line must be terminated with LF (line feed control code). If the text of data 1 begins with * (asterisk), the search text can be at any position within the line. The replaced data or error information is stored in data 2. If data 1 is empty, a new line with data 2 is inserted at the line specified by Number.
Lowercase characters store the data without sending them via email.
Example: S
Values:
CSV: Number of CSV columns
01_
Example: 04_
Attachment file name up to the }
You can use file names with all characters that are typically allowed in file systems (including the blank). You may choose a different extension than TXT or CSV.
The delete operation allows using wildcards (*, ? but not the combination *.*) to remove a set of files.
Example: filename.csv