LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Execute case structure a certain number of times within a while loop

Hi guys,

 

I was wondering if it was possible to execute a case structure a specified number of times within a while loop. Basically I'm running a camera where each iteration of the outer while loop displays a frame of a live video feed and I'd like to capture the next x amount of frames (specified by the user) each time the 'Start Capture' button is clicked. The block diagram within the case structure captures and saves an image frame. As the program is written right now, frames will continue to be captured until the 'Start Capture' button is clicked again. Instead of having to click the button again to stop the case structure from executing for each iteration of the while loop, I'd like it to only execute for the next x iterations of the while loop. Any help would be appreciated. Thanks.

 

 

image.png

0 Kudos
Message 1 of 2
(2,169 Views)
Hello Uxorious, A while loop has a iteration counter that gives an integer value of how many times the loop has iterated. You can utilise this to count the number of frames captured. I assume that the program could be running for any amount of time before clicking start capture, if that is the case then you will need to be able to detect when you have clicked the button and add the desired number of frames you wish to capture to the current loop iteration. If you use a shift register on the outer loop with the start capture button connected to it (inside the loop) you will be able to compare its current value to its previous value. If it changes from false to true then you can add the desired number of frames to it to give you the loop iteration value where you need to stop. Then you can compare the current loop iteration value to that number and once reached, you can use a property node to change the value of your start capture button back to false. One final thing, don't forget to initialise the shift register I suggested to false so that you don't run the risk of missing the first time you press the button. I hope that makes sense. Alistair
Best regards,
Ali Bailey
National Instruments

----------------------------------

Don't forget to Kudos useful posts!
0 Kudos
Message 2 of 2
(2,129 Views)