skyfox

Get file names from NX1P2 SD card into a string array?

8 posts in this topic

Is it possible to enumerate all the files in the SD card get their names into a string array?

File names will have the format...

RUN0001 data.csv

RUN0002 data,csv

.....

RUN9999 data.csv

I want to be able to first find the # of data files (get a count) and load the first ten file names it finds into an array and display those names on the HMI. User then presses a button on HMI and PLC gets the next 10 filenames to displays and so forth. All file names on the card will have the same name format (fixed length file names).

Can this be done with Sysmac studio and NX1P2? I did not find any SD function blocks that had this capability.

Cheers.

 

 

Share this post


Link to post
Share on other sites

I can send you sample Omron NX code that will generate a list of the files in a defined directory on the SD Card and put them into an array of strings. I also have a variable that will return the file count for you. I originally did the code in an NX102-1220 to test and then changed the device to an NX1P2. The only problem would be your request for 1 to 9999 files. With the NX102-1220 I set the read list array size to [0..10000] and it will work but with the NX1P2 there is not sufficient memory in the PLC to support those large arrays. I can limit the array size to [0..2000] and use up about half the PLC memory in the NX1P2. So depending on how big the rest of your program is that size may still not be practical.

I have tried many times but for some reason I have never been able to attach any files on this Forum. I always get an upload failed message. Just let me know if you want the sample code for getting the list of files. If you send me a message I can email you the file.

 

ON another note related to one of your posts about SD Card size, the last few years I have been using 16 GB and 32GB SanDisk Ultra (120 MB/s) SD cards on NJ and NX PLCs. I used a 32 GB in the NX102-1220 for testing the code I just did for returning the file list.

 

Share this post


Link to post
Share on other sites

Str8jCkt,

That would be awesome and thank you. My NXIP2 Array will still be say 20 elements. SD Card can have 1000 files; I only want to load 20 file names at a time using the same array. I will send you my email address as soon as I figure out how. Thank you so much. Your help is greatly appreciated.

Cheers.

 

Share this post


Link to post
Share on other sites

Hi @Str8jCkt,

I don't suppose you still have that sample code for listing files?

I'd be really interested in seeing it, I'm working on something now that needs this exact functionality.

Share this post


Link to post
Share on other sites
2 hours ago, Str8jCkt said:

The idea is ...

Clever!

Share this post


Link to post
Share on other sites
3 hours ago, Str8jCkt said:

@AlphaPapa here is the file i had reated.

The idea is to turn on the PLC ftp server. Then have the PLC ask itself what files are on the server directory (SD Card).

 

65ce1e46510c0_FTPServer.png.8e5d4a02ea8b

R&D - ReadSDFileList.smc2

You can also use the loopback address (127.0.0.1) and this will make it so that changing your PLC's IP address won't break your code.

Share this post


Link to post
Share on other sites

Thanks for sharing.

After i saw you're post i was wondering how on earth you'd done it and then had the same idea, also using the loopback address. 

 

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