03-07-2012 05:55 AM
Hi,
I have learned state machines from my previous post http://forums.ni.com/t5/LabVIEW/How-can-I-stop-the-inner-while-loop-when-the-outer-while-loop/m-p/18....
I want to learn more about Queued State Machines.
Can anyone post a simple example using DAQ?
Using LabVIEW 2010, 2011
03-07-2012 06:30 AM
Hi,
I found the following example:
Using Queues to Create a More Flexible State Machine:
http://zone.ni.com/devzone/cda/epd/p/id/3909
Its not an example with DAQ but maybe it will help you.
03-07-2012 06:59 AM
thanks, hadnt thought of running my state machines that way
03-07-2012 09:04 AM
Thank you Xenox and Akiel,
It's a good example . 🙂
What is an enqueue element? and how does it jump between state if there is no shift register?
When do we use a queued SM rather than SM? I have read the
But the article dates back to 2003.
Does it simplify the code ?
Best
03-07-2012 09:10 AM
enqueue element simply places an item on an existing queue.
what i expect would happen is you would place the initial states on the queue, then as the state machine starts to run you would add and remove items from the queue as the situation dictates. the while loop will ensure the state machine keeps running and the queue will keep defining the next state, so should run indefinatly until a stop condition is reached
03-07-2012 09:38 AM
@A.A.A. wrote:
...
When do we use a queued SM rather than SM? ...
Does it simplify the code ?
Best
Warning!
The are different opinions about when to use a Queued State Machine (QSM).
QSM's are the favorites on old-school coders that use a programming paraidgm similar to pushing and popping from Stacks. THe QSM is a natural for them and they use that construct like they would have in other langauges.
I use State Mahcines and seldom QSMs. The big differnce is I can draw up a State Transition Diagram for a SM. Due to the nature of the QSM (call any one or more of all states from any state) I run into transitons that can not be documented.
I also find SM easier to trouble shoot becuase I KNOW what states executed prior to a failure. In a QSM I only know if I am single-stepping.
Ben