LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Strange run-time problem

I have a problem in my vi. When the vi loads up, everything seems to work fine, however I have two radio buttons at the top of the vi, and when I use them to select something my vi seems to freeze up. I've tried all kinds of debugging, and I can't find the error. I've also tried to eliminate all race conditions. Could someone please help me find the problem. Thanks!
0 Kudos
Message 1 of 5
(2,741 Views)
Hi Marshall

Your Problem Seems to Stem from the Fact that you have two Event Structures in One Loop. If you look up Caveats and Recommendations under event Structure in Labview Help, there is a Paragraph "Avoid Using two Event Structures in One Loop".

I took your Vi and Did the following Experiments.

1. Verified that the Vi does Hang as Claimed.
2. I Put the Tab control at "TTL" and then Deleted the Event Structure form the case "RS232" and than Ran your Vi. It works fine.
3. Instead of deleting the Event Structure totally, I deleted the event cases which are duplicated in the two event structures. "Yes" Value Change, "No" Value Change event and "Cancel" Event form event Structure under the RS232 Case. Left the timeout Case as is. I ran the Vi Again it Works Fine.

I believe - The Problem is this. Each Event Structure waits for events it has been programmed for. The event structures are in the same loop. The Event structures themselves have no way of knowing that they are embedded in a case structure and only one of them needs to execute. So after the First event the Program kind of hangs as the second Event structure Waits indefinitely for the Program to Pass execution to it.

So the Fourth Experiment -

4. I Used a Local Variable to Change the Tab to RS232 if I was in TTL and to TTL from RS232 if I was in RS232. This Local Vaiables are under the Yes Value Changed Event And Now I checked the Program, If Clicked Yes The TTL Case Executes Changing it and Correspondingly Changing the NO value, then it Changes the Tab Value So on the Next Iteration of While Loop my Program is in RS232 Case and Event Structure Executes and puts the Tab Back to RS232. In effect I have Made My Program Go through Both Event Structures This Works Everytime Only when I click on YES. I click on NO and Program Hangs as I did Not Built the Same Functionality for this case.

The Event Structures Cache the Events they have been Programmed for andthe First Event Must be Handled Before A second Event can take Place. In your Case One Event is in two Structures and at any given time One of these Structures executes. The Other Structure Waits and Inhibits furthur interaction till the Event generated can be handled by it.

On a Side Note. It is Advisable to Create an Event Structure and Embed your Cases within them And Also have Only One Event Node to Handle One Event Such as "YEs" Value Change. So you know what is Going on. and easy to Maintain Code. Also It will Help If you could Club Similar Controls in an Array and handle them that way rather than individually

I Hope I am clear in my explanation. I hope this is the reasoning why Your Program Hangs. I have attached your Vis slightly modified for you to see.

Good Luck!!
Good Luck!

Mache
Message 2 of 5
(2,741 Views)
First of all, thanks for the answer. This was one of the best responses I have ever received to a question.

Secondly, I had already thought that the two event structures might be conflicting in some similar manner, so that is why I put the timeouts on both of the event structures. However, as you see, this didn't work. Any ideas as to why, for this should have triggered the stucture that was hanging everything, and allowed the loop to run back around again, just as if you had manually triggered something on the other event stucture. Any ideas as to why this didn't work.

Thirdly, does anyone know if the ability to nest event structures in a case statement (or otherwise), is something which will be added in the release of Labview 7.0 (this fa
ll) ?

Thanks Again.
0 Kudos
Message 3 of 5
(2,741 Views)
HI Again,

Lets Say you do not Put Any Value of time Out. The Only Way you can come Out of Event Structure is if there is any Front Panel Activity which Generates Events. If there is no Event generated the Loop reaches upto the Event Structure And then Everything Waits.

If now you Had a timeout Value of 20 ms Wired in. The Event Strucrture After 20 ms will Execute the Timeout Case and then Loop Back.

This Explains Why Everything Works Initially.

Now If you generate Event Activity, which has a case Programmed then the event does not have to wait till time out. An Event is generated for which a case is programmed so lets execute the case in Proper Sequence. The Problem is - as we know - All Front panel Activity is Frozen till this event is ha
ndled. And If our Program does not Bring the Logical Flow to Event Structure for it to execute - Voila!! Your Program goes to Siberia!!.

So Time Out is only effective if No Event is generated But If Event is Generated then you must let the Data flow Handle it ( Or Discard it). Time Out is needed if you have other activity that needs to be performed continously in addition to Polling for Front Panel Events. Otherwise the Program will be Struck at Event Structure Waiting for Event.

Regarding, Labview 7.0, I dont Know whether it is in works or not. Or what features it will have. Or When it Will Be Out.

Good Luck Once Again~
Good Luck!

Mache
0 Kudos
Message 4 of 5
(2,741 Views)
When I was at my lv basics courses, the instructor mentioned something about labview 7.0 coming out later this fall, and possibly sometime this winter. He also stated that they were possibly trying to optimize a lot of the way that lv runs on your machine (i'm hoping the abundance of memory management problems associated with arrays wll be addressed). Anyone have any ideas?
0 Kudos
Message 5 of 5
(2,741 Views)