LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

what is the difference between run continuosly and while loop

You could put the .vi code inside a while loop with the condition terminal wired to a TRUE constant. Better yet, use a boolean control on the front panel wired to the condition terminal of the while loop. That will allow the .vi to run continuously until the I have two methods for a program ro run continuosly

1)The user has to run my appln by pressing the run continously button

or

2)Using a while loop by selecting "stop if true" condition and wiring a stop boolean control to it.

which is the better way.
0 Kudos
Message 1 of 6
(5,989 Views)
You should never use the RUN CONTINUOUSLY button for anything other than testing.

Don't make the user click anything to run your application. A finished application should start when it's opened - why make them click something else?

The usual way is to have a main WHILE loop - the condition is set to STOP if TRUE, and a STOP button wired to it. If all you're doing is waiting for user input, don't forget to use a WAIT for 100 mSec or so in the loop - otherwise you'll hog the CPU.
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 2 of 6
(5,988 Views)
The "run continuously" button is pretty useless as soon as you programs become a bit more complex. It is not intended to be used except for quick debugging of very simple code. Why would you want to constantly re-start your program over and over again?

The only correct way to do this is with a while loop. Also don't forget to to place a short wait statement inside. Even better, place a "wait for front panel activity" or an event structure inside the loop so it only executes when the input has changed. You don't want it to suck up all CPU calculating the same stuff repeatedly ....

The only real use for the continuous run button is during quick seperate debugging (e.g. play with input parameters) of subVIs that are normally intended to be call
ed from other VIs.
0 Kudos
Message 3 of 6
(5,988 Views)
Hello,

These are great responses. I agree, the "run continuously" button is intended to be strictly a development/debugging tool, and you should avoid using it at all in most situations.

I would also suggest using a while loop with a stop button enabled. The suggestion to have the application run on startup is also a good one, but be VERY careful when making this setting on your VI. If the application runs on startup and it is a very time-intensive or CPU-intensive app, it can trap the user into waiting until a certain function is complete before quitting the app. Usually I like to allow the user to press "Run" themselves unless it is a very top-level, polished and finished product that runs exactly how I want it to every time.

Good luck with your applicat
ion. Have a great week!

Liz Fausak

Applications Engineer
National Instruments
0 Kudos
Message 4 of 6
(5,991 Views)
OK, but here's something interesting:

I have written my VI to send out and receive a test signal with the USB-6251 DAQmx card. When I hit Run continuously, the whole VI runs, completes, and runs again (basically how you would want run continuously to work). The Sine wave I am sending out begins and ends at 0 Volts.

BUT...when I use a WHILE loop, the beginning and the end of the signal generated move up and down with each iteration, following the sine pattern as it runs.


WHY?

I have a DAQmx clear task at the end of the VI, and it should be starting over each time as it does with "Run Continuously".
0 Kudos
Message 5 of 6
(5,717 Views)

Hi SailinShoes,

The VI your using to generate the sine wave doesn't start at 0V and end at 0V every time.  After the first iteration of the loop, it begins the sine wave a tick after zero.  So, after several iterations, it will begin to generate the sine wave starting at a new value (increased by a bit) every time.  This is why the graph appears to be shifting.  I would recommend generating your own sine wave with a “for loop”.  When you run continuously, your program redraws the first sine wave (0V to 0V) every time. 

I hope this helps,
Paul C.

0 Kudos
Message 6 of 6
(5,665 Views)