Producer consumer vs state machine

Hi there,
I have been on and around for quite a while to understand how can I re-design an application, which was originally built using a mix of sequence structure, while loops and event structures. And now I am making a newer version of the same application, for research purposes, while learning the LabVIEW techniques. Earlier I used LabVIEW versions 5 and 6 to make simple programs for fuzzy logic and neural networks. And that's not a good reference.
Ok, after learning that Producer Consumer (PC) and Standard State Machines (SSM or SM) are two new approaches for a better (scalable, flexible and efficient) coding as suggest by veterans, in one thread where I asked about another issue, I have started digging into this topic and now I am on a point where I have to implement it finally (spent pretty much time in the learning phase).
I have several questions.
To start the discussion, I would give a brief description of my application.
It's a networked application, where the network communication happens using DataSocket (one reason to use LabVIEW as the environment).
We are talking about the client application, which communicates with other applications on remote computer, via Internet.
User interface involves a tab control, with several pages-
On startup, the controls/indicators (now onwards referred as controls only), are initialized, datasocket connection is checked (rather internet is checked, and a connection established with the remote datasocket server) (page 1)
If connected to the datasocket server, the user selects Login/Registration (page 2)
Login and/or Registration happen on page 3/4
Then the user sees a table of remote users to connect to (page 5)
Upon selection of a remote user, and after clicking on "connect", the user will see a video indicator, with a lot of other controls. (page 6)
On this page with video indicator and controls, the user has a lot of activities, in which many messages are sent and received to/from the remote machine.
the user may disconnect and go back to page 5, and log out and go back to page 2 and so on.
I hope this is clear.
I have thought about two different ways to do this application. Using PS or by SSM.
In the attachments, I have given a diagram (with errors, of course, because of unlinked controls), for each of the approach, plus the original application's diagram.
I hope this is sufficient for anybody to understand my case and give suggestions.
I am looking for suggestions about which is a better model for my type of case. I have been to discussions like this one and saw that there are many issues regarding dequeue in PC model. So I am curious to know if SSM is a better and latest model or it's more primitive? Which looks better for my application's performance?
Thanks ahead!
Vaibhav
Attachments:
OldDesign.vi ‏41 KB
PCDesign.vi ‏42 KB
SSMDesign.vi ‏46 KB

Vaibhav wrote:
@ Harold
Thanks. Any suggestion how can I start and stop that loop in parallel with other loops? Like, if some event occurs, the loop should start execution, and keep on moving, while other events are being traced and executed.
In those examples where you had a while loop inside a case structure, that bit of code will only execute one time.  It will immediately read the boolean at the start of the program, if the value was true before the porgram started, then the while loop will run.  Once that while loop stops, the case structure will end.  It will never execute again unless you completely stop and restart your program.  If the boolean is false before the program starts, the false case will execute immediately.  Nothing happens since it is empty and it is done, never to run again (unless you stop and restart your VI)  You should turn the structure around.  Put the case structure in the while loop.  Make sure you put a small wait statement in the loop so that it doesn't run full speed eating up CPU cycles just polling the status of the boolean.
@ Ravens
Thanks for the detailed comment.
One thing I would clarify. The user will not be able to switch between the pages using the tab control. The program will direct appropriate page to the user. I kept the tabs visible just for your idea of the pages. Sorry, I didn't mention that.
Do you think it's still a bad design?
If the tabs will be hidden or disabled, you will probably be okay.  I wouldn't call it a bad design.  I wouldn't do it that way.  But as long as you understand the possibility of problems and prevent that.  Especially some time down the road when you modify the program in some other way that could lead to a problem because you forgot about the dependencies of the event structures on the state of the state machine. 
Yes, I agree about only one event structure to handle all the events. But since the user will not be able to click somewhere else, other than those possible controls, I thought to keep it like this.
I thought the events are captured only if we are in that case. I think I am wrong, right? Events are captured at any time, even if the case has never executed before, or will never execute.  Ok, The events will be captured, but will not be executed until in that case.
And that's the reason why I have two separate event structures, in two separate phases of the program.
Because, prior to page 6, the events will occur sequencially. The user will click somewhere, then some message will be transmitted over DataSocket, then some message may come , then again some user action and so on. But, when the user starts using page 6, there will be parallel process of user controls events and actions, and incoming messages and corresponding actions. For this, in the page 6, I need a different kind of execution. So I separated the two event structures.
At first I thought to have SSM, and then I thought to PC, just because I can have two separate parallel processes - one for user events, and another for messages (because that way I can take maximum advantage of message tracking). But looking at other complexities, I find SSM more appropriate. Can you please tell me how can I have my message loop and events loop parallel to each other and just one event structure?
You can have a dequeue function in your state machine loop and have it be a consumer loop.  Use a timeout on the Dequeue.  If there is a timeout, have the statemachine execute normally after that perhaps just passing the enum wire straight into the case structure of the state machine.  If it doesn't timeout meaning you got a message, then look at the message that is dequeued and act on it.  Perhaps it means ignoring the enum coming in from the shift register and changing the enum to something else to feed into the case structure of the state machine.  Attached is an example
Attachments:
PCDesign[1]_BD.png ‏6 KB

Similar Messages

  • 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]

  • Producer Consumer with a state machine within the consumer

        Hi All,
    I have been trying to develop a data acquisition system with the producer consumer architecture.  To the left of the two main loops I initialize the serial port and any constants and variables im using.  I also have an obtain queue VI needed for enqueue and dequeue. Then in the producer loop i have a state machine.  The first state is where I wait for a button press on the front panel to write a GO signal on the serial line which will tell the device connected to the serial port to begin sampling data.  After this button press I go into the next state which is called my read state.
    In the read state I use a property node to read all of the available bytes at the serial port and then enqueue this collected data into a queue.  The state machine then is directed to continously go to the read state again and collect more data.
    Now this is where my dilemma is......  The consumer loop has the dequeue VI inside it and after this VI i have a state machine (while loop and case structure) which contains the following states
    1.  Build Array - build an array from the dequeue element and if there is any left over data from the parsing states it will build an array with the left over data and the dequeued data
    2.  Determine packet type - this state looks for the packet type byte(not necessarily the first byte in the message) and also check the next byte (packet length) to ensure that I am at the begininng of this chunk of data.  This state may be a little slow because there can be three different packet types and based on this byte and the packet length it may have to search the array several time to find the valid starting point.  This state also determine the next state to go to based on the packet type.
    3 packet type 1 parsing - parse data and store the remaining data it leftOver array.  Go to exit state.
    4 packet type 2 parsing - "" ""
    5 packet type 3 parsing - "" ""
    6 exit - leave this state machine and fall back to the consumer while loop.
    After it exit I think it should fall back to the consumer while loop and dequeue more data and enter the state machine again to build a new array with the dequeued data and leftover data.  It seems to work when I trace the execution using the Highlight execution feature, however when I run this all at full speed, it seems to go into the consumers 1st and 2nd states back and forth and not completely go through the state machine.
    I tried adding in a delay in the producer loop to give the consumer loop time, but I didnt notice any difference.  Is it possible that my dequeue element is retreiving more data while im still in the state machine, causing the execution to leave the state machine before it finished all states?
    Is there a better approach to take to solve this problem. Basically I need to read data at a 1,000,000 baudrate and parse it as quickly as possible so that I can break it up into 3 different packet types, write the data to a file, and graph the actual data (header info removed) in realtime.  I need to also ensure that I am not losing any of the collected data.  Data loss cannnot occur.

    A couple of things more to go along with Ben's pointers:
    You convert your data from a string, to a U8 array, to a Hex string array in the producer loop, then convert back to a integer to determine what to do with it.  In the process, you create two or three copies of your data, slowing yourself down quite a bit.  The code would be quite a bit more efficient if you left the data as a U8 array.  You can change the format of the controls and indicators to show hex values instead of integer by right clicking on them and selecting Format and Precision...
    Your search code is fairly inefficient.  I made a whack at making it a bit better.  See attachment below.
    If you continue to run into race conditions, you can debug them using a calls to the Windows debug write sprinkled liberally about your code.  Check out the post here for more information.
    Don't let your lack of format LabVIEW training stop you.  The biggest thing to get is the data flow paradigm (aka data is wires, not registers).  Once you get past that and learn how to pass data around using shift registers, queues, events, etc, you are most of the way to mastering LabVIEW.  The rest is just learning the plethora of functionality LabVIEW gives you (yes, I have reimplemented LabVIEW native code more than once in the process of learning).
    Let us know if you need more help.
    This account is no longer active. Contact ShadesOfGray for current posts and information.
    Attachments:
    serialUtil_V3_DFG.zip ‏137 KB

  • State machine VS producer consumer architecture - Time Analysis

    After learning various methods to program efficiently and learn how to use SM and Producer consumer. I built a program to control stepper motor in both these techniques.
    Here is the RESULT. As we can see a simple state machine without any complicated producer consumer technique performs faster than the second one.
    I am not sure which is still the best based on performance and optimization. Please advise which one should I keep and why.
    Abhilash S Nair
    Research Assistant @ Photonic Devices and Systems lab
    [ LabView professional Development System - Version 11.0 - 32-bit ]
    LabView Gear:
    1. NI PXI-7951R & NI 5761
    2. The Imaging Source USB 3.0 monochrome camera with trigger : DMK 23UM021
    OPERATING SYSTEM - [ MS windows 7 Home Premium 64-bit SP-1 ]
    CPU - [Intel Core i7-2600 CPU @ 3.40Ghz ]
    MEMORY - [ 16.0 GB RAM ]
    GPU - [ NVIDIA GeForce GT 530 ]

    This is with state machine alone
    Abhilash S Nair
    Research Assistant @ Photonic Devices and Systems lab
    [ LabView professional Development System - Version 11.0 - 32-bit ]
    LabView Gear:
    1. NI PXI-7951R & NI 5761
    2. The Imaging Source USB 3.0 monochrome camera with trigger : DMK 23UM021
    OPERATING SYSTEM - [ MS windows 7 Home Premium 64-bit SP-1 ]
    CPU - [Intel Core i7-2600 CPU @ 3.40Ghz ]
    MEMORY - [ 16.0 GB RAM ]
    GPU - [ NVIDIA GeForce GT 530 ]
    Attachments:
    Control 1.ctl ‏6 KB
    Control 2.ctl ‏6 KB
    Motor-UNI_Directiona Dev 3-TIME_ANALYSIS-2.vi ‏54 KB

  • State Machine and producer consumer design patterns

    Hi!
    In my application I am using state machine(for top level VI) and producer consumer(for subVIs) design patterns throught out.
    If there is no activity on the front panel for 1min then the ideal state is invoked. Following are the situation of the ideal state:
    1. It checks for any hardware present on the network . If no hardware is found on the network within 1 min then the application and LabVIEW exits.
    2. While the ideal state checks for the hardware, and user clicks on any front panel button then it should exit the ideal state. The control
    should be in the respective button state.
    I am able to achive the point#1 mentioned above but could not get the point #2 to work. I am including the snap shot of
    the state machine(default case) and prouducer consumer(deafualt state).
    Each screen has the concept of the ideal state. The only additional step in the subVIs is that when the ideal state is reached and the time has expired then it will close the subVIfront panel.It will go to the exit state of the Main(top level) VI. Thus closing the application and quitting LabVIEW.
    Any ideas or suggestions. Will multithreading and notifiers help?
    TIA
    Rachana
    Attachments:
    Sanpshot_Of_Design.zip ‏75 KB

    Hi Rachana,
    I was thinking about using event structures wherein there would an event case that would handle any value change event for any of the buttons on the front panel. But before suggesting that, I would need to know more about the Ideal State subvi( more specifically, how is it checking for any hardware present on the network and where is the one minute wait coming from?).
    Please feel free to respond to this post with your questions/comments.
    Regards,
    Ankita A.

  • Producer/consumer state machine

    Hello,
    I have a State Machine with an Idle state that has an Event Structure to handle user events in it. I would like to include in that state, and in parallel with the Event Structure, a VI that polls for data every 10 seconds. Is there a way to have the Event Structure respond automatically to User events without having to wait 10 seconds before polling new data? Is the Producer/Consumer the way to go and how am I going to program this?
    Thank you,
    Richard
    Attachments:
    Tombeau_NewArchitecture1.vi ‏171 KB

    If you are polling for data (in the same state) in parrell to the event case then surely the event structure would execute at the same time you poll.. it would just not be able to jump to the next state in your state machine until the polling had completed.
    I had a quick look at your code, not to be mean but it's not the easiest thing to read. Try to keep the block diagram to a single screen so you don't have to scroll if possible. If that isn't possible, have it only scroll in one direction. You can achieve this with the use of Sub VIs.
    Also, be careful with using local variables to read and write. They are terrible for introducing race conditions. Instead trying using an FGV/Action Engine.
    Olly
    The day is quickly coming when every knee will bow down to a silicon fist, and you will all beg your binary gods for mercy.

  • Progmatically stop vi with producer/consumer architecture

    I can't seem to get my VI to fully stop, so that I can go on to do some more things in the program.  I am trying to progmatically stop the vi (pictured below), so that I can return to my main gui (not pictured).  The main gui just consists of a login, exit test system, and run test.  Once the user presses run test, the vi pictured below opens.
    I am using a producer/consumer architecture with a state machine.  The problem I run into is that when I press the "Main Menu" button, it should close the pictured vi and return to the main gui.  I tried using the vi server, and when the user presses the Main Menu button, it fires an event and then it goes to the Stop state in the consumer loop, which opens a reference to the vi's (one for the strip chart vi and another for the gage vi), closes the front panel using an invoke node and then closing the reference.  I also tried adding in the abort vi method after the close front panel and it still gave me the same result.
    Here is the catch, it does close the vi's, but it does not stop the while loops (producer and consumer), or it stops only one of the loops.  I thought of putting in a constant in the event structure for when the Main Menu event is fired, but that will stop the producer loop before the consumer loop reveices the info to go to the stop state, so the consumer loop does not end.
    I also tried a "dummy" control that was connected to the comsumer loop Stop terminal (for the while loop), and then progmatically changed the value in the stop case to true and then read that value in the producer loop to, hopefully, stop both loops, but it did not work either.
    I am sure that it is something so stuipidly simple that I cant see it right now
    Kenny
    Kenny
    Attachments:
    test system.gif ‏252 KB

    Hi Kenny,
    I think of two solutions to your problem. First, use the message queue to pass the message "stop" or something from producer to consumer or second (and I think, better), use occurrences. I made a little draft how it could work.
       You have to pass the occurence- Refnum to both VIs, the producer and the consumer, when the producer finishes execution, then use "Set Occurence".
       In the consumer blockdiagram you react on the generated occurrence.
    If you set in the VI- properties "Open Frontpanel when called" and "Close if originally..." the VI Frontpanel should disappear itself when execution is stopped.
    Hope this helps,
    Dave
    Message Edited by daveTW on 08-14-2006 04:53 PM
    Greets, Dave
    Attachments:
    occurrence 1.png ‏1 KB
    occurrence 2.png ‏5 KB

  • Data acquisition & state machine

    Hi all,
    I am working on a project that is capable of data acquisition, analyse, and record processes. I have to acquire data of temperature from 8-32 channels and that of pressure from 7 channels. After analysis, I have 48 outputs. I want to record raw data (acquired) and analysis data at the same time.
    1) Is it possible to record two text files (raw data and analysis data records) at the same time?
    I also want to adjust acquired sample rate but I have doubts about utilizing it in a state machine. For now, I have just used time elapsed function to acquire data once in 60 seconds.
    2) How could I set sample rate of acquisition except using time elapsed function?
    I also have one more doubt about timing. If I needed to acquire sample once in 60 seconds, but the analysis took more than 60 secs, what would happen?
    3) How can I prevent data loss in this case?
    I have not prepared a user interface yet.
    4) How can I utilize it? Do I put graphs and indicaters in the same VI or is it better to prepare another vi just for user interface?
    Thanks in advance
    Egemen
    Attachments:
    Program.llb ‏433 KB

    Hi Egemen
    -          If we need to acquire data and analyze it at the same time we recommend the architecture producer-consumer to prevent data loss, and yes you can record two text files at the same time. Please take a look to this architecture.
    -          http://www.ni.com/white-paper/3023/en
    -          Basically you use the first loop to acquire data and the second one to analyze and record data (using queues).
    -          https://decibel.ni.com/content/docs/DOC-2431
    -          You can also find examples about this architecture at the developer zone.
    Regards

  • Input and output on same device, producer/consumer structure

    Hello interested people,
    I have a question about using the same device for both digital inputs
    and outputs.  I have written a simple program of one while loop
    that continuously polls the device, processes, and requests.  I
    have addressed the device using two DAQmx Asst. and I have attached
    them with their error in/out cluster terminals to provide data flow and
    eliminate the chance of addressing the devices at the same time (which
    produces an error).  Now I want to change this program structure
    to a producer/consumer loop foundation with state machine.  
    In this design, I will have the DI in the producer loop and the DO in
    the consumer loop, under one of the states.  I can't simply
    connect the error in/out ports in this configuration, so my question is
    how to avoid the error caused by addressing the same device
    simultaneously with two different tasks (input and output)?  I
    have attached two VI's, the "One Loop" vi is the original configuration
    (simplified), and the Producer-Consumer vi is a NONSENSICAL program
    that simply represents the desired configuration.  (I don't need
    any comments on the programming of this vi, it is only an example for
    illustration of the problem). 
    I am thinking about bundling the input data and the error cluster, both
    from the PXI 6528 DI, into one cluster, queueing that up, and
    unbundling the de-queued elements for some kind of data flow between
    the producer loop and the "Request" state of the consumer loop. 
    Is this the right approach, or am I barking up the wrong tree?
    Thanks
    Attachments:
    One Loop DO DI.vi ‏102 KB
    Producer-Consumer DI-DO.vi ‏106 KB

    Hello,
    It sounds to me like you really have two modes:
    1. user interface actions determine execution
    2. user interface is locked, and execution is automated.
    I think it would make sense to use the producer consumer for an architecture.  Basically you would do the following:
    1. program the producer to handle the user interface as you normally would.
    2. provide one additional event case in the producer which would be your "automated handling" case.  In that case, you could put a state machine which could run until whatever conditions were met to put your program back in "user interface mode".
    Keep in mind that you can use custom USER EVENTS to programmatically generate events ie. you can trigger the start of your "automated handling" form anywhere in your code at virtually any time.
    I think this would allow you to take advantage of the producer consumer architecture in its intended spirit, while integrating an automated routine.
    I hope this helps!
    Best Regards,
    JLS
    Best,
    JLS
    Sixclear

  • Producer/Consumer Architecture

    Hello All,
                    I am currently working on an application using State Machine Architecture where I have to monitor various parameters (7 temperature values & 3 pressure values), along with this I have to On/Off a Clutch using a digital Output for set time (e.g. On for "X" seconds OFF for "Y" seconds), but as soon as the pressure and temperature values go beyond upper or lower limits or whenever the user presses the Emergency Stop (that means I have to monitor Digital Input as well) so I am moving to different error cases depending on which values go beyond limits or emregency pressed etc..
                But this realisation is not working fine as I have to monitor and control several other things in addition to acquiring data....till now I just have used State Machine Architecture, I have seen Producer/Consumer Template but not quite sure how to realise such kind of application which involves data acquisition along with user interaction and monitoring.
    Could someone please put some light on giving similar kind of example or what else I can try with this problem.
    Regards
    James

    Hello James,
    A Producer/Consumer architecture will certainly do the trick for you. I am sending you an example that has the Data Acquisition section in the producer loop. However, you can also put your User Interface in the Producer loop and have the Data Acquisition in the Consumer loop. The Queues are used for sending data from the Producer to the Consumer(s) loop(s) (you can have multiple comsumer loops).
    You will just have to design specific cases to react to different user inputs.
    By the way, this example is from LabVIEW Basics II training course. If you have never taken LabVIEW Basics I and II, I highly recommend them. You can self-pace the class or take it with an instructor.
    LabVIEW Courses
    Hope this helps!
    Message Edited by Kalin T on 03-23-2007 09:57 AM
    Kalin T.
    National Instruments
    Attachments:
    ImplementedProducerConsumer.zip ‏250 KB

  • Producer Consumer Parallelism Failing!

    I'm controlling multiple automation stations with a single cRIO 9074 -- the multiple stations are all following the same logic but should be independently controlled. I'd like to accept all digital inputs (from all stations) in a producer loop, queue them up, and then consume the data in 3 consumer loops which actually perform the logic (take a digital input and then decide what to output at each station).
    The actual logic is functional, but the three consumer loops are outputting the data with a time delay.
    So, for example, if I want my first step to be "Event 1", once I start the program the state machines decide that:
    Station 1: Event 1
    Station 2: Event 1
    Station 3: Event 1
    And when a decision is made to switch to Event 2, the 3 stations take turns switching (the action is not simultaneous), so you may get:
    Station 1: Event 2
    Station 2: Event 1
    Station 3: Event 1
    and momentarily after,
    Station 1: Event 2
    Station 2: Event 2
    Station 3: Event 1
    etc...
    Attachments:
    cRIO_fake.vi ‏27 KB

    RavensFan wrote:
    Queues are meant for a one to one, or many to one relationship.  Here you have a one to many which is wrong.  When something is sent, only one of the three loops will get the message depending on which is ready to grab the message first.
    You should have a different queue for each consumer loop.
    Or a User Event, and have all the consumer loops register for the single event so they can all act on it when one event is generated.
    Attatched is a quick example of what I was thinking.  You can make this more complicated, and wrap some functionality into SubVIs to help scale it for larger applications.  User Events do work in LabVIEW Real-Time but I believe you would need some kind of FIFO to User Event to go from a host PC to the RT to have work be done.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.
    Attachments:
    User Event Request Example.vi ‏17 KB

  • Producer/consumer architecture - timing

    Hello.
    I have some question about producer consumer pattern.
    People say that consumer shound NOT add elements into producer queue. Lets say that some states in in consumer need to stay active for eg 5 minutes. We also should be able to pause/resume state execution and exit program in any time. 
    I ve used functional global timer but consumer adds elements into queue and this should be avoided.
    How to solve timing problem? Some people have written about creating another thread - watchdog or asynchornous calls to vi...
    Could someone explain this to me?  :

    People have consumers add to their own queue all the time.  It is usually in a Queued State Machine though.  If you have a process that just needs to run for so long, then have the consumer run another while loop until the time is up.  It can then process the next item in the queue.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • How to start and stop video acquisitio​n in a state machine

    hello,
    I'm a neuroscience student and here's what I'm trying to do: 1) trigger a GigE camera (200fps), 2) start video acquisition, 3) trigger a light that will stay on for x miliseconds, 4) trigger a valve that will blow an air puff, 5) stop the tone and the valve simultaneously and 5) stop the video acquisition 1second after 4). For that, my VI is a state machine, with a state for each trigger (ex, 1 state for trigger camera, 1 state for trigger light, ect) plus a state to "stop" and a state "time to wait". Everything was working except the video acquisition - the program would trigger the camera but only acquire one frame, because it wasn't running in a while loop and this is my first question: for a video acquisition is it always necessary to have a while loop?
    I assumed the answer was yes, so I built a "consumer" loop for the camera. Putting a queue in the state "trigger camera" in the producer loop, I was then able to start the video acquisition but now the problem is to stop it in the right time. I have another queue in the "stop" state in the producer loop, but it isn't able to start the "stop" state in the consumer loop, I think that may be because the consumer loop gets "stuck" in the while loop.
    I hope you can help me, the VI is attached. Thanks!
    Solved!
    Go to Solution.
    Attachments:
    trigger_cam.jpg ‏345 KB
    trigger_stop.jpg ‏354 KB
    Conditioning MS vi 2010.zip ‏68 KB

    Hi Gak,
    Thanks for the suggestions. I still didn't got it to work though. I moved the stop command to inside the while loop like you said but it didn't work. The problem seems to be in the communication between the producer/consumer loops. When I run the VI in highlight, the queue message "trigger camera" leaves the producer and arrives at the consumer loop in the appropriate time, starting the "trigger camera" state of the case structure. However, the message "stop" doesn't seem to be sent by the producer loop, so the consumer doesn't receive a signal to start the "stop" state of the case structure. Can you think of anything I should change in the producer loop so that the second state (stop) is added to the queue?
    About the functional global, I read about it, it seems that either that or a local variable could work, but I don't quite know how to implement it in my state machine, since the stop of the first while loop isn't activated in the "stop" state but in the "shutdown" state. It works more or less like this: after 10 loops of triggering and stopping the camera, light and valve (so after acquiring 10 movies), it goes for shutdown. Can you show me what you had in mind with the functional variable?
    Attachments:
    Untitled.jpg ‏286 KB

  • Best way to update indicators in state machine ?

    What is the best method to update indicators constantly in a SM ? ... 
    MY INDICATORS: I want to update the cluster of OUTPUT INDICATORS for ever new update that is happening inside the FOR LOOP (see next image). How could I achieve that ?
    Abhilash S Nair
    Research Assistant @ Photonic Devices and Systems lab
    [ LabView professional Development System - Version 11.0 - 32-bit ]
    LabView Gear:
    1. NI PXI-7951R & NI 5761
    2. The Imaging Source USB 3.0 monochrome camera with trigger : DMK 23UM021
    OPERATING SYSTEM - [ MS windows 7 Home Premium 64-bit SP-1 ]
    CPU - [Intel Core i7-2600 CPU @ 3.40Ghz ]
    MEMORY - [ 16.0 GB RAM ]
    GPU - [ NVIDIA GeForce GT 530 ]

    Since on my machine, the second screenshot is cropped, i cannot see the complete FOR loop. You do refer to the loop writing to VISA, correct?
    If so:
    - Is this loop timed? If so, what is the average iteration time? Note: if this is faster than about 50ms, you should not update the indicator in every iteration as the human simply cannot see changes that fast. An average user would only see some flickering and from time to time something "readable".
    - Do you update the indicators elsewhere as well?
    Possible solution:
    - As Yamaeda suggests: Put the indicator in the FOR loop. Works well if only this loop updates these indicators.
    - Local variable: As dataflow serializes access to the indicator (variable in loop, terminal outside the state case), you wont have race conditions. On the other hand bears risks if someone introduces concurrent loops using the same indicators (variables).
    - Property node "value": Same as local variable, but is bound to UI thread. Therefore, it takes more time which induces performance drawbacks. On the other hand, a property node has error in/out and is better suited to be placed in well designed dataflow programming.
    - Extract UI updates from the state machine and introduce a parallel running "UI Update" loop. Refer to the Producer/Consumer template for an initial start point.
    hope this helps,
    Norbert
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.

  • Other events interfere with abort for state machine started by an event

    In the attached VI there is a state machine that is triggered by a boolean “start” change event.  There is also a boolean “stop” that stop the state machine, a numeric “voltage” that has an event handler and a boolean “exit” that has an event handler.
    The stop button works as expected unless if the voltage value is changed before the stop button is pressed.  I was thinking this might be because there is an event for the voltage value change but there is also an event for the exit button value change and the problem does not occur if the exit button is pressed before stop.
    If anyone could explain the reason I am only running into the problem with the voltage value change and/or how to properly implement the stop/abort function I would appreciate it!
    Thanks,
    Dave (LabVIEW 7.1)

    Well that certainly solves the problem I was having!  The case in a while in a case in a while reminds me of the 10-level deep if statements I used to end up when starting C programming.  I guess the inner case/while are required for the state machine and the outer while is required for the Producer / Consumer.  I always find myself thinking in terms of "if/then" statements and the case/comparison took the place of that. 
    Regardless, problem solved.  If anyone has tips on how to make it (attached) look better, please post them!
    Lynn, I wasn't quite sure about your instructions on passing the exit and stop commands through the queue.  I went with the idea of keeping the long-running loop separate.  I know I still have a bit more to work out such as use of exit button while state machine is running, and the stop button only works in between state machine iterations.
    Message Edited by davey31415 on 11-27-2006 07:04 PM
    Attachments:
    PowerfoldMeasStat.vi ‏158 KB

Maybe you are looking for

  • Different view in OBIEE answers

    Hi, I am new to OBIEE.Plz help. In answers i go to criteria and select few columns For Ex:Department,Region and sales and then click on results tab to see the result. now similarly i create pivot view and give the compound layout to see both views. N

  • SQL Plus & End with Errors

    In my Process Flow I have a SQL Plus activity that calls a custom DML Express program. How would I trigger the End with Errors activity if my custom DML program errrors out? Currently my SQL Plus activity is as follows: --SET SERVEROUTPUT ON -- PL/SQ

  • My site manager is missing some elements

    trying to set a default page when i go to site manager default pages are not listed i upgraded to from web basic to web marketing last night any thoughts?

  • Photoshop cs6 photomerge shows error 48

    I can´t i start photomerge in PS cs6 on my macbook. It always shows error 48.

  • Ipod keeps restartin in the middle of some apps

    my ipod touch 16 gb 2nd gen keeps restarting on its own wen i use apps. i think its overheating but i dont know. i tried the ipod touch troubleshoot but that didnt work SOMEONE PLEASE HELP!!! i cant afford a new one