Event Structure Problems

Hello all,
Im using the following code trying to obtain voltages and then use the peak voltage to trigger an event. My event structure doesn't seem to be working properly and I'm not sure what I need to do.
Take a look, and any help would be great!
Attachments:
Untitled 5.vi ‏43 KB

hey,
there are a couple of things wrong with your layout, other than the Event Structure isn't being called. What you have here doesn't do a lot and that is the beauty of LabVIEW: you can do the same thing in many different ways.
Following the Event Structure design you are intending to go with I have attached a redesign of your code, including comments. I believe this should work for you now. I have followed the common State Machine approach, which quite nicely, uses the Event Structure - when in a 'stable' or non-working state.
The main aspect you need to consider is how the Event Structure is called. It needs an interrupt in order to identify a state that it needs to address. In this case here, to increment a counter each time the peak voltage is detected.
The Enumerated data type (the value that holds the state of the State Diagram) can be added to or changed. Normally you should 'Customize...' the data type (right click) and create a Type Def variable (ensures all changes are provided throughout the code, where it is used).
There is more you can do with this structure, it is quite useful and powerful. There are quite a few examples online or within the LabVIEW help function to give you more. In regards to the DAQmx, there is a State Machine project already set up for you - with all type-defs and some events already created for you. After you've mastered this you should go along and check that out more.
All the best. David.
Attachments:
Untitled 5.vi ‏25 KB

Similar Messages

  • Event structure problem

    HI!
    I am a Labview Newbie and i have some problems with my event structure in the program "Biegelinie"! I get always failure from the event-structure in the failure-list!
    Could somebody help me???
    best regards,
    Peter
    Labview 7.1 on Windows 2000
    Attachments:
    program.zip ‏134 KB

    For a less complicated system, you can achieve nearly the same
    functionality without using an event structure.  Simply poll the
    state of the booleans you require and feed them into case
    structures.  By placing these case structures and the polling into
    a loop with a "wait until ms multiple" set to around 50 or 100ms, the
    responsiveness of the code should be high enough without bogging the
    processor down with the polling.
    If you want have a look at the example VI I've attached.
    Hope this helps
    Shane.
    PS Are you sure the document linked below is relevant for you?  It
    states that the event handler isn't in the base 6.1 version of LabVIEW,
    but your sig says you're using 7.1........
    Message Edited by shoneill on 07-25-2005 11:30 AM
    Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
    Attachments:
    Polling boolean.vi ‏23 KB

  • Event structure problem in updating array

    Hi, i have a problem with my .vi...
    i have an array of 10 boolean i want to modify by pressing SET TRUE or SET FALSE buttons, after selecting (with the ring selector) which is the elemente that should be changed...
    there seems to be something strange in the behaviour... the array is not correctly updated... maybe there a big mistake i cannot find...
    i  hope you could help me
    tks
    Attachments:
    array_modify.vi ‏18 KB

    The problem is the the Ring control is read before the event structure, so it return "old" data when you click of either SET TRUE or SET FALSE.
    You need to move it so that it is read inside the event structure after you click on one of the "SET" buttons.
    Create a local of the Ring for one of the SET events and move the Ring terminal into the other.
    Or create a blank event for the Ring control so that it will update the input tunnel going into the event structure.
    Or create a single event to handle both SET TRUE and SET FALSE.
    Omar
    Attachments:
    array_modify.vi ‏9 KB

  • Problems using event structure to write new parameter values to VISA

    Attachments:
    FMA_event_2.vi ‏28 KB
    FMA_event_2.vi ‏28 KB

    It seems I'm also having trouble using forums..not sure what happened...updated and corrected thread: http://forums.ni.com/t5/LabVIEW/Problems-using-event-structure-to-write-new-parameter-values-to/td-p...

  • Strange problems about my projects(efficiency,event structure,queue)

    hey,guys,i am a labview user from china,so forgive me about the chinese words of my projest. i found something wrong with my work. .
    there are two functions in my "While loop", the first one depends on "queue" and  is to get information from UART, the second one is "event structure" to send information through UART. my problems:
    1. i can not stop while loop by pressing "停止“, and i find two ways to stop it. first, i press"停止”,then, i press any buttons that can trigger "event structure"twice, at last, while loop can stop.the second way, i press buttons for "event structure" one time, then "停止”, and then the same button for"event". it also works
    2.my work does not run efficiently. you guys can try. once you press buttons for "event structure", it responses very slowly,and if you press many times,the whole program seems like suspending.i have added a LED named test at the front panel, it should light once you press "运行“. and it also shows how slow the whole program is.
    i have attached my work, and my main vi is "串口通信 主VI".
    can any body give me some suggestions? thanks a lot
    Attachments:
    Uart.zip ‏140 KB

    Your event structure will execute exactly once per loop of the main loop, thus the other three loops must stop before handlig the next event. You will also get a race condition between the top loop and the events when writing.
    I'd put the top loop as the timeout case in the event and place the loop around the event for starters.
    /Y
    LabVIEW 8.2 - 2014
    "Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
    G# - Free award winning reference based OOP for LV

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

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

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

  • I am using many events structures in my applicatio​n,but i am getting caught in my problems ,can any body tell me abt events programmin​g on time out

    i have extensive gui application ,i am using events ,but i am caught,i want to konw abt events ,there pros and cons,time out ,how to program in time out

    It is unclear as to exactly what you are asking. The event structure is very handy for monitoring front panel activity and performing tasks accordingly. The default event in the event structure is the timeout. In order to set the timeout you just wire the amount of time before timeout (in ms) to the timeout terminal of the structure. You may have tasks that you want to perform at timeout or you may just have an empty case. I strongly suggest using a timeout and putting the case structure in a while loop in order to keep monitoring the events until the loop exit condition has been met.

  • Problems with event source using event structure

    Hello!
    I'm using an event structure block. It works correctly when the event source is a control and the event is change value. But i want to use an indicator like event structure or a variable (like a matrix or a vector). I want that when the value changes, an event occurs, but it doen't work, I dont' know why?. What i have to do to work with indicators or variables in a event structure block?
    Thank you in advance
    Larson

    of course!
    regards timo
    Attachments:
    change_detection.vi ‏20 KB

  • Can you share FP Controls between different Event Structures

    I'm creating a program that will either read real-time data from an VNA on the GPIB bus, or read a saved s2p (Agilent) file and analyze it. The FP consists of 5 graphs, and various controls which handle events like printing, changing filters, or exiting. on the BD I have a case structure controlled by an operator selection pop-up. I tried using the same FP controls in the event structures I have setup in each case, as only one event structure would ever be executing at any given time, but the program doesn't seem to like it ast run-time. I've worked around the issue by creating "duplicate" controls and using the property setting to make them visible/disabled, etc., but the is seriously congesting my BD.
    Anyone know a way to share controls with seperate event structures?

    It sounds like the root problem is the overall structure of your program. I highly recommend that you check out the Queued Message Handler project template in LabVIEW 2012, that will show you how to utilize a single event structure and pass events to a consumer loop. If you program is too large to consider an architecture change at this stage of the game, then there is a workaround for your problem.
    What is most likely happening is that you have the event structures all set to lock the front panel until the event completes. However the case structure that you have wrapped around these event structures is causing all but one of these event structures to be unreachable thus preventing you from handling the event. Again, as I stated above, the "RIGHT WAY" to fix this is to select a better program structure but the "kluge work-around" fix is this: Dynamically register for the value change event on all of the controls you are trying to trap events for. Dynamic events can be deregistered and re-registered at run time. This will allow only the event structure in the active owning case structure to be registered for the events, thus no other event structures will get in your way.
    Disclaimer: This advice is given based on very minimal information and a great deal of speculation and may not be correct. Please include your code if you need further assistance.
    Charles Chickering
    Architecture is art with rules.
    ...and the rules are more like guidelines

  • Daqmx "Done" event not triggering event structure

    I would like the user to be able to abort my daqmx task by pressing a button.
    I am attempting to use the method in this VI:
    https://decibel.ni.com/content/docs/DOC-15815
    It utilizes an event structure with the daqmx Control Task VI to abort.
    The example VI above works for me, on my system with my USB-6356 device, as expected.
    When I attempt to incorporate the same method into my VI it does not--despite having an identical arrangement, so far as I can tell.
    I believe that my problem lies with the event structure, and the dynamic registration.  I am unfamiliar with this and must be using it incorrectly.
    I have attached my VI, though it is cumbersome.  The code which I am struggling with is in the "Acquire" case.  As far as I can tell, I am doing exactly the same this in this particular case as in the example mentioned.  Yet in the example, the event structure completes, or aborts, whatever you want to call it, right after the "Wait Until Done" VI executes.  In my own VI, the "Wait Until Done" and "Clear Task" VIs execute, but the event structure does not register it.
    Here are my specific questions: is there anything extra or special that one must do in order for the Task to properly trigger a "Done" event and pass through the event structure?  At what point is the daqmx task "Done"? 
    thanks,
    Matt
    Attachments:
    BoomTubeMain.vi ‏175 KB

    natasftw,
    My event structure is identical to theirs; what you are seeing are the two different cases that exist in the event structure.  In both the example and the VI, there is a <task out>: Done and a "Dynamic Event": Value Change.  In the dynamic event case, I have my abort button and relevant code--this I believe is the code you were referring to, which you thought I was missing...  Regarding my multiple event structures, they should operate completely independently as they respond to different events.

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

  • How can i use the same front panel graph in more than one events in an event structure?

    i want to display the signals from my sensorDAQ in a graph.but i have more than one event in the event structure to acquire the signal and display it in the graph.the first event is to acquire the threshold signals and its displayed in the graph as a feedback.after the first event is executed, i will call the second event,where the further signals are acuired and compared with the threshold signals from the event 1.my question is how can i use the same front panel control in more than two events in the event structure?please answer me i'm stuck.
    Solved!
    Go to Solution.

    Hi,
    I have attached here an example of doing the same using shift registers and local variables. Take a look. Shift register is always a better option than local variables.
    Regards,
    Nitzz
    (Give kudos to good answers, Mark it as a solution if your problem is Solved) 
    Attachments:
    Graph and shift registers.vi ‏12 KB
    graph and local variables.vi ‏12 KB

  • How to use a event structure with a state machine

    First, I would like to inform you that I only work on LabView part time, and have much to learn.  Anything I do learn, I usually forget until I need it again, because I only work on it part time.
    Using your StopWhileLoopMOD[1].vi, I am trying to put a state machine inside the event structure.  
    Related link: http://forums.ni.com/t5/LabVIEW/How-to-stop-while-loop-in-Event-case/td-p/465564/page/2
    Here is my application:  on the front panel, the user can select any combination of 7 different tests.  I have created cases to perform each step of each test in the correct order, but if the user presses stop, the tests won't stop because some of the cases have a while loop inside the event structure (like you mentioned is a bad idea).  The user should be able to stop the test, reselect tests to perform, and re-start the tests. 
    When the start button is pressed for the event structure, I need all the cases to run in the proper order, unless stop is pressed.
    In the past I have indexed an array and used that to run the state machine, but it won't stop immediately.  
    I have sub VIs that are built in while loops because the outputs of the product needs time to stabilize.  The state machine stops and waits up to a certain number of iterations.  If it passes the test, the while loop stops and the next state starts.  If it takes too long, it exits and reports an error.  Maybe I need to just use the state machine and not an event structure?
    Is there a good example of an event structure?
    metzler CLAD
    Solved!
    Go to Solution.

    I'm not sure exactly what you are asking, but it sounds like you want to script a bunch of tests and if the user says stop, to immediately stop the current test and abandon the others?  I'm going to assume that you know how to clear the array so that it will abandon the others, so I'm guessing that you are having trouble abandoning the current test?  If this is indeed the case, then the problem is that you are not able to propagate the message from the main VI FP which is the GUI to the sub vi which is the test, where the test may or may not have a GUI (FP visible) of it's own.  Threading was the first thing to come to mind, but this may not be necessary using events.
    You can do this by passing a refnum of the stop button to the subVI, where you can then add that wait to the event case structure.
    I've attached 2 VIs, mainvi.vi which is just a loop displays the count*2 (number of seconds passed since running) that will call subvi.vi and then check to see if the stop button is pressed.  mainvi.vi is by no means a state engine, it is just a simple loop for demonstration purposes.  subvi.vi just waits 2 seconds and leaves, it is a better structured state engine with an init state to start a poll case to wait for events and an exit state to clean up.  You can modify this any way you wish to get it to do what you want.  You will note that even if subvi.vi is being executed, it will terminate immediately when the stop button is pressed.
    Hope this helps.
    A
    Attachments:
    mainvi.vi ‏17 KB
    subvi.vi ‏33 KB

  • Using Event Structures with Array of Clusters

    Using LabVIEW 8.5
    Hi all,
    I'm trying to convert an existing application to one that can be used
    through a touch screen. I updated the UI and added an event structure
    to listen for mouse ups on controls that require a HMI keyboard or
    numpad to show up. Although I've been programming for a while, I'm new
    to LabVIEW and am struggling with a problem:
    Is there any way to have an event case listen to an event within
    arrays? I've seen a few examples on the forums, but they all start with
    breaking up the arrays into individual variables. Using the variables,
    they build arrays. This seems pretty tedious, and I'm pretty sure I
    can't apply it to one of my arrays. Essentially, I just want to know
    which cluster in which array the user has clicked on, so I can open the
    HMI keyboard or numpad and send the text to that cluster. In my watered down app (Array of Clusters.vi), I've put 3 arrays of clusters and a few stand-alone controls to give you guys an idea of what I'm taking about.
    BTW, I'm using the HMI Keyboard and Numpad built by the Beta Community (http://decibel.ni.com/content/docs/DOC-1062) and modified it to add a "Clear" button to the keyboard and numpad. Please let me know if I implemented this in the best way.
    Thanks for the help,
    Kunal
    Message Edited by bhatiak on 08-04-2008 03:55 PM
    Attachments:
    Array of Clusters4.llb ‏274 KB

    My old tic tac toe example shows how to determine which square of a 2D array has been clicked.
    http://forums.ni.com/ni/board/message?board.id=170&view=by_date_ascending&message.id=247044#M247044
    You probably can adapt some of it for the arrays on the right. If the array can be scrolled, you also need to account for the "indexvals" offset.
    The Layers controls is easiest, because you only show one element. Just read the "index vals" property to get the array element and parse the coordinates to get the cluster element.
    btw: the small while loop on the right serves no purpose at all and acts just as a CPU burner. You can delete it without any change in functionality. Is there anything else to it?
    LabVIEW Champion . Do more with less code and in less time .

  • Can I have multiple event structures with the same event cases?

    Hello, 
    I'm doing an application that reproduces the front panel of the HP6675A power supply. To achieve this, I have done a state machine with different states
    (initialize, measures, voltage, current, ocp, ov, store, recall, etc). In each state, should have an event structure that catches the events of the buttons, like for example: if the current state is the Voltage mode and the user press the current button the next state will be the Current mode. For this in each state of the state machine should be the same event structure with the same events.
    My problem is that the Vi doesn't work properly when I have multiple event structures with the same event cases. There are some possibily to do this, and how? Or is impossible to have multiple events? I have been reading some posts, but I don't find solutions. 
    Any help is appreciated.
    Thank you very much.
    Solved!
    Go to Solution.

    natasftw wrote:
    Or as others mentioned, make two parallel loops.  In one loop, have your state machine.  In the other, have just the Event Handler.  Pass the events from the handler to the state machine by way of queues.
    A proper state machine will not need the second loop.  The "Wait For Event" or "Idle" state (whatever you want to call it) is all you really need in order to catch the user button presses.  The setup is almost there.  Maybe add a shift register to keep track of which state to go to in the case of a timeout on the Event Structure.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

Maybe you are looking for