LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Data acquisition set for 1 second is periodically skipping a second

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.

 

0 Kudos
Message 1 of 15
(3,244 Views)

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.

Second Stepper.png

0 Kudos
Message 2 of 15
(3,238 Views)
A wait with a single sample read is imprecise unless you are on s real time os. If the hardware supports it, you can configure a hardware timed single point acquisition. Any hardware timed acquisition will work such as 1000 samples/second and 1000 samples. Be sure to use continuous mode.
0 Kudos
Message 3 of 15
(3,232 Views)

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.

 



0 Kudos
Message 4 of 15
(3,179 Views)
Please read what I said and implement hardware timed acquisition and forget about using the wait function of you really care about precise timing.
0 Kudos
Message 5 of 15
(3,170 Views)

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.

0 Kudos
Message 6 of 15
(3,165 Views)
Sorry, I assumed you were using better hardware.

You'll need to check with the vendor for a function that acquires multiple points at a time.
Message 7 of 15
(3,159 Views)

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.

0 Kudos
Message 8 of 15
(3,147 Views)

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.

0 Kudos
Message 9 of 15
(3,137 Views)
I think you should try the wait ms multiple function. This is by no means perfect but will probably do for you. It will keep much better time.
0 Kudos
Message 10 of 15
(3,122 Views)