LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Start stop while loop with tab control

Solved!
Go to solution
I want to be able to start and stop a while loop by entering and leaving a tab.  I am using an event structure to do so but it doesn't seem elegant or the right way to do this.  The only way I was able to get it to kind of work is by unchecking the lock front panel box in the event structure.  I have attached a sample vi of what I have so far.
0 Kudos
Message 1 of 6
(5,549 Views)
Solution
Accepted by topic author secr1973

The problem is that you can't even stop the program by hitting the stop button until you leave the tab, which is not a friendly user interface.

 

 

Event structures should just handle basic user events.  Any given event case should not take a long time to run.  While you are in the diagnostics tab, your code is stuck in that while loop.  Although fixing the lock front panel allows you to do other things, the LabVIEW is just queuing up all of those other UI events (like Stop button value change) and can't handle them until the inner while loop stops and allows the outer while loop to iterate again.

 

You should have a parallel while loop to handle the waveform graph.  You can use notifiers or queues or an action engine FGV (see Ben's Action Engine Nugget) to pass the starting or stopping of the waveform graph update to the parallel while loop.

Message 2 of 6
(5,537 Views)
Yea, I noticed that too.  I see what you are saying about having a parallel loop, but I don't want to run that loop all the time.  I just want it to run when you enter that tab.  How can I use queues or notifiers to start and stop a parallel loop?  Thanks
0 Kudos
Message 3 of 6
(5,532 Views)

I would use a state machine to "loop" through the states, and use an event structure in one of the states to handle the user interface, when user changes the tab control, it is diverted to a different state other than the state running the waveform graph, and enter back to that state when the tab control was changed back.

Since I cannot open your code with my LV8.6 at this station, I maybe far off.

Bryan

0 Kudos
Message 4 of 6
(5,521 Views)
Okay, I think I got it using a queue.  Let me know what you guys think.
0 Kudos
Message 5 of 6
(5,514 Views)

I think Tab>Value change>NewVal=Diagnostics would suffice instead of two case structuresSmiley Wink since it returns a boolean you could wire it directly to an enque element.

 

Also- You should check the displayed tab control once prior to entering the producer loop and enque either a start or a stop so that the operator does not need to change off the diagnostics page and re-enter it to start the first time-

 

Other than that- Pretty nifty and clean!


"Should be" isn't "Is" -Jay
Message 6 of 6
(5,492 Views)