warthur Posted April 7, 2020 Share Posted April 7, 2020 I have been building a program in DaqFactory for a while and recently noticed that the data that it logs, though it looks right and seems to last for the time I tell it to, only shows exactly 1 second less than what I told it to do. The code that I use is as follows: The following is in a script that runs when the program opens Global Duration The user inputs the amount of time they want to test in an Edit box component on the main page which is connected to the variable "Duration" The following runs within a switch statement and after some code to make sure it start when I want it to. while (filedone == 0) If (File.GetFileExists("C:\Users\user\Documents\LabJack Files\H Skidmore Data\HData" + FileName + format("-%u",filenum) + ".csv") = 1) filenum = filenum + 1 Else logging.DataH.FileName = "C:\Users\user\Documents\LabJack Files\H Skidmore Data\HData" + FileName + format("-%u",filenum) + ".csv" filedone = 1 Endif endwhile Logging.DataH.Start() Status = 3 wait(Duration) logging.DataH.Stop() The first part is just for asigning the name of the file to log to, then it logs as you can see. Attached is a file I logged for what I thought was 2 seconds as well as the settings in my log set. MDatatest-1.csv Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted April 7, 2020 Share Posted April 7, 2020 Logging sets aren't designed to start/stop on a dime. This is due to optimization / alignment features. An export set of one line of data being triggered at an interval by a sequence is more reliable. Using File. functions is the best. Or for simplicity, just let the logging set run for two seconds longer than you want. Quote Link to comment Share on other sites More sharing options...
warthur Posted April 7, 2020 Author Share Posted April 7, 2020 Ok, but the data doesn't look like it started late or ended early. Otherwise I would have caught this problem much sooner. I was thinking that somehow it was counting time wrong, maybe? In order to do an export set, do I have to put it in a loop something like export.[exportset].start(0) or can I do something like export.[exportset].start(500) for the last 500 points? thanks, Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted April 7, 2020 Share Posted April 7, 2020 The export set will have channels with [0] after to only write one line at a time, then do: export.myExport.start() at whatever interval you want to log. It will then write one line and stop, so you don't stop it yourself. Put that inside a loop. But it may not be able to handle 100hz. Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted April 7, 2020 Share Posted April 7, 2020 And it is not that it is starting late or ending early, it is that when you start it, it doesn't actually start writing data for a short bit, and likewise, when you stop it, there may be data queued up in memory for alignment that is never logged. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.