bbosse Posted April 18, 2019 Share Posted April 18, 2019 Hello there! I'm trying to log data for 10 seconds every 10 minutes - each 10 seconds of data saved to its own separate file. So I have 2 problems with my script pasted below: 1) For some reason the file will have the first 6 or 7 seconds of data and not the entire 10 seconds 2) but even more annoying is that when the 10 minutes is up and it is supposed to switch to a new file, for some strange reason it records the first second or two in the previous file before finally making the switch to a new file. It's like it starts logging in the file from 10 minutes ago for a second or two before finally opening a new file to begin logging. I've tried troubleshooting this in a variety of ways but still have been unable to get 10 seconds of data to save in its own file every 10 minutes. Any help is appreciated, thank you. Logging.DataLog.FileName = "D:\ALT DAQFactory Saves\ALT_" + formatDateTime("%y%m%d_%H%M%S", systime()) + ".csv" beginlogging(DataLog) // Loop to read stream data and append it to the DF Channels. while(1) dataIn = LJM_eStreamRead(identifier) if (systime() <= timestamp + 10) // If the first 10 seconds of every 10 minutes, log the data - otherwise don't read the data data = insertTime(dataIn.data.AIN0, st, 1 / scanRate) Channel0.AddValue(data) // Needs to match channel defined in "Channels". data = insertTime(dataIn.data.AIN1, st, 1 / scanRate) Channel1.addValue(data) data = insertTime(dataIn.data.AIN2, st, 1 / scanRate) Channel2.addValue(data) data = insertTime(dataIn.data.AIN3, st, 1 / scanRate) Channel3.addValue(data) data = insertTime(dataIn.data.AIN4, st, 1 / scanRate) Channel4.addValue(data) data = insertTime(dataIn.data.AIN5, st, 1 / scanRate) Channel5.addValue(data) data = insertTime(dataIn.data.AIN6, st, 1 / scanRate) data = data*55.45 - 17.78 // Convert channel voltage from mV to degrees C Channel6.addValue(data) data = insertTime(dataIn.data.AIN7, st, 1 / scanRate) data = data*55.45 - 17.78 // Convert channel voltage from mV to degrees C Channel7.addValue(data) endif if (systime() >= timestamp + 600) // dont log data for next 10 minutes (600 seconds) // From the DAQFactory Manual: "changing the file name while the logging or export set is running will close the current file and open the new file" // We change the filename for each new 10 minute interval of data Logging.DataLog.FileName = "D:\ALT DAQFactory Saves\ALT_" + formatDateTime("%y%m%d_%H%M%S", systime()) + ".csv" timestamp = systime() // 10 minutes complete - reset timestamp to current system time saveCount += 1 // 10 minutes completed! - update saveCount endif st += scansPerRead / scanRate backlog = dataIn.ljmscanBacklog timeLeft = 600 - (systime() - timestamp) endwhile Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.