12-12-2008 12:16 PM
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
12-12-2008 12:27 PM
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.
12-12-2008 01:23 PM
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
12-12-2008 02:24 PM
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.
12-12-2008 02:30 PM
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?
12-12-2008 02:37 PM