Event structure freezing when short delay inserted

Well, the simple stuff in LabVIEW I can do, but I'm still struggling to get my head around the concept of "Events" and how LabVIEW handles them. If I only have one type of event (i.e., pushing a button out of several on the UI, or reading a serial input and handling it programatically), I think I'm good. But my application requires me to be able to handle either of these at the front panel.
Going through the LV Knowledgebase got me this link (it's a little old - LV8.6, but seemed to handle the basics), from which I downloaded "events.vi" (attached). My situation is a little different, so I modified it a bit to "EventExperiment.vi" (also attached) to have a bare-bones template I could use for my application. If I run it as shown, it seems to run fine (with a serial input, the "1" and "2" lights turn off, but the Bytes at Serial Input indicator always shows "0" and the "Serial Indicator" light never lights - I am assuming that these change and revert too quickly to see in the UI). My concerns with my VI are:
If you add a short delay in the processing of the serial input event (say 1 second delay in that event case, or even a 1 second delay subVI after the serial flush connected through the error line), the VI accepts no further UI input after the first serial event.
If you add an error wire through all the events subVIs (whether you merge this wire with the one going through the serial subVIs, the program just hangs up.
And, one little bothering thing is that the original "events.vi" takes three presses on the "stop" button to close. I'm figuring here that it's because of those local variables being passed between loops, but it hasn't been enough of a bother to worry about.
Your help is greatly appreciated,
Cameron
To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.
To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):
LabVIEW Unit 1 - Getting Started
Learn to Use LabVIEW with MyDAQ
Attachments:
events.vi ‏24 KB
EventExperiment.vi ‏25 KB

Well, I thought I'd add a final post for some closure to this one.
To summarize what I was trying to accomplish: I wanted to have some kind of an event structure where you could use both regular User Events (button pushes, numerical control changes, etc.) and an outside (non-keyboard/mouse/touchscreen) event, like a serial character coming into a COM port, to initiate an action. This was to eliminate a loop where the computer would be polling the COM port continually at a pretty fast rate. (I must have read a hundred times in the past month that you don't want to run a While loop for polling if you can help it.)
It turns out (after a couple of confusing days, I talked with the NI service engineers) that you can't do this. In order to detect a character at a COM port, you have to be polling the port periodically with a Read and look for a change in the bytes available or another parameter. You can do this through a timed loop separate from your Event loop or through a Timeout event case inside the loop, like Don_Phillips suggested.
However, I believe I'll go the separate loop route, since my head's actually more comfortable with it than the Timeout route.
Thanks, folks, for your help,
Cameron
To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.
To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):
LabVIEW Unit 1 - Getting Started
Learn to Use LabVIEW with MyDAQ

Similar Messages

  • Event Structure Freezes Vi After Capturing The First Event

    My Event structure catches the first instance of my button press but then it freezes my Vi.  The reason is because of the while loop but I need the while loop to constantly read from a serial port and send data to a serial port. The vi included is stripped down to be just a while loop that does nothing.  I have also tryed putting the event structure in the while loop, but the same thing is happening.
    Any ideas?
    Thanks,
    Cason Clagg
    SwRI
    LabView 7.1, Windows XP

    Also, put the button inside the event structure where it is acted upon, from LV help (suggest you read the entire events section of help):
    When you trigger an event on a Boolean control configured with a latching mechanical action, the Boolean control does not reset to its default value until the block diagram reads the terminal on the Boolean control. You must read the terminal inside the event case for the mechanical action to work correctly. As a reminder, a note appears in the Edit Events dialog box when you configure a Value Change event on a latched Boolean control.
    Refer to the Handling a Latched Stop Boolean Control in an Event Structure caveat for information about how to handle a latched Boolean control.
    When you trigger an event on a Boolean control configured with a latching mechanical action, the Boolean control does not reset to its default value until the block diagram reads the terminal on the Boolean control. You must read the terminal inside the event case for the mechanical action to work correctly. As a reminder, a note appears in the Edit Events dialog box when you configure a Value Change event on a latched Boolean control.
    Refer to the Handling a Latched Stop Boolean Control in an Event Structure caveat for information about how to handle a latched Boolean control.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~
    "It’s the questions that drive us.”
    ~~~~~~~~~~~~~~~~~~~~~~~~~~

  • Robohelp 7 freezes when trying to insert an image

    Not sure how this happened, but now I can't insert images
    into my RoboHelp 7 project. Now when I attempt to go to Insert >
    Image and then click the folder to browse for an image to insert,
    Robohelp freezes until I hit the escape button. This is surely a
    bug. I'm on Windows XP.
    As a workaround, I have to drag the images into the project
    folder manually and then select them from the list or type their
    names in the field.

    It sounds like the Insert Image dialog box has somehow fallen off the edge of your screen (Esc is closing the dialog box, returning focus to the main RoboHelp window). Try this:
    1. Press Alt, Spacebar, M
    2. Press any arrow key.
    3. Waggle the mouse madly until the dialog box appears on your screen.
    4. Click to drop the screen where you want it.

  • Itunes freezes when trying to insert IPOD

    Hello all,
    We are trying to restore a click shell IPOD (+ HP). When Itunes is running and the IPOD is inserted in the base attached via USB to the computer (Dell D620), Itunes freezes thus preventing the restoration. I have tried to deinstall Itunes and reinstall but no luck. Any ideas?
    Jordan

    Since no one has replied to my requests, I will reply to myself.
    It turns out that the IPOD may have had really bad stiction.
    I got it restored using the origninal HP+IPOD CD installer. But then when trying to get all 485 songs downloaded in Itunes it got to about 147 and hung. So, I "carefully" tapped the sides of the IPOD actually harder than many times before. I then did a soft reset on the IPOD and started to download the 485 songs again from Itunes. This time it worked with no problems. Now, the question is whether it will hold up this time or start "sticking" again.

  • Mail freezes when trying to insert large contact group

    I am trying to send an email blast to a large number of clients (roughly 1,200), but every time I try to input the name of the group Mail freezes and nothing happens. I have gotten so far as the name of the group appearing and being able to click send, but it always freezes and never send the mail. Is my contact group too large? That is the only thing I can think of, I am using the newest model 15 inch mbp with 16gb RAM so I have a hard time believing its the computer itself.

    Found the resolution to this, my gmail was limiting how many contacts I send an individual email out to... nothing to do with Mail really.

  • Powerbook freeze when DVD is inserted

    Hi,
    This issue has just started happening. Everytime I put a dvd into my combo drive it makes my mac crash. DVD player starts to open and then it hangs and I have to manually shut the computer down. I tried using frontrow instead but this was no better. I dont think its a mechanical issue because other cd's work fine, i think it is only DVDs.
    Has anyone else had this issue or can anyone at least point me in the right direction on how to fix it?! It is frustrating because I really like the DVD aspect of the mac!
    Thanks

    I checked here http://discussions.apple.com/thread.jspa?threadID=1313471&tstart=0 and found this fix http://www.hurrikenux.com/Testing/UnofficialLeopardGraphicsUpdateRollback1.2.zip thanks!

  • Event structure in a subVI

    I know this problem has been posted, but I've already am passing everything by reference. I can't get my subVI to respond to my top layer VI. It runs fine as a stand alone, but when I ask it to monitor events from a reference, it won't do anything. I've attached what my sub VI looks like. My goal is to have the the event structure respond when a new file path is sent, stop button pressed, or a enum is changed. The subVI is called Read Track shown in the top VI with all the references passed.
    Top VI
    Message Edited by d1sturbanc3 on 02-27-2008 12:30 PM
    Message Edited by d1sturbanc3 on 02-27-2008 12:31 PM
    Attachments:
    event.JPG ‏163 KB
    top event.JPG ‏301 KB

    You should use dynamic events.
    Your SubVI with the event structure should run in parallel with your main code.
    What you currently have will never work.
    Here's an idea of how the subVI should look like:
    Try to use the Code Capture Tool to get images of your code...
    Good luck,
    Ton
    Message Edited by TonP on 02-27-2008 07:45 PM
    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!
    Attachments:
    PathEventChange.png ‏5 KB

  • Event Structure Help

    So I wrote this program not knowing how event structures worked ahead of time, and I did pretty well except for 1 problem.  I set the event to continue on a value change of the "Continue..." button on the bottom right of the screen (block diagram is attached) but when I wrote it, I did so thinking that it would run all the code on the inside first, and then pause for me to pick what I wanted next (that big case structure on the right side) and then click the continue.  Instead the order of operations is backwards, it pauses and waits for me to click "Continue..."  in the very beginning, then runs the code inside. 
    This would be fine, if it didn't cause the test I was running to be a step behind.
    Is there a way to change the settings so that it runs the code, and then waits for the "Continue..." button, or do I need to re-write this from psuedo-scratch so that it does everything in the right order?
    Hope that was all clear, let me know if it's not.
    Attachments:
    Reversal Adjustment.jpg ‏297 KB

    Looks to me like the problem your running into is that the control selecting the case structucture is read as soon as you enter the case structure, i.e. at the same time the rest of your other code is executing.  By the time you reach your 'pause' the conditions for the next iteration are already set, and changes to the case structure control, will be read NEXT time through the loop, making it appear to be one step behind.  Use 'Highlight Execution' to verify.
    If you don't mind pressing the 'continue' button first, you can get rid of the shift registers, move the case structure to the left and feeding its outputs directly into the various subVIs directly.  The case will be selected by the 'NextUp' control when the 'Continue' button is pressed.
    -or-
    Move the code you want to run first outside the event structure.  Leave just the 'Next Up' control, the case structure, and the 'Continue' control inside the event structure.  
    When you execute, the code outside the eventstructure will execute using the defaults outside the 'while loop',  and pause at the event structure until the 'Continue' button is pressed.  When you press the 'Continue' button, 'NextUp' control is read selecting the case setting the shift registers for the next time through the loop. (you should probably use an error wire to force execution flow)
    Attached are abbreviated examples

  • How to exit from the DO-while loop in the event structure

    Hi all
    I am just a beginner for Labview
    I want to build a loop in the event structure, but when I enter in the loop, it seems the system is dead, and I can't exit the loop.
    here I attached a simple sample.
     In the sample.  when I press the start_calculation button , the calculation start, but the system is dead, and I can't exit calculation loop.
     actually, i just want switch the different operation by changing the event action.
    anybody has a good idea about it??
    thanks so lot
    Attachments:
    event_problem.vi ‏17 KB

    Your problem is that you are trapped inside an event case. It is not a good idea to run extended code inside event cases, else the event structure cannot service other events.
    Why don't you use the outer loop for everything? Now things don't step on each others toes. What good is an event structure if it cannot react at all times???
    Message Edited by altenbach on 07-25-2008 12:26 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    event_problemMOD.vi ‏17 KB

  • Event structure and automatic queueing of events.

    I have found out the long way that the event structure queues all the events taken place while it has been executing yur most current event.
    In other words... I understand why the locking of the front panel is an automatic option that is selected. As it will prevent you from queueing more events,  and causing yur program to execute endless event structure runs, when you wanted it to stop 15 button presses ago.
    case in point.... is in this simple VI i attached.
    My question is ... is there a way to turn off this automatic queueing of events??
    Attachments:
    EventStructureHUH.vi ‏53 KB

    Well ... the problem for me... was, for example, in the VI I posted....
    The OK button in the VI I posted, has an event triggered to it in the event structure.... So when I enter that loop after hitting the enter loop button... it registers those OK clicks...
    Say the OK button and NOT the continue button takes me out of the little loop and back into the big loop. Now, after leaving the little loop and entering into the big loop, I will immediatly enter back into the event structure to handle the OK button click.
    Basically I wanted one button to control the termination condition of the little loop, but also have an event in the event structure associated with it, so basically one button to exit the little loop AND the big loop.
    I hope Im making sense. I found a solution, by just making two buttons, when entering into the little loop, the one button dissapears... and vice versa when entering into the big loop. So to the USER it appears like ONE button... but in the code its actually two.
    I just wasnt sure if there was another way around it... it was tough to figure out what was really happenening in my code... took my about an hour or two to track down.
    EDIT: Yea.. thanks for the reply....  as for the comments in my code... yea, I get a little crazy towards the end of the day... after 6-8 hours of straight labview programming. 
    Message Edited by MJBrehm on 06-30-2006 02:21 PM

  • Cut text using event structure

    Hi everyone.
    I'm making a project with LV Student E. 7.1.1. I have an event structure, its function is scanning a value change in a "control text". Any change in the control text is detected by the event structure, except when I CUT the text (selecting part of the text and presing CTRL+X). The NEW VALUE isn't detected!!! Somebody knows why?

    It works if Update Value while Typing is not checked, provided you change the focus after the cut. But then you do not get events for each character as entered.
    It works as you would expect in LV8.
    Lynn

  • Can event structure detect window minimized

    Can the (LV 8.5.1) event structure detect when a window is being minimized?
    Solved!
    Go to Solution.

    Yes, you can!
    The event 'Panel Resize' is the triggered event:
    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!

  • Inserting a short delay between tracks at some places when playing

    I have a lot of classical music on iTunes, copied from my CD's. In a few places, two successive tracks play with no delay between them: this is very disturbing. How can I add a short delay (a few seconds) between the sounds from two successive tracks ? I am using iTunes 7.0.1, but I noticed the problem already with 6.0.5 and with 7.0 (as far as I remember)
    PowerBook G4 15" 1GHz   Mac OS X (10.3.9)  

    Hi jeanjeener -
    You might want to look in the iTunes preferences and select the
    playback tab . I have ixnaid the Crossfade Playback selection and
    albums now play as I remember them from the vinyl LP days .
    You might try that . When I read the suggestion rooted in my own
    dissatisfaction in "heel toeing" I recall it took a few days
    before I was satisfied it had eliminated the stacked play .
    Frederick

  • Frontpanel freezes when an event of an already closed event structure occurs

    Hello,
    I´d be very glad if someone could explain to me the behaviour of the attached short and simple vi.
    If you press the OK button #1 once and then the OK button #2 the vi finishes, but if you press the first button more than once before pressing the second button, the front panel is locked. In both event structures, the feature "Lock front panel until the event case for this event completes" is enabled. If it is disabled the front panel is not locked after pressing the first button twice. What I do not understad is why if the feature is enabled the front panel locks after pressing the first button twice. I would think that after the loop containing the event structure closes, the event case should definitively be completed.
    Attachments:
    Event.vi ‏12 KB

    This is expected behavior.
    If you look at your event configuration, both events are set to "lock front panel until event completes". If you fire the second event first, the FP locks and you cannot trigger the first event any more.
    Quick and dirty solution: uncheck "lock front panel...".
    Better solution: learn about dataflow and proper program design. What you are doing here is not a good program architecture. Deadlocks, too sequential,  event structures that cannot be serviced immediately due to dataflow dependency, etc.
    Maybe you can tell us in a more general way what you are trying to do.
    LabVIEW Champion . Do more with less code and in less time .

  • Find Control in Event Structure doesn't show the object when it is not in the frontmost Tab page [Bug Report, LabVIEW 2012]

    When you are looking for the control/indicator handled by a case in the Event structure, you can use the contextual menu item "Find Control" (doesn't distinguish between control and indicator, BTW).
    The result is that the control/indicator is highlighted on the FP. The problem is, if that control is in a Tab and specifically in a page of that Tab that happens to not be the frontmost, the only thing you'll see is marching ants, but no control:
    <=========== the wrong TAB page was shown. LV did not bother to switch to the relevant one....
    In other words, "Find Control" in the Event Structure doesn't switch the tab to the owning page. This is contrary to what happens if you right-click, say, the terminal of this control: the FP will switch to the owning Tab page.
    I'd call this a bug and this is definitely an annoyance (which most likely has been around since the creation of the Event Structure).

    I did not. Is there any better chance for it to be caught there by a NI eye than it is in the LV forum? I though these threads were deemed to gather bugs/features that had been already acknowledged by NI with a CAR number.
    I (and others!) wished there was something like this: http://bugs.sun.com/ or http://bugs.python.org/ for LabVIEW...
    I am just coming back from a short conference of scientists who quite uninamously ended up with the conclusion that LabVIEW was to be disregarded as a lab development environment because of maintenance problems (which could have been argued for any language in my opinion, although I think they meant spaghetti diagrams are the natural tendency of students who could not care less as they are not going graduate because of their LV skills or lack thereof), but I guess I could have added my grain of salt and added the complete opacity on bug and feature handling by NI.

Maybe you are looking for