1 Second Missing


warthur
 Share

Recommended Posts

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

MLogging.PNG

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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,

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share