Jump to content
SofiaShahid

Performing a series of sequential task without sequence structure

Recommended Posts

Hello,

 

For my application I need to perform 25 operations in series that requires opening and closing of switches and checking the system parameters and all should be in sequence. I do not want a sequence stucture for every task. Please recommend a suitable alternative.

 

I am using Labview 2012 on windows 7

 

Regards,

 

Sofia

Share this post


Link to post
Share on other sites

The most obvious (and most popular) answer is a state machine.  You can queue up your 25 operations and then do them one after another.  With a state machine you can have it update data, between states, or go to cleanup if something fails on step 15 or do what ever you want.  You aren't limited to performing the 25 states one after another until they are all complete.

 

I recommend a modified type of state machine called a Queued Message Handler (QMH).  Go to File >> New... and select the Queued Message Handler under VI >> From Template >> Frameworks >> Design Patterns.  This works in a similar way to a normal state machine but uses strings for the state names (not enums) and is more flexible, but also is more error prone (mis-spelled states for example).

Share this post


Link to post
Share on other sites

I second the recommendation of a state machine.  I actually would use a normal state machine for what you quickly described.

Share this post


Link to post
Share on other sites

Connecting VIs via their error terminals is the preferred method to a sequence structure.

  • Like 1

Share this post


Link to post
Share on other sites

With the ambiguity of the question, one could even suggest something as simple as a for loop.  Without knowing how similar the 25 operations are (they could be the same operation 25 times with the same data type in/output), I'll "second" ShaunR's post and "third" a state machine.

Share this post


Link to post
Share on other sites

Based on the limited information associated with the post, I would also recommend using a Queued Driven Message Handler (QDMH)(Template available via the 2012 sample/template projects)

 

I presume you're a relatively new developer and as useful as the QDMH is in making sure your application can do what you want, it has a variety of key flaws for handling flow control, especially if it's event driven from the Front Panel.

 

For simplicity sake, it might be best to defer to a basic state machine and simply index the enumeration +1 for each itteration of the loop.

 

Also, based on experience, Shaun's response is probably not what you'd choose right now because you're likely sharing a variety of pieces of information between each one of the steps and you don't feel comfortable making each of these calls into their own unique SubVI or making a well structured TypeDef cluster to store all this information.

 

However, on the latter point of my previous comment, whether or not you use a QDMH or a basic State Machine, I would HIGHLY recommend that you use a 'Mother Cluster' going through a shift register to share information from step to step of your sequence.

The QDMH template project and TLB http://lavag.org/topic/14164-discuss-tlb-top-level-baseline/ are good examples of this practice.

 

Best,

Norm

~,~

 

ps. Good luck and straighten your wires out! They have too many random kinks in them. (people like to help people more who write cleaner code)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.