LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

while loop does not stop

Well....

Humm....

With reference to the block diagram that you posted earlier, the "Query Inputed Devices.vi" doesn't do anything.

You could use the info from the input device to select from the case statement..

I'll do an example and post it..

back in a minute..

RayR

0 Kudos
Message 11 of 16
(1,332 Views)
The attached vi will run until you click STOP outer loop if no joystick is present.
 
It will run the outer loop until a joystick is detected (I don't have a joystick to test - sorry).
And it will stop both loops if there is a joystick and you press stop inner loop.
 
Have a look at the vi and how it was implemented.
 
Should work.
 
The Joystick info is actuially an array of clusters.  It is empty (0) if no joystick.
 
Experiment & have fun...
 
RayR
Message 12 of 16
(1,327 Views)
Well...ain't no words...THANKS!Smiley Very Happy Works just great.
 
Only one thing that was what happens in my code, when I just turn off the "stop outter loop" button, labview hangs it on. Just when I press "stop inner loop" button, simulation stops. Wich I think that's because of the inner loop still running...Tried to make the same thing (putting a OR to the inner stop condition with both buttons, and stills "waiting" for the "stop inner loop" button to be pressed...
 
 
0 Kudos
Message 13 of 16
(1,323 Views)

The easiest way to discover what is going on with respect to dataflow is to run the VI using execution highlighting while watching the diagram. Wires are NOT like their electric equivalent.

Throwing the switch at any random time during execution will NOT switch the wire state and everything that is connected to it. Everything occurs strictly by dataflow. The switch terminal is read once it gets its turn in the outer loop and its values is fed to the input tunnel of the next structure. The value of that tunnel will only change next time the terminal is read again, which only occurs once the outer loop recycles.

In your particular case, the switch control is never read while the inner loop is running. You are painting yourself into a corner. Typically, you should place controls in the innermost loop.

Simple things like that are easiest done with an event structure.

Also don't forget to place a small wait (e.g. 10ms) in the inner loop. It is not nice to all other processes to hog 100% of the CPU by spinning a trivial loop millions of times per second.

Message 14 of 16
(1,324 Views)
Thank you for the help. I will continue trying. Seems that the event structure might be the solution.
 
About the 10ms, I had it in the "Marco joy" vi, but took it out into the inner loop.
0 Kudos
Message 15 of 16
(1,310 Views)

Thanks Altenbach for the detailed description.

You deserve 5 ***** for the info, buddy..

Yep..  I should have added the delay in the example... 🙂

 

0 Kudos
Message 16 of 16
(1,302 Views)