LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to control loop from an event structure

Hi All,

 

The main concept of user interface is to allow user start and break (go out) while loop. Start again, and break again. Start... and so on.To do that I created vi presented on vi1.png

 

Two buttons (Start & Stop), two events structures (to try to make them independent - right now I know it doesn't work). Start button triggers while loop. The mechanism to accept notifications and break that loop is presented in the file vi2.png

 

However, that system is not working and I'm thinking I miss a kind of funtametal LV feature designing that solution. Despite putting these two buttons in separate and independent event structures UI is blocked and loop inside the Start event is unable to receive a 'Stop' notification. 

 

Could you tell me is there posibility of multiply calling (one by one - not all toghether) the while loop with ability to stop it and go out any time?

 

How can I start with a button a while loop as a separate thread or process and go to main vi back without waitin for results from that triggered loop?

 

I want that the start and stop events will be triggered by user.

 

Cheers,

 

K.
Download All
0 Kudos
Message 1 of 7
(4,522 Views)
well one thing is you normally dont put a while loop in the event structur if you want something to happen as it it is in a while loop try sing the timeout part of the event structure
Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
0 Kudos
Message 2 of 7
(4,500 Views)

Hi MiniKLM,

you shouldn't use two event structures. You can use a parallel loop with a queue in it.

See the attached example.

 

Mike

Message Edited by MikeS81 on 09-09-2009 10:34 AM
Download All
Message 3 of 7
(4,493 Views)
You should read this from the LV Help File.
- Partha ( CLD until Oct 2027 🙂 )
Message 4 of 7
(4,471 Views)

It is difficult to debug a picture. Please always attach actual VIs. We cannot see if there are other event cases and we cannot see how the events are configured. We also cannot see the mechanical action of your various buttons.

 

As others have said, there are some very basic design flaws.

  1. Don't place while loops inside event structures (upper loop). It will prevent the event structure form reacting to new events because of dataflow. By default, the front panel is also locked while an event executes.
  2. You don't need any waits if you have event structures, makes no sense.
  3. Don't make multiple controls with the same or very similar name ("Stop", "stop", ...). That leads to confusion and accidental errors.
  4. Why are there no events for the loop terminations?
  5. You don't need to reset to defaults if you use latch action buttons.
  6. Most likely you could do all with one single while loop and one event structure. You can use the timeout case for the code in the inner loop (see e.g. this or this example ).
Message 5 of 7
(4,426 Views)

Hi All,

 

Thank you very much for your responses.

 

Many thanks to parthabe and altenbach for constructive feedback. MikeS81, your solutnion doesn't allow me to go out and start that loop again, does it? Harold, could you use more punctuation and capital letters please?

 

An idea for my solution was like that:

 

1. Trigger one loop by one event

2. To exit that loop send a notification by clicking a button controled by SECOND and INDEPENDENT event structure.

 

I think that concept would have worked if the LV hadn't controlled those two event structures as one. The reason that my concept doesn't work is the UI is frozen (despite the fact that I'm using two separete and independent event structures)

 

Having read your posts I concluded that  I have to base my solution on Register Event Callbacks technique. Is that correct?

 

What you would do if you were in my shoes?

 

The main criteria is: to start the same while loop multiple times.

 

K.

0 Kudos
Message 6 of 7
(4,348 Views)

Hi MimiKLM,

i'm not sure what you mean. You can "start" and "stop" the example counter. Why should you exit the loop?

 

Mike

0 Kudos
Message 7 of 7
(4,342 Views)