LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parallel loops, pausing a faster loop when its time for a slow one to run

I have an application that has three parallel loops, a fairly fast one acquiring video data from a USB camera, with one slower loop periodically saving a video frame, and another slower loop periodically saving some analog data (different rates). The problem I'm having is the slower loops sometimes fail to run when they should.  Can someone give me a recommendation on the best method (notifier? semaphore?) to force the faster loop to pause when its time for the slower loops to run?  I'm just using 'wait until next ms multiple.vi' to control the loop speeds.  I've tried slowing the faster loop somewhat, but the situation has not improved. 

I'd like to keep the video as seemless as possible, but its more critical that the loops saving data run on-time.

 

Thanks for any suggestions you can offer - I'm running Labview 8.2

0 Kudos
Message 1 of 6
(3,180 Views)

You are not telling us much about your overall setup. How do you acquire from the USB? Is there a third party DLL involved, for example.

 

Is there a wait in the fastest loop? Remember, even a 0ms wait will allow a switch to another loop, while without any wait a fast loop will spin multiple times before another loop is allowed to run.

 

Do you have multiple CPUs/cores? If you use a timed loop, you can assing it to a certain core.

 

How are you handling data between the loops? Can you show us some code? Are things optimized for efficiency?

 

An alternative would be to use one single loop and place the other code parts inside case structures that activate on certain integer multiples of the iteration count.

0 Kudos
Message 2 of 6
(3,176 Views)

What about using the procuder/Consumer Design pattern ?

a loop which is mainly busy Producing (enqueing) Video frames (element) while other 2 consumer loops , each for a purpose ?

using this way we will ensure that all loops will read from a FIFO buffer and nothing will be lost.

and as mentioned by altenbach , the wait functions are necessary 

 

Eng. Mohammed Ashraf
Certified LabVIEW Associated Developer
InnoVision Systems Founder, RF Test Development Engineer
www.ivsystems-eg.com
0 Kudos
Message 3 of 6
(3,168 Views)

The video acqusition does involve using a 3rd party DLL; and I do have a wait in the fastest loop.  Even though I have a wait in the faster loop, it sometimes behaves as if the slow loops don't have a chance to run.  Most of the time it works fine, but every so often I will get a period of usually about 5 seconds where no data is collected.  The video is seemless, so its not as if the DLL is hanging-up.   Currently I have the wait in the fastest loop at 50 ms.  I'm handling data between the loops just using local variables.

 

0 Kudos
Message 4 of 6
(3,159 Views)

djb wrote:

I'm handling data between the loops just using local variables.


Local variables force extra data copies in memory and are thus not great if performance is a factor. I assume these local variables are arrays. How often do they change in size?

0 Kudos
Message 5 of 6
(3,155 Views)
There is only one local variable involved, its the array of data associated with the most recent video frame captured.  It never changes size.
0 Kudos
Message 6 of 6
(3,148 Views)