LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Beginner question re: random number function & timing

Solved!
Go to solution

Hi Eric,

 

So if I put an event structure in the 2nd frame, would that eleiminate the need for the wait function in the first frame? Wha tother benefits would it have?

 

Thanks!

 

George

0 Kudos
Message 11 of 14
(911 Views)

@gsrokmix wrote:

I also found out that you can't really wire the "Stop" button to the While Loop when using the Sequence Structure. I have put it in the last frame which will only allow the user to stop the VI within the 2 second window I have put in.

 

 


No.  Putting the Stop button in the last Frame means that you don't read it until the answer has been given.

Suppose you don't put the Stop Button into a Frame, but wire it directly to the Stop indicator, outside the Frame sequence.  Let's say you have just finished a loop and have started the next one, and the first thing you do is push the Stop button.  Will you stop on that loop?  Probably not, because LabVIEW tries to do everything in the loop that it can when the loop start, including reading (and remembering) the value of the Stop Button.  When the loop starts, the Stop Button is False (else the previous loop would have stopped), so since the Stop button isn't in a Frame, it gets read when the loop starts, and is (still) False.  So the value present to the Stop Indicator is False, the value given subsequently to the Stop Control (because you pushed it) is True, and when the next loop start, it will be passed to the Stop Indicator.

 

Now consider it in the last frame.  Again, you push it when the loop starts.  As long as you don't "unpush it" before the last frame, its value will stay True.  Whatever value it has when you enter the last frame, that value will be used to control the While loop.  [Again, if you push it one second after entering the frame, that will "not count", as the value that is used will be the value when the Frame was entered].

 

Bob Schor

 

0 Kudos
Message 12 of 14
(904 Views)

Hi Bob,

 

That all makes total sense. I will put it back inside the while loop. So there is really no easy way using the sequewnce to have the stop button be available any time then?

 

Thanks,

George

0 Kudos
Message 13 of 14
(891 Views)
Solution
Accepted by topic author gsrokmix

No. That is why a state machine is usually a better choice than a sequence structure. We can hope that your instructor put the requirement for a sequence structure into the assignment to show how hard they make things.

 

Lynn

Message 14 of 14
(887 Views)