Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I use IMAQ Grab like MAX without using all CPU resource?

I want to create a video in my labview program using IMAQ, but it takes too much CPU resource. I noticed that the Grab function that MAX has uses significantly less CPU. How do I do that in my LabView program.
Thanks,
Kono
0 Kudos
Message 1 of 4
(3,237 Views)
The best way to do this is to add a wait until next millisecond multiple before your your acquire vi. What is happening is the acquire VI constantly polls to see if the next image is ready. This is a good thing when you need to catch every frame and you are not sure how long it will be before the next frame is ready. In most cases though you do know how long it will be before the next frame is ready. For instance if you know your frame rate is 30 fps you know frames will come about every 33 ms. There is no reason to be polling for first 30 ms, so you can just put your while loop to sleep by calling Wait for Next ms Multiple with an input of 30. Make sure this is executed before the acquire vi. The one thing you'll want to be careful about is making sure
you don't miss any images.
Message 2 of 4
(3,237 Views)
Hi,
Thank you for your advise. I found out that it makes a big difference if you put the Wait for Next ms Multiple before the acquire. If I put acquire and wait together under the loop, it consumes a lot of CPU, but if I put Wait and then acquire in a sequence structure, everything works great. Can you explain why this is so?
Thanks,
Kono
0 Kudos
Message 3 of 4
(3,237 Views)
The important thing here is that they don't happen in parrallel. You only want to call the acquire when you are expecting the image to come in. As soon as you call it, it begins the polling. If you wait before the the acquire, there is less time that it does the polling before the image comes in. If you do it in parrallel, you the acquire is called immeadiatly, and polling is happening the entire time with the wait happening in a separate thread.
0 Kudos
Message 4 of 4
(3,237 Views)