LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

start button in a flat sequence

Can you save it as LV 2014 or lower? LV 2012 might be good so more people can see it.

0 Kudos
Message 11 of 17
(2,238 Views)
  • Never do equal comparisons with DBLs (especially if one is a random number!), a match will never happen in your lifetime.
  • Eliminate the inner loops as already suggested
  • The number terminal needs to be inside the loop.
0 Kudos
Message 12 of 17
(2,229 Views)

Try something like this (LV 2015):

 

 

0 Kudos
Message 13 of 17
(2,214 Views)

I would like to know how i can add sequence in an event structure. Assume, after the number is < the random number generate, I want to start another sequence say 1+ 1 = 2 or something. How do I make a sequence in this? I tried using a flat sequence but then realized that it cannot be stopped in between. 

Attached is the vi saved under previous version. 

Thanks. 

0 Kudos
Message 14 of 17
(2,181 Views)

@vsrinivasan wrote:

I would like to know how i can add sequence in an event structure.


If you're saying this, you need to stop coding and start taking some of those training links that were posted on the first page.

 

1) You need to break this reliance on the Sequence Structure.  You're abusing it.  It's a lot like if you learn to use a hammer and then use it in every situation.  You've got a screw?  Hit it in with a hammer.  You've got a zipper?  Smack it with a hammer.

 

2) Events are meant to handle quick pieces of code.  If your code is complex enough it requires a sequence structure, it doesn't belong in the event structure.

 

 

Learn dataflow.  This is how you control order of execution in LabVIEW.

0 Kudos
Message 15 of 17
(2,173 Views)

@vsrinivasan wrote:

I would like to know how i can add sequence in an event structure. Assume, after the number is < the random number generate, I want to start another sequence say 1+ 1 = 2 or something. How do I make a sequence in this? I tried using a flat sequence but then realized that it cannot be stopped in between. 

 


Learn about state machine architecture.

 

Have you looked at my code yet?

0 Kudos
Message 16 of 17
(2,147 Views)

@vsrinivasan wrote:

I would like to know how i can add sequence in an event structure. Assume, after the number is < the random number generate, I want to start another sequence say 1+ 1 = 2 or something. How do I make a sequence in this? I tried using a flat sequence but then realized that it cannot be stopped in between. 

Attached is the vi saved under previous version. 

Thanks. 


You're having trouble with this idea because it won't work. If you have a "sequence" of operations within an event case then the program can't be stopped until that sequence finishes. The way to code this is to trigger another case that does the step 1 of the sequence and then trigger another case that does step 2 of the sequence.

 

Here's a broad example of how a state machine works:

  • States: Init, Idle, Exit, DoThing1, DoThing2, DoThing3
  • Each state contains code that might take some time. Ideally, not too long because that's how long you code could be unresponsive.
  • The Idle state contains an event structure for all user interaction.
  • The front panel has a button that says "Do Thing 1".
  1. Loop Iteration 0: Application begins, first state is Init. The Init state does some initialization stuff and tells the application to go to the Idle state when finished.
  2. Loop Iteration 1: Application goes to Idle state. It sits there, waiting at the event structure.
  3. Time goes by, then user presses button "Do Thing 1". There is no code, or minimal code, within this event case. The output of this event state tells the application to go to the DoThing1 state.
  4. Loop Iteration 3: Application goes to DoThing1 state. There is code here that does some stuff. The output of DoThing1 state tells the application to go back to the Idle state.
  5. Loop Iteration 4: Application goes to Idle state where it waits at the event structure again.
  • Each of the states can tell the application to go to any state they want. Want to reinitialize? Go to the Init state again. Want to end the program? Go to the Exit state? Want each state to trigger another (like a sequence)? Have DoThing1 output DoThing2, which outputs DoThing3,  which outputs Idle.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 17 of 17
(2,144 Views)