LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

execute one frame of flat sequence after asking user

Solved!
Go to solution

Dear Friends,

 

I have flat sequence with more than 10 frames, in frame 4 I have a camera and should wait there until user change the focus and then capture picture and continues.

I am thinking how can I make pause in one frame?

 

I made very simple VI which explain what exactly I mean and my first solution, as you can see in my VI I used while loop which continues running until user press stop button. I believe this is not the best idea while I don't like to put whole my sub vi which is also too big and complicated in while loop.

 

Please let me know if you have any other suggestion?

 

Best regards

Arvin

0 Kudos
Message 1 of 9
(5,779 Views)

Hi Arvin,

 

Either a while loop or an event structure with a large timeout would be able to accomplish your goal here. You can also use the Wait VI within your while loop to control the speed at which you poll the stop button and avoid hogging the processor.

 

Check out these options for timing your VI's.

 

Duncan W.

0 Kudos
Message 2 of 9
(5,770 Views)

There is rarely a need for a Flat Sequence in LabVIEW.  Many times, using the Error Line to "sequence" functions is all you need.  This doesn't apply in your case, as you are only using numeric functions.  But notice what you are doing -- five "things" in sequence.  One way to do this is to say "I want to do 5 things in sequence, so I'll use a For loop with a count of 5, inside it I will put a Case Statement that looks at the For's Index (i) that goes from 0 to 4, and in each Case, I'll do what I need".  If you do this, and if you recognize that the variables Numeric, Numeric2, and Numeric3 can be better reproduced as wires connected to a Shift Register (eliminating the troubling Local Variables, eliminating the unneeded Numeric and Numeric2 Controls that are never used as Front Panel objects, and relegating Numeric3 to simply "indicate" the changing value of the Numeric3 "wire-variable"), you'll have a much simpler, easier-to-expand, framework.

 

Case 3, the Wait, can now be a little While loop (I'd put a Wait-for-100 msec function inside so your CPU isn't "counting nothing as fast as it can").  I'd name the "Stop" control "Continue", and change the name on the button, as well.

 

I've attached my suggested revision.  I would save it as a Snippet, but it would be in LabVIEW 2016, and you're running 2015.  This should be 2015 (unless I made a mistake in saving it) ...  (note I kept the name, but it should not be a Flat Sequence now, but a Case-within-a-For Loop).

 

Bob Schor

Message 3 of 9
(5,754 Views)

I understand Sequence structures need to be kept around for backwards compatibility but I would like to see NI deprecate the flat (and stacked) sequence and bury it deep in the menu structure so new programmers do not see it or use it.

========================
=== Engineer Ambiguously ===
========================
Message 4 of 9
(5,741 Views)

Thanks for your reply, I have also these problem which my processor is hopping. what do you mean avoiding that by larger time out?

 

0 Kudos
Message 5 of 9
(5,735 Views)

@RTSLVU wrote:

I understand Sequence structures need to be kept around for backwards compatibility but I would like to see NI deprecate the flat (and stacked) sequence and bury it deep in the menu structure so new programmers do not see it or use it.

But I hear they're great for documentation 😉


GCentral
0 Kudos
Message 6 of 9
(5,734 Views)

@cbutcher wrote:

@RTSLVU wrote:

I understand Sequence structures need to be kept around for backwards compatibility but I would like to see NI deprecate the flat (and stacked) sequence and bury it deep in the menu structure so new programmers do not see it or use it.

But I hear they're great for documentation 😉


And new icons.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 7 of 9
(5,727 Views)

My first though when I read "flat sequence with more than 10 frames" was "you need to change to a State Machine.  The beauty of a state machine is you can reuse your steps and you can abort the sequence.

 

As far as your waiting for the user, just use a 1 Button Dialog instructing the user what to do.  When they hit the OK button, you just move on.  No extra loops or even structures.  Just a single function call.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 9
(5,716 Views)
Solution
Accepted by topic author arvin1947

I would highly recommend you implement a state machine. It may work for now to just cycle through a for loop, but I think later when you try to add features to your program, you could have problems. For example, what if the user wants to stop the program completely instead of continuing? It will be difficult to add if you just have a while loop spinning and waiting only for the continue button.

 

Here is how I would modify your code to work as a state machine. Notice, how I've added the ability for it to stop at any time if the user closes the VI.

Event State Machine.png

This uses an event structure, which I highly recommend. I think it makes it very flexible in that you can respond to any event easily by changing your state.

 

If for some reason you don't want to use an event structure, you could do it with polling as well, like this, but I don't think it's as flexible. It does at least give you the ability to stop midway through though.

State Machine.png

 

--Hope

Message 9 of 9
(5,714 Views)