Log in

View Full Version : How to force break a loop


kamocat
11-04-2009, 17:55
Not a problem, just a question:
In my autonomous independant VI, I use a while loop, and have the "false" constant tied to the conditional terminal. (It's set to stop if true)
From what I can tell, the robot should be stuck in Disable once the DS switches to teleop, because the code should be stuck in autonomous (it doesn't look like there's anything to stop the autonomous code and allow Teleop to proceed).

How does Labview force that loop to break execution?
Or am I using a very inefficient coding technique in that Labview doesn't actually stop the autonomous code, it just ignores it?

I'm not running into any problems, it just seems like a very useful thing to know.

Burmeister #279
11-04-2009, 17:58
if you look at the get robot mode virtual instrument you can find where it switches between modes. before it switches out of autonomous it uses a labview control vi to stop the independant vi execution.


the loop itself isn't stopped nor paused, the whole independant.vi is closed/stopped.

Uberbots
11-04-2009, 18:24
normally to "pause" a loop without terminating it (which would imply that you cant start it up again), youd use a sync vi to have the loop constantly waiting for that vi to return something (like a semaphore). the reason the loop "pauses" is because a loop is programmed to not continue until all inner vi's have outputted something

kamocat
11-04-2009, 19:28
if you look at the get robot mode virtual instrument you can find where it switches between modes. before it switches out of autonomous it uses a labview control vi to stop the independant vi execution.


the loop itself isn't stopped nor paused, the whole independant.vi is closed/stopped.


So that's why Begin.vi requires a VI reference to the autonomous mode?

Burmeister #279
11-04-2009, 19:30
basically yes.

Greg McKaskle
12-04-2009, 08:14
The puzzle has been solved. I'll just add that aborting running VIs is not something you should do on a regular basis. We are doing it here to make the framework simpler to use. The normal way of exiting a loop is for the code in the loop to say "I'm done". It can include info from anywhere else in the program to make that decision.

Using the Run and Abort methods on a VI is a way for you to spawn and kill a task similar to an OS thread.

Greg McKaskle