LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple while loops

I have two while loops in my application which run seperately. The program looks as follows
 
---------------------------         -----------------------
:                                 :       :                            : 
:   while loop 1           :       :  while loop2        :
:                                 :       :                            :
---------------------------         -----------------------
I want to stop while loop 2 as soon as while loop 1 stops. I tried to connect the stop condition of while loop1 to the stop of while loop2, but the loop stops immediately after one iteration. How to go about it.
 
Regards,
Giridhar Rajan
Automation Engineer
Cruiser Controls
Mumbai, India
0 Kudos
Message 1 of 4
(3,076 Views)
If you had tunneled the "Stop" value from Loop1 to Loop 2 , the second loop will never execute till the first finishes and  when stopped both stop. Thus the second loop can never run. Not sure if this is your problem.

Probably one way of doing it  could be like that in the sample code that is enclosed  ? Not sure if it will meet with your requirement though ...

Raghunathan

Message Edited by Raghunathan on 07-17-2005 06:05 AM

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 2 of 4
(3,072 Views)

The big concept in LV is dataflow - a piece of code will execute when all its inputs are available. When you connected the two loops you caused a data dependency - the data in the wire coming out of loop one will only be available when the loop ends. So what happens is that you run loop 1 and when you stop it, the T value goes over to the second loop, which only starts running now. Since it gets T, it stops after one iteration. You can see this if you turn on Highlight Execution (the light bulb button). There are several ways to go around this - the simplest is a local variable - right click the stop button and select Create>>Local Variable. You can change this to be read and put it in the second loop. You will need to change the mechanical action of the button and make sure you set it back to false. A more advanced method is the event structure.

These are the basics in LV. To learn more, I suggest you read the LabVIEW user manual. Also, try searching this site and google for LabVIEW tutorials. Here and here are a couple you can start with. You can also contact your local NI office and join one of their courses.
In addition, I suggest you read the LabVIEW style guide.


___________________
Try to take over the world!
Message 3 of 4
(3,069 Views)

Hi tst,

I downloaded LV style guide and those tutorials. Thanx for the info. It will surely help.

Regards,

Giridhar Rajan

Automation Engineer,

Cruiser Controls

Mumbai, India 

0 Kudos
Message 4 of 4
(3,052 Views)