LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Unwanted time delay in while loop

Hi,
 
I am Xiaofei, a beginner of LabVIEW. Now we are trying to collect data from a probe using DAQassistant and DAQcard 6062E to detect displacement. And we want to collect the data at a fixed rate like 100Hz or higher. We meet a problem with the timing of loop. We first run our code outside a loop, there is no problem with timing, the data can be collected at the rate we set in the DAQassistant, but we have to set a sample number, which is unwanted. therefore we put it in a loop, then the problem comes: no matter what kind of loop we use( either while loop, simulation loop, or time loop), and no matter how big the value we set for the rate of the loops, there is always a time delay approximately 0.03 sec between loops, which is weird. I first thought i was the highest rate the computer could run, but now that when outside the loop the DAQassistant can collect data at the rate we want, it shouldn't be a limitation from the computer itself. Then i am really confused. If you know why, please tell me, i will be really grateful! If you know how to correct this delay or how to run DAQassistant outside a loop without a fixed sample number, that will be even more awesome.
 
Another question is about the waveform chart in a while loop. It runs well, but i just don't quite understand its time axis.  When the first time i run it, everything is perfect. But whenever i stop the code and then run it again, the time does not reset to 0 but start from the value at the last stop. Do you know why it's like this? Is there a way to reset the time? thanks a million!!!
 
regards,
Xiaofei
0 Kudos
Message 1 of 5
(3,049 Views)
When you initialize the DAQ hardware you define the size of the buffer to be associated with the acquisition process. The data will be acquired and put into that buffer with no gaps. In LV you simply read the buffer in a while loop. As long as you don't take so long between iterations that the buffer overflows you can be assured that the data is sampled properly.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 5
(3,046 Views)
Concerning your question about the chart graph, this is different fom the others in that it incorporates memory that doesn't get cleared automatically. You have to clear it yourself by either right-clicking on it and selecting Data Operations>>Clear Chart, or writing an empty array of the proper data type to the indicator's History Data property.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 3 of 5
(3,045 Views)

Thanks Mike!

So do you know if there is any other kind of plot i can use that can automaticly clear the memory and reset the time?

 

0 Kudos
Message 4 of 5
(3,031 Views)
Hi Xiao,

well, two options:
1) you may use a CHART and clear it at start of your vi - as suggested by Mike
2) you may use a GRAPH - this only plots the data you have wired to it, so you have to do the data collection on your own (using arrays/shift registers)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 5
(3,008 Views)