From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

calling a Vision Acquisition Express VI in a Loop

Solved!
Go to solution

Hi there. I've been working on a personal project for a while now, and I've seem to come to a brick wall. I'm relatively new to IMAQ, but I feel I understand some of it.

 

Let's call our test user Bob.

 

Bob needs to be able to see what the camera sees, and when the camera is focused on a barcode, Bob has to hit a "Capture" button, which will take the last acquired image from the continuous acquisition, and use that image for barcode reading and later, parsing the data.

 

Bob runs into a problem though. His Block Diagram is set up in two different ways, both yielding the same result. (see the attached photos). this is inside a Sequence structure, which in turn is inside of a while loop, which can be exited at any time. To prevent automatic cycling in the big while loop, the first frame of the aforementioned sequence is an event structure which allows the process to continue when a "New Capture" button is pressed. What happens? The first time through the sequence, Bob gets successful results. However, after the execution of the entire while loop, the camera image, which should be displayed in sync with what the camera sees until the "Capture" button is pressed, is just a white background.

 

What could be causing the express VI to not be called the second time through the loop and beyond?

 

Thanks in advance.

 

(EDIT 1: added front panel image after the problem has occured)


"Whether you think you can or can't, you're right."
~Henry Ford
Download All
0 Kudos
Message 1 of 7
(3,221 Views)

After exiting the first while loop (the IDLE loop), the LabVIEW VI won't automatically enter that while loop again. You could consider creating another while loop around the whole diagram so that you can re-enter the IDLE loop with the Vision Acquisition Express VI.

 

Jeremy P.

Applications Engineer
National Instruments
0 Kudos
Message 2 of 7
(3,152 Views)

Just to clarify.

Once the while loop has been executed once, the next time that frame of the sequence executes, the inner while loop (the one with the image acquisition express VI) is skipped?

 

If so, is there a way to force its execution each time the sequence runs?


"Whether you think you can or can't, you're right."
~Henry Ford
0 Kudos
Message 3 of 7
(3,134 Views)

Once the while loop is terminated, the Express VI will not run again unless the While Loop is called again. However, there doesn't appear to be anything in your code to call that While Loop again. The Sequence Structure will not automatically loop again back to the beginning. You need to put another while loop around the sequence structure so that it loops back to the first frame after the last frame is finished.

 

Jeremy P.

Applications Engineer
National Instruments
0 Kudos
Message 4 of 7
(3,096 Views)

I've modified my block diagram slightly, as you suggested but still to no avail. Here's the entire VI.

 

1. Start VI

2. User presses New Scan

 

3. User snaps photo with the Grab Photo button, (which i currently have to manually release)

 

4. Photo gets processed

 

5. back to step 2 OR end the VI

 

[attachment removed]


"Whether you think you can or can't, you're right."
~Henry Ford
0 Kudos
Message 5 of 7
(3,080 Views)

I actually took a look at your code and it seems like you put it together well. The only thing that I noticed that could cause a problem is that the buttons have "switch" as their mechanical action, which means that once you press them once they will toggle to the opposite value and remain there until the user presses the button again. This could be a problem because the next time the code enters that loop then the code will only process one iteration before exiting the loop. It would be a good idea to switch them to latching buttons or to use local variables to force the value to what you want after the loops have terminated.

 

Jeremy P.

Applications Engineer
National Instruments
0 Kudos
Message 6 of 7
(3,058 Views)
Solution
Accepted by topic author T16626

This still doesn't seem to fix the problem. A finite capture as determined in the Express VI is the only way I've found to call the express VI an infinite number of times. This works for my purposes, so I'm going to close the thread.


"Whether you think you can or can't, you're right."
~Henry Ford
0 Kudos
Message 7 of 7
(3,040 Views)