Home > Forum > Controllers SlimLine e Netsyst (LogicLab) > How to use the SDCard for saving log files
- This topic has 19 replies, 10 participants and was last updated 4 years, 11 months ago da Sergio Bertana.
-
AuthorPost
-
August 4, 2011 at 8: 44 am #35074Authorlessnot ready yet
I just upgraded the firmware on the CPU module SlimLine with the new version that supports the file system. I'm trying to make a simple program that saves data to an SDCard log file, but I can't get it to work. Can you give me some information?
August 4, 2011 at 8: 46 am #36879Sergio BertanaAdministrator ForumThe operating system of the SlimLine from version SFW167C100 (For upgrade see FAQ), supports the file system. Two directories are managed Storage (From 100 Kb) located on the EEPROM memory present on the CPU module, SDCard (Max 512 Mb) present on the SD Card that must be inserted in the CPU module. To access the directories it is necessary to perform the formatting, command Format by Telnet. For the complete list of Telnet commands refer to reference manual, the default login credentials for both Telnet and Ftp for the administrator are Username: admin, Password adminIn line with the Format command it is necessary to define the number of files accepted for each directory, up to a maximum of 12 total files. The first parameter refers to the files in Storage, the second to the files in SDCard (If not present, enter 0). Example, to have 2 files on storage and 4 on SDCard we will give the command Format 2, 4, if the command is executed correctly it will return the message Format Ok, Storage: 2 files, SDCard: 4 filesBy connecting to the SlimLine with an FTP client (Example fileZilla), it will be possible to view the tree of directories and access in reading and writing, creating, deleting, editing the files inside them (See screenshot).
August 4, 2011 at 10: 16 am #36880Sergio BertanaAdministrator ForumAs for your need to write a log file to SDCard, I created a simple LogicLab program (Download) that saves a named file CLog.txt, with inside 50 log records of the voltage value acquired by an analog input.
The file contains records saved in CSV format in order to be easily imported into Excel, each record contains 5 fields separated by ";" (Example: 01;12;12;03;01.8;). The 1st field is a progressive record from 0 to 49. The 2nd, 3rd, 4th field shows the hour, minutes, seconds of the record. The 5th field shows the voltage value acquired in volts.
Writing the log record is done by this program in ST (Listing), which "fills" the array LogRecord with log ascii string (5 fields separated by ";"). The function SysVarsnprintf writes the value followed by the terminator code "0", then it is necessary to start writing the next value at the position of the array where the previous writing has placed the terminator code.
Ended the log record, with the function Sysfseek, positioning is performed on the file in the write position, and with the function Sysfwrite writing is done.
June 25, 2012 at 10: 32 am #37297MicheleParticipantUo one SlimLine and I would like to use the SDCARD as a data logger, I saw on this Topic that we talk about SD Card max 512MB. Is this limit due to the use of the SD Card as SPI Flash or can I also use an SD Card with a size greater than 512?
Thanks as always for the valuable support of this forum and congratulations for the efficient management of the same.
June 25, 2012 at 11: 58 am #37298Sergio BertanaAdministrator ForumFile system management on the CPU module SlimLine ARM7 is limited, so a limit has been imposed on the maximum size of the SD Card that can be managed. SD Cards with a maximum size of 2Gb can be used but in any case the maximum size of the memory area managed by the file system is 512Mb.
September 9, 2014 at 2: 02 pm #38407OscarParticipantThanks for the tip, I tried to follow these steps but I encountered the following problems. I executed the command Format 4, 0 as reported in this post but I received an error message, then I ran the command Format Storage, 4 as Telnet command manual through Toolly. I read the command Dir Storage:
Directory of "Storage"
Space for 4 file (s) of 67254 byte eachI then tried to connect with FileZilla, configured according to the parameters you suggest, the connection is correctly established with the server, but in response I get the message that the PLC has no folders to make available. With explorer the ftp remains "hanging" without answers. I sent the proposed program, modifying
IF (SysClock1000 = Pulse) THEN RETURN; END_IF;
Pulse: = SysClock1000; (* Time base pulse *)
Fp: = Sysfopen ('Storage / CLog.txt', 'a'); (* Open the file in "append" mode. *)In
Time: = SysTime;
WHILE SysTime - Time <60000 DO END_WHILE; (* to write a line to the log every minute *)
Fp: = Sysfopen ('Storage / CLog.txt', 'a'); (* File pointer *)The rest remains unchanged. The writing 'Storage / CLog.txt', 'a' appears in red in the ST editor. I run the program in the Back task, in the Slow Task I have other programs that work correctly.
At this point the PLC freezes, the status goes to NOT RUN, I tried to send a previously working program but the USB connection was lost. I have turned off and powered up the PLC, the RUN LED starts flashing with a fixed sequence. After a series of attempts to restart and send programs I was able to restart it with an old program. I stopped here.
Could it be that the space in which to deposit the file is not correctly available? Can you tell me what I may have done wrong?
September 9, 2014 at 2: 45 pm #38408Sergio BertanaAdministrator ForumLet's try to answer your problems in order. The Format command from a certain version of the operating system has been modified, now you need to indicate which directory you want to format and how many files you want to leave space. So your command Format Storage, 4 format the Storage directory to contain 4 files that will divide the available space (as reported by the command YouI do not understand why the FTP client does not connect, you do not tell me what operating system you are using, with Total Commander and with the Windows 7 explorer that I usually use I have never had problems (Topic) possibly check if you have the latest version of the operating system. The mistake you made is very serious… you can never stop a PLC program in a closed loop. WHILE (SysTime-Time) <60000 DO END_WHILE; This causes the system watch dog to intervene and reinitializes the execution which closes again in the infinite loop and is reinitialized again. This blocks all system resources including communications (Topic). How does it come out ... after a certain number of restarts the system stops in sleep and so it is again possible to resume the connection and load a new program.
September 9, 2014 at 4: 30 pm #38409Sergio BertanaAdministrator ForumHow to solve the timing correctly, in the forum you will find endless examples of using the system time, here's how you can do it.
IF ((SysGetSysTime (TRUE) -Time)> 60000000) THEN
Time: = SysGetSysTime (TRUE); (* Time buffer (uS) *)
Fp: = Sysfopen ('Storage / CLog.txt', 'a'); (* Open the file in "append" mode. *)… Other program statements
END_IF;Note: The variable Time must be of type UDINT.
October 7, 2014 at 9: 03 pm #38452LuisParticipantGood morning, I wanted to make a datalogger with a PLC SlimLine to record the values of 4 analog inputs every 10 seconds in CSV format with the date (year, month, day, hour, minute, second) and make a file for each day. I need a little help.
October 8, 2014 at 8: 24 am #38453Sergio BertanaAdministrator ForumIf you download the program that you find in one of the posts of this topic you already have a good starting point. However starting from the program of the previous post I have prepared a program that realizes what you need, here is the print of the WriteLog program.
As you can see I have defined an array of strings for defining the days of the week, so it is possible to write a CSV file for each day (The file will have the name of the day). When the day changes, the file of the same day is deleted (this is the file of the previous week) and a new file of the day is created with the new data. This way you have one week to download the stored log files via FTP.
I created the log record in the format 2014-10-08 09:25:58;02.8;02.8;02.8;02.8, as you can see the date/time field is followed by the 4 analog values. In my example I perform a single analog acquisition for all 4 channels but I leave the task of carrying out the 4 acquisitions and reporting them in the record to you.
I believe that with this example together with the previous example you have all the information to create your own DataLogger. here is the source program.
October 25, 2014 at 6: 34 am #38476AuthorlessIdleThe example shown in the previous post is very fitting with the problem I have to face, the only objection is that I would like to store data for a period greater than a week. In one of the previous posts I read that SlimLine can manage up to 512MB of memory on SDCard with up to 64 files.
Having to store a log file composed of 7 REAL values (5 4-20mA signals and 2 values read by Modbus protocol) plus the data field in CSV format, how much space in terms of memory does each record to be historicized occupy?
Assuming to store a record every 10 seconds, would it be possible to make files with the values of an entire week (or even a month) and not just for a single day as in the example?
Another possibility seeing that SlimLine is accessible via FTP client, it would be possible to schedule a program on a PC that automatically reads the log files from the SlimLine and back it up on a server thus dramatically increasing the possibility of logging?
October 25, 2014 at 7: 23 am #38477Sergio BertanaAdministrator ForumI assumed a log record with the data you need (Date / time; 7 REAL values), the record is of the type:
25/10/2014 00:00:00;120.5;75.8;1200.0;145.76;1560.6;456.8;985.75
As you can see there are 64 bytes that we round up to 70. Considering a log every 10 seconds we will have 360 Records / Hour (Equal to 25Kb Hour). Even assuming a continuous log 24 hours a day and 24 days a month, we will have 31 records every month with an amount of data equal to 267840Mb. Formatting the SDCard to contain the 18 months we will have 12Mb of data available for each file as shown by the command:
Format SDCard 12
Are you sure? (Y, n)
Format Ok, Files: 12, FSize: 44738688, Time: 54.290 (mS)With regard to the solution you propose to read from a PC through an FTP connection the files from SlimLine, I would say that it is an excellent solution to ensure effective data backup in corporate storage. If you opt for this solution, I would keep the files on SlimLine smaller (So I would do a daily storage) and the central server can every day download the file of the previous day having in the SlimLine a lung of 7 days.
March 22, 2016 at 4: 17 pm #39475AlbertoParticipantAfter inserting the SDCard in the PLC, I formatted it directly on the PLC with the illustrated procedures and I used it to write data files, everything ok.
But now I would like to copy the files to a PC but inserted in the reader it is empty, in practice the PC does not see the stored files. What have I left out? The files are surely present on the SDCard.
March 23, 2016 at 8: 24 am #39476Sergio BertanaAdministrator ForumYou did everything correctly SlimLine to ensure the non-corruptibility of the data when the system is suddenly shut down, it uses a proprietary file system that is not recognized by the PC.
So to transfer data from the SDCard to the PC and / or vice versa you must use an FTP client (Topic) you can also use Windows Explorer (Screenshot).
June 17, 2016 at 8: 05 pm #39633AntonioParticipantHaving upgraded an old CPU slimline model A to the latest Firmware version (167) available I have completely lost the System folder which I cannot add in any way (in FTP with filezilla with resource management etc.) it always gives me access denied or operation not allowed.
Also connecting with Toolly and trying to format (even the only two folders present Storage and SDCard) gives me wrong parametrer (clearly the command is not wrong).
Is there a way to restore the entire FileSystem?
-
AuthorPost
- You must be logged in to reply to this topic.