Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

How to exit from IMAQdx infinite timeout?

The IMAQdx Grab2 VI allows wiring a -1 to the Timeout, which waits indefinitely for the requested image. The question is how do we exit from this indefinite wait programmatically and not having to Abort the program?

For example: if we have a Stop button in the While loop in which the IMAQdx Grab2 VI is running with a -1 wired to its Timeout, then once the VI is started the Stop button does not work, which is probably because the IMAQdx Grab2 VI is still waiting in the indefinite loop to get the image. The only way to close the VI is to Abort. Is there a better way to exit from the infinite Timeout? 

0 Kudos
Message 1 of 5
(1,174 Views)

You are right, if You have wired -1, the VI will wait until the camera has a new image. Why do you need to set the timeout to infinity? Set it to 1000ms for example and check the frame number. According to this post:
https://forums.ni.com/t5/Machine-Vision/IMAQdx-Get-Image2-vi-Issues/td-p/3329711
You should also get an error message in case of a timeout.


Another option would be to use "Register for Events"
https://documentation.help/NI-IMAQdx-VI/IMAQdx_Register_Events.html#details
and then select "new frame" or something similar. You can implement an event case and don't need blocking calls. However, I had a bad experience with this in Vision 2014 because it did not work reliably.... I hope this has changed in the meantime.

 

 

0 Kudos
Message 2 of 5
(1,160 Views)

Thanks a lot for your reply. I will try the first option. In that case would you suggest wiring a Yes or a No to the Wait for Next Buffer input?  If I wire a Yes, won't it be the same as waiting indefinitely for the image?

Also, if I understand correctly, what you are suggesting is that I wire a 1000 ms to the Timeout and then compare the Buffer Number Out output to its previous value to check if a new image has been acquired, correct? So I can use something like a shift register on the While loop to keep track of the previous Buffer Number Out value, right? finally, if the Timeout does occur I need to handle it by connecting an error handler so that it does not stop the program from attempting to acquire new image, correct? 

0 Kudos
Message 3 of 5
(1,150 Views)

To be honest, I'm on vacation right now and don't have an NI Vision installation at hand. And I've never used Grab 2.Vi before and could not find any help in internet for it.... But I often use IMAQdx Grab.VI with Wait for Next Buffer = False. That means I have to pool and check buffer number. Because in my case the trigger comes with at most 1Hz, pooling with about 50ms is no problem.

The most elegeant solution in my opinion is an event from the IMAQdx driver when there is a new frame. But as I said, that has to be tested first, that it works reliable.

0 Kudos
Message 4 of 5
(1,132 Views)

You can call Close on the IMAQdx Session. That is what Abort does under the hood.

0 Kudos
Message 5 of 5
(1,108 Views)