NI Home > Community > NI Discussion Forums

LabVIEW

Showing results for 
Search instead for 
Do you mean 
Reply
Member
ishmael
Posts: 13
0 Kudos
Accepted Solution

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

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

Knight of NI
altenbach
Posts: 27,605
0 Kudos

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

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. :smileyvery-happy:)

 

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?


LabVIEW Champion . Do more with less code and in less time .

Member
mahu
Posts: 109
0 Kudos

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

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

Member
ishmael
Posts: 13
0 Kudos

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

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.

Knight of NI
altenbach
Posts: 27,605

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

[ Edited ]

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.

 

 


LabVIEW Champion . Do more with less code and in less time .

Member
ishmael
Posts: 13
0 Kudos

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

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.

Member
AnoAno
Posts: 7
0 Kudos

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

Can someone please downconvert the file to version 10.1?

 

Thank you in advance.

Knight of NI
altenbach
Posts: 27,605
0 Kudos

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


AnoAno wrote:

Can someone please downconvert the file to version 10.1?


Here you go....


LabVIEW Champion . Do more with less code and in less time .