LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding a loop to a vi

Solved!
Go to solution

I created a vi to control a mower test with much help from the NI community. Currently I am running this vi in the 'run continuously' mode, which I was told is not a best practice for operation. I am getting errors every few hours and believe it is due to the run continuously mode. What do I need to do to have the vi run continuously on its own? Thanks.

0 Kudos
Message 1 of 7
(2,967 Views)

If you have a "1" hardwired to the N input of a For loop, you should just get rid of the For loop altogether.  In your case you do have some delays in the loops so you should probably change them to flat sequences or put the delays on the error chain.

 

What you probably want to do is put a While loop around the 3 bits of code that are currently in For loops.  The most likely cause that you crash after a while is that you are constantly creating, starting, stopping, and destroying your DAQmx channels/tasks and eventually run out of some resource or another.

 

Create one new button that you attach to the "stop" control in the new While loop to stop your program.  Probably also ought to put the error handling VI inside the While loop.

Message 2 of 7
(2,930 Views)

In addition, this article has a lot of good coding practices and examples that may be good to understand for your application

 

http://www.ni.com/product-documentation/2835/en/

Chase
NI Technical Support Engineer
0 Kudos
Message 3 of 7
(2,869 Views)
Solution
Accepted by topic author RonSS

1. Use a FOR loop and a 2-D array for looping through your 3 settings.

2. You initialize and closing of the DAQmx task should be outside of your main loop.

 

Here is my quick cleanup.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 7
(2,857 Views)

Thank you for the suggestion. Our solution was very similar to yours.

0 Kudos
Message 5 of 7
(2,807 Views)

Thank you for the information. It was very helpful.

0 Kudos
Message 6 of 7
(2,806 Views)

Thank you for the information on why we were having run time issues. The while loop solved the problem. Thanks again.

0 Kudos
Message 7 of 7
(2,804 Views)