LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

question about event structure

Hi there,
I got a question about event structure, I put a event structure inside a "while" loop, when I run this program, the event structure will always wait for my input in "numeric control", otherwise, the while loop will not continue to loop, my question is: are there anyway I can keep the while loop run and still can put this event structure inside the while loop? Attached is the test code.
 
Thanks 
Mike
0 Kudos
Message 1 of 10
(4,069 Views)
There is a Timeout event in Application events.  Take a look at that.
Randall Pursley
0 Kudos
Message 2 of 10
(4,061 Views)
I have looked at the time out option, but it seems not solving the problem.
 
Mike
0 Kudos
Message 3 of 10
(4,053 Views)
The event structure in your example is doing exactly what it is supposed to do. The while loop is not supposed to just spin. That is the whole purpose of the event structure. You have to explain exactly what you think the problem is.
0 Kudos
Message 4 of 10
(4,049 Views)

Hi denis,

The problem is: I have another part of code(B) inside the while loop and outside the event structure,  I need the part of code (B) to run continuesly, but because of the event structure,  Part B can not run, so are there any way to keep part B running? please see attached modified code.

Thanks,

Mike

0 Kudos
Message 5 of 10
(4,043 Views)
As mentioned above, the timeout event will do the trick. Set a very small timeout with an empty timeout case and the loop will spin.
 
Still, you might want to rethink your approach. What are you actually trying to do? Another alternative would be to use two independent loops, for example.
Message 6 of 10
(4,037 Views)
How tightly do you need it to run?  I added a timeout event, wired 1mS to it, and it does what you said it should do.  Just Like Dennis said

Paul
0 Kudos
Message 7 of 10
(4,035 Views)
Then you can do 2 things.
 
1.  Put a timeout value on the event structure.  Then when it times out it will allow the loop to finish and begin again.  In the timeout event, you can do nothing if that's what you want.  (You may want to put the stop button mouse up as an event as well so that the event can stop waiting in the event of of a click of the stop button.)
 
2.  Put the code that you want to run continuously in it's own parallel loop.  You may need to use local variables, global variables, queues, notifiers, or other structures if you need to pass data between the loops.  You will also need to use a local variable of the stop button to stop that loop.
0 Kudos
Message 8 of 10
(4,030 Views)
If some other mechanism provides pacing of the loop, you can even set the timeout to zero, making the event structure basically transparent to the loop, while still servicing other events if needed.
0 Kudos
Message 9 of 10
(4,029 Views)
Hi altenbach and Paul,
Both of your codes works nicely, it is just what I want, thank you all,

 

Mike


0 Kudos
Message 10 of 10
(4,009 Views)