LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to start and stop a timed loop from an event loop

Solved!
Go to solution

I would like to have a timed loop and an event loop running simultaneously.  Is there a simple, clean way of doing this?  (i.e. without hideous queues, etc.)  My attempt is shown below.  Unfortunately, as soon as the timed loop starts, the event loop becomes unresponsive.  Thanks for your help!

 

labview_event_test.png

0 Kudos
Message 1 of 8
(4,800 Views)

You have a data dependency and the outer loop cannot complete until everything in it has completed.

 


@ishmael wrote:

I would like to have a timed loop and an event loop running simultaneously.  Is there a simple, clean way of doing this?  (i.e. without hideous queues, etc.) 


You could use a regular queue. I would recommend against hideous queues, even though I don't quite know hat that would be. :D)

 

In order for the event structure to be ready at all times, it needs to be in its own loop.

 

(Nobody likes to write examples from scratch, so please attach your code so someody here can maybe try to modify it).

 

Also please be more specific about the purpose of your code. What is is actually supposed to do?

0 Kudos
Message 2 of 8
(4,794 Views)

Try put the button start/stop inside the while loop and replace signal of button with NewVal, the event case will work and the control refresh your status when run. 

 

regards

0 Kudos
Message 3 of 8
(4,791 Views)

Thanks for the reply, altenbach.  I've attached my VI - sorry about that.  All I'd like my code to do is allow for a timed loop to be started or stopped with the click of a button.  In my sample code, when the timed loop is running, it should just display an increasing loop count.

0 Kudos
Message 4 of 8
(4,790 Views)
Solution
Accepted by topic author ishmael

You don't need the outer loop. Place the event structure inside the timed loop and manipulate the timeout between zero and infinite, depending on the desired state.

 

 

Download All
Message 5 of 8
(4,776 Views)

That's great, thanks!  It works perfectly, although intuitively, I would have thought that the event loop would not run until after the timed loop was already running.  In any case, this is elegant and simple.  Thank you.

0 Kudos
Message 6 of 8
(4,767 Views)

Can someone please downconvert the file to version 10.1?

 

Thank you in advance.

0 Kudos
Message 7 of 8
(4,495 Views)

@AnoAno wrote:

Can someone please downconvert the file to version 10.1?


Here you go....

0 Kudos
Message 8 of 8
(4,490 Views)