An example of a state machine with transition array?

I am looking at state machine design patterns and am interested particularly in a state machine with boolean trasition array which defines the next state to be executed using an array. Here, the index of the first “True” boolean in the boolean array corresponds to the index of the new state in the array of enums. Has anyone got an example of this design pattern as it would greatly help in my understanding of it. Refer to figure 3c in http://zone.ni.com/devzone/cda/tut/p/id/3024#toc2 for clarity on what i am asking for.
Thanks in advance.

That seems like a lot of extra work. Why not just use a queue, and queue up the enum you want to go to next? Look up examples on queued state machine. No need for an array and then a boolean to index that array. here is an example
CLA, LabVIEW Versions 2010-2013

Similar Messages

  • Need help created state machine with timed digital output

    Hello everyone I'm new in LabView especially about how to make a state machine. I want to make simulation about state machine with digital output. In Front Panel there are volt_in as an input slider (0-10 V), two numeric control (upper limit and bottom limit), a waveform chart to plot those 3 value, and three boolean (P0.0, P0.1, P0.2) as an indicator. Boolean indicator will on if input from slider exceed the limit in certain situation. This simulation will work as follow:
    1. Define the upper & bottom limit (ex. 8 & 4V)
    2. Make an input from slider (0-10V)
    3. If input (2) exceed the upper limit but less than 10 second (ex. you have 9V input for 8 second, but after 8 second you change the slider back to normal between 4-8V) then the boolean indicator P0.0 & P0.2 will stay off
    4. If input (2) exceed the upper limit more than 10 second (ex. you have 9V input for 4 second, change to 8.5 V for 3 second, and then change to 10V for 3 second) then the boolean indicator P0.0 will turn on for 5 second, turn off, then follow by indicator P0.2 for 5 second, and turn off
    5. Wait 15 second, then repeat process from (2)
    Same process for input that exceed the bottom limit (P0.1 and P0.2 as indicator).
    Can you help me make the block diagram of this process? I will appreciate any of your help.
    Best Regards
    juventom 
    Attachments:
    State Machine Digital Output.vi ‏28 KB

    I would highly recommend you to open the template in LabVIEW to design state machines. You can the Standard State Machine template if you go to File -> New.. and Browse to VI -> From Template -> Frameworks -> Design Patterns.
    Also, here is a good explanation of one:
    https://decibel.ni.com/content/groups/northeast-oh-labview-users/blog/2009/09/08/state-machines
    Adnan Zafar
    Certified LabVIEW Architect
    Coleman Technologies

  • Problems closing several loops in a state machine with an event structure

    I am having some problems closing three loops running in parallel in a state machine.  I have one loop for an event structure to monitor user controls to change the state.  The other loop is the state machine which will control an actuator, and the third loop is for data aquisition/analysis.  I want to be able to hit the stop button and go to a "shutdown" state where I can home the actuator then close the loops and finally go to the last "shutdown" subdiagriam in the flat sequence structure.  Currently when hitting the stop button it goes into the shutdown state and will end the state machine loop but it appears the other loops are not closing until I hit the stop button again.  Could this be due to using a local variable for the boolean to control the loop conditions? I attached a screenshot of the block diagram.  Any advice would be great!
    Attachments:
    example.png ‏108 KB

    You have a classic race condition due to overuse of local variables. If the stop event fires in the upper loop, the local variable connected to the loop termination condition has already been read (it is false!). This means that the upper loop will iterate once more and again wait at the event structure for the next event. At this time, the local variable connected to the loop termination is TRUE, but the loop cannot complete until the event fires again, for example if you press the stop button once more.
    The correct way is to connect the terminal of the stop button across the right event frame directly to the loop termination terminal. Now it will get the TRUE value correctly once the stop event fires for the first time.
    LabVIEW does not execute left to right, execution order is determined by the wiring.
    I also agree with the above message that you should rethink and re-architect your code using established coding guidelines. 
    LabVIEW Champion . Do more with less code and in less time .

  • Performance of state machine with enum vs string?

    I am laying out the groundwork for a very large state machine. It will have about 60 to 100 states. I kind of want to use an enum for selecting the states for convenience. But then if I use a string I can use Jim Carmody's case select tool so that wins out in convenience in one respect.
    One concern about using a string is performance. Since an enum is just an integer wouldn't the selections perform better? I need to squeeze out every ounce of performance and in fact this state machine will be set for subroutine priority. Another concern that I have about a typedef enum is that I have heard something about the possibility of them getting "out of sync" between VIs when you edit them. Is there some way to avoid that, such as making sure all VIs that use this typedef are in memory when editing it?
    =====================
    LabVIEW 2012

    Steve Chandler wrote:
    As for the number of states, I am pretty sure that it has to be one state machine. I'm afraid I cannot give a lot of details.
    I am having trouble figuring out the "has to" part.
    See this thread for designs I have posted previously.
    In this SM
    please look the section that is entered from "Change Request 8 " can take multiple paths but all ends at "Stop Monitoring? 15". I could have implemented that as a sub-SM and it would have reduced the number of state required for that part of the work from five to one.
    Any time I see "single entry, fan out, merge" I think sub-SM.
    This could also help with your shift register as well because (again seea bove) the bulk of the ose states deal with Logging so rather than use a SR, put what would have been in the SR (file path or ref) to be used there OR possibly an AE that can be used in each of those states.
    So I still don't understand why sub-SM aren't a possiblity.
    Trying to help,
    Ben 
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Shutting down a queued event state machine with multiple parallel loops

    I am trying to find the best way to shutdown a program that consists of a queued event state machine architecture with multiple parallel loops. Can anyone recommend the best way to accomplish this in my attached VI? (From browsing the forum, this seems to be a common question but I haven't found a solution that works for me.)
    I welcome any other feedback on my code as well, if anyone is willing to offer it.
    My Program Requirements:
    If the user presses the "Shutdown" button, the program should prompt the user with "Are you sure you want to stop the program?" and then either return to the Idle state or proceed to stop the program. Additionally if there is an error, the program should prompt the user with "Clear error and continue, or Stop program?" Then either return to the Idle State or proceed to stop the program.
    Details of architecture:
    The program consists of 3 parallel loops: (1) an Event Handling loop that enqueues various States to a State Queue, (2) a State Machine which enters the latest state that is dequeued from the State Queue, and (3) an Error/Shutdown handling loop which processes any errors in the Error queue.
    During normal Shutdown, in the Event Handling loop the "Program.Shutdown" event case executes, and the States "Shutdown" and "Idle" are added to the State Queue. In the State Machine, the "Shutdown" state is invoked. A special error code "5000" is added to the Error Queue. In the Error/Shutdown handling loop, the "5000" error triggers a prompt that asks the user if they want to stop the program. If the user chooses not to stop, a notifier StopNotif is sent to the "Shutdown" state and "Program.Shutdown" event case with the notification "Go". If the user chooses to stop, the notifier sends the notification "Stop". The Event handling loop and State Machine are terminated if they receive the notification "Stop".
    In case of error, the program behaves similarly: if the user chooses to clear the error and continue, the program returns to the "Idle" state.
    HOWEVER - if the user chooses to stop the program, the program stalls. The notifier that is sent to stop the Event Handling Loop and State Machine cannot be read because the Program.Shutdown event case and the Shutdown state (which contain the "Wait for Notifier" function) are not active.
    I have been able to activate the Shutdown state by enqueuing it in the Error/Shutdown handling loop. But I don't know how to activate the "Program.Shutdown" event programmatically, and thereby access the "Wait for Notifier" function inside it.
    I tried to place the "Wait for Notifier" function outside the event structure, but then the Event Handling loop never completes. Placing timeouts on the "Wait for Notifier" and on the Event structure makes the program work, but I want to avoid using timeouts because I don't want to turn my event-driven program into a polling-based program. I'd also like to avoid using variables or property nodes to stop the loops, because that requires creating a control/indicator for something that the user doesnt need to interact with.
    Thank you!
    Solved!
    Go to Solution.
    Attachments:
    Queued event state machine parallel loops empty.vi ‏46 KB

    Thanks for clarifying that, Ravens Fan.
    I marked crossrulz as the solution for pointing out User Events to me.
    I also adopted Ravens Fan's suggestion to keep the Shutdown procedure out of the Error Handling Loop. This has simplified the architecture by eliminating the need for Notifiers. Instead, I have used booleans in case structures to stop the Event Loop and State Machine, and Release Queue to stop the Error Handling Loop.
    For reference, I'm attaching my corrected code.
    Thank you to everyone who helped!
    Attachments:
    Queued event state machine parallel loops empty in progress.vi ‏44 KB

  • State machine with using event case

    Hallo everyone,
    i have a question about how to realize the "Timeout". In the flow diagram below we can see 2 different situation:
    1. in the 1st Situation i have used the state machine, it begins at state 1, which contains a event case. In there it will be at first determined, if the input value has changed within 10 second,  if it didn't, the state machine will go to state 2, if it 's  changed, will be furthermore determined, whether the input value equal to 3, if yes, the state mashine will jump to state 3, if no, jump back to state 1. (this VI i have done before, you can take a look at the Attachment).
    2. my question is in the 2nd situation. It begins also at state 1. In there the input value can also be changed (once or many times) or not. If the value has not been changed within 10 s, or even though it's been changed many times within 10s, but  it's never been equal to 3, the state machine will go to state 2; only when the input value within 10s equal to 3, it can jump to state 3.
    This problem i have no idea how to solve, does anybody have  idea or better methods?
    thanks a lot!!
    Solved!
    Go to Solution.
    Attachments:
    situation 1.vi ‏12 KB

    The statement in the OP is not covering all cases.
    mexaviesta wrote:
    2. my question is in the 2nd situation. It begins also at state 1. In there the input value can also be changed (once or many times) or not. If the value has not been changed within 10 s, or even though it's been changed many times within 10s, but  it's never been equal to 3, the state machine will go to state 2; only when the input value within 10s equal to 3, it can jump to state 3.
    This problem i have no idea how to solve, does anybody have  idea or better methods?
    thanks a lot!!
    Just check my implementation for Situation 2 and let us know, if it works for you.
    I am not allergic to Kudos, in fact I love Kudos.
     Make your LabVIEW experience more CONVENIENT.
    Attachments:
    Situation 2.llb ‏40 KB

  • How to use elapsed time function with state machine in Lab VIEW

    Hello
    I've been trying to use state machine with elapsed time function in order to sequentially start and stop my code. The arrangement is to start the code for 1 minute then stop for 5 minutes. I've attached the code, the problem is when I place the elapsed time function out of the while loop it doesn't work, on the other hand when I place it inside the loop it does work but it doesn't give the true  signal to move to the next state. 
    Could you please have a look to my code and help me to solve this issue.
    Regards 
    Rajab
    Solved!
    Go to Solution.
    Attachments:
    daq assistance thermocouple(sate machine raj).vi ‏436 KB

    Rajab84 wrote:
    Thanks apok for your help
    even with pressing start it keeps running on wait case 
    could you please explain the code for me, the use of Boolean crossing, increment , and equal functions 
    Best Regards 
    Rajab 
    OK..I modded the example to stop after 2 cycles. Also recommend taking the free online LabVIEW tutorials.
    run vi. case statement goes to "initialize", shift registers are initialized to their constants. goto "wait"
    "start"= false, stay in current state. If true, transition to "1 min" case
    reset elapsed timer with True from shift register(counter starts at zero)."time has elapsed"=false, stay in current state(1 min). If true, goto "5min" case
    reset elapsed timer with True from shift register of previous case(counter starts at zero)."time has elapsed"=false, stay in current state(5 min). If true, goto "1min" case. Also, bool crossing is looking for "true-false" from "5 min" compare function to add cycle count.
    Once cycle count reaches 2, stop while loop.... 
    Attachments:
    Untitled%202[1].vi ‏42 KB

  • How do you create array of enums for transitions in a state machine?

    Hello,
    I am trying to build a state machine, but, I am struggling with understanding the methods for determining which state to transition to next.  In other words, I have several states, but, I don't want to go in any particular sequence.  If I have states numbered 1 through 10, I want to be able to go 1-4-2-5-6-2-6-1-10 etc. in no particular order. I want the transition to the next state  (and actions) to be determined by the streaming data, which can be random and require access to any of my 10 states at any time and in any sequence.
    I saw this picture on the "Application Design Patterns: State Machines" white paper, but, it leaves out some important details.  How does one create the structure in BLUE shown in 3C?  When I try to create this array of enums, all of them are the same. I am not able to make a list of different enum values.  In other words, when I type in "2", then, all the values in the array display as "2."
    There is a nice, simple video example of a state machine for dispensing soda for $0.15, however, this state machine moves in a single sequence, from 5 cents, to 10 cents to dispense; it does NOT illustrate how to select a state "out of order."  I need to understand how a state machine can move from "5 cents" state to dispense directly, with the addition of 10 cents to the "5 cents" state.
    Can anyone suggest a really good tutorial on how to make the selector work in a state machine?  I have been reading some of the available material on ni.com, but, I can't find a good detailed explanation of how to do it.  I remain confused. 
    Or, can you just explain how they created the BLUE array in the attached picture?  Maybe I can figure it out from there.
    Thanks,
    Dave
    Solved!
    Go to Solution.
    Attachments:
    next state.jpg ‏75 KB

    Hi Kathryn,
    Yes, this is EXACTLY what I want to accomplish...
    So it would basically run:
    State 1
    Read input
    Determine next state (say 3)
    State 3
    Read input
    Determine next state
    State
    Read input
    Determine next state
    And so on...
    But, I am quite new to programming Labview state machines, and can't figure out how to even start when the sequence of states is random instead of fixed!!! I can do 1,2,3,4, like the vending machine VI example, but,  not 1,3,2,2,2,5,2,1 etc. based on external input.  Is there some simple example case I can study?  I can't believe I am inventing this for the first time.
    "select the state to run" 
    But, HOW do I do this???????   This is exactly the question I am asking...how is this done?  Please see the attached 3-state system....how do I hook this up????  I am totally lost here...can you help me understand how to wire this thing??  In this simpe RED/GREEN/BLUE case, my input is just the number a user would input on the front panel....  Apparently, there are two files necessary... a vi and .ctl???  What  is .ctl?
    Thanks,
    Dave
    Attachments:
    forum nov 12 red green blue.vi ‏7 KB
    forum nov 12 red green blue.ctl ‏5 KB

  • Help me with a state machine design

    I have a little bit of a problem.  I have a system with several modes, each selected by the user and called with a case structure.  Each case in the case structure is its own state machine with a few states (like 4-6).  Now here's the catch.  I need one of the states within one of the modes to call and execute an entirely different mode (and all of its states) without actually changing the mode command, and to do so every iteration until I jump out of that state into another state within the first mode.
    Is there a simple way to do that that I'm just not thinking of?
    Lee Jay

    Lee, my first thought would be to use just a big state machine.  For example if each mode needs 4 states, mode 1 gets states 0-3, mode 2 get states 4-7, and so on.  This way, if you need to change modes in the middle of another mode, you just direct the state selector to the state that starts the mode.  (If that makes sense).  It's not real elegant, but it works fairly well as you still maintain the flexibilty of the state machine design, including the ability to add and rearrange cases. 
    Don't forget you can use any method to select the cases, including strings, so you have full flexibility with how you setup case select.
    Troy

  • Double Click Property Node not functioning with Queued State Machine

    I am writing an application which relies on input from the operator to start different steps in a process of steps.  I am using a queued state machine, however I cannot get the Double-Click property of my listbox to function with in this Queued state machine.  I have tried Creating a refrence to the Listbox and creating a property node from that refrence.  I have tried a property node of the control.  The double click functon works only if the queueing is not occuring.  It has something to do with the queue but I am at a loss as to what is causing it.  Any help would be GREATLY appreciated.  I have attached a simplified version of the state machine with the double click function.  Thanks for any help on this.  It is written in LV7.1
    Attachments:
    Test Q.llb ‏55 KB

    Hi
    Its  Simple....
    Your Properrty node is not getting read..... dont understand how..
    see the attachment...
    now laugh at your small mistake... (even i have the habbit of making such small mistakes ;-) )
    Message Edited by Tushar Jambhekar on 01-11-2006 11:38 AM
    Tushar Jambhekar
    [email protected]
    Jambhekar Automation Solutions
    LabVIEW Consultancy, LabVIEW Training
    Rent a LabVIEW Developer, My Blog
    Attachments:
    Test Q.llb ‏55 KB
    Picture.JPG ‏44 KB

  • How do I add new data to the same file in a State Machine?

    Hello,
    I have a State Machine, with a State where 3 samples of data are collected in a For Loop. I would like to save this data in a file and keep adding new data to the same file each time I get to this state. The problem I'm running into is that each time I reach this State, my old data in the Excel file gets replaced with the new data instead of being continuously added in the same file.
    Ive tried Shift Registers but I may not be using them correctly since my file keeps displaying only 3 new data points.
    Any ideas will be appreciated!
    Thank you, so much.
    -Peter

    Where should I place these shift registers? Where should I place my File I/O VIs? Is it possible to use the Write to Spreadsheet File VI in this situation?
    Ive attached a very simple example of the problem. Thank you.
    Attachments:
    StandardStateMachine 2.vi ‏16 KB

  • Wiring Data in a State Machine

    I have a state machine with about 20 cases all handling different user interactions and all completely independent of one another. That is, what one case does has nothing to do with what another does (for most of them anyway). They just execute one case and then go back to the default case. Some of them though do require data to be passed out of one case so that it can be read in another (actually not the data but just the data structure to be reused). Shift registeres work just fine of course, but this requires me to wire this data through all the other cases that don't need it just so they can have an output for the tunnel. Is there anything else I can do to avoid wiring paths through every case that doesn't actually need the data?

    Here's a real simple example. I can't give you too much insight with respect to the memory usage, except to say that I've never had any problems doing things this way. I've written a couple of big vi's with 30 - 40 variables clustered this way.
    Attachments:
    Clustered_Variables.vi ‏35 KB

  • Event structure in a State machine

    Hello all,
    I've got a state machine with a sort of Stand-by state from where a user can select the next state using buttons. I tried using an Event structure with value change to select the next case but when the state machine is in a specific case and the button of an other state is pressed the whole thing blocks. I've attached an example, the LEDs just indicate what state you are in.
    Thx for your time,
    Bert
    edit: Indeed, I miss-clicked
    Solved!
    Go to Solution.
    Attachments:
    Question.lvproj ‏2 KB
    Question.vi ‏21 KB

    All your inner while loop should not be there, they just gum up the gears. It is a bad idea to trap the code inside inner loops, because during that time, events cannot be handled, whil they are still queued up. For example if you are in state 1 and press state 3 100 times, then exit state 1, state 3 will be entered 100 times in a row, witout a possibility of escaping.
    Thus the use of an event structure is also ill advised here.
    Here's is a quick draft showing the same code without inner loops and without the event structure just to give you an idea what I meant. See if it gets you some ideas. It is still not perfect ...
    (Sorry, I had to disconnect the type definitions, because you did not include it)
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    Question 1mod2.vi ‏19 KB

  • Adding multiple states in state machine

    Hi all,
    I have a state machine with many states.  I am using an enum to select state.  I didn't add all the state in the enum at the beginning, so I am adding more statess to the enum and to the state machine as I go.  I found the following pretty troublesome.
    If after I made the first 3 state, and I realized that that next 3 states are very similar to the first 3 states.  I want to copy duplicate the first 3 case all at once, instead of duplicating one case at a time.
    If I duplicate one state, and the wrong enum is assigned to the state, is there a quick way to change it? 
    Are their anything out there that would help plan and keep track of the state machine?
    Let me know if you have any cool tips to speed up state machine development, especially topic on enum and case structure (adding, deleting, multiple copy, etc).
    Yik
    Kudos and Accepted as Solution are welcome!

    jyang72211 wrote:
    after I made the first 3 state, and I realized that that next 3 states are very similar to the first 3 states.  I want to copy duplicate the first 3 case all at once, instead of duplicating one case at a
    If at all possible, never copy and paste code that is very similar to another piece of code! Try to write modular code. If there are several states that are almost identical except for a few slight differences, wrap those differences in a small case structure within the case.
    If you ever find yourself tempted to copy and paste a diagram of code that is larger than a POSTAGE STAMP, reconsider!
    a.lia-user-name-link[href="/t5/user/viewprofilepage/user-id/88938"] {color: black;} a.lia-user-name-link[href="/t5/user/viewprofilepage/user-id/88938"]:after {content: '';} .jrd-sig {height: 80px; overflow: visible;} .jrd-sig-deploy {float:left; opacity:0.2;} .jrd-sig-img {float:right; opacity:0.2;} .jrd-sig-img:hover {opacity:0.8;} .jrd-sig-deploy:hover {opacity:0.8;}

  • Using "Enum constant" in state machine.

    hallo all.
    i bild state machine, with 10 states. i move beetwen the states with Enum constant.
    my qustion is: if i want to add/delete some  states, why i need to update the Enum constant at every state ?
    there is  way to update "Enum constant" at one state, and  all other "Enum constant"(in other states) will update automatically
    thanks

    If you save you enum as a type def and replace all of the current occurences of the enum wi the type def, you shoud there after only have to update teh typedef.
    1) Find an oocurance of the enum
    2) Right-click and change to control.
    3) Find control and select Advanced customize
    3) Pull down on selector and change from "control" to "type def"
    4) Save control.
    5) close editor and when prompeted say yes to replace control.
    6) Change control back to constant
    7) replcae all previous occurances by choosing replace >>> the typedef'd control.
    8) Case structure will folow typed def from that point forward.
    Ben
    Message Edited by Ben on 12-24-2006 03:31 PM
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

Maybe you are looking for

  • Problem with Adobe BRIDGE getting Photoshop/Image Processor menu

    When I open my drop-down or fly-out menu under TOOLS in Bridge (CS3 version), the entire portion of the menu which is supposed to appear next underneath the Cache line option is missing (i.e., Photoshop, Illustrator, InDesign, Start Meeting..., Photo

  • Parameters to FM FLTP_CHAR_CONVERSION_FROM_SI

    Dear all, I want to use this Fm FLTP_CHAR_CONVERSION_FROM_SI  but i m unable to pass the required paarmetres . My Unit IS KWH . value  3.5561772000000000E+13 Please help me  as soon as possible . Thanks and regards, Sonal.

  • How to create OIM group with partial edit privileges?

    I need to create an service desk group that has the privilege to reset the password of a user but cannot edit any of the other user attributes. Also grey out the 'edit' button for them. Also, members of this group should not be able to delete the acc

  • Error: SAPinst not connected to AS Java

    Hello, i had already installed minisap and want to Run Adobe Form On it. so I am installing sap netwevear SDN_Preview_SR_5_CE71. JAva Enviorment is already installed on my system and i am installing it on windows server-2003. but i am getting error "

  • Ultra 60 console port gives OK Illegal Instruction

    I've got an Ultra 60 whose video no longer displays. The ethernet port had died a couple of weeks previously. I had been trying to swap in a couple of base 100 ethernet pci cards into, to see if they were recognized. I had installed one last week, bu