Creating Daily Log Files


teratrailer

Recommended Posts

I have a logging set which logs channels every 3 seconds to a csv file.

 

I have a sequence setup which renames the logging file destination to the current day on a delay(1) while loop (code below).

 

Problem:

My daily log files always contain a 1-2 data points from the next day at the end of the file. I don't understand why this is happening, my rename sequence is running every 1 second (with delay()), but I end up with datapoints from 0-6 seconds after midnight at the end of every log file, before the sequence causes the renaming to occur and data points get recorded to a new file. The sequence thread priority is set to "3-logging"

 

Sequence code:

while(1)
   logging.Daily_Log.strFileName = "D:\DAQFactory\Daily_Logs\daily_" + formatdatetime("%Y_%m_%d", sysTime()) + ".csv"
   delay(1)
endwhile

Example of the end of my daily log file for 2014-5-13:

Time                       Pressure	Temperature
2014/5/13 23:59:57	   123.23	76.2
2014/5/14 00:00:00	   123.21	76.23     (*this row should be at the start of the next file, not the end of the file for 2014-5-13))
2014/5/14 00:00:03	   123.23   	76.24

Link to comment
Share on other sites

First, if you are using 5.90, you can get it to autoname your files by using the same specifiers you would in formatdatetime.  So, in the logging file name for the logging set you could put:

 

D:\DAQFactory\Daily_Logs\daily_%Y_%m_%d.csv

 

If not, raise the priority level of your sequence, and drop the loop time to 0.1.  Also consider adding a dummy Test A to D channel that isn't included in the logging set.  This might help trigger the logging set to at least wake up and look at the time.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.