07-15-2014 05:02 PM - edited 07-15-2014 05:05 PM
I have data that needs to be recorded every second, so I put in a wait timer for 1000 ms. After reviewing my data I found that it would skip a second here or there and was therefore not continuous. I need the data to be continuous so that I can upload it to a server that operates off of UTC time down to the second. It could be the case that each point is off by a tenth of a millisecond and causes each point to be off by more and more. I'm not sure how to deal with this.
Code is attached. It is the first while loop at the top that I am concerned about, (SO2) readings.
07-15-2014 05:08 PM - edited 07-15-2014 05:16 PM
From the sounds of this the problem is most likely that you are waiting 100ms, but your code can take 5-20ms to run, therefore every 50-200 samples you will miss a second completely. The best way to resolve this would either to be to use the DAQ inbuilt timing to ensure the 1Hz measurement freq or taking on demand samples, this could be done by setting the wait to 200 ms and then checking whether the program has entered a new second, if it has not then simple wait until checking again.
If you really need the program to have a longer wait you should be able to run the program up to about 800 ms wait between checking samples, as long as the Wait Delay+operation time < 1 second you should be able to sample every second.
07-15-2014 05:16 PM
07-16-2014 12:22 PM
I tried constructing the Second Stepper you posted. Is the feedback node supposed to be linked to the wait VI somehow? If so I'm not sure how to do that. Also, should the second stepper be in its own while loop inside my SO2 VI while loop? Currently it is just functioning like a typical wait VI would.
07-16-2014 01:08 PM
07-16-2014 01:18 PM
Dennis,
I took your option into consideration, but I have no idea how to do that. My code shows that I'm simply reading a voltage (through a labjack) and recording the time every time the loop executes and writes that voltage to a file. There is no formal DAQ system so I'm not sure if I'm even able to accomplish what you suggested.
07-16-2014 01:25 PM
07-16-2014 02:16 PM
Which LabJack are you using?
Once a second seems like a really easy interval to hit 100% of the time even on a busy Windows machine. In fact, not only would I expect you to hit every interval but would also expect just a few milliseconds of jitter on the 1000ms interal. How often do you miss a second?
For comparison try running LJLogUD.exe with Interval=1000 and see if it ever misses an interval.
I don't have convenient access to LV2012 right now. Can you post a screenshot so we can see what you are doing?
All LabJacks support hardware timing (stream mode), but 1 scan/second is really slow for that. You can certainly do it, but I would expect a software timed loop to be fine.
07-16-2014 03:50 PM
The intention was to use the second stepper as a trigger for a case structure, so that when the LED went on it would indicate that a sample was being taken and while the LED is off it is waiting for the current second to change.
Using a LabJack system however, why do you not simply use DAQFactory to build a simple logger, the DAQFactory program is fairly simple to use and can interface with LabJack hardware pretty well so you may be able to figure the hardware timing from within the program.
07-16-2014 04:46 PM