LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I run two while loops independent of each other?

I have a simple VI. I have loop 1 with and LED and a stop button and I have loop 2 with an LED and stop button.  They are both in while loops.  When I run the VI,if I stop loop 1, I can not turn it back on.  If I stop loop 2, it will not stop.  I've attached a file with my VI.  

0 Kudos
Message 1 of 6
(4,851 Views)

bebesbabe,

 

This looks like a learning exercise, so I will not present a complete solution.

 

1. It is not polite to post to the Forum a VI which will not stop except by pressing the Abort button.  The Abort button should only be used to stop a VI if something is wrong with the program during development. Add a stop button to the outer loop.

 

2. A loop with no delay will try to run as fast as possible, consuming all the CPU resources it can get. Since these loops are for user interfaces, delays of 100 to 200 ms are appropriate. Use the Wait (ms) function.

 

3. Your main problem is understanding dataflow. In LabVIEW any node may execute only when all of its inputs have been given data and it will not complete its execution until all nodes inside it have completed.  Your VI does not have external inputs so waiting for data is not a factor. Each loop is considered a node. So the outer loop will iterate only after BOTH of the inner loops have stopped.  On the next iteration both inner loops will be started again.  Of course if the stop buttons are still pressed, the will stop after one iteration, which will seem almost instantaneous. But because of dataflow as I have described, your program cannot really work the way you want. You cannot restart one loop until both have stopped. Put an indicator on the "i" terminal of the outer loop.

 

4. You may wish to consider changing the mechanical action on your stop buttons to Latch when Released.  Read the help to learn about mechanical actions.

 

The way the instructions on the front panel read, it is not clear what the intended solution is. What control or user action or program action is required to turn the loops back on? Changing the stop button?  Automatically after a delay? A separate On switch?  How is the entire program supposed to stop?

 

Lynn

Message 2 of 6
(4,844 Views)
Thanks for your help. I'm learning LabVIEW as a hobby. I just wanted to make a simple VI and use the push button to turn my LED on and off. If I can master that, I can move on to more productive stuff. Thanks again.
0 Kudos
Message 3 of 6
(4,814 Views)

OK.  It is good to start simple.  Work through some of the things I suggested.  When you get stuck again, post your latest VI and ask for more help.

 

Lynn

Message 4 of 6
(4,783 Views)

Can you please convert your vi to 2011 compatible.

 

If there is no connection between two loop. They will run independently by default

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
Message 5 of 6
(4,771 Views)

You might want to go through some of the on-line tutorials

LabVIEW Basics

LabVIEW 101


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 6 of 6
(4,765 Views)