LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Loop with 2 loops. Start 2 'inside' loops at different time.

Hello,
 
I've got a question. Is there a technique or a certain road which will provides the following... I have a while loop. In that while loop I have some other while loops. Now I want to start the while loops in the big loop at differents time... how can I do that...
 
I included the problem in the vi. When I press start for inside loop 1 I can't start inside loop 2. 
It's obvious that I can't do that because I can't iniziate a other while loop because the 'inside' loop is still running. But is there a certain technique for this? It is because I've certain modules I want to start seperatly from each other...
 
Thanks in advance.
 
Regards,
 
Wouter Geelen
0 Kudos
Message 1 of 5
(3,428 Views)
Your code makes very little sense. You need to familiarize yourself with dataflow.
 
At the beginning of the program the outer loop will start and both inner loops will start spinning. Both loops will terminate immadiately because the condition is FALSE. A nanosecond later things start over, consuming 100% of your CPU while doing nothing useful. Once one of the buttons is pressed, one of the inner loops will start spinning and since the outer loop MUST wait until ALL structures in it have finished, it cannot continue until the inner loop has stopped. This also means that nothing else in the outer loop will happen until the spinning loop has completed.
 
To break the deadlock, you need to place indepdendent code sections into their own outer loop.
 
There are probably much better ways to do all that. Maybe all you need is a state machine. Can you tell us a bit more about what you are trying to do?
 
Your use of local variables is completely unneccesary. Eliminate the locals and instead place the approriate terminals in their place directly.
0 Kudos
Message 2 of 5
(3,423 Views)
I would place the 2 "inside loops" in different SubVI:s. Then call the subVi:s with a vi invoke node, method "Run VI" (look for "vi server" examples). The invoke nood input "wait until return" set to False. In this way the 2 inside loops can be started independently.
 
/Sture
0 Kudos
Message 3 of 5
(3,418 Views)

Well I got three 'modules'...

- 1 for the communication between server and client.

- 1 for the controle of the motor (no output)

- 1 for the output of the motor (iowarrior).

All three of them do not have te be running at the sametime. For example I got several indicators which shows me the output to the controle of the motor. So I can see what the motor 'should' be doing. So I don't need to have an output to the motor. Also the connection between server & client do not have to be established because the modules can be working seperatly from each other.

So what I want is that I can start them up seperatly from each other. So first I start the controle of the motor. Do some tests I can see from the indicators that everything is running okay. Then I start the output so I can see the motor running. Then when I see everything is working I start the communication between server and client.

I hope you understand.

Regards,

Wouter



Message Edited by Wouser on 12-03-2007 05:10 PM
0 Kudos
Message 4 of 5
(3,417 Views)
Use 3 parallel while loops.  Make sure to have appropriate wait ms or wait until next ms functions inside each loop.  Have your start buttons wired to a case structure with nothing in the false case and all of your code in the true case.  Use shift registers if you need to carry values from one iteration to the next.  Look at producer/consumer design patterns if you need to pass data between the loops.
0 Kudos
Message 5 of 5
(3,408 Views)