LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

IMAQdx stopping grab vi

Solved!
Go to solution

Hello,

I am trying to develop an application using IMAQdx to communicate with my camera connected via USB. This application is supposed to set certain parameters such as image height, width, X-offset and Y-offset at run time, then capture the images. On start up of the vi I can set the parameters as I want them, but when I go back to the settings page to put in new settings, the new settings don't seem to take.

I have checked and know that the height and width settings can only be set when the camera is not grabbing. But I can seem to find any thing to stop the grab. I tried using the "stop acquisition" but that too does not seem to work.

I have attached my Vi.

Help would be greatly appreciated.

Thank you,.

0 Kudos
Message 1 of 3
(2,548 Views)
Solution
Accepted by topic author reghu1972

The problem is (I think) an improper use of the Event Structure + a failure to understand how Boolean Controls work with the Event Structure.  Let's examine your code and what might be happening (I don't know the order you "push your buttons").

  1. At some point, you push the Grab button, configured as a Switch when Released.  It turns True, the Value Changed Event fires, and you are (temporarily) locked in a While Loop, acquiring Images.
  2. Suppose you push Save Settings during this time.  You are still locked in the While Loop, so the Event Structure can't "fire" for Save Settings.  In addition, the surrounding While Loop in which the Event Structure is embedded can't proceed (since the Event hasn't ended).  So you keep acquiring.
  3. Now you push Grab again, turning it off.  You are still locked in the inner While loop, but now Grab is false, so you exit.  There are now two Events pending, Save Settings VC (Value Change) and Grab VC.  Let's assume Save Settings will be first (I'm pretty sure there is a FIFO Queue for Events).
  4. We start the outer While that contains both the Save Settings button and the Event Loop.  Which executes first, reading Save Settings (which will turn it off) or the Event Loop which processes Save Settings VC?  Can't tell (Principle of Data Flow), but lucky for you, since you ignore the value of Save Settings, you don't care (I confess I missed this "happy accident" -- you should, for safety, put the Latched Variable, Save Settings, inside its VC Event Case.
  5. So Carefull Analysis (and writing it down, with this being Step 5) shows I partly mis-diagnosed your problem.  I'll exit and explain ...

I now think the problem is you might be trying to push Save Settings while Grab was in force, thinking it would override the Acquisition, but as I argue above, it cannot.  I also thought that having Save Settings outside its Event Case was going to cause problems, but in your situation, it (luckily) doesn't.

 

What you probably really want is a State Machine, with a parallel Event Loop able to change the "Next State" (possibly via a Notifier or a Tag).  Ordinarily, if doing a Grab, the Next State would, again, be Grab.  If the User "turned off" Grab, the Event Loop would change Next State to "Stop Acquisition".  If the User pushed "Save Settings", the Event Loop would change Next State to "Save Settings". 

 

Bob Schor

0 Kudos
Message 2 of 3
(2,524 Views)

Hi Bob,

Thanks for your reply. I'm still learning Labview while at the same time trying to develop an application using VAS, so any input it welcome. I appreciate your step by step analysis as it allowed me to pick up somethings regarding how the data flow is happening in my application.

 

I have implemented your suggestion by having a local variable monitor my "Grab" button, and on false I had the case statement stop the acquisition. Now I can properly set my camera settings.

 

Thank you very much.

0 Kudos
Message 3 of 3
(2,510 Views)