08-23-2017 11:16 PM
I have made a program that uses a flat sequence to complete 20 steps 10 output and 10 input, now the program is just a monitoring build which has an array for each o/p so I am able to select what I measure for each point. I was after some advice on the best way to build a multiplexer or something along that line to replace the flat sequence.
Any advice is appreciated
08-23-2017 11:25 PM
Search the forums for "state machine".
08-23-2017 11:42 PM
Share the piece of code you tried so that you can get the better solution
As suggested pls practice design patterns (State Machine preferably)
08-24-2017 08:00 AM
If you are doing "multiple steps", a State Machine (which uses a loop structure, with common values placed in Shift Registers and a Case Statement selecting which step you are doing, with one of the Shift Registers usually serving as "Which Step is Next?" decision) makes sense, and also has the side benefit of taking a long strung-out Block Diagram and "stacking" it in a "natural" structure.
On the other hand, some use the Sequence structure to (... pause ...) control the sequence of the VIs/functions involved. In many cases, a better way to sequence things is to use the Principle of Data Flow, which often means The Error Line Is There for a Reason -- Use It. Note that most NI functions have Error In and Error Out terminals, and NI Best Practices recommends that you use a 4-2-2-4 Connnector Pattern for your sub-VIs, with Error In and Error Out in the lower corners. Functions place on the Error Line with (by the Principle of Data Flow) execute in the order they appear on the Error Line.
One of the few times that a Frame Sequence is required is if you need a 100-msec delay between one function finishing and the next one starting: the Wait function doesn't have an Error Line, so when I need this, I either use a sub-VI I write that includes the Error Lines and a Wait inside, or use a Frame Sequence to surround the Wait and make sure "An Error Line Runs Through It". [My apologies to those who may not catch the bad pun there ...].
Bob Schor
08-24-2017 08:31 AM - edited 08-24-2017 08:33 AM
@Bob_Schor wrote:
<snip>
One of the few times that a Frame Sequence is required is if you need a 100-msec delay between one function finishing and the next one starting: the Wait function doesn't have an Error Line, so when I need this, I either use a sub-VI I write that includes the Error Lines and a Wait inside, or use a Frame Sequence to surround the Wait and make sure "An Error Line Runs Through It". [My apologies to those who may not catch the bad pun there ...].
Bob Schor
I was concentrating more on the fact that you contradicted yourself from one sentence to the next. Apparently it isn't required, Error Line Phoenix. 😉 (And my return pun is even more obscure.)
08-24-2017 09:40 AM
LabVIEW provides this really useful tool called a stacked sequence. It's great! just take each from from your flat sequence and copy it into the stacked sequence structure.... much better than those Queued Message Handlers and State Machines. More sustainable too!
08-24-2017 09:49 AM
@Tim_McClung wrote:
LabVIEW provides this really useful tool called a stacked sequence. It's great! just take each from from your flat sequence and copy it into the stacked sequence structure.... much better than those Queued Message Handlers and State Machines. More sustainable too!
I hope this message was one that is intended to be a joke.
08-24-2017 10:00 AM
Bob, Bill. 2017 has this really nifty vim. Called delay dataflow
08-24-2017 10:16 AM
@RavensFan wrote:
@Tim_McClung wrote:
LabVIEW provides this really useful tool called a stacked sequence. It's great! just take each from from your flat sequence and copy it into the stacked sequence structure.... much better than those Queued Message Handlers and State Machines. More sustainable too!
I hope this message was one that is intended to be a joke.
Humor often resides in ambiguity. 😉
08-24-2017 10:35 AM
@Tim_McClung wrote:
@RavensFan wrote:
@Tim_McClung wrote:
LabVIEW provides this really useful tool called a stacked sequence. It's great! just take each from from your flat sequence and copy it into the stacked sequence structure.... much better than those Queued Message Handlers and State Machines. More sustainable too!
I hope this message was one that is intended to be a joke.
Humor often resides in ambiguity. 😉
It scared me that a new user might not have recognized the humor and would be come someone who believes a stacked sequence is a good thing.
08-24-2017 11:15 AM
Valid point. Thanks for holding the straight line and helping people learn good coding practices.
Cheers,
Tim