This tutorial describes the procedures to record Datalogger data to an external memory of the PLC, which will be configured as an FTP server and have its files remotely shared using FileZilla as the FTP client.
Components
Software: MasterTool IEC XE version 3.52
PLC: XP340 ; Firmware 1.14.20.0
Tutorial Sections
1. ARCHITECTURE
2. DEVELOPMENT
2.1. Configuring the FTP server
2.2. Configuring the Datalogger
2.3. Configuring the FTP client
1. ARCHITECTURE
For the development of this tutorial, the proposed architecture was to connect the Ethernet cable to the Xpress and then to the computer.
The version of MasterTool used was 3.52 and the PLC model is XP340 with firmware version 1.14.20.0. The Codesys libraries were updated for this version, but the way it was updated, when you update the project to a new version of MasterTool, the related libraries will update normally.
2. DEVELOPMENT
In this tutorial, you will learn how to use the Nexto Xpress Datalogger to record data to an external memory and configure an FTP client and server to access them remotely.
REMEMBER: The file developed for this example is available for download at the end of this tutorial.
2.1. Configuring the FTP server
To configure the FTP server, simply enter the IP address of your PLC in your browser and access its WebPage. There, you will find a settings menu. Go to "FTP Server", then check the option "Enable Server" and then click "Apply". Then, enter a username and a password, click on "Apply". In this case, "admin" was used as username and password.
2.2. Configuring the Datalogger
First, you need to import the "LibDatalogger" library.
Then, configure the "Datalogger" block according to the image below:
Input parameters
ENABLE:
The ENABLE parameter enables or disables the function block. The parameter is of type BOOL and takes the values TRUE and FALSE for on and off respectively.
FILE_NAME:
The FILE_NAME parameter is of type STRING and defines the file name (without the .csv) and allows a value of up to 20 characters. (If the parameter has more than 20 characters, the block will only consider the first 20 characters).
STORAGE:
This parameter is of type DATALOGGER_STORAGE and defines the device where the records will be stored. The value INTERNAL_MEMORY will store the data in the internal memory of the CPU and the value MEMORY_CARD will store the data on the memory card (when inserted). In Nexto Xpress, the value USB_MASS_STORAGE saves the data to the device connected to the USB port.
FILE_RECORDS:
Parameter of type UINT that defines the number of records that will be written to the file. Allowed value range: from 100 to 65535. This parameter is valid only for continuous mode.
NUMBER_OF_FILES:
Parameter of type UINT whose function is to define the maximum number of files to be stored. Allowed range: from 1 to 65535.
MODE:
This parameter of type DATALOGGER_MODE can take two values:
CONTINUOUS_MODE: The data is recorded and written to the log file continuously at a sampling interval defined by the user. The number of records per file is a maximum of 65535 (FILE_RECORDS) and a minimum of 100, with the file limit (NUMBER_OF_FILES) limited by memory or 65535 files, which is the maximum value the variable can take. This mode supports the CIRCULAR functionality, which will be explained later.
TRIGGER_MODE: Same as continuous mode, but data will only be written to the log file when a trigger occurs. When a trigger occurs, a new file is created, where records before and after the occurrence will be written, as defined by the user. It is possible to store 2001 records per file, i.e., 1000 records corresponding to TRIGGER_BEFORE, 1000 to TRIGGER_AFTER, and 1 at the moment of the trigger. In TRIGGER mode, the maximum number of files (NUMBER_OF_FILES) will also be limited by memory space and the variable limit, which is 65535 files. This is because each rising edge on the TRIGGER input creates a new file. This mode also supports the CIRCULAR functionality.
CIRCULAR:
Parameter of type BOOL that enables circular mode. It can take the values TRUE and FALSE for enabled and disabled respectively. Circular mode has the functionality that, after reaching the maximum number of files, it reopens the first file and overwrites it, i.e., the application always records in a way to keep the same number of files, thus, circular.
TRIGGER_BEFORE:
Of type UINT, defines the number of records before the trigger event that should be written to the file. Allowed value range: from 1 to 1000. Parameter valid only for trigger mode.
TRIGGER_AFTER:
Of type UINT, defines the number of records after the trigger event that should be written to the file. Allowed value range: from 1 to 1000. Parameter valid only for trigger mode.
TRIGGER:
External trigger input, activated by a rising edge. Type BOOL.
REC_INTERVAL:
Of type TIME, defines the interval at which data will be recorded. For TRIGGER mode, the value must be ≥ 10ms and for CONTINUOUS mode the value must be ≥ 100ms.
COMMA_DELIMITER:
Parameter of type BOOL, when its value is TRUE the columns of the CSV file are delimited by commas and the decimal point is a dot. Otherwise (value FALSE), the columns in the CSV file are delimited by semicolons, and the decimal point is a comma.
FILE_HEADER:
Of type STRING, defines the headers of the data that will be stored in the file. Mandatory field, with headers separated by semicolons. The maximum number of characters supported by this input is 3307.
INPUT1...INPUTN, N≤256:
Type REAL. Data input. The Datalogger supports up to 256 data inputs.
Output parameters
DONE:
This parameter of type BOOL returns TRUE if the function was executed and FALSE if the function was not executed.
BUSY:
Of type BOOL returns TRUE if the function is recording the data to memory and FALSE if the function is not recording the data to memory, or entered an error state.
ERROR:
Parameter that returns TRUE if an error occurs or the function is aborted and FALSE when there is no error. Parameter of type BOOL.
STATUS:
Indicates the status of the Datalogger. Type DATALOGGER_STATUS.
CURRENT_RECORDS:
Of type UDINT, indicates the number of records since the start of the process.
MISSED_TRIGGERS:
Counter of triggers ignored by the Datalogger during the period in which the function is running in trigger mode. Type UDINT.
2.3. Configuring the FTP client
First, before configuring an FTP client, you need to download and install the FileZilla Client.
Download link: https://filezilla-project.org/download.php?type=client
After installing the FileZilla Client, fill in the fields with the same data that was configured in the PLC Webpage.
Host: IP address of your PLC.
Username: name defined in the Webpage.
Password: password defined in the Webpage.
Port: you can leave it blank, but the default for FTP is 21.
Finally, click on "Quick Connect". A list of files will be displayed. The Datalogger data will be recorded on the PLC's external memory, represented by the folder "Mass_Storage".
Note: an error may occur when connecting between the FTP client and server. Make sure there is no active antivirus or firewall blocking port 21.
Comments
0 comments
Please sign in to leave a comment.