06-30-2016 06:19 PM - edited 06-30-2016 06:21 PM
I am using Labview to program a camera to take a single shot on a hardware trigger. In the program, I would like to reconfigure the camera settings if there is a change in the user interface controls (exposure time, delay time, gain, etc). All of this is composed in a while loop where if there is a settings change, the code breaks out of the while loop and reconfigures the camera (see attached). Unfortunately, most of the loop duration is spent in pause waiting for the trigger, thus rendering the code inert. After a settings change, it thus takes one more photo to change the settings. The camera’s temporal response is critical due to the small timescales of the experiment (femto- to microseconds). We would like for the camera to be waiting for the trigger for as much time as possible.
Is there any way to break a while loop even if the loop has not fully executed? I have read for non-parallel processing this is the case. Master/Slave and Producer/Consumer parallel formats seem promising for the purpose of this code, but are they limited by the same stopping limitation as non-parallel codes?
Thanks!
06-30-2016 06:49 PM
@lpuppy79 wrote:
Is there any way to break a while loop even if the loop has not fully executed?
No. Everything in the loop must finish. What you can do is use a state machine architecture and break any given state down into smaller states that will execute more quickly. If you need to stop and reconfigure, then you detect that and move on to the reconfigure state directly rather than having it move on to the next state you had planned.
I don't know IMAQ or how camera triggers work, but if you spend a long time waiting for a trigger to timeout, you need to plan to detect that you want to reconfigure before you start the wait for trigger, or set the trigger to a smaller wait and repeat that state of waiting for the trigger more often. There is always a risk that whatever you are waiting to trigger on happens to happen right after your trigger timeouts and before you have a chance to wait for the trigger again. But you'll have to figure out for you special circumstances the risk/reward.
With just a couple partial screenshots, we can't help you with the overall architecture any more, except for a few comments.
Tthe flat sequence structure is often not needed. The fact you have it tells me that each of those frames probably belongs as a separate state in a state machine.
Why are you using all of those value property nodes? You should be using the terminals themselves. And if you can't use that, then a local variable would be better than a property node.
You have multiple AND functions strung together. Instead of that, use a Compound Arithemetic Node. Set it for AND mode. You can then put in multiple inputs you want to AND together and get rid of all the extra AND functions.
07-03-2016 11:06 AM
I completely agree with Ravens Fan, but will make a few additional (or maybe the same, said a different way) comments.
Do try to "hide the messy details" by judicious use of sub-VIs -- it is extremely difficult to understand a piece of code if wires, controls, and functions are running all over the place.
Bob Schor