Loop with event structure

I put an "event structure" inside of a while loop. My target is to keep the
VI running and make selections to run different subVI. But I got two
questions:
1. how to use two button on front panel? I mean, when I press one button,
step 1 runs, when I press the other button, step 2 runs. Is event structure
the best way to do that? another side quesition is that how I can make the
button jump back after I pressed it? It kept in the "down" position and I
have to press it again to release it.
2. When I test the VI, I found the while loop can't stop. The boolean input
of false won't stop the VI. I wonder if there is a rule that the event
structure must run at least once? or any other hidden properties I didn't
notice?
thank you very much!
cheng

"Michael Sachs" wrote in message news:...
> You can change the boolean's mechanical action to a latched type and then it
> will pop back up.
> The event structure has a timeout input that defaults to infinite. If the
> event loop is waiting for an event or timeout then your outer while loop
> will not cycle. Use the hightlight execution lightbulb on the diagram to
> see what the data flow is doing.
>
> Mike Sachs
> Intelligent Systems
>
> "Cheng" wrote in message
> news:[email protected]...
> > I put an "event structure" inside of a while loop. My target is to keep
> the
> > VI running and make selections to run different subVI. But I got two
> > questions:
> >
> > 1. how to use two button on front panel? I mean, when I press one button,
> > step 1 runs, when I press the other button, step 2 runs. Is event
> structure
> > the best way to do that? another side quesition is that how I can make the
> > button jump back after I pressed it? It kept in the "down" position and I
> > have to press it again to release it.
> >
> > 2. When I test the VI, I found the while loop can't stop. The boolean
> input
> > of false won't stop the VI. I wonder if there is a rule that the event
> > structure must run at least once? or any other hidden properties I didn't
> > notice?
> >
> > thank you very much!
> >
> > cheng
> >
> >
Hi Cheng,
that's not quite the whole story. The event structure breaks down
into two types. Those that get actioned between the start of the event
(i.e. mouse down) and the result of that event (i.e. the button
registers true) which are filtered events, and the other type (like
mouse up) which occur after the event and the result of the event.
With filtered events you can modify the result of the event as it
happens. Whichever you choose to use, you need to do one of two things
to get the button to pop back up (setting to latch when pressed on
it's own won't work) - you can either read the FPTerm within the event
itself with this set to Latch when pressed, or (my prefered method) is
to use the CtrlRef that's available inside the event, and use the
ActiveX method Reset to Default. This way the FPTerm for the button
can be left somewhere else, and it's more obvious what the program is
doing at this point.
Your while loop is actually a do {} while loop, i.e. it must execute
at least once before it checks to see if it should iterate again.
Mike's suggestion of follow the hi-light execution is the best
solution.
Hope that helps
Sash.

Similar Messages

  • How to stop a while loop of event structure from a main vi

    Hello;
    sorry for my english
    I have to stop a subvi from my main vi, the subvi contains a while loop and an event structure so I need to stop this loop while directly from my main vi I have tried global variable but it did not work
    any help please or example !!!   
    Solved!
    Go to Solution.
    Attachments:
    stop a while loop and event structure from main vi.png ‏16 KB

    IYED wrote:
    Hello;
    sorry for my english
    I have to stop a subvi from my main vi, the subvi contains a while loop and an event structure so I need to stop this loop while directly from my main vi I have tried global variable but it did not work
    any help please or example !!!   
    If this is an example of how your code looks, I'd clean it up before the developer who has to work on it next hits you over the head with his LabVIEW Style Book. 
    Bill
    (Mid-Level minion.)
    My support system ensures that I don't look totally incompetent.
    Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.

  • I need help with event structure. I am trying to feed the index of the array, the index can vary from 0 to 7. Based on the logic ouput of a comparison, the index buffer should increment ?

    I need help with event structure.
    I am trying to feed the index of the array, the index number can vary from 0 to 7.
    Based on the logic ouput of a comparison, the index buffer should increment
    or decrement every time the output of comparsion changes(event change). I guess I need to use event structure?
    (My event code doesn't execute when there is an  event at its input /comparator changes its boolean state.
    Anyone coded on similar lines? Any ideas appreciated.
    Thanks in advance!

    You don't need an Event Structure, a simple State Machine would be more appropriate.
    There are many examples of State Machines within this forum.
    RayR

  • How to stop While Loop in Event Structure with same button?

    Hello,
    I have a problem. I want to use one control to activate an event in a event structure, and the same control to terminate a while loop in that event.
    It is possible to use 2 controls to do this, but I need it to be only one.
    Thank you  
    Message Edited by Heinen on 02-19-2009 06:16 AM
    Message Edited by Heinen on 02-19-2009 06:20 AM
    The Enrichment Center is required to remind you that you will be baked, and then there will be cake.
    Solved!
    Go to Solution.

    Hello,
    I have a bit different problem.
    I have a tab control, with several buttons on different pages.
    In the current situation, we can talk about two pages, where one page ("Settings") in the Image, has a START and EXIT button, while second page ("Wait") has an EXIT button.
    In a while loop, I have event structure, which handles events of the START and EXIT buttons of the Settings page. This is fine. But I also want to control the Exit button of the Wait page.
    The control works like this:
    When I click on Start in the Settings page, the front panel shows Wait page and attempts to connect to a datasocket server on the remote computer. If the user wants to stop this process, he can click on Exit on Wait page too. But, this doesn't give any immediate effect. On the even of Start button, the front panel is not locked, so the user can actually click the Exit button on the next page when it's visible. But it's of no immediate effect. Means, what the LabVIEW does is, finishes the execution of event in Start button's click, and while this executes, it doesn't consider the Exit button's refreshed value (shown in Red circle in the block diagram).
    Simple question: Is there any way to check the updated (latest/live) value of a control during some event's execution? Or if I write an Event "Value Changed" for the Exit button and pass it to some variable. Is it the only solution?
    Thanks ahead.
    Vaibhav
    Attachments:
    terminate event_diagram.jpg ‏200 KB
    terminate event_front_1.jpg ‏63 KB
    terminate event_front_2.jpg ‏63 KB

  • Front panel locks with event structure loop and another while loop

    Hi,
    Why is the front panel locking after changing the value of the "boolean switch" twice? This problem disappears if I uncheck the "lock front panel" option in the event case. However I don't understand why that is the case since the event structure loop has already finished executing.
    thanks

    Do you really want the event handling to stop after detecting the first event? If so then as Christian says the event structure will cause the front panel to lock. What you can do is dynamically register and unregister the events. You right click on the event structure and enable "Show Dynamic Event Terminals" Then  you can programatically register and unregister events.
    Here is your vi modified to do that.
    Edit: Just in case - right click on the control and create a reference. When selecting the source of the event in the structure look under the dynamic section.
    =====================
    LabVIEW 2012
    Attachments:
    event structure test.vi ‏13 KB

  • Help with Event Structure!.

    Hello,
    I am trying to config one event structure in the way I could change the range of sample graph to analyze it. 
    I have 3 graphs. The upper is the signal input.  In the middle is the signal fitted with some calculations and the bottom is the graph where I fix the sample width to analyze with anothers values.
    I put event structure in the way I read from file and later update the array of data to force the execution of Case "array 2". 
    Its only one example but I would like to change the value of "start" and " length" of sample signal but I cant get the data to show again. I tried diferent options, like put another event source inside of event case "array 2".
    I could join case 1 and 2, but the problem is with "start and lenght" control, I can`t get its display when i change the values.
    I created a example since its part of my program, to simulate the similar way i need.
    Thank in advance, Fred.
    Solved!
    Go to Solution.
    Attachments:
    example-eventStructure.vi ‏56 KB
    006_RR.txt ‏7 KB

    altenbach wrote:
    billko wrote:
    crossrulz wrote:
    You need to wire up the value of Array 2 to the output tunnel of the event case.  Currently, that output tunnel is set to "Use Default if Unwired".  So since you didn't wire up that tunnel, the value going into the shift register will become an empty array.
    That's one thing I am totally paranoid about.  I hate that the tunnels in an event structure are "Use Default if Unwired" by default, yet they don't show that little dot that suggests that it is.
    Of course they do! What makes you say they don't?
    I actually like the current behavior, especially for the boolean going to the stop button. I would not want to wire it in all the other cases where the loop should not stop.
    Maybe the behavior could be a bit fine-tuned. Automatic "Use default if unwired" should only apply to scalars. Tunnels for arrays and clusters, etc. should require a manual "use default if unwired" setting.
    Ha - it's because of my own paranoia about the "Default if Unwired" that led me to believe this.  I guess I always have something wired to every single case so I haven't seen it in ages.  I created one just now and specifically looked for the dot, and when I added a second case, there it was.  Of course if I wire something to that second case, it disappears.
    Bill
    (Mid-Level minion.)
    My support system ensures that I don't look totally incompetent.
    Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.

  • Logic AND with event structure

    hi everyone,
    The event structure can handle multiple events at a time to do the same thing : looks like a logical OR. But I haven't found a way to sequence events to approach a logic AND. Example: first click on a Draw button and then enter the image would make the mouse cursor change. With an event structure, I can handle these 2 events separetely or together (either one would change the cursor), but i cannot make a sequence of events.
    Is this possible to do that with an event structure?
    I hope I am clear (sorry for the english btw). And thanks in advance.
    Christophe
    Solved!
    Go to Solution.

    Mark Yedinak wrote:
     In the event processing you would have to check if the required event occurred before this event. If it did, do your processing. If not ignore the event.
    That's exactly what I am trying to do! I am already working with a producer/consumer architecture and with a state machine in the consumer loop. I tried to add state info as you suggested in the event loop. But i do not know if i am doing this well. I attach a very small example where I try to demonstrate what I am trying to do with 2 booleans to be pressed in order.
    Tell me what you think of the state info in the event loop.
    @Mike : same solution as Mark if I use a shift register and a case structure inside the event loop?
    Message Edited by superfunk on 03-03-2010 10:24 AM
    Attachments:
    event_test.vi ‏27 KB

  • Load defaults from file with event structure in vi

    Hi All,
    I've been trying to figure out how to do this but have not quite got there. Taken a look at lots of posts but can't quite find the answer to the question that i've got.
    I've got a vi for controling 4 PCI cards making calls to some DLL's. I've got quite a number of controls on the FP and i use an event structure to update the values on calls to the DLL. On startup, one of the first calls that i make is initalise and that sets the cards up. I then want to load my own set of default values from a file to initalise the cards to my particular set up. While the software is running the user may change the values and wish to save a file with the new default values, or he may wish to load a different file of default values (depending on the test that he is running). I've got the Control Values:Get All [variant] and the Control Valueset [Variant] working to save all the controls values to a file and read that file in and set all the controls values. So far so good. Problem is i'm using an Event Stucture and it doesn't register that the values have changed. I could complish this by using Value(signaling) but the data from the Control Values:Get All is variant data and the Value(signaling) needs the same data type as the control. What do i do?
    One thing i have thought about is to write all the values from the file to all the conrols and then have a read Value and a write Value (signaling) to trigger the events. Problem is i don't want to set this up for every control (it'll take me ages). Can i do it programitically? Is there a better way to do it?
    Thanks,
    Phil

    You could create a boolean control/indicator and signal that value when you've updated the values on the FP.
    Name it something like "update FP". The event case for that boolean will have the code to update the necessary parts of the FP.
    André
    Regards,
    André
    Using whatever version of LV the customer requires. (LV5.1-LV2012) (www.carya.nl)

  • Quit while loop in event structure

    Hello,
    I used event structure in my application and I would like to quit a while loop in an event structure when I pressed a control. But I have a problem because I'm in the event.
    Do you have a solution.
    Sam.
    Attachments:
    Problem.vi ‏34 KB

    Hi,
    connect a true constant to the While loop conditional terminal in the STOP event case.
    See your example modified.
    Good luck,
    Alberto
    Attachments:
    Problem[2].vi ‏35 KB

  • Array of Cluster with event structure

    Hi,
    I am having Array of cluster with cluster having 1 String Control , 1 Combo box, 1 Led control and 2 Numeric control. In the combo box i am having two options to select ('Binary' and 'PWM').Whenever Binary is selected then Led control has be enabled and whenever PWM is selected 2 Numeric control has to be enabled.
    Is there any way to do this??
    Pleas help me...
    Regards
    Meenatchi

    actually in my application, the front panel has to have 16 rows of controls (1 string control, 1 combo box, 1 Led control, 2 numeric control).so i planned to keep all those controls in a cluster and create one array.If i didnt so i will have 16x5 controls in my front panel and i have to put 16 event cases for each combo box to do the enable and disable of controls..
    is there any simple way to do this..i have attached my front panel view
    Attachments:
    Untitled10.vi ‏139 KB

  • Using a "menu ring" feature on the front panel with event structures

    hello - right now i have many event cases controlled by many "ok buttons". i would like to use a menu ring on the front panel to save space from all those buttons, but i don't see how it will work with all the individual event cases. currently each event is tied to a single button, and the menu ring acts as one thing on the block diagram so i can't tie an event to a choice in the menu. any suggestions? thanks....

    Alternativley, you could use an enum control instead of a menu ring. It will name the cases according to the selection automatically.
    If you want to use a menu ring and strings, you could do something like in this image.
    Message Edited by altenbach on 02-09-2006 01:43 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    RingText.png ‏3 KB

  • Event structure in "for loop" and stacked sequence

    I tried to put an event structure into a for loop sequence, then used a pause button to pause the program (one loop with event structure.vi). The pause button functioned normally since the program could be paused whenever the button was pressed. Then, I put this for loop sequence into a stacked sequence (Problem.vi), which has 2 frames and every frame has the for loop sequence in it. After the pause button was pressed once, the pause button and stop button will no longer effective anymore. Where should I modify so that this program will work properly? Thanks a lot.
    Attachments:
    Problem.vi ‏42 KB
    one_loop_with_event_structure.vi ‏27 KB

    Ah, at last something weird !
    The answer is simple : don't do that !
    You should either avoid having 2 event structures handling the same events, or learn how to process dynamic events.
    Why didn't you read the answers to a question posted a few hours ago (still on the overview page of this forum ?). See here.
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        

  • LabVIEW 2012 while event structure cannot stop

    I am trying LabVIEW 2012.
    An example of while-loop with Event structure inside cannot be stopped with the boolean stop button.  Any thing wrong?
    Please see the attached VI.
    Thanks.
    Solved!
    Go to Solution.
    Attachments:
    Close VI prompt.vi ‏9 KB

    Yep, something is wrong. You need to add a event case to detect a value change on the stop button.
    The thing is now your event structure keeps waiting for one of the event that it handles, and ight now it only handles the "panel close" event, the "timeout" event is handled too but since you haven't connected anything to the timeout terminal (top left corner of the event structure) the timeout is -1. So when you run the VI the while loop is stuck in the first iteration and waits for a panel close, the stop button will only be taken into account after the even structure catches an event ; I think this is because LabVIEW will execute code linked to the stop terminal of the while loop only after all the rest of the code in it has finished executing.
    Hope this helps
    When my feet touch the ground each morning the devil thinks "bloody hell... He's up again!"

  • Event structure without user interface

    I looked for a fast and efficient solution for an event structure which does not have a timeout case and is part of a vi that does not have user interface but I need to sent data configuration to this event structure.
    I will be more clear: I have a camera which is generating multiple events taken by a loop with event structure inside.
    The camera provider give me this Labview code example with all the events I am interested on and how they are implemented. I must mention that when you write a command to camera this one answer
    with an event, but when you first connect to camera there are over 100
    events generated by it, or when you download camera there are also
    multiple events. When there is no communication to camera the event
    structure from the example is idle. The example has a user interface for changing parameters and program responds very well.
    I have to integrate this camera in s big application in which camera is going to be configured pragmatically with no the type of user interface existing in the example given by camera manufacturer.  First I tried to design a loop with timeout case in which a queue can send data configuration for setting camera. Everything is good until the download when the code must take events to a certain way; in my case one event is taken another goes to timeout and so on. After two series of 100 frames downloading, during the third series Labview gets blocked (Labview does not respond) and I have to kill Labview. I understood from camera's designer that if camera events are not taken they are kept on a stack and when the stack gets full causes the Labview being locked.
    Maybe I give too many details but the issue is: how to communicate with a event structure which does not have a timeout case and is not part of a user interface vi (it does not have an open panel in my application)?
    Solved!
    Go to Solution.

    Hi Virginia,
     I've attached an NI KnowledgeBase article that contains an example VI here from a previous similar issue.  In this VI, however, the user event is triggered by a certain keystroke, but I think you should be able to modify it to do what you are trying to do. 
    http://ae.natinst.com/public.nsf/web/searchinternal/1199d3582e97ce6786256f2a0010b69f
     In the example, the output of the subVI (in your case, your event data VI) is wired directly to the dynamic event terminal of the event structure that contains the Generate User Event VI. 
    This VI was written in an old version (7.1), but I was able to open it up in 2010 here.
    If trying something like they did in the example still doesn't work for you, then could you attach your code, especially your VI that is generating the camera data?
    Thanks,
    Austin
    Regards,
    Austin S.
    National Instruments
    Academic Field Engineer

  • Is it better to have one Event Structure with more (10 or 15) cases or several with fewer?

    I have several buttons and events on the GUI of my app to monitor. Would it be better to use one Event Structure with several cases (10 or 15) or have a couple and split the cases evenly? None of the cases have much processing to handle, so there is not a time lag issue. I am just worried about overloading the structure. One of the tech support guys mentioned that the event structures are not that hard to get confused.
    Has anyone had any problems with Event Structures?

    I use event structures very often in my code. I use them just to handle the interface and to run small code. I have had event structures that handled over 50 user interface events and never had a problem. In my personal opinion If there was any code to run I would let the event structure handle the the user interface event that fired a que in another while loop that handled the code.You can find examples on this, if not I will send you one. It is just good programming practice for beginners because it will alow you to build more robust VI's in the future.
    Hope this helps
    Joe
    Joe.
    "NOTHING IS EVER EASY"

Maybe you are looking for