LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a better way to run a VI continuously??

Hi everyone,
 
I am using LabVIEW 7.1 and would like to create a VI that run continuously. Attach is my VI, please give me some suggestions.
 
When I run this program, I can feel that my computer is acting significantly slower than if I were to remove the outermost while loop. Is there some problem about my programming? How can I improve this VI so that I can just start it and let it run forever without using the "run continously" button??
 
Many thanks in advance.
 
 
 
Tak
 
 
0 Kudos
Message 1 of 4
(4,549 Views)
Put a delay within the while loop. Without it the CPU is spending most of its cycles executing the while loop. A delay of 10-100msec would be acceptable.
~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
0 Kudos
Message 2 of 4
(4,544 Views)
In addition to what the kid just said:
 
There is no reason to set such a VI to time critical priority(!) As you have done here. This makes the VI extrememly greedy for system resources and everything else running on your computer gets starved and suffers. Long ago, I had a wireless network driver that would loose connection in such a case. (I am sure that you noticed that even the mouse actions don't get the system attention that you learned expect). Anything above normal priority should be reserved for small, low-level driver VIs that complete very quickly and only run occasionally. In general, don't change the default priority unless there is a very, very compelling reason to do so and it really makes a difference to the outcome (it virtually never does!).
 
Since you are just starting out, here are a few tips:
  • Always use a small wait in any toplevel while loop of the UI.
  • Don't use indicators as controls. An LED is not an obvious control to the typical user.
  • Use latch action booleans, eliminating the reset via local variables.
  • Use proper data types. Set your numeric indicators to I32 in agreement with the data.
  • You probably can get away with a single while loop containing a case structure. Much better than stacked while loops.
  • Make sure your controls are not "blocked". For example it is currently impossible to stop the VI with your stop button while the inner loop is running.
  • Learn about the event structure. It makes many things much cleaner.

Happy wiring! 😄

Message 3 of 4
(4,535 Views)

Hi Kid and altenbach,

Now, the program is working much better with the delay. Thanks!!

Also, thanks for the suggestions, altenbach!!

 

tak

0 Kudos
Message 4 of 4
(4,526 Views)