LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how can a control for true/false be changed while program is running

In the attached Vi, I want to change the condition of the case structure with control 1 while the program is running. Do you know  how I can do that? Thanks
0 Kudos
Message 1 of 8
(3,141 Views)
You shoul place control terminals inside of the loop.

Message Edited by EVS on 08-25-2005 09:38 AM


Jack
Win XP
LabVIEW 6.1, 7.0, 7.1, LabWindows/ CVI 7.1
Let us speek Russian 🙂
0 Kudos
Message 2 of 8
(3,139 Views)
In the attached Vi, I need to run loop 1 for time a t1 that I will select. Do you know how I should do that? I believe that I have to somehow subtitute the "stop condition" of loop1 with the the tick count (?).  
0 Kudos
Message 3 of 8
(3,089 Views)
You need to take a tick count before entering the loop, then another tick count at every iteration inside the loop. The difference will tell you the elapsed time that you can compare with the threshold. If you need to be able to change the timeout during the run, the terminal should go inside the loop too. Modify as needed.
 

Of course in a more general case, you would add another button or local variable and use logical OR between them so the loop can also be stopped either with the timer or manually as needed.

Message Edited by altenbach on 09-19-2005 11:13 AM

0 Kudos
Message 4 of 8
(3,084 Views)
And, since you're using 7.0, you can also use the Elapsed Time function on the Time & Dialog palette.
0 Kudos
Message 5 of 8
(3,073 Views)
Thank you. Why should I use the "wait until next multiple ms" inside of the while loops? Thanks again
0 Kudos
Message 7 of 8
(3,058 Views)

If you don't use a wait, the loops will spin as fast as they can, millions of times/second gobbling up all CPU. A small wait will give other processes running on your computer a better chance to get a slice of the pie.

Monitor your CPU usage. Run a tiny VI with one while loop. The CPU will be pegged at 100%. Now add a few ms wait statement and the CPU usage will be near 0%, insignificant. A typical multitasking computer has many processes running. You migh browse the web, edit a document, and so on. Imagine each program would be written to cosume all available CPU. Your computer would be unusable!

The main user interface loop should always use a wait statement of e.g. hundred milliseconds. There is no need to check for user input 1000x per second, because it does not happen that often. It does also not make sense to recalculate the same old inputs over and over again as fast as you can. Often, the user interface loop can use an event structure so thing only get recalculated when needed, but then without any delay.

(Of course there is a use for loops without any wait statements, for example a small FOR loops that does some quick computation on arrays.)

0 Kudos
Message 8 of 8
(3,045 Views)