LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parallel while loops, restart and stop independently.

I have more than two while loops in a VI. Attached is a simplified version. First there is initialization, here a number then while loop do something with it and will stop when I click stop button. However once stopped it can not be restarted unless the second while loop is also stopped and hence the outer most while loop triggers again. The outer most loop is optional but I don't see any other work around. Is there a way to start any of the inner while loops without having to stop rest of them.

0 Kudos
Message 1 of 6
(1,926 Views)

Hi Charles,

 


@CharlesChavandish wrote:

Is there a way to start any of the inner while loops without having to stop rest of them.


Yes.

Spoiler
To run code parts independently from each other you should place them in different loops…
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(1,918 Views)

All you really need is one loop, i.e. the outer loop that you think is not needed. Have a look at state machines.

 

Can you attach a simplified VI that is more closely related to the real problem? Both your inner loops are constant folded, just burn 100% of a CPU core, and don't do anything interesting. You would get exactly the same result if you would delete the two inner loops.

 

It would seem more interesting to take a step back and describe what you want to to, not how you want to do it. What are typical control values. How often do they change? How is the VI operated during the run? What should happen as a function of user interaction? I am sure we could come up with a great solution. Currently, it seems you are barking up the wrong tree.

 

 

0 Kudos
Message 3 of 6
(1,894 Views)

@GerdW wrote:

Hi Charles,

 


@CharlesChavandish wrote:

Is there a way to start any of the inner while loops without having to stop rest of them.


Yes.

Spoiler
To run code parts independently from each other you should place them in different loops…

In addition to this, you should learn about a state machine architecture. Your loops should be separate and your case structures should be inside the loops.

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

@altenbach wrote:

All you really need is one loop, i.e. the outer loop that you think is not needed. Have a look at state machines.

 

Can you attach a simplified VI that is more closely related to the real problem? Both your inner loops are constant folded, just burn 100% of a CPU core, and don't do anything interesting. You would get exactly the same result if you would delete the two inner loops.

 

It would seem more interesting to take a step back and describe what you want to to, not how you want to do it. What are typical control values. How often do they change? How is the VI operated during the run? What should happen as a function of user interaction? I am sure we could come up with a great solution. Currently, it seems you are barking up the wrong tree.

 

 


I made the assumption that this was example code and that the actual code needs to be running independently. I agree that for the code given there is no need for the inner loops. A state machine is appropriate in any event.

0 Kudos
Message 5 of 6
(1,889 Views)

Thank you very much for your reply.

I am quite new with LabVIEW and I am working on multiple projects. I learned about state machine architecture and trying to implement it for my problem. Of course, the toy VI I have attached does not do any justice, since my original project is quite complicated and uses drivers provided by the manufacturer, there is little point in posting it as it is. I will make something more resembling it and perhaps you can guide me. Thank you for your patience, and willingness to help me.

0 Kudos
Message 6 of 6
(1,818 Views)