How to implement state machine architecture

Earlier in this forum, i had taken help in improving the subparts of my main vi, now i had developed a main vi,it is working correctly without any error, but i had used sequence architecture in that and as everyone says we should use state machine instead of sequence architecture, i am posting my vi please help how to implement state machine architecture in this, and actually in my vi, i am having 5 tabs( presently i have developed only 2 tabs) 1. patient info, 2.naadi acquisition, 3.nostril temp., 4.vision acquisition, 5.other info. presently with tab control i am using case structure so that only only particular page runs at particular time, i want to know how can i improve this code to work more efficiently.
Attachments:
intelligent diagnostic bench.lvproj ‏68 KB

i am sorry, i thought that vi's are by default attched with project files,i am attaching the main vi and all other associated subvi's also. 
Attachments:
Final Diagnostic Project.vi ‏375 KB
createfolder(SubVI).vi ‏65 KB
checkstring(SubVI).vi ‏11 KB

Similar Messages

  • How to run a particular case continuously in event based state machine architecture.

    I am making a program using event based state machine architecture, it is running as expected whenever i am generating an event, case structure corresponding to that event executes.
    we are taking some measurements from oscilloscope e.g. i am having one boolean button for rise time whenever i am pressing that that button it displays the value of rise time, it displays only once( since i have generated an event on that boolean button so it executes only once and displays value for one time and then comeback to timeout state) but in our program what we want, we want it to update value continously once that button is pressed.
    Now for a time being i have placed while loop on the case corresponding to rise time but this is not the right approach.
    since i am using state machine architecture( event based ), i am not getting how to run particular case continuously ,or if there is any other better architecture that i can use to implement the same application.
    Attached below is the program.
    Attachments:
    OScilloscope .zip ‏108 KB

    Say, in the attached program, when the user selects Autoset, it inserts corresponding state (Autoset) and now if you want this state to run again and again, probbbly you can again insert Autoset state while executing Autoset state... ohhh its confusing... check the picture below (A picture is worth a thousand words):
    1. Based on user selection, insert Autoset state.
    2. Re-insert Autoset state again and again while executing Autoset state.
    3. Now to come out of this loop, based on appropriate event generation, insert any other state AT FRONT (equivalent to Enqueue Element At Opposite End).
    I am not allergic to Kudos, in fact I love Kudos.
     Make your LabVIEW experience more CONVENIENT.

  • How to create State machine workflow?:

    How to create State machine workflow

    Hi,
    According to your post, my understanding is that you want to send email to Assigned to person when item is created in Task List.
    You can set E-Mail Notification to Yes under your Workflow Tasks list > Settings > Advanced Settings. By doing so user specified in AssignedTo will receive e-mail notification when task is created.
    Here is a similar thread for your reference:
    https://social.technet.microsoft.com/Forums/office/en-US/44f63c3c-8dfc-4f02-b627-a92249404ae3/task-list-advance-settings-email-notification-send-email-when-ownership-is-assigned-or?forum=sharepointgeneral
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • How to do state machine using events .

    Hi all.
    i like to create a state machine using events methos .
    i have 4 functions 1,2,3,4. (event based functios) (seperate sub vis)
    1.i will trigger the 1 function.
    then end of the first function should trigger the next function.
    like state machine .
    how to create this method in labview .. i tried value signaling its still not working . what i want.
    Solved!
    Go to Solution.

    JGar wrote:
    Wouldn't it make sense to have the entire state machine within one event case?  When you trigger the event case the state machine then executes like a normal state machine.
    DO NOT DO THAT!!!!!!  Long parts of code do NOT belong inside of an event case.
    The Event Structure should be in its own state and the state machine should to to that state every once in awhile to check for user events.
    Alternatively, you could put just the state case structure inside of the Timeout event case.  Something like this: http://www.notatamelion.com/2015/03/02/building-a-proper-labview-state-machine-design-pattern-pt-2/
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • How can A state machine be used to monitor flow from a micro motion using bridgeview/labview

    I want to be able to use a state machine to monitor if the flow stops during a chemical charge. Currently I am using labview 5.0 and this monitors flow but I need an alarm to let me know if flow stops during a charge. Any suggestions?

    this example might explain what i meant.
    A Rafiq
    Attachments:
    statemon.vi ‏55 KB

  • How to implement State of charge kalman filter algorithm in C code

    hi,
    I am going to implement kamlan filter algorithm in C code. Is anyone here did this before. Please share your ideas and tell me how i can implement this. Give me some ideas. It would be highly apreciate. thanks in advance
    here i attached the kalman filter algorithm file.
    regards,
    usman
    Attachments:
    1.docx ‏74 KB

    Hi,
    did you already have a look at some implementations of the Kalman filter ? For example, that one : 
    Kalman filter c code implementation. How to tune required variables?
    http://forums.udacity.com/questions/1021647/kalman-filter-c-code-implementation-how-to-tune-required...
    or that one :
    http://alumni.media.mit.edu/~wad/mas864/psrc/kalman.c.txt
    Hope it helps!
    Aurelie

  • Data acquisition in a state machine

    I've recently learned how to implement state machines, but I have a question that I haven't been able to find an aswer to.
    Question:
    How do I record uninterupted data (presently i'm using the DAQ assistant to record a single channel at 10kS/s at 1kS intervals) without interfering with my state machine?  
    Background:
    I have a time sensitive test setup (measuring pressure in a rocket chamber), and I'm using labview to both record a single pressure transducer as well as operate the valves (O2, N2, igniter, etc).  I'm using a state machine Labview architecture (just learned how).  Presently, the DAQ assistant sits in the "Idle" state, and timers (valves need to be turned on at specific times) and manual buttons control when the other states are activated.  I have a 10ms timer controlling how often each state is run, and this is the root of my concern.  
    Main concerns:
    I'm worried that:
    1)  I'm forced to change my data recording to 10ms intervals to match the 10ms timer, and
    2)  The 10ms timer will interrupt my data recording when it's in another state.  
    It's very important that the pressure data is recorded without interruption but that I have high time resolution in controlling my valves as well.
    Thoughts:
    1)  Maybe I put the 10ms timer in the "Idle" state only, and this way the other states won't interrupt the data acqusition
    2)  Maybe there is a way to completely isolate the state machine for controlling the valves and the data acqusition.  I'm not sure how to do this.
    3)  People on the forums have been talking about Queuing their data acqusition, but I'm not sure how this would benefit my situation.  
    Thanks to everyone for their feedback!

    The data acquisition and state machine timer do not have to be equal, you should however have the same data write rate as you have data read rate, otherwise over the course of long running programs you can build up a large buffer of data to be written using a lot of memory, or lose data.
    Your data acquisition should be continuous, the most common way of doing this is every time you receive data write it to a queue, then when you are in other states except your data write stage you simply build up data in the queue that is to be written when you enter the write state again.
    Think of it as traffic reaching a set of lights:
    The traffic represents the data acquisition, there is a constant flow of it always coming through, the state of your state machine is the lights, green is the data write state clearing the queue, red is when in any other state, letting the traffic build up behind the lights.
    It is just important that the light is green long enough to let the traffic not build up too much, otherwise you have a jam.
    EDIT: For the basics of how queues work, look at the Queue basics example from the example finder. 

  • Queued State Machine, not a state machine?

    I've been reading up a bit on design patterns that seem popular among LabVIEW users, and I have a question with regards to the design pattern described in the following article:
    http://expressionflow.com/2007/10/01/labview-queued-state-machine-architecture/
    I don't see how this is a state machine at all. To me it just looks like a producer/consumer pattern for queuing up actions (what is described in the article as states) to be executed in the consumer loop. I don't see where a state machine comes into play, determining state transitions based on current state and inputs, like shown in the following:
    http://zone.ni.com/devzone/cda/tut/p/id/3024
    Am I completely off?

    Yeah exactly.
    I was thinking a nice way to implement something QSM-like would be to produce instances of a message handler object that maintains its own state and a message queue. You could produce a new object for network I/O that inherits from the general message handler, one for managing the UI, data aquisition etc. They would communicate in a network by passing messages back and forth to their respective queues and each would be a true implementation of a state machine.
    Has to be right up LabVIEW's visual alley
    Edit:
    Now that I come to think of it, this would be almost exactly what could be done compactly with LabVIEW event handlers and user-generated events.

  • Tips to remember when using Queued State machine

    I have been able to work through to convert my State Machine architecture to a QSM thereby eliminating using Local variables/property nodes to send values/data to my State machine but instead sending them through queues.
    I would like some tips/advice on making use of them perfectly. Especially, "Not to do" stuff with queues and How to efficiently release a queue etc. What is the convention when using queues? Thanks!
    V
    I may not be perfect, but I'm all I got!
    Solved!
    Go to Solution.

    VeeJay wrote:
    Hmmm!! I jumped the gun... I would have to say, Neither... I guess it isn't really QSM or Queued message handler. My State machine is the generic one. But, data for the SM is obtained from a queue and feedback is sent back from the State machine through a queue. Does that clarify ?
    BTW, good to know more variations.. Thanks!
    That is a QSM.
    I will defer to those that use them regularly.
    I would only use such a a construct if the queue was limited to a single entry and prevented inserting multiple states at the front or back of the queue.
    As long as the queue is limited to a single entry then a State Transition Diagram could be used to described all of the states.
    The multiple entry version can be thought of as a method to implement a "goto" statement in LV. Very useful for those that come from a background working with stacks and pushing and popping off work and those that use them often love them.
    But for me let me refer to a letter from Dijkstra quote from here
    "GOTO Staements Concidered Harmful" goto statement introduces chaos
    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

  • Handling menu selection in multi states of states machine

    Hi everyone,
    My application uses states machine architecture, I have to handle menu selection in two different states and the 2nd of them has to be handled by the event case structure.
    The problem is that when I use event structure in the 1st state it is also handled later by the event case in the 2nd state and it is impossible to handle menu selection in the 1st state by the "Get Menu Selection" block because according to it's descripton if event structure is configured to handle the same menu as item as this block, LabVIEW ignores this function.
    I would be greatful for any clue.
    Greetings,
    Mariusz
    Solved!
    Go to Solution.

    Thanks for respond.
    Here's a code explaining the main idea.
    Attachments:
    Untitled 1.vi ‏9 KB
    Enum_States.ctl ‏5 KB

  • Using multiple events structure inside state machine to control the Tab

    Hi y'all,
    Anne here.I have a Tab indicator in my front panel and I want to be able to control the flow of my program based on what controls I clicked inside the tab. I am using a state machine architecture and inside every state, I use an event structure to check for user interaction  to determine the next state and what tab page is going to be displayed next. This means that I am actually using multiple event structures in my application and I use them in just one while loop, but just that they are not running in parallel since I am only using "one event structure per state" which means that only one event structure is running at one time. My questions is, programming technique wise, am I doing it correctly? So far, I am not facing any problem (I am still in the early stage of the project) but I want to check with you all first on your opinion regarding this architecture. Will there be any issue on using multiple event structures in a vi? Since I will be using a tab, and the controls available in the tab will be the controls that will control my event structure for that state, by right, there should be no issue. Am I correct to assume this? Is there any limit on the use of event structures? I have attached here a simple sample of the architecture that I am talking about for your reference. I have attached a 2010 version and a 8.6 version. Let me know what you think or any opinions that you may have.
    Hoping to hear from you soon! Thanks so much in advance!
    Cheers!
    Anne
    Attachments:
    State Machine-Event Structure Sample_2010.vi ‏19 KB
    State Machine-Event Structure Sample_8.5.vi ‏25 KB

    Hi jak888,
    I decided to use tabs cause I don't want to have subvi pop ups every time i need to perform the process in the state and show an update in the front panel. This is actually going to be more of an ATE where you will have to choose first whether the one using is the operator or the engineer. If the operator is logged in, she will proceed to choose what test to run (this state will have its own event structure). This part, I don't want a pop up, so what happens is that from Login page, if the user logs in as operator, the tab will automatically switch to the Test Selection page. After selecting the test, it will proceed to Start Test state and the tab will show the Result Summary page. If the user logs in as engineer, then a totally different tab will be automatically shown next and so on. By doing this, I will be able to show an update on the front panel objects without having the subvis pop up. I will also just need to use the call reference functions to call my subvis, making my Main VI more generic. The tab Page header will be hidden so the operator will actually not see that there is a tab and that there are a lot of controls and indicators cause they are hidden in the tabs and that page will only be shown based on what they selected from the main tab. 
    I appreciate your thoughts! thanks so much!

  • Web Services for a State Machine Based VI

    Hello,
    I am new to the Web Services approach but so far I have managed to build a simple VI which is used with Web Services to display a Graph and make some simple calculations.
    However, I have a more complex application which uses a State Machine architecture to command some circuitry using the NI USB 6211 device. This program includes different states and all the action takes place inside a while loop. This loop uses shift registers to pass the states arround (the JKI State Machine).
    My question is: Could such a program be used with the Web Services without modifying this structure?
    In the programs that I have tried, if I place the execution inside a While structure then I get no result with the Web Services. 
    An example of a simple program which includes a while loop and the Web Services approach would be helpful, if possible.
    Thank you in advance.

    Hello again,
    I was trying to do what Nathand indicated.
    1. "Put a functional global in it that stores whatever value you want to be queried over the web,"
    So I opened a new Project and added the Index.vi just to generate the numbers continuously. This VI writes to a global variable entitled "GlobalOutput.vi".
    This works as I have attached the jpg image.
    2. "and make that VI accessible through VI server."
    This I am not so sure I did correctly. I opened the Tools->Options->VI Server, and here at the section Exported VIs, I added the GlobalOutput.vi. I have attached the image.
    3. "Then, in your web services VI, open a VI server connection to that functional global and run it, by reference, to obtain the value stored there."
    Now I have created another VI, called ServerConnection.vi which runs the GlobalOutput.vi. I have attached the image with the error I get. Something is wrong in what I am doing. In the end I thought that I would create a Web Service for this last vi and basically be able to read the global variable.
    As I understand it, you have a VI which runs locally, in a while loop and updates some global variables. Then another vi reads the values of those global variables.
    It is this last vi that you should create a web service and interogate to find out the values of those variables. What am I missing?
    Thank you in advance.
    Attachments:
    GlobalVariable.JPG ‏21 KB
    ViServer.JPG ‏36 KB
    error message.JPG ‏38 KB

  • Well-oiled typical state machine

    In my new-to-LV adventures I feel like I'm spinning my wheels to revinvent the wheel.
    My project has modest complexity and it was advised to be a state machine architecture.
    Can you post an example of a well-made state machine that of low to medium complexity?
    I think If I could study several good examples, I could answer most of my questions. 
    Please post if you would like to share. 

    http://www.ni.com/tutorial/7595/en/
    http://www.ni.com/white-paper/7604/en/
    http://k12lab-support-pages.s3.amazonaws.com/lvadvancedhome4.html
    https://www.youtube.com/watch?v=vtw6HMwaTIQ
    This lot took me at least 8 seconds to find with Google. Invest a little more time and you could probably do even better
    (there really is a lot of stuff out there!)
    EDIT - okay so this crossed with your last post, and is probably a tad sarcastic and looks even worse following your last reply. But you will do well with a bit of searching because, like you want to not re-invent the wheel, neither does everyone else when there are already so many good examples out there.
    EDIT - for a little more complexity, check out the Continuous Measurement and Logging sample project template - althogh a slightly different architecture it has all the elements you listed and more.

  • LabVIEW Queued State Machine as Parellel Process Enabler

    Hi
    LabVIEWs Queued State Machine Architecture is a detailed article on its application for parallel process programming geared to take advantage of LabVIEWs hyperthreading capabilities and multi-core processor PCs of today.
    I am writing future book chapters as blog articles so your critique/comments are appreciated.
    Anthony L.

    I have really enjoyed the articles on ExpressionFlow.  I also like this one, but I think it could use just a little work.  I think that the content is good.  However, about 1/4 of the way down, you have:
    A general layout of QSM-PC architecture comprises of the four objects annotated by the encircled numerals 1 to 4 shown in Figure 1.
    These objects are namely: (1) Queue reference object; (2) User events
    object (optional for head-less embedded applications that require no
    user interaction); (3) Main state machine object; (4) One or more
    parallel processes subVI objects.
    You then go on to have
    Item (1) The Queue Reference
    Item (2) Consumer Object State Machine
    Item (4) Parallel Process SubVIs
    You need to reconcile the two.  I think that a separate (probably earlier??) chapter/article on event structures including dynamic (user) events could be referenced as item 2.
    Thanks for the articles and I hope that this helps!
    Bob Young
    Bob Young - Test Engineer - Lapsed Certified LabVIEW Developer
    DISTek Integration, Inc. - NI Alliance Member
    mailto:[email protected]

Maybe you are looking for