Event structure input event question

I'm using a state machine to do some data decoding stuff. The default initial state is Idle, which checks an output boolean value from a FIFO buffer. If the boolean value is True, go to the next state; otherwise, keeps waiting. See attached "idle_noEventStructure.vi" for part of the code. But this method will consume a lot of CPU usage.
In order to save CPU time, I try to use an event structure in Idle state to wait for the output boolean value change. But I don't know how to add an event for the boolean value change. See attached "idle_eventStructure.vi".
Any one could help?
Thanks.
Attachments:
idle_noEventStructure.vi ‏7 KB
idle_eventStructure.vi ‏8 KB

MileP,
First off, in the state machine example you give "idle_noEventStructure.vi" the reason you may be experiencing poor performance (high CPU) is that your while loop is running as fast as the OS will allow sicne there is no timing implemented.  You should always you a "wait" function inside the loop (see attached file).  The loop should only run as fasat as you need to check the FIFO for new data.
If you want to use an Event structure you can use dynamic event registration to create an event for the FIFO data.  I have outlined this in the attached code.  It may not be eactly what you need but should give you he right idea.  An event is created for the boolean output from the FIFO and this event is registered with the event structure.  I am simulating the FIFO data using the "Producer Loop" and the Trigger control.  I am simply stopping all the loops when the Trigger button is pressed, but this is done using the event creation.  This method still requires a polling loop ("Consumer Loop" in my example) to check for FIFO data, but the lopp rate can be handled more carefully this way.  And I am not sure there is anyway around using some method of polling.
Dan
Attachments:
Event Registration.vi ‏17 KB

Similar Messages

  • Event structure misses events

    Hi,
    I've got an event structure with events reading all my inputs, and one dynanmic event running every 10 ms.  The dynamic event is a pretty heavy piece of code.
    It works swell, except that sometimes the events generated by inputs from the front panel are ignored.  Is there a way around this?  A screen shot of my code is attached.
    Thank you!
    Christopher
    Attachments:
    events missing.png ‏69 KB

    This suggestion is based on partial information and a picture so apologies if this is not relavent.
    I would change your structure with queues, it looks like you generate a notification every 10ms. You could replace all of this with a single consumer loop which essentially is a dequeue loop with a 10ms timeout and do all of the dynamic event processing when the dequeue times out. You can also enqueue any front panel activity to the same queue in the event structure. Look for producer consumer examples, it is very elegent
    Beginner? Try LabVIEW Basics
    Sharing bits of code? Try Snippets or LAVA Code Capture Tool
    Have you tried Quick Drop?, Visit QD Community.

  • Event Structure - Lock Event: Does it Queue ?

    I had couple of question related to this post in other posts but I thought I'd use a new one since it might be more relevant (others were related to local variables, and VI file sizes)
    I have this event structure running about 10 different tasks. For some I would like to lock the panel when it runs. I used "Lock panel ..." but during the run, if you click on any boolean and menu ... for some reason it queues the task and performs it after the event is complete ... is there any way I can lock the event and not have any event queued ? Thnks !
    Kudos always welcome for helpful posts

    If you were to change the value of the Block Panel Event boolean using a local variable it wouldn't fire an event so I'm not sure that would be the way to go.  I had intended that just to be an example control.
    I have further modified the example to show how a custom user event can be programatically fired to signal that the front panel should be "unlocked" and that new events should be added to the event queue.  In the new example you will see that while the LED is flashing no events are queued.  Once the LED is done flashing it communicates to the event structure via a user event.
    It may also be possible to change the value of the "locked?" boolean without requiring an event to do so.  I didn't explore this option but it may be a valid approach.
    Also please remember that any example I have posted here is not meant to be incorporated into an application - I am merely attempting to demonstrate ideas and concepts.  It will be more beneficial for you to examine and understand how I programmed a certain behavior and then use those concepts to create your own application than to try to make my code fit into your application.
    Regards,
    ~ Simon
    Attachments:
    lock event 2-1.vi ‏75 KB

  • Resetting a variable in an event structure (dynamic event)

    I'm working on moving an event structure into a sub VI. This means I have to register dynamic events. 
    The event structure is handling some button clicks. The state of the button (mechanical action = latch when released) resets itself automatically as long as the variable is placed within the value change case.  Leaving the button in this case is not possible when the event structure is put in a sub VI and the variable is located in the parent VI.  How do I make sure the button unlatches after clicking on it?  I have attached an example where all the code is in one VI (the local variable must be moved outside the event structure in order for it to be moved into a sub VI).  Any ideas?
    If you open the VI and run it, you can click Start which will cause the counter to start incrementing.  The button only unlatches as long as the variable is located in the value change case.
    (Btw, how do you put images inline in a post?)
    Rob
    LV2011,LV2012,LV2013
    Attachments:
    img.png ‏18 KB
    main.vi ‏17 KB

    Race conditions are the primary reason not to do that. But since your treating your variable as a latch, I doubt your using the value you read from it anywhere, and in that case it can't create a race condition. There's also the possibility that the control's reference could become invalid. But since this is a sub VI of the control's VI that can't happen (even if it could you can check the error out of the value property node to see when it happens and deal with it).
    I'm not sure about the flickering, Since I can't seem to duplicate it with a simple test case on my machine. It might related to whatever else you're doing in the event apart from reseting the value to false.

  • How to use event structure of event data nodes event filter nodes in programming

    hi,
    I need manual of how to use 'event structure' events of 'event data nodes' and 'event data filters'...please help me....
    Regards
    Ravindranath

    I'm not really sure what you are looking for here.  Did you do a search in the LabVIEW help for Event Structure?
    The Event Data Node just returns information about the event, like control data, control reference, what caused the event, etc.
    The Event Data Filters are just used in Filter Events.  This allows you to discard an event or change the data that the event will recieve.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Event structure capture event on dimmed buttons

    Hi,
    I have a MMI with buttons I dynamically disable or enable by means of Property Nodes. I capture the Release Mouse Button Event on these buttons with an Event Structure. The problem is that my application seems to recognize this event even when the buttons are disabled and greyed out... What am I doing wrong? Is this a LabVIEW bug? What can I do to prevent this from happening?
    Thanks

    This is the expected behavior: disabling a control prevents the user from changing its value (and other attributes for compound controls like graphs), but does not prevent the control from receiving mouse events.
    You may want to test for a disabled state and filter the event, yourself.
    Good luck,
    -Jim

  • Event Structure with Event source: This VI and Event: Mouse Up

    I downloaded an old example from 2008 on this forum and would like to duplicate it.  It uses an event structure with an event case of just Mouse Up.  Under Event Specifiers:  the Event Source is <This VI>  and Event: Mouse Up.  This works like I want in LV 2009.
    In LV 2009 if I choose for Event Source  <This VI>   under Events Mouse Up is not an option!    I tried Event Source: Pane,  and  then Event  Mouse Up is an option, but this does not trigger the event if you drag the mouse off the pane before you lift the mouse button.
    I can copy the Event Structure over to my VI  and rewire every case but that does not seem to be a good solution cuz I want this in several VIs.
    I have attached the original VI with the Event Specifier I want.  How do I get this Event Specifier in LV 2009?
    Attachments:
    Slider event control.vi ‏19 KB

    phillman wrote:
    I downloaded an old example from 2008 on this forum and would like to duplicate it.  It uses an event structure with an event case of just Mouse Up.  Under Event Specifiers:  the Event Source is <This VI>  and Event: Mouse Up.  This works like I want in LV 2009.
    In LV 2009 if I choose for Event Source  <This VI>   under Events Mouse Up is not an option!    I tried Event Source: Pane,  and  then Event  Mouse Up is an option, but this does not trigger the event if you drag the mouse off the pane before you lift the mouse button.
    So what you can do is monitor the 'Mouse Leave' event for th pane, and then start polling the mouse state.
    Technically it is correct that there is no Mouse Up event detected since the Mouse Up is not happening on th epane.
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • Event Structure: Multiple Events ??

    All
    I have a project where I have an event structure handling about 10 individual events. Would it be possible to fire multiple events at the same time ? For instance, if my event 3 is triggered and the corresponding process is running, can I trigger an event 7 to have it's process running ?
    Kudos always welcome for helpful posts

    Edit your event and make sure to uncheck "Lock front panel until the event case for this event completes", else you won't be able to do much.
    Attached is a simple example using two event structures. (All that said, maybe there is a better solution than using two events, just re-think your code).
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    2events.vi ‏42 KB

  • EVENT structure remembers events from previous call?

    LV2013, Win7
    My customer has complained about this misbehavior, and I made a basic VI to show it.  No one noticed this behavior in LV 7, 8, or 2010.
    Given a SubVI with a RETURN button, that is set to SHOW FP WHEN CALLED and CLOSE IF ORIGINALLY CLOSED, then we have what seems to be a misbehavior by LabVIEW.
    The SUBVI is normally closed.  If you run the TEST vi and click the DO IT button, the subVI comes up.
    If you click the RETURN button TWICE, during that five-sec interval, the button sticks in the DOWN position.  I understand that.
    When the timer expires, the window closes.  I understand that.
    If you click the DO IT button again, the window comes up again.  I understand that.
    But the window will close BY ITSELF, after another 5 seconds !  I DO NOT understand that.
    Even if bringing up the window acts to pop out the button, that cannot cause termination, because termination is caused by a VALUE CHANGED event, changing to TRUE!    But it does.
    I tried limiting the events in the queue to 1, no change in behavior.
    Attached is a test vehicle, try it yourself.
    Is this a bug in my thinking, or a bug in LabVIEW?
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks
    Attachments:
    TestEventQueue.zip ‏16 KB

    when you define a static event, the registration for that event (that's the point where it starts queueing up events) happens as soon as the VI that the structure is in enters run mode. That doesn't mean that the VI is actually running, but rather that it is running or reserved for running. The unregistration happens when the VI leaves run mode.
    OK, I understand that.  Although I didn't think about it before, that makes good sense.  The dynamic registration system is the root behavior, the statis stuff just supplies fixed references at RUN MODE time. Fine.
    But how is it that the second call, which depends on a VALUE CHANGED event, with a value of TRUE, doesn't just get ignored?
    OIC - what is queued is the original event, which IS a transition from false to TRUE.
    Funny - I've used LabVIEW for 25 years and never noticed this issue myself.  I guess I thought the event queue was flushed when the window came up.
    So, I should use a FLUSH EVENT QUEUE at the start of every such VI, I guess.  I don't want to add a time-check to every single event case.
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks

  • Add event cases to an event structure using scripting

    Hello,
    Iam trying to (using scripting) update an event structure (add event cases) on a vi that is not on memory.
    i get error 1054 The specified object was not found.
    here is a picture of it.
    any help in this will be greatly apreaciated.
    Solved!
    Go to Solution.

    Another suggestion, the following VI is a wrapper for Traverse for GObjects VI and allows you to specify the name of the object you want. I always use this VI, I never use the Open VI Object Reference function, for the reasons tst mentioned:
    vi.lib\Utility\traverseref.llb\TRef Find Object By Label.vi
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman

  • Multiple event structures in one program

    I know it's not good practice to have one event structure inside another event structure (I don't know exactly why). But if another event structure is in the subvi, is it safe? Please comment.

    guangdew1 wrote:
    I know it's not good practice to have one event structure inside another event structure (I don't know exactly why).
    This is because of dataflow and the way event structures work. If you have an event structure inside an event structure, both event structures will accumulate events whenever one occurs, but it is unlikely that they can be handled in the order they occur or at all. By default, event structure are set to lock the front panel until the event completes, meaning that if an inner event gets triggered first, the code will lock up, because it will no longer be possible to trigger one of the outer events. If the outer event occurs first, it cannot complete, because it requires a later firing of one of the inner events before it is ready to handle the next event that occurs in the UI. Even if it marginally works if the panels don't get locked, you are requiring the user to trigger events in a certain order. How is he supposed to know what's allowed or not?
    If this is not exactly clear to you, you need to start with a few tutorial and learn about dataflow, Then start using a single event structure and see how things work by programming scenarios and see what happens.
    guangdew1 wrote:
    But if another event structure is in the subvi, is it safe? Please comment.
    Event structures are only useful inside interactive subVIs that show their front panel. even then I strongly advise against calling anything interactive, or anything that takes excessively long, inside a main event structure. You end up with code that can become unpredictable, can deadlock, is hard to debug and flies in the face of all good programming guidelines.
    Obviously, you have some specific application in mind where you think something like that is useful, I can guarantee you that there is a much better solution is you think about this a bit longer. If you need help, please describe exactly what the program should do and how it should react to user interactions at the various stages.
    A program should always be approached from the code and UI needs. Don't start with a harebrained code construct (events inside events) and then look for a use. It does not exist! 
    Event structure only belong in toplevel loops. They should never be hidden insde squences or case structures (or other event structures as already mentioned above). If you have multiple toplevel loops that run in parallel, it is safe to place up to one event structure inside each. Each event structure can have an unlimited number of event cases. This should be sufficient to handle any programming need you might have.
    LabVIEW Champion . Do more with less code and in less time .

  • Using nested Event Structures

    Hi ,
    I wanna clarify whether using nested event structures in a vi is good Labview programming ?
    I have a vi which has two event structures nested,assuming it has two buttons GO1 and GO2.
    The outer event structure handles event triggered by GO1 and inner event structure handles Go2.
    The outer structure does fine by handling the button click on GO1,the problem is inability of inner
    event structure to handle click on GO2 button.
    I'm also attaching a sample.vi for reference.It would be great if you could help me
    solve this issue.Thanks in advance.
    Regards,
    Nalin
    Attachments:
    sample.vi ‏30 KB

    You can actually make this work, but like the others, I don't recommend it.
    To make your VI work. Right click on the "GO1" structure and select "Edit Events.....". At the bottom of the dialog, there is a checkbox that reads "Lock Front Panel until the event case for this event completes". With this checked, all front panel objects are locked until the GO1 event completes. This is what is causing the GO2 button not to work. Uncheck this and your application will work as you want it to.
    If your intent is to have GO2 disabled until you click GO1, try the attached VI. It uses property nodes to disable the GO2 button until you click the GO1.
    Another thing that you have setup that doesn't look necessary is the Timeout event, especially set to 1ms. The basic idea of the Event Structure is to not have to constantly poll for front panel events. If you just deleted the timeout event cases and removed the 1ms constant, your application would just well, but would just sit and wait for you to click a button.
    Ed
    Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
    Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
    Attachments:
    sample.vi ‏27 KB

  • Parallel event handlers disabling events while handling

    Hi, I have an application where there are multiple event handlers in multiple while loops that are driven from the same front panel.  The front panel controls are designed to provide diferent motion control moves for different axes under control.  All events that trigger these moves are fired by the same event handler for the same axes of motion. Hence, for safety reasons, I do not want some of these controls to be executable while certain other move profiles are executing. Sounds simple to implement right?
    When I use traditional prop nodes like disable to disable the front panel controls, the event queue still acquires the event and then subsequently executes it.   I want to be able to clear this event queue so that no other events from a certain group of my front panel controls can be executed simultaneousy.  However, I do not want to disable all front panel controls since I have other buttons that are capable of controlling other indepenedent things and safety functions like stopping.
    It is like I need a disable events property or soemthing that can be done programmatically. Can someone please advise me on what makes sense to do here?
    Attachments:
    evntdisable.vi ‏119 KB

    There is no way to interact directly with the event queue that LV maintains. If you need to do that you need to utilize the queue functions that LV provides and create your own event queue. However, if all you need is prevent interactions while an event in being processed, value change events have a setting that is (set by default) called: Lock Panel Until Handler Completes. And for other kinds of events, there's an option in the event structure's event-definition dialog box that perhorms the same action.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • How to make Vi file as input file in Event structure?

    Hiii All..
    i got problems when to construct a event structure. The file input  (vi format) doesnt have source of wire connection to conect the wire (shift register) .For your information the vi that i create only contain simple mathematical equation.
    I already study the New Event Handler Example. but the file input for that example (acquire data.vi) have a source of connection. anyone can help me? 
    thank you very much
    [email protected]
    Solved!
    Go to Solution.
    Attachments:
    TOTAL.vi ‏18 KB

    Well, in your subVI you do need to wire up some inputs and outputs to your connector panel.  As I said, a basic LabVIEW skill that you will find in the tutorials.
    You have a number of inputs to your subVI.  More than you would want to attach to a connector panel.  You should perhaps use a cluster to group them together.
    To get you started, here are the steps to connect a control or indicator to the connector panel.
    1.  Open subVI.
    2. Right click on icon at upper right.  Show Connector.
    3.  Hover over a block you want to be a connector terminal, it will change to a spool of wire.  Click.
    4.  Go to the control or indicator on the front panel that you want to associate it with.  Click again.
    5.  Repeat as needed for other controls and indicators and save your subVI.  Now the subVI instance in your main VI can have wires connected to it.
    You should plan your connector panel so that controls are on the left side of the panel, and indicators on the right.  This will allow data to "flow into" and "flow out of" the subVI in a normal looking left to right orientation.

  • I using an event structure for an input box and also for hardware input

    Hi there!
    I have many input boxes and display boxes on my user interface and i have a case for it in the event structure. If the user changes the values of the input boxes, the particular event case writes this new value to the hardware. However, in the timeout section of the event structure, we read the inputs from the hardware and we set the value for its related display object.  Within the timeout section i set the value for the related user interface display component, by making use of the property node value.
    Furthermore, for most of the display components, i have a event case for a value change associated with it. In that event case, i check for range errors and so forth.
    My assumption was that when i read the value in from the hardware and set the property node value, the user interface component's value will change and it would then trigger the event of the value changed for that component. 
    My assumption worked to the point of updating the component's value, however, it did not trigger the event  for the value changed for this component.
    Please advise me on how to achieve what i wish to.
    Thanks.
    Regards,

    Local variables are actually much more efficient than property nodes as far as execution speed goes. Take that same VI and delete the property node and instead write to a local variable inside the loop. You'll see the speed nearly identical to writing directly to the indicator. But note that variables also cause a copy of the data to be created. So if you're just using the "Value" property, you're much better off using a local variable. But don't use both at the same time. If you are reading/writing other properties when you update/read the value, you might as well use the value property.
    Sometimes you can't get around using either variables or property nodes. Initializing controls to saved values from an ini file is one example. But in this case, they are only written to once as the application starts so the performance hit is negligible.
    One thing you can do is store values in a shift register as they are read and pass this through your application so the last value read can be accessed from anywhere. You can even create a cluster that runs through the shift register to hold several values in a single register. This can be expanded a bit farther to create what's called a Functional Global. This basically a subVI with a While loop that only runs once on each call. It has a shift register to store data and a Case structure to Read or Write data into the register. There's a pretty good example that ships with LabVIEW showing how these work. Open the Example finder and search for "Functional Global Communication". This example shows how to use them to pass data between two independent loops, but they work just as well in a single loop application.
    One of the big advantages of these Functional Globals over the standard LabVIEW Globals and local variables is that you can add cases to manipulate the data in addition to just storing it. Also, since it's a subVI, access to the data is protected to one caller at a time whereas variables can have multiple reads and/or writes at the same time. This can cause race conditions.
    Hope that helps a bit.
    Ed
    Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
    Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.

Maybe you are looking for

  • Error message in ESS

    Hi All, I am getting an error message displayed on the portal in ESS business package whenever I enter the working time hours (that comes under Record Working Time application in Attendance workset) in the wrong format. Can anybody suggest me where d

  • Using Lightroom 3 with OS Maverick

    I have just bought a new computer that is at OS 10.9 Maverick and likely will need to be upgrade to 10.10 Yosemite.  I have stayed with LR3 because I have not needed the upgrades. I have been told by another LR user that LR5 has a cloud service where

  • Missing photos in upgrade to iPhoto '08

    I'm sure there's an easy answer but I haven't found it yet. New MacBook with Leopard. Old G4/Tiger behaved very badly in the migration - I actually migrated data from a backup on an external drive. Almost all my pics transferred but for some 207 or s

  • How to filter data in OWB.

    I have moved data from customer_adress table to target table.there are duplicates values in the customer table. i need to filter out the records from the customer table on the basis of max value for last_update_date cloum in case there are duplicate

  • Two apple ID's on the same iPhone?

    I have an apple ID, obviously. Is there any way that my wife can create her own apple ID to purchase music, but merge both on her iPhone so that she can listen to music from both?