LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

timed while loop

"I am trying to read in from a DAQmx card and periodically write to a file.  i tried encasing the write vi in a timed loop, however this seems to cause a delay to my entire program  I was wondering if there is some way to isolate the timed loop from the while loop.  Thanks"
 
 
I have exactly the same problem. My program reads several times in a row from a DAQmx card and I used a timed loop to do so. Quite often the whole Labview process stops for more than 2 seconds while processing this timed loop. Even other loops running at the same time with higher priority are affected and pausing completely.
 
The interval in the timed loop is 10ms and i read one single voltage value from daq.
 
When i replace the timed loop with a while loop and add a 10 ms wait in the loop, the problem is gone.
 
Why?
0 Kudos
Message 11 of 17
(1,054 Views)
Sfreitag:

It is very strange that you are experiencing a similar issue with timed loop. Conceptually, the timed loop should behave like a while loop with a timer inside. The advantage is that, with timed loops you can develop applications with multi-rate timing capabilities. It would greatly be helpful if you could post your VI or a screenshot, so that I can figure out where the issue might be.

Regards,

Rudi N.
0 Kudos
Message 12 of 17
(1,033 Views)

Yes, indeed it is very strange.

I have attached three files for you.

I     while.vi  My program with a ordinary while loop and a 10 ms wait.

II    timed.vi My program with a timed loop with 10 ms loop frequency.

III   indicator.vi A normal timed loop to detect the "hangups.

LabView 8.0

Just run I+III simultaneously or II+III simultaneously and watch the counter in III panel for a few minutes. At my PC the counter stops for up to 10 seconds(when running II and III)from time to time and then continues. The priority of IIIs timed loop is higher than IIs.(I just use the "run continuously" funtion, to run I or II, to reproduce this issue. However in a more sophisticated test, I can also reproduce it overnight with a decent pause between the subsequent calls of II.)

Regards

Sebastian F.

 

*edit* clarification of some issues(I am not native english speaker, so I found some errors...)

Message Edited by Sfreitag on 01-12-2007 07:09 AM

Message Edited by Sfreitag on 01-12-2007 07:10 AM

Download All
0 Kudos
Message 13 of 17
(1,016 Views)
Sfreitag,

I tried running your VIs as you said but I was unable to see any delay.

One thing you might want to test is to monitor the "Finished Late [i-1]" boolean value returned by the timed loop.  This will let you know if the loop is finishing late or if the problem is just with the screen not being updated.



Regards,

Simon H
Applications Engineer
National Instruments

Message Edited by Simon H on 01-15-2007 03:19 PM

0 Kudos
Message 14 of 17
(997 Views)

The "stop" does not occur very often, but I run an overnight Test of a car radio with this vi and In my results I can see it happen 4-5 times at CRITICAL moments in the test per night, which leads to wrong test results. I was able to fix it for my Test, but it is still annoying when the timed loop does not work as intended. It is not a problem of the screen not beeing updated, thats is proven by the fact, that I get bad test results and the "finished late" variable is also true in that cycles.

But thx for your analysis, perhaps it is a problem related to my computer system / OS (interferring with other applications)

 

Regards

 

Sebastian

 

 

0 Kudos
Message 15 of 17
(974 Views)
Sebastian,

It sounds like you could well be correct in think the problem is related to your OS.  Using the timed loop on a Windows based machine does not guarantee that the loop period will be constant as LabVIEW shares the processor time with all your other applications.

If you are looking for deterministic software control I would invite you to read more about our real-time product offerings.

Another solution you may wish to consider is to setup your DAQmx read as a hardware timed continuous acquisition.  In this configuration the hardware clock controls when samples are taken and these samples are passed to the software in chunks (i.e. a large group of samples).  This decreases the chances of you missing a sample but will require you to rethink your program architecture.

I hope this helps.

Regards,

Simon H
Applications Engineer
National Instruments
http://www.ni.com/support

0 Kudos
Message 16 of 17
(970 Views)

Thank you for your help. I was already considering to purchase LabView realtime. Can you already tell, how good Windows Vista will work with LabView in real-time aspects?

0 Kudos
Message 17 of 17
(934 Views)