LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with wait function and simultaneous loops

Hi,
 
I use a vi that simulates a choice between two circles or sides. Clicks on circles give points only after a certain delay fixed by an array constant. 
I use two while loops (for programming events in each side) inside a while loop that fix the number of trials. It would stop after a fixed number of points gained. It was my first problem, I don't know how to do this. 
The second problem is I would like to register the number of clicks on each side or circles during the wait function runs, so I would like to register all clicks on each side during the execution of the vi. I have found a way to count the number of clicks but not while the wait function runs because it blocks the execution of the vi. 
 
Can you help me please. Thanks.       
0 Kudos
Message 1 of 3
(2,521 Views)
Hi nousome,

I've made up a possible solution (attached) for what you're trying to do.  It's not exactly stellar code, but it shows a few things.

Instead of blocking execution with a wait, it checks the time of each button click.  If enough time hasn't elapsed since the last button click, the button click count isn't increased.

There are a lot of things that you could do differently for this: separate timers on for each button, separate exit conditions for each count, etc.

You might want to look up how the event loop/structure in my example works.  It's a little easier than checking mouse coordinates (and somewhat less susceptible to timing problems of control updates and property nodes).

Good luck,

Joe Z.
0 Kudos
Message 2 of 3
(2,503 Views)
Thank you very much for your solution. I have just modified some things to count the total number of clicks at left and at right.
0 Kudos
Message 3 of 3
(2,469 Views)