Introduction
This guide demonstrates how to utilize Window’s built in FTP client to automatically download and delete files from the NB Screen’s FTP server via script and Windows Task Scheduler.
Pre-Requisites
OMRON NB Designer Knowledge
Further Reading
OMRON NB Designer Operations Manual
Microsoft Windows FTP Command Reference
Procedure
Step1 - NB Configuration
For this example the NB IP address is set as default: 192.168.250.2
FTP is enabled with default password 888888
Under Event History Setting:
Save to external memory: Enabled
Export to CSV file: Enabled
Subfolder: Event
Storage Type: Daily File
Step 2 - Creating the FTP Script and Batch Files
Choose or create a folder as a destination to receive the files from the OMRON NB screen via FTP.
For this example C:\Users\User\Desktop\FTP (a folder named FTP on the desktop)
In this folder, create a new text file and name it - ftpscriptdownload.txt
Enter the following text and save the text file
open 192.168.250.2 root 888888 cd usb1/event/event ls mget *.csv mdel *.csv quit
As shown in the image below
Line | Description |
---|---|
open 192.168.250.2 | Login to ftp server with IP address 192.168.250.2 |
root | Login with username root |
888888 | Login with password 888888 |
cd usb1/event/event | Change the to the directory where the history files are to be downloaded from (usb) |
ls | Lists all the files with the current directory of the FTP server |
mget *.csv | multiple gets or copies files from the FTP server with names from the (ls) list ending with suffix .csv |
mdel *.csv | multiple deletes files from the FTP server with names from the (ls) list ending with suffix .csv |
quit | closes the FTP connection and exits |
Create a new text file and add the contents below
@echo off ftp -i -s:ftpscriptdownload.txt
Save this as a batch file by typing in the diesired name with a .bat suffix. For this example filedownload.bat was used.
The folder should now have two files: filedownload.bat and ftpscripdownload.txt
When filedownload.bat is executed, this file will run the ftpscriptdownload.txt script. This will download all the .csv files from the OMRON NB screen into the same folder. It also deletes all the files on the usb connected to the OMRON NB screen to make space.
Step 3 - Task Scheduling
Open the Task Scheduler app on the Windows PC and click on Create Basic Task...
Give the task a name, in this example DownloadEventHistory.
Select the task's trigger, when the task will execute. For this example Daily
Go through the Create a Basic Task Wizard, Choose a particular time. Next
Select Start a program. Next
For Program/script: click on Browse and locate the filesdownload.bat. For this example it is located in the C:\Users\User\Desktop\FTP\filedownload.bat.
For Start in (optional): C:\Users\User\Desktop\FTP
Click Next, then Finish
Under Active Tasks search for the newly created task DownloadEventHistory and double-click it to open its Properties
Take note on how the tasks run and make changes accordingly. The properties window also allows the user to make edits on when or how often the tasks need to run.
For example, for this task to run - Run only when user is logged in - the user will have to be logged in at the trigger time for it to work.
Another example would be under the Conditions tab. The task will only run if the computer is on AC power (under the Power section)
The tasks will now run automatically provided that the above as been considered and actioned.