LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Execute events sequentially

Solved!
Go to solution

Hi Folks.

 

I the VI attached there are 3 buttons which implement 3 different tests. I would like to have only one button that will execute all events sequentially. Is this possible to do?

 

Thanks,

 

Mark.

0 Kudos
Message 1 of 16
(4,511 Views)
Solution
Accepted by topic author MarkGreally

Yes, use a state machine. Have one state for each test and then you can either run an individual test or you can cycle through the states to do each test in turn.

 

Here are some examples/tutorials:

http://www.ni.com/tutorial/7595/en/

http://www.ni.com/white-paper/3024/en/


LabVIEW Champion, CLA, CLED, CTD
(blog)
Message 2 of 16
(4,504 Views)

Yes.  There are many ways to do this, but the simplest way is to conceptualize the three tasks (which, I presume, to execute the code in the Event cases Amp @ 3mv, AMP Def, and Frequency Sweep).  Replace the three tasks (and three buttons) with a single Task/Button called "Do All Three" and string the three tasks, in the order you wish them to be executed, on a single Error Line using appropriate data.  Of course, this will require not 3 monitors side-by-side, but nine, rather a pain.

 

Or you could learn about sub-VIs, and put each task in its own sub-VI, where it would occupy a 32 x 32 pixel area on your top-level VI (much less space, could fit on a fraction of a screen).  You might want to consider bundling your inputs and outputs into Clusters so that you don't have to pass 20 parameters in and out, but only 5.

 

Now that you have things down to a more managable size, you can consider whether you want them to alway execute in a fixed sequence (in which case you can simply wire them that way) or where the order of execution might depend on certain conditions, in which case a State Machine architecture might be more suitable.  Either way, by "hiding the details" about how each task is accomplished, you can concentrate on what you want to do (from a broader perspective), a "Top-Down" approach.

 

Bob Schor 

Message 3 of 16
(4,470 Views)

Thanks folks.

 

The state machine seems to work quiet well. However I have one issue. I want to keep the "Unlock" button and seems to be interfering. When I remove the event structure containing this button the program runs fine but when I leave it in it does not. What is the best way to handle the event change of this button?

 

Mark.

0 Kudos
Message 4 of 16
(4,436 Views)

What do you mean by interfering?

Tim
GHSP
0 Kudos
Message 5 of 16
(4,424 Views)

if I hit  'start' nothing will happen but then if i click 'unlock' each of the cases will be implemented. The event case is clearly having some sort of affect on it.

0 Kudos
Message 6 of 16
(4,412 Views)
Solution
Accepted by topic author MarkGreally

The event structure is like a loop the difference is that if you do not aonnect to the event timeout in thte top left corner is does nothing. You will need to put it in a loop by itself for this to work. Otherwise it is just holding up the other loop from executing.

Tim
GHSP
Message 7 of 16
(4,403 Views)

@MarkGreally wrote:

if I hit  'start' nothing will happen but then if i click 'unlock' each of the cases will be implemented. The event case is clearly having some sort of affect on it.


Data flow dictates that a loop cannot iterate until EVERYTHING inside has completed.  So your Event Structure must complete before you can go to the next state.  The Event Structure will just sit there and do nothing until an event it is registered for happens.  So your two options are 1) privide a timeout for the event structure or 2) put it in another loop.  In this case, I think I would go with 1.


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 16
(4,349 Views)

The event timeout worked just fine.

 

Quick question in relation to enums in the case structure. I tried to add extra "Result" case but all the cases go to numbers. I have since saved them as type defs but the case structure still has numbers. There in no options in the properties to do this. Please dont tell me I have to delete my cases and start again. Surely this should be fairly simple but I cannot seem to get them assigned.

0 Kudos
Message 9 of 16
(4,329 Views)

You also need to attach the typedef'd enum. Once you create a typedef, you need to replace ALL instances of the plain enum with the typedef. Currently you have coercion dots everywhere.

Message 10 of 16
(4,317 Views)