12-11-2009 08:46 AM
Hi,
I have a time lag problem in my .vi. I have a producer loop which acquires data through the DAQ Assistant (16 analog channels, continuous acquisition, 100 samples, 1000 Hz). I have a Wait 100ms function in the loop.
I'm using a queue to transfer data to the consumer loop which does some calculations on the data. I noticed that when I run the .vi for a long time, the timestamp of the dynamic data (in the producer loop) starts lagging behind the system clock. The consumer loop is not to blame (as it shouldn't), since the queue size is always zero. If I overload the processor with other tasks, the queue fills up, but it clears steadily back to zero when I free up the processor. But when looking at the data on a chart, the effect of this lag is the same as it is when the queue is not cleared. The data doesn't catch up to "real time".
Any ideas what could be causing this? I don't know if this is relevant, but I initialize the queue with a scalar array, converted to dynamic data.
Thanks for all your help.
Tomaž
Solved! Go to Solution.
12-14-2009 01:16 AM
I tested my .vi on a different system and I get the same lag.
Anyone have a clue what's going on?
Thanks,
Tomaž
12-14-2009 07:43 AM
There could be many things going wrong, but we would need your code to determine which of them it is. Given the symptoms, my best guess is that your code is generating an initial timestamp and them simply adding to this as the data comes in. Mismatches in the timing circuits of the data acquisition card and your computer then result in the drift. Things which could contribute to this problem:
12-15-2009 01:11 AM
I seem to have found the problem. There was a Wait(ms) function left over in the producer loop. Removing that seems to have solved it. The DAQ Assistant was continuously acquiring data. I thought that even with the Wait(ms) function the loop would get the data packet with the timestamp of the query, but it seems that data is buffering and it just sends the next packet in the queue. Am I making sense?
12-15-2009 07:24 AM
12-17-2009 05:56 AM
12-17-2009 07:33 AM
12-17-2009 07:47 AM
Here's the code of the acquisition loop. In the second image, you can see that the dynamic data coming from the DAQ Asistant is "from the future".
12-18-2009 08:40 AM
Given the information I have, you are probably seeing a drift between the data acquisition clock (on the DAQ board) and the system clock (on the motherboard). However, the drift is a bit large (~0.4%/unit time). Older, uncalibrated hardware in either place could cause the issue. Do you sync the system time with an internet time server? If so, do you see similar drifts when you resync? If not, what DAQ board are you using? Has it been calibrated recently? Finally, as a long shot, what versions of the drivers are you using? I vaguely remember an issue several years ago where one of our drivers was doing something to the system clock. If your drivers are recent, this should not be an issue.