Matthew Page

Omron NA Copy Files from USB to FTP

13 posts in this topic

Please can someone assist me with a project we are working on. We use NA HMIs to log data to a USB drives. Our client requires access to these files via FTP. The HMI has an FTP area that can be accessed however there is no direct way of copying these folders between locations. I can run some VB script in the background and trigger the sub routine from the PLC.

Not knowing anything about VB scripts I'm struggling to get this to work.

This code only works if the date is included IO.DirectoryInfo("\UsbDisk\Data Logging\Log Files\DataSet0\yyyymmdd") a new folder is created every night at midnight with a new date. so having a fixed date will only work for that day. Ideally I want the to copy everything from (UsbDisk\Data Logging\Log Files) ignoring the (DataSet0\yyyymmdd")

'Code behind Page - Add local subroutines for the page.

Sub Test

Dim di As New IO.DirectoryInfo("\UsbDisk\Data Logging\Log Files\DataSet0\20191127 ")

Dim Diar1 As IO.FileInfo() = di.GetFiles()

Dim dra As IO.FileInfo

 

For Each dra In Diar1

System.IO.File.Copy(dra.FullName, "\User\SysmacHMI\FTP\" + dra.Name,True)

 

Next

End Sub

Share this post


Link to post
Share on other sites

Anyone come up with a solution to this? I'm also trying to access data logs via FTP.

Share this post


Link to post
Share on other sites

I tried to do it, I manage to copy the folders and files from each folder, but not yet the sub-folders .

rob5029 , what do you want to do ?

 

Share this post


Link to post
Share on other sites

We have some data logs running on the HMI, at present I have to go to site and remove the memory card from the HMI to transfer the files to my laptop.

With the older NS screens you can FTP direct to the memory card, and download the files remotely. On the NA they have a dedicated FTP folder, and only files within that folder can be accessed remotely, and there is no option to save the log files direct to the FTP folder.

I spoke to Omron technical help and they sent me this:
https://www.support-omron.fr/details/iag.php?id=2017-03-09%20-%2014-57-37%20-%201628257134

Which should give the ability to copy the contents of the SD card to the FTP folder and visa versa, I haven't tried it yet so not sure if it works. But you would have to use the VNC interface to remote control the HMI and navigate to the screen that this function block has been inserted on and manually execute the command prior to FTP download.

I'm waiting for a new HMI to be delivered so I can try this on a test bench rather than on the live plant.

Cheers
Rob.

Share this post


Link to post
Share on other sites

may be  you can copy the log files every day or week by a subroutine to the ftp .

i don't know how work VNC but that's true you can copy files of SD to FTP or USB .....

 

Share this post


Link to post
Share on other sites

I bet you can write a script the copies files between USB/SD/FTP directory. 

That IAG for file manager works great, I have used it to get files from a USB onto the SD card many times.  I added a USB port on the front of my demo, cabled to the back of the HMI, and the HMI has an SD installed. 

I made a project that has the IAG full screen.  I use the backup/restore function in the HMI to load it from the SD card.  Then I plug a USB drive into the extension cable on the front of the machine, copy the files I need, and then use backup/restore to put the HMI project back.  Obviously you can put the IAG into a page in the HMI, like a maintenance page, and load it from there, but I have 8 different projects I switch the HMI between and didn't want to update them all.

Share this post


Link to post
Share on other sites

Here an example to copy file received on NA5 FTP from external client to NA5 program:

Sub FTPCopyFile(filename As String)
	If System.IO.File.Exists(filename) Then
		System.IO.File.Copy(System.IO.Path.Combine("\User\SysmacHMI\FTP\", filename), System.IO.Path.Combine("\User\SysmacHMI\", filename), True)
		System.IO.File.Delete(System.IO.Path.Combine("\User\SysmacHMI\FTP\", filename))
	End If
End Sub

To specify a device with an absolute path, place "\" before the name. (eg. \UsbDisk\Sample.csv)

Name Supported version Description
UsbDisk V1.00 Signifies the USB Memory inserted in USB Host Port 1.
UsbDisk2 V1.00 Signifies the USB Memory inserted in USB Host Port 2.
SDCard V1.00

Signifies an SD Memory Card.

FTP

V1.03 Signifies the folder that can be accessed externally via FTP.

Share this post


Link to post
Share on other sites
On 2.12.2020 at 4:58 PM, Crossbow said:

I bet you can write a script the copies files between USB/SD/FTP directory. 

That IAG for file manager works great, I have used it to get files from a USB onto the SD card many times.  I added a USB port on the front of my demo, cabled to the back of the HMI, and the HMI has an SD installed. 

I made a project that has the IAG full screen.  I use the backup/restore function in the HMI to load it from the SD card.  Then I plug a USB drive into the extension cable on the front of the machine, copy the files I need, and then use backup/restore to put the HMI project back.  Obviously you can put the IAG into a page in the HMI, like a maintenance page, and load it from there, but I have 8 different projects I switch the HMI between and didn't want to update them all.

Hello,

first time implementing an IAG and I can't get the filemanager running.

I do have an datalog running which is saving on the SD Card and I have to move it to the FTP to access it.

So the filemanager IAG seems to have a problem with the detection of the SD-Card. Do I have to declare some special variables that I am missing?

I can't see any codes in the IAG - is this a normal thing or is something wrong?

 

Edited by HulleFu

Share this post


Link to post
Share on other sites

I have found that the file manager will only detect the SD card if there is also a USB stick present. In future I'll just save to USB

The IAG has the ability to delete files, but it appears that it leaves the directories there, would be good if there was the option to delete the directories as well (would be even better if Omron allowed the log to be saved directly to the FTP area!)

Share this post


Link to post
Share on other sites

As soon as I read your post this morning I tried to plug in an USB-Stick and the file manager detected the SD-Card. Thank you for that.

For the future I use an USB-Stick and not the SD-Card.

The best solution would be that we have the ability to access the SD-Card or USB Stick directly via ftp. (kind of like in the machine controllers)

 

Share this post


Link to post
Share on other sites

Here is how i solved it. It transferes files from the SD-card to a subfolder in the FTP directory. It cleans up old empty folders as well. 

Sub CopyLogToFTP
	Dim sourceDirectory = "\SDCard\Dataset0\"
	Dim targetDirectory = "\User\SysmacHMI\FTP\"


	For Each folder As String In System.IO.Directory.GetDirectories(sourceDirectory)
		Dim folderDate = System.IO.Directory.GetCreationTime(folder)

		For Each file As String In System.IO.Directory.GetFiles(folder)
			Dim fileName = System.IO.Path.GetFileName(file)
			Dim fileCreationDate As String = System.IO.File.GetCreationTime(file).ToString("yyMMdd")
			Dim datePath As String = System.IO.Path.Combine(targetDirectory, fileCreationDate)
			Dim fullPath As String = System.IO.Path.Combine(datePath, fileName)

			If System.IO.Directory.Exists(datePath) Then
				Else
					System.IO.Directory.CreateDirectory(datePath)
			End If
		
			If System.IO.File.Exists(fullPath) Then
				Else
					System.IO.File.Copy(file, fullPath)
			End If
			
			System.IO.File.Delete(file)
		Next
		
		If folderDate.DayOfYear = DateTime.Today.DayOfYear
			Else
				System.IO.Directory.Delete(folder)
		End If
		
	Next

End Sub 

 

2 people like this

Share this post


Link to post
Share on other sites

Thanks ECKO, 

It is working. You saved my lot of time. 

Share this post


Link to post
Share on other sites

Where i have worked.. on those machines that  as a full windows-ish version installed (like Panel PC's or regular PC+screen) we often install Filezilla Server, there you can mount other folders into the ftp folders, and inmy experience, simplifies everything, like having a vision camera ftp up an image to be stored for later reviews or logging image to database/datalake for legal tracabillity

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now